Commit dafbc3f7 authored by Alexandre Julliard's avatar Alexandre Julliard

Removed remaining references to advapi32 registry functions from

kernel functions.
parent 29d48a50
......@@ -71,6 +71,35 @@ inline static UINT get_lcid_codepage( LCID lcid )
/***********************************************************************
* create_registry_key
*
* Create the Control Panel\\International registry key.
*/
inline static HKEY create_registry_key(void)
{
static const WCHAR intlW[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
HKEY hkey;
if (RtlOpenCurrentUser( KEY_ALL_ACCESS, &hkey ) != STATUS_SUCCESS) return 0;
attr.Length = sizeof(attr);
attr.RootDirectory = hkey;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, intlW );
if (NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) != STATUS_SUCCESS) hkey = 0;
NtClose( attr.RootDirectory );
return hkey;
}
/***********************************************************************
* update_registry
*
* Update registry contents on startup if the user locale has changed.
......@@ -78,20 +107,27 @@ inline static UINT get_lcid_codepage( LCID lcid )
*/
inline static void update_registry( LCID lcid )
{
static const WCHAR LocaleW[] = {'L','o','c','a','l','e',0};
UNICODE_STRING nameW;
char buffer[20];
WCHAR bufferW[80];
DWORD count = sizeof(buffer);
HKEY hkey;
if (RegCreateKeyExA( HKEY_CURRENT_USER, "Control Panel\\International", 0, NULL,
0, KEY_ALL_ACCESS, NULL, &hkey, NULL ))
if (!(hkey = create_registry_key()))
return; /* don't do anything if we can't create the registry key */
if (!RegQueryValueExA( hkey, "Locale", NULL, NULL, (LPBYTE)buffer, &count ))
RtlInitUnicodeString( &nameW, LocaleW );
count = sizeof(bufferW);
if (!NtQueryValueKey(hkey, &nameW, KeyValuePartialInformation, (LPBYTE)bufferW, count, &count))
{
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)bufferW;
RtlUnicodeToMultiByteN( buffer, sizeof(buffer)-1, &count,
(WCHAR *)info->Data, info->DataLength );
buffer[count] = 0;
if (strtol( buffer, NULL, 16 ) == lcid) /* already set correctly */
{
RegCloseKey( hkey );
NtClose( hkey );
return;
}
TRACE( "updating registry, locale changed %s -> %08lx\n", buffer, lcid );
......@@ -99,8 +135,9 @@ inline static void update_registry( LCID lcid )
else TRACE( "updating registry, locale changed none -> %08lx\n", lcid );
sprintf( buffer, "%08lx", lcid );
RegSetValueExA( hkey, "Locale", 0, REG_SZ, (LPBYTE)buffer, strlen(buffer)+1 );
RegCloseKey( hkey );
RtlMultiByteToUnicodeN( bufferW, sizeof(bufferW), NULL, buffer, strlen(buffer)+1 );
NtSetValueKey( hkey, &nameW, 0, REG_SZ, bufferW, (strlenW(bufferW)+1) * sizeof(WCHAR) );
NtClose( hkey );
#define UPDATE_VALUE(lctype) do { \
GetLocaleInfoW( lcid, (lctype)|LOCALE_NOUSEROVERRIDE, bufferW, sizeof(bufferW)/sizeof(WCHAR) ); \
......@@ -445,15 +482,14 @@ static INT get_registry_locale_info( LPCWSTR value, LPWSTR buffer, INT len )
KEY_VALUE_PARTIAL_INFORMATION *info;
static const int info_size = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
if (RegOpenKeyExA( HKEY_CURRENT_USER, "Control Panel\\International", 0, KEY_READ, &hkey))
return -1;
if (!(hkey = create_registry_key())) return -1;
RtlInitUnicodeString( &nameW, value );
size = info_size + len * sizeof(WCHAR);
if (!(info = HeapAlloc( GetProcessHeap(), 0, size )))
{
RegCloseKey( hkey );
NtClose( hkey );
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return 0;
}
......@@ -489,7 +525,7 @@ static INT get_registry_locale_info( LPCWSTR value, LPWSTR buffer, INT len )
ret = 0;
}
}
RegCloseKey( hkey );
NtClose( hkey );
HeapFree( GetProcessHeap(), 0, info );
return ret;
}
......@@ -714,11 +750,10 @@ BOOL WINAPI SetLocaleInfoW( LCID lcid, LCTYPE lctype, LPCWSTR data )
/* FIXME: profile functions should map to registry */
WriteProfileStringW( intlW, value, data );
if (RegCreateKeyExA( HKEY_CURRENT_USER, "Control Panel\\International", 0, NULL,
0, KEY_ALL_ACCESS, NULL, &hkey, NULL )) return FALSE;
if (!(hkey = create_registry_key())) return FALSE;
RtlInitUnicodeString( &valueW, value );
status = NtSetValueKey( hkey, &valueW, 0, REG_SZ, data, (strlenW(data)+1)*sizeof(WCHAR) );
RegCloseKey( hkey );
NtClose( hkey );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
......
......@@ -40,7 +40,6 @@
#include "wingdi.h"
#include "wine/winuser16.h"
#include "winerror.h"
#include "winreg.h"
#include "winternl.h"
#include "wine/unicode.h"
#include "drive.h"
......@@ -745,37 +744,53 @@ static BOOL DIR_TryModulePath( LPCWSTR name, DOS_FULL_NAME *full_name, BOOL win3
static BOOL DIR_TryAppPath( LPCWSTR name, DOS_FULL_NAME *full_name )
{
HKEY hkAppPaths = 0, hkApp = 0;
WCHAR lpAppName[MAX_PATHNAME_LEN], lpAppPaths[MAX_PATHNAME_LEN];
WCHAR buffer[MAX_PATHNAME_LEN], *lpAppPaths;
LPWSTR lpFileName;
BOOL res = FALSE;
DWORD type, count;
DWORD count;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
KEY_VALUE_PARTIAL_INFORMATION *info;
static const WCHAR PathW[] = {'P','a','t','h',0};
if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths", &hkAppPaths) != ERROR_SUCCESS)
return FALSE;
if (!GetModuleFileNameW(0, lpAppName, MAX_PATHNAME_LEN))
static const WCHAR AppPathsW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'A','p','p',' ','P','a','t','h','s',0};
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, AppPathsW );
if (NtOpenKey( &hkAppPaths, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) return FALSE;
if (!GetModuleFileNameW(0, buffer, MAX_PATHNAME_LEN))
{
WARN("huh, module not found ??\n");
goto end;
}
lpFileName = strrchrW(lpAppName, '\\');
if (!lpFileName)
goto end;
lpFileName = strrchrW(buffer, '\\');
if (!lpFileName) lpFileName = buffer;
else lpFileName++; /* skip '\\' */
if (RegOpenKeyW(hkAppPaths, lpFileName, &hkApp) != ERROR_SUCCESS)
goto end;
count = sizeof(lpAppPaths);
if (RegQueryValueExW(hkApp, PathW, 0, &type, (LPBYTE)lpAppPaths, &count) != ERROR_SUCCESS)
goto end;
TRACE("successfully opened App Paths for %s\n", debugstr_w(lpFileName));
attr.RootDirectory = hkAppPaths;
RtlInitUnicodeString( &nameW, lpFileName );
if (NtOpenKey( &hkApp, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) goto end;
RtlInitUnicodeString( &nameW, PathW );
if (NtQueryValueKey( hkApp, &nameW, KeyValuePartialInformation,
buffer, sizeof(buffer)-sizeof(WCHAR), &count )) goto end;
info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
lpAppPaths = (WCHAR *)info->Data;
lpAppPaths[info->DataLength/sizeof(WCHAR)] = 0;
res = DIR_SearchSemicolonedPaths(name, full_name, lpAppPaths);
end:
if (hkApp)
RegCloseKey(hkApp);
if (hkAppPaths)
RegCloseKey(hkAppPaths);
if (hkApp) NtClose(hkApp);
if (hkAppPaths) NtClose(hkAppPaths);
return res;
}
......
......@@ -27,15 +27,76 @@
#include <stdio.h>
#include "winbase.h"
#include "winreg.h"
#include "winnt.h"
#include "winternl.h"
#include "winerror.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(reg);
static BYTE PF[64] = {0,};
static void create_registry_keys( const SYSTEM_INFO *info )
{
static const WCHAR SystemW[] = {'M','a','c','h','i','n','e','\\',
'H','a','r','d','w','a','r','e','\\',
'D','e','s','c','r','i','p','t','i','o','n','\\',
'S','y','s','t','e','m',0};
static const WCHAR fpuW[] = {'F','l','o','a','t','i','n','g','P','o','i','n','t','P','r','o','c','e','s','s','o','r',0};
static const WCHAR cpuW[] = {'C','e','n','t','r','a','l','P','r','o','c','e','s','s','o','r',0};
static const WCHAR IdentifierW[] = {'I','d','e','n','t','i','f','i','e','r',0};
static const WCHAR SysidW[] = {'A','T',' ','c','o','m','p','a','t','i','b','l','e',0};
int i;
HKEY hkey, system_key, cpu_key;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW, valueW;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, SystemW );
if (NtCreateKey( &system_key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) return;
RtlInitUnicodeString( &valueW, IdentifierW );
NtSetValueKey( system_key, &valueW, 0, REG_SZ, SysidW, (strlenW(SysidW)+1) * sizeof(WCHAR) );
attr.RootDirectory = system_key;
RtlInitUnicodeString( &nameW, fpuW );
if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) NtClose( hkey );
RtlInitUnicodeString( &nameW, cpuW );
if (!NtCreateKey( &cpu_key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ))
{
for (i = 0; i < info->dwNumberOfProcessors; i++)
{
char num[10], id[20];
attr.RootDirectory = cpu_key;
sprintf( num, "%d", i );
RtlCreateUnicodeStringFromAsciiz( &nameW, num );
if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ))
{
WCHAR idW[20];
sprintf( id, "CPU %ld", info->dwProcessorType );
RtlMultiByteToUnicodeN( idW, sizeof(idW), NULL, id, strlen(id)+1 );
NtSetValueKey( hkey, &valueW, 0, REG_SZ, idW, (strlenW(idW)+1)*sizeof(WCHAR) );
NtClose( hkey );
}
RtlFreeUnicodeString( &nameW );
}
NtClose( cpu_key );
}
NtClose( system_key );
}
/***********************************************************************
* GetSystemInfo [KERNEL32.@]
*
......@@ -62,7 +123,6 @@ VOID WINAPI GetSystemInfo(
) {
static int cache = 0;
static SYSTEM_INFO cachedsi;
HKEY xhkey=0,hkey;
if (cache) {
memcpy(si,&cachedsi,sizeof(*si));
......@@ -91,23 +151,13 @@ VOID WINAPI GetSystemInfo(
/* Hmm, reasonable processor feature defaults? */
/* Create these registry keys for all systems
* FPU entry is often empty on Windows, so we don't care either */
if ( (RegCreateKeyA(HKEY_LOCAL_MACHINE,"HARDWARE\\DESCRIPTION\\System\\FloatingPointProcessor",&hkey)!=ERROR_SUCCESS)
|| (RegCreateKeyA(HKEY_LOCAL_MACHINE,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor",&hkey)!=ERROR_SUCCESS) )
{
WARN("Unable to write FPU/CPU info to registry\n");
}
#ifdef linux
{
char buf[20];
char line[200];
FILE *f = fopen ("/proc/cpuinfo", "r");
if (!f)
return;
xhkey = 0;
while (fgets(line,200,f)!=NULL) {
char *s,*value;
......@@ -149,10 +199,6 @@ VOID WINAPI GetSystemInfo(
break;
}
}
/* set the CPU type of the current processor */
sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
if (xhkey)
RegSetValueExA(xhkey,"Identifier",0,REG_SZ,buf,strlen(buf));
continue;
}
/* old 2.0 method */
......@@ -177,14 +223,6 @@ VOID WINAPI GetSystemInfo(
break;
}
}
/* set the CPU type of the current processor
* FIXME: someone reported P4 as being set to
* " Intel(R) Pentium(R) 4 CPU 1500MHz"
* Do we need to do the same ?
* */
sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
if (xhkey)
RegSetValueExA(xhkey,"Identifier",0,REG_SZ,buf,strlen(buf));
continue;
}
if (!strncasecmp(line,"fdiv_bug",strlen("fdiv_bug"))) {
......@@ -206,14 +244,6 @@ VOID WINAPI GetSystemInfo(
if (sscanf(value,"%d",&x))
if (x+1>cachedsi.dwNumberOfProcessors)
cachedsi.dwNumberOfProcessors=x+1;
/* Create a new processor subkey on a multiprocessor
* system
*/
sprintf(buf,"%d",x);
if (xhkey)
RegCloseKey(xhkey);
RegCreateKeyA(hkey,buf,&xhkey);
}
if (!strncasecmp(line,"stepping",strlen("stepping"))) {
int x;
......@@ -238,19 +268,15 @@ VOID WINAPI GetSystemInfo(
memcpy(si,&cachedsi,sizeof(*si));
#else /* linux */
FIXME("not yet supported on this system\n");
RegCreateKeyA(hkey,"0",&xhkey);
RegSetValueExA(xhkey,"Identifier",0,REG_SZ,"CPU 386",strlen("CPU 386"));
#endif /* !linux */
if (xhkey)
RegCloseKey(xhkey);
if (hkey)
RegCloseKey(hkey);
TRACE("<- CPU arch %d, res'd %d, pagesize %ld, minappaddr %p, maxappaddr %p,"
" act.cpumask %08lx, numcpus %ld, CPU type %ld, allocgran. %ld, CPU level %d, CPU rev %d\n",
si->u.s.wProcessorArchitecture, si->u.s.wReserved, si->dwPageSize,
si->lpMinimumApplicationAddress, si->lpMaximumApplicationAddress,
si->dwActiveProcessorMask, si->dwNumberOfProcessors, si->dwProcessorType,
si->dwAllocationGranularity, si->wProcessorLevel, si->wProcessorRevision);
create_registry_keys( &cachedsi );
}
......
......@@ -48,9 +48,10 @@
#include "wine/library.h"
#include "thread.h"
#include "stackframe.h"
#include "msvcrt/excpt.h"
#include "wine/server.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "msvcrt/excpt.h"
WINE_DEFAULT_DEBUG_CHANNEL(seh);
......@@ -210,6 +211,8 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c
*/
static BOOL start_debugger(PEXCEPTION_POINTERS epointers, HANDLE hEvent)
{
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
HKEY hDbgConf;
DWORD bAuto = FALSE;
PROCESS_INFORMATION info;
......@@ -219,40 +222,75 @@ static BOOL start_debugger(PEXCEPTION_POINTERS epointers, HANDLE hEvent)
DWORD format_size;
BOOL ret = FALSE;
static const WCHAR AeDebugW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'A','e','D','e','b','u','g',0};
static const WCHAR DebuggerW[] = {'D','e','b','u','g','g','e','r',0};
static const WCHAR AutoW[] = {'A','u','t','o',0};
MESSAGE("wine: Unhandled exception, starting debugger...\n");
if (!RegOpenKeyA(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", &hDbgConf)) {
DWORD type;
DWORD count;
format_size = 0;
if (!RegQueryValueExA(hDbgConf, "Debugger", 0, &type, NULL, &format_size)) {
format = HeapAlloc(GetProcessHeap(), 0, format_size);
RegQueryValueExA(hDbgConf, "Debugger", 0, &type, format, &format_size);
if (type==REG_EXPAND_SZ) {
char* tmp;
/* Expand environment variable references */
format_size=ExpandEnvironmentStringsA(format,NULL,0);
tmp=HeapAlloc(GetProcessHeap(), 0, format_size);
ExpandEnvironmentStringsA(format,tmp,format_size);
HeapFree(GetProcessHeap(), 0, format);
format=tmp;
}
}
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, AeDebugW );
count = sizeof(bAuto);
if (RegQueryValueExA(hDbgConf, "Auto", 0, &type, (char*)&bAuto, &count))
bAuto = TRUE;
else if (type == REG_SZ)
if (!NtOpenKey( &hDbgConf, KEY_ALL_ACCESS, &attr ))
{
char buffer[64];
KEY_VALUE_PARTIAL_INFORMATION *info;
format_size = 0;
RtlInitUnicodeString( &nameW, DebuggerW );
if (NtQueryValueKey( hDbgConf, &nameW, KeyValuePartialInformation,
NULL, 0, &format_size ) == STATUS_BUFFER_OVERFLOW)
{
char *data = HeapAlloc(GetProcessHeap(), 0, format_size);
NtQueryValueKey( hDbgConf, &nameW, KeyValuePartialInformation,
data, format_size, &format_size );
info = (KEY_VALUE_PARTIAL_INFORMATION *)data;
RtlUnicodeToMultiByteSize( &format_size, (WCHAR *)info->Data, info->DataLength );
format = HeapAlloc( GetProcessHeap(), 0, format_size+1 );
RtlUnicodeToMultiByteN( format, format_size, NULL,
(WCHAR *)info->Data, info->DataLength );
format[format_size] = 0;
if (info->Type == REG_EXPAND_SZ)
{
char* tmp;
/* Expand environment variable references */
format_size=ExpandEnvironmentStringsA(format,NULL,0);
tmp=HeapAlloc(GetProcessHeap(), 0, format_size);
ExpandEnvironmentStringsA(format,tmp,format_size);
HeapFree(GetProcessHeap(), 0, format);
format=tmp;
}
HeapFree( GetProcessHeap(), 0, data );
}
RtlInitUnicodeString( &nameW, AutoW );
if (!NtQueryValueKey( hDbgConf, &nameW, KeyValuePartialInformation,
buffer, sizeof(buffer)-sizeof(WCHAR), &format_size ))
{
char autostr[10];
count = sizeof(autostr);
if (!RegQueryValueExA(hDbgConf, "Auto", 0, &type, autostr, &count))
bAuto = atoi(autostr);
info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
if (info->Type == REG_DWORD) memcpy( &bAuto, info->Data, sizeof(DWORD) );
else if (info->Type == REG_SZ)
{
WCHAR *str = (WCHAR *)info->Data;
str[info->DataLength/sizeof(WCHAR)] = 0;
bAuto = atoiW( str );
}
}
RegCloseKey(hDbgConf);
else bAuto = TRUE;
NtClose(hDbgConf);
} else {
/* try a default setup... */
strcpy( format, "winedbg --debugmsg -all --auto %ld %ld" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment