From c42b415fabfc7b4428c1790b1bddc08e5a79f1ed Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 21 May 2020 13:36:06 +0200 Subject: [PATCH] wineboot: Use wide character string literals. Signed-off-by: Alexandre Julliard --- programs/wineboot/wineboot.c | 366 ++++++++++------------------------- 1 file changed, 104 insertions(+), 262 deletions(-) diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index ac0b04d6d81..09925bfa235 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -84,34 +84,28 @@ extern void kill_processes( BOOL kill_desktop ); static WCHAR windowsdir[MAX_PATH]; static const BOOL is_64bit = sizeof(void *) > sizeof(int); -static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0}; -static const WCHAR winedatadirW[] = {'W','I','N','E','D','A','T','A','D','I','R',0}; -static const WCHAR wineconfigdirW[] = {'W','I','N','E','C','O','N','F','I','G','D','I','R',0}; - /* retrieve the path to the wine.inf file */ static WCHAR *get_wine_inf_path(void) { - static const WCHAR loaderW[] = {'\\','l','o','a','d','e','r',0}; - static const WCHAR wine_infW[] = {'\\','w','i','n','e','.','i','n','f',0}; WCHAR *dir, *name = NULL; - if ((dir = _wgetenv( winebuilddirW ))) + if ((dir = _wgetenv( L"WINEBUILDDIR" ))) { if (!(name = HeapAlloc( GetProcessHeap(), 0, - sizeof(loaderW) + sizeof(wine_infW) + lstrlenW(dir) * sizeof(WCHAR) ))) + sizeof(L"\\loader\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) ))) return NULL; lstrcpyW( name, dir ); - lstrcatW( name, loaderW ); + lstrcatW( name, L"\\loader" ); } - else if ((dir = _wgetenv( winedatadirW ))) + else if ((dir = _wgetenv( L"WINEDATADIR" ))) { - if (!(name = HeapAlloc( GetProcessHeap(), 0, sizeof(wine_infW) + lstrlenW(dir) * sizeof(WCHAR) ))) + if (!(name = HeapAlloc( GetProcessHeap(), 0, sizeof(L"\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) ))) return NULL; lstrcpyW( name, dir ); } else return NULL; - lstrcatW( name, wine_infW ); + lstrcatW( name, L"\\wine.inf" ); name[1] = '\\'; /* change \??\ to \\?\ */ return name; } @@ -119,15 +113,14 @@ static WCHAR *get_wine_inf_path(void) /* update the timestamp if different from the reference time */ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp ) { - static const WCHAR timestampW[] = {'\\','.','u','p','d','a','t','e','-','t','i','m','e','s','t','a','m','p',0}; BOOL ret = FALSE; int fd, count; char buffer[100]; - WCHAR *file = HeapAlloc( GetProcessHeap(), 0, lstrlenW(config_dir) * sizeof(WCHAR) + sizeof(timestampW) ); + WCHAR *file = HeapAlloc( GetProcessHeap(), 0, lstrlenW(config_dir) * sizeof(WCHAR) + sizeof(L"\\.update-timestamp") ); if (!file) return FALSE; lstrcpyW( file, config_dir ); - lstrcatW( file, timestampW ); + lstrcatW( file, L"\\.update-timestamp" ); if ((fd = _wopen( file, O_RDWR )) != -1) { @@ -164,10 +157,10 @@ done: static const WCHAR *prettyprint_configdir(void) { static WCHAR buffer[MAX_PATH]; - WCHAR *p, *path = _wgetenv( wineconfigdirW ); + WCHAR *p, *path = _wgetenv( L"WINECONFIGDIR" ); lstrcpynW( buffer, path, ARRAY_SIZE(buffer) ); - if (lstrlenW( wineconfigdirW ) >= ARRAY_SIZE(buffer) ) + if (lstrlenW( path ) >= ARRAY_SIZE(buffer) ) lstrcpyW( buffer + ARRAY_SIZE(buffer) - 4, L"..." ); if (!wcsncmp( buffer, L"\\??\\unix\\", 9 )) @@ -221,14 +214,12 @@ static unsigned int get_model( unsigned int reg0, unsigned int *stepping, unsign static void get_identifier( WCHAR *buf, size_t size, const WCHAR *arch ) { - static const WCHAR fmtW[] = {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ','M','o','d','e','l', - ' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0}; unsigned int family, model, stepping; int regs[4] = {0, 0, 0, 0}; __cpuid( regs, 1 ); model = get_model( regs[0], &stepping, &family ); - swprintf( buf, size, fmtW, arch, family, model, stepping ); + swprintf( buf, size, L"%s Family %u Model %u Stepping %u", arch, family, model, stepping ); } static void get_vendorid( WCHAR *buf ) @@ -505,24 +496,6 @@ done: /* create the volatile hardware registry keys */ static void create_hardware_registry_keys(void) { - static const WCHAR SystemW[] = {'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 FeatureSetW[] = {'F','e','a','t','u','r','e','S','e','t',0}; - static const WCHAR IdentifierW[] = {'I','d','e','n','t','i','f','i','e','r',0}; - static const WCHAR ProcessorNameStringW[] = {'P','r','o','c','e','s','s','o','r','N','a','m','e','S','t','r','i','n','g',0}; - static const WCHAR SysidW[] = {'A','T',' ','c','o','m','p','a','t','i','b','l','e',0}; - static const WCHAR ARMSysidW[] = {'A','R','M',' ','p','r','o','c','e','s','s','o','r',' ','f','a','m','i','l','y',0}; - static const WCHAR mhzKeyW[] = {'~','M','H','z',0}; - static const WCHAR VendorIdentifierW[] = {'V','e','n','d','o','r','I','d','e','n','t','i','f','i','e','r',0}; - static const WCHAR PercentDW[] = {'%','d',0}; - static const WCHAR ARMCpuDescrW[] = {'A','R','M',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d', - ' ','R','e','v','i','s','i','o','n',' ','%','d',0}; - static const WCHAR x86W[] = {'x','8','6',0}; - static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0}; - static const WCHAR amd64W[] = {'A','M','D','6','4',0}; - static const WCHAR authenticamdW[] = {'A','u','t','h','e','n','t','i','c','A','M','D',0}; unsigned int i; HKEY hkey, system_key, cpu_key, fpu_key; SYSTEM_CPU_INFORMATION sci; @@ -544,21 +517,22 @@ static void create_hardware_registry_keys(void) { case PROCESSOR_ARCHITECTURE_ARM: case PROCESSOR_ARCHITECTURE_ARM64: - swprintf( id, ARRAY_SIZE(id), ARMCpuDescrW, sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) ); + swprintf( id, ARRAY_SIZE(id), L"ARM Family %u Model %u Revision %u", + sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) ); break; case PROCESSOR_ARCHITECTURE_AMD64: - get_identifier( id, ARRAY_SIZE(id), !wcscmp(vendorid, authenticamdW) ? amd64W : intel64W ); + get_identifier( id, ARRAY_SIZE(id), !wcscmp(vendorid, L"AuthenticAMD") ? L"AMD64" : L"Intel64" ); break; case PROCESSOR_ARCHITECTURE_INTEL: default: - get_identifier( id, ARRAY_SIZE(id), x86W ); + get_identifier( id, ARRAY_SIZE(id), L"x86" ); break; } - if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, SystemW, 0, NULL, REG_OPTION_VOLATILE, - KEY_ALL_ACCESS, NULL, &system_key, NULL )) + if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System", 0, NULL, + REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &system_key, NULL )) { HeapFree( GetProcessHeap(), 0, power_info ); return; @@ -568,22 +542,22 @@ static void create_hardware_registry_keys(void) { case PROCESSOR_ARCHITECTURE_ARM: case PROCESSOR_ARCHITECTURE_ARM64: - set_reg_value( system_key, IdentifierW, ARMSysidW ); + set_reg_value( system_key, L"Identifier", L"ARM processor family" ); break; case PROCESSOR_ARCHITECTURE_INTEL: case PROCESSOR_ARCHITECTURE_AMD64: default: - set_reg_value( system_key, IdentifierW, SysidW ); + set_reg_value( system_key, L"Identifier", L"AT compatible" ); break; } if (sci.Architecture == PROCESSOR_ARCHITECTURE_ARM || sci.Architecture == PROCESSOR_ARCHITECTURE_ARM64 || - RegCreateKeyExW( system_key, fpuW, 0, NULL, REG_OPTION_VOLATILE, + RegCreateKeyExW( system_key, L"FloatingPointProcessor", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &fpu_key, NULL )) fpu_key = 0; - if (RegCreateKeyExW( system_key, cpuW, 0, NULL, REG_OPTION_VOLATILE, + if (RegCreateKeyExW( system_key, L"CentralProcessor", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &cpu_key, NULL )) cpu_key = 0; @@ -591,16 +565,16 @@ static void create_hardware_registry_keys(void) { WCHAR numW[10]; - swprintf( numW, ARRAY_SIZE(numW), PercentDW, i ); + swprintf( numW, ARRAY_SIZE(numW), L"%u", i ); if (!RegCreateKeyExW( cpu_key, numW, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) { - RegSetValueExW( hkey, FeatureSetW, 0, REG_DWORD, (BYTE *)&sci.FeatureSet, sizeof(DWORD) ); - set_reg_value( hkey, IdentifierW, id ); + RegSetValueExW( hkey, L"FeatureSet", 0, REG_DWORD, (BYTE *)&sci.FeatureSet, sizeof(DWORD) ); + set_reg_value( hkey, L"Identifier", id ); /* TODO: report ARM properly */ - set_reg_value( hkey, ProcessorNameStringW, namestr ); - set_reg_value( hkey, VendorIdentifierW, vendorid ); - RegSetValueExW( hkey, mhzKeyW, 0, REG_DWORD, (BYTE *)&power_info[i].MaxMhz, sizeof(DWORD) ); + set_reg_value( hkey, L"ProcessorNameString", namestr ); + set_reg_value( hkey, L"VendorIdentifier", vendorid ); + RegSetValueExW( hkey, L"~MHz", 0, REG_DWORD, (BYTE *)&power_info[i].MaxMhz, sizeof(DWORD) ); RegCloseKey( hkey ); } if (sci.Architecture != PROCESSOR_ARCHITECTURE_ARM && @@ -608,7 +582,7 @@ static void create_hardware_registry_keys(void) !RegCreateKeyExW( fpu_key, numW, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) { - set_reg_value( hkey, IdentifierW, id ); + set_reg_value( hkey, L"Identifier", id ); RegCloseKey( hkey ); } } @@ -625,72 +599,49 @@ static void create_hardware_registry_keys(void) /* create the DynData registry keys */ static void create_dynamic_registry_keys(void) { - static const WCHAR StatDataW[] = {'P','e','r','f','S','t','a','t','s','\\', - 'S','t','a','t','D','a','t','a',0}; - static const WCHAR ConfigManagerW[] = {'C','o','n','f','i','g',' ','M','a','n','a','g','e','r','\\', - 'E','n','u','m',0}; HKEY key; - if (!RegCreateKeyExW( HKEY_DYN_DATA, StatDataW, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL )) + if (!RegCreateKeyExW( HKEY_DYN_DATA, L"PerfStats\\StatData", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL )) RegCloseKey( key ); - if (!RegCreateKeyExW( HKEY_DYN_DATA, ConfigManagerW, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL )) + if (!RegCreateKeyExW( HKEY_DYN_DATA, L"Config Manager\\Enum", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL )) RegCloseKey( key ); } /* create the platform-specific environment registry keys */ static void create_environment_registry_keys( void ) { - static const WCHAR EnvironW[] = {'S','y','s','t','e','m','\\', - 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', - 'C','o','n','t','r','o','l','\\', - 'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\', - 'E','n','v','i','r','o','n','m','e','n','t',0}; - static const WCHAR NumProcW[] = {'N','U','M','B','E','R','_','O','F','_','P','R','O','C','E','S','S','O','R','S',0}; - static const WCHAR ProcArchW[] = {'P','R','O','C','E','S','S','O','R','_','A','R','C','H','I','T','E','C','T','U','R','E',0}; - static const WCHAR x86W[] = {'x','8','6',0}; - static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0}; - static const WCHAR amd64W[] = {'A','M','D','6','4',0}; - static const WCHAR authenticamdW[] = {'A','u','t','h','e','n','t','i','c','A','M','D',0}; - static const WCHAR commaW[] = {',',' ',0}; - static const WCHAR ProcIdW[] = {'P','R','O','C','E','S','S','O','R','_','I','D','E','N','T','I','F','I','E','R',0}; - static const WCHAR ProcLvlW[] = {'P','R','O','C','E','S','S','O','R','_','L','E','V','E','L',0}; - static const WCHAR ProcRevW[] = {'P','R','O','C','E','S','S','O','R','_','R','E','V','I','S','I','O','N',0}; - static const WCHAR PercentDW[] = {'%','d',0}; - static const WCHAR Percent04XW[] = {'%','0','4','x',0}; - static const WCHAR ARMCpuDescrW[] = {'A','R','M',' ','F','a','m','i','l','y',' ','%','d',' ','M','o','d','e','l',' ','%','d', - ' ','R','e','v','i','s','i','o','n',' ','%','d',0}; HKEY env_key; SYSTEM_CPU_INFORMATION sci; WCHAR buffer[60], vendorid[13]; const WCHAR *arch, *parch; - if (RegCreateKeyW( HKEY_LOCAL_MACHINE, EnvironW, &env_key )) return; + if (RegCreateKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", &env_key )) return; get_vendorid( vendorid ); NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL ); - swprintf( buffer, ARRAY_SIZE(buffer), PercentDW, NtCurrentTeb()->Peb->NumberOfProcessors ); - set_reg_value( env_key, NumProcW, buffer ); + swprintf( buffer, ARRAY_SIZE(buffer), L"%u", NtCurrentTeb()->Peb->NumberOfProcessors ); + set_reg_value( env_key, L"NUMBER_OF_PROCESSORS", buffer ); switch (sci.Architecture) { case PROCESSOR_ARCHITECTURE_AMD64: - arch = amd64W; - parch = !wcscmp(vendorid, authenticamdW) ? amd64W : intel64W; + arch = L"AMD64"; + parch = !wcscmp(vendorid, L"AuthenticAMD") ? L"AMD64" : L"Intel64"; break; case PROCESSOR_ARCHITECTURE_INTEL: default: - arch = parch = x86W; + arch = parch = L"x86"; break; } - set_reg_value( env_key, ProcArchW, arch ); + set_reg_value( env_key, L"PROCESSOR_ARCHITECTURE", arch ); switch (sci.Architecture) { case PROCESSOR_ARCHITECTURE_ARM: case PROCESSOR_ARCHITECTURE_ARM64: - swprintf( buffer, ARRAY_SIZE(buffer), ARMCpuDescrW, + swprintf( buffer, ARRAY_SIZE(buffer), L"ARM Family %u Model %u Revision %u", sci.Level, HIBYTE(sci.Revision), LOBYTE(sci.Revision) ); break; @@ -698,81 +649,67 @@ static void create_environment_registry_keys( void ) case PROCESSOR_ARCHITECTURE_INTEL: default: get_identifier( buffer, ARRAY_SIZE(buffer), parch ); - lstrcatW( buffer, commaW ); + lstrcatW( buffer, L", " ); lstrcatW( buffer, vendorid ); break; } - set_reg_value( env_key, ProcIdW, buffer ); + set_reg_value( env_key, L"PROCESSOR_IDENTIFIER", buffer ); - swprintf( buffer, ARRAY_SIZE(buffer), PercentDW, sci.Level ); - set_reg_value( env_key, ProcLvlW, buffer ); + swprintf( buffer, ARRAY_SIZE(buffer), L"%u", sci.Level ); + set_reg_value( env_key, L"PROCESSOR_LEVEL", buffer ); - swprintf( buffer, ARRAY_SIZE(buffer), Percent04XW, sci.Revision ); - set_reg_value( env_key, ProcRevW, buffer ); + swprintf( buffer, ARRAY_SIZE(buffer), L"%04x", sci.Revision ); + set_reg_value( env_key, L"PROCESSOR_REVISION", buffer ); RegCloseKey( env_key ); } static void create_volatile_environment_registry_key(void) { - static const WCHAR VolatileEnvW[] = {'V','o','l','a','t','i','l','e',' ','E','n','v','i','r','o','n','m','e','n','t',0}; - static const WCHAR AppDataW[] = {'A','P','P','D','A','T','A',0}; - static const WCHAR ClientNameW[] = {'C','L','I','E','N','T','N','A','M','E',0}; - static const WCHAR HomeDriveW[] = {'H','O','M','E','D','R','I','V','E',0}; - static const WCHAR HomePathW[] = {'H','O','M','E','P','A','T','H',0}; - static const WCHAR HomeShareW[] = {'H','O','M','E','S','H','A','R','E',0}; - static const WCHAR LocalAppDataW[] = {'L','O','C','A','L','A','P','P','D','A','T','A',0}; - static const WCHAR LogonServerW[] = {'L','O','G','O','N','S','E','R','V','E','R',0}; - static const WCHAR SessionNameW[] = {'S','E','S','S','I','O','N','N','A','M','E',0}; - static const WCHAR UserNameW[] = {'U','S','E','R','N','A','M','E',0}; - static const WCHAR UserDomainW[] = {'U','S','E','R','D','O','M','A','I','N',0}; - static const WCHAR UserProfileW[] = {'U','S','E','R','P','R','O','F','I','L','E',0}; - static const WCHAR ConsoleW[] = {'C','o','n','s','o','l','e',0}; - static const WCHAR EmptyW[] = {0}; WCHAR path[MAX_PATH]; WCHAR computername[MAX_COMPUTERNAME_LENGTH + 1 + 2]; DWORD size; HKEY hkey; HRESULT hr; - if (RegCreateKeyExW( HKEY_CURRENT_USER, VolatileEnvW, 0, NULL, REG_OPTION_VOLATILE, + if (RegCreateKeyExW( HKEY_CURRENT_USER, L"Volatile Environment", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) return; hr = SHGetFolderPathW( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, path ); - if (SUCCEEDED(hr)) set_reg_value( hkey, AppDataW, path ); + if (SUCCEEDED(hr)) set_reg_value( hkey, L"APPDATA", path ); - set_reg_value( hkey, ClientNameW, ConsoleW ); + set_reg_value( hkey, L"CLIENTNAME", L"Console" ); /* Write the profile path's drive letter and directory components into * HOMEDRIVE and HOMEPATH respectively. */ hr = SHGetFolderPathW( NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, path ); if (SUCCEEDED(hr)) { - set_reg_value( hkey, UserProfileW, path ); - set_reg_value( hkey, HomePathW, path + 2 ); + set_reg_value( hkey, L"USERPROFILE", path ); + set_reg_value( hkey, L"HOMEPATH", path + 2 ); path[2] = '\0'; - set_reg_value( hkey, HomeDriveW, path ); + set_reg_value( hkey, L"HOMEDRIVE", path ); } size = ARRAY_SIZE(path); - if (GetUserNameW( path, &size )) set_reg_value( hkey, UserNameW, path ); + if (GetUserNameW( path, &size )) set_reg_value( hkey, L"USERNAME", path ); - set_reg_value( hkey, HomeShareW, EmptyW ); + set_reg_value( hkey, L"HOMESHARE", L"" ); hr = SHGetFolderPathW( NULL, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, path ); if (SUCCEEDED(hr)) - set_reg_value( hkey, LocalAppDataW, path ); + set_reg_value( hkey, L"LOCALAPPDATA", path ); size = ARRAY_SIZE(computername) - 2; if (GetComputerNameW(&computername[2], &size)) { - set_reg_value( hkey, UserDomainW, &computername[2] ); + set_reg_value( hkey, L"USERDOMAIN", &computername[2] ); computername[0] = computername[1] = '\\'; - set_reg_value( hkey, LogonServerW, computername ); + set_reg_value( hkey, L"LOGONSERVER", computername ); } - set_reg_value( hkey, SessionNameW, ConsoleW ); + set_reg_value( hkey, L"SESSIONNAME", L"Console" ); RegCloseKey( hkey ); } @@ -781,10 +718,6 @@ static void create_volatile_environment_registry_key(void) */ static BOOL wininit(void) { - static const WCHAR nulW[] = {'N','U','L',0}; - static const WCHAR renameW[] = {'r','e','n','a','m','e',0}; - static const WCHAR wininitW[] = {'w','i','n','i','n','i','t','.','i','n','i',0}; - static const WCHAR wininitbakW[] = {'w','i','n','i','n','i','t','.','b','a','k',0}; WCHAR initial_buffer[1024]; WCHAR *str, *buffer = initial_buffer; DWORD size = ARRAY_SIZE(initial_buffer); @@ -792,7 +725,7 @@ static BOOL wininit(void) for (;;) { - if (!(res = GetPrivateProfileSectionW( renameW, buffer, size, wininitW ))) return TRUE; + if (!(res = GetPrivateProfileSectionW( L"rename", buffer, size, L"wininit.ini" ))) return TRUE; if (res < size - 2) break; if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer ); size *= 2; @@ -809,7 +742,7 @@ static BOOL wininit(void) /* split the line into key and value */ *value++ = 0; - if (!lstrcmpiW( nulW, str )) + if (!lstrcmpiW( L"NUL", str )) { WINE_TRACE("Deleting file %s\n", wine_dbgstr_w(value) ); if( !DeleteFileW( value ) ) @@ -827,7 +760,7 @@ static BOOL wininit(void) if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer ); - if( !MoveFileExW( wininitW, wininitbakW, MOVEFILE_REPLACE_EXISTING) ) + if( !MoveFileExW( L"wininit.ini", L"wininit.bak", MOVEFILE_REPLACE_EXISTING) ) { WINE_ERR("Couldn't rename wininit.ini, error %d\n", GetLastError() ); @@ -837,64 +770,24 @@ static BOOL wininit(void) return TRUE; } -static BOOL pendingRename(void) +static void pendingRename(void) { - static const WCHAR ValueName[] = {'P','e','n','d','i','n','g', - 'F','i','l','e','R','e','n','a','m','e', - 'O','p','e','r','a','t','i','o','n','s',0}; - static const WCHAR SessionW[] = { 'S','y','s','t','e','m','\\', - 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', - 'C','o','n','t','r','o','l','\\', - 'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r',0}; WCHAR *buffer=NULL; const WCHAR *src=NULL, *dst=NULL; DWORD dataLength=0; - HKEY hSession=NULL; - DWORD res; + HKEY hSession; - WINE_TRACE("Entered\n"); + if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager", + 0, KEY_ALL_ACCESS, &hSession )) + return; - if( (res=RegOpenKeyExW( HKEY_LOCAL_MACHINE, SessionW, 0, KEY_ALL_ACCESS, &hSession )) - !=ERROR_SUCCESS ) - { - WINE_TRACE("The key was not found - skipping\n"); - return TRUE; - } - - res=RegQueryValueExW( hSession, ValueName, NULL, NULL /* The value type does not really interest us, as it is not - truly a REG_MULTI_SZ anyways */, - NULL, &dataLength ); - if( res==ERROR_FILE_NOT_FOUND ) - { - /* No value - nothing to do. Great! */ - WINE_TRACE("Value not present - nothing to rename\n"); - res=TRUE; + if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, NULL, &dataLength )) goto end; - } + if (!(buffer = HeapAlloc( GetProcessHeap(), 0, dataLength ))) goto end; - if( res!=ERROR_SUCCESS ) - { - WINE_ERR("Couldn't query value's length (%d)\n", res ); - res=FALSE; + if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, + (LPBYTE)buffer, &dataLength )) goto end; - } - - buffer=HeapAlloc( GetProcessHeap(),0,dataLength ); - if( buffer==NULL ) - { - WINE_ERR("Couldn't allocate %u bytes for the value\n", dataLength ); - res=FALSE; - goto end; - } - - res=RegQueryValueExW( hSession, ValueName, NULL, NULL, (LPBYTE)buffer, &dataLength ); - if( res!=ERROR_SUCCESS ) - { - WINE_ERR("Couldn't query value after successfully querying before (%u),\n" - "please report to wine-devel@winehq.org\n", res); - res=FALSE; - goto end; - } /* Make sure that the data is long enough and ends with two NULLs. This * simplifies the code later on. @@ -902,19 +795,13 @@ static BOOL pendingRename(void) if( dataLength<2*sizeof(buffer[0]) || buffer[dataLength/sizeof(buffer[0])-1]!='\0' || buffer[dataLength/sizeof(buffer[0])-2]!='\0' ) - { - WINE_ERR("Improper value format - doesn't end with NULL\n"); - res=FALSE; goto end; - } for( src=buffer; (src-buffer)*sizeof(src[0])User.Sid, &sid); - if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_list, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &hkey, NULL)) + if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", + 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL)) { if (!RegCreateKeyExW(hkey, sid, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &profile_hkey, NULL)) { DWORD flags = 0; if (SHGetSpecialFolderPathW(NULL, profile, CSIDL_PROFILE, TRUE)) - set_reg_value(profile_hkey, profile_image_path, profile); + set_reg_value(profile_hkey, L"ProfileImagePath", profile); RegSetValueExW( profile_hkey, L"Flags", 0, REG_DWORD, (const BYTE *)&flags, sizeof(flags) ); RegCloseKey(profile_hkey); } @@ -1418,7 +1267,7 @@ static void update_user_profile(void) /* execute rundll32 on the wine.inf file if necessary */ static void update_wineprefix( BOOL force ) { - const WCHAR *config_dir = _wgetenv( wineconfigdirW ); + const WCHAR *config_dir = _wgetenv( L"WINECONFIGDIR" ); WCHAR *inf_path = get_wine_inf_path(); int fd; struct stat st; @@ -1563,13 +1412,6 @@ static void usage( int status ) int __cdecl main( int argc, char *argv[] ) { - static const WCHAR RunW[] = {'R','u','n',0}; - static const WCHAR RunOnceW[] = {'R','u','n','O','n','c','e',0}; - static const WCHAR RunServicesW[] = {'R','u','n','S','e','r','v','i','c','e','s',0}; - static const WCHAR RunServicesOnceW[] = {'R','u','n','S','e','r','v','i','c','e','s','O','n','c','e',0}; - static const WCHAR wineboot_eventW[] = {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s', - '\\','_','_','w','i','n','e','b','o','o','t','_','e','v','e','n','t',0}; - /* First, set the current directory to SystemRoot */ int i, j; BOOL end_session, force, init, kill, restart, shutdown, update; @@ -1655,7 +1497,7 @@ int __cdecl main( int argc, char *argv[] ) /* create event to be inherited by services.exe */ InitializeObjectAttributes( &attr, &nameW, OBJ_OPENIF | OBJ_INHERIT, 0, NULL ); - RtlInitUnicodeString( &nameW, wineboot_eventW ); + RtlInitUnicodeString( &nameW, L"\\KernelObjects\\__wineboot_event" ); NtCreateEvent( &event, EVENT_ALL_ACCESS, &attr, NotificationEvent, 0 ); ResetEvent( event ); /* in case this is a restart */ @@ -1667,23 +1509,23 @@ int __cdecl main( int argc, char *argv[] ) pendingRename(); ProcessWindowsFileProtection(); - ProcessRunKeys( HKEY_LOCAL_MACHINE, RunServicesOnceW, TRUE, FALSE ); + ProcessRunKeys( HKEY_LOCAL_MACHINE, L"RunServicesOnce", TRUE, FALSE ); if (init || (kill && !restart)) { - ProcessRunKeys( HKEY_LOCAL_MACHINE, RunServicesW, FALSE, FALSE ); + ProcessRunKeys( HKEY_LOCAL_MACHINE, L"RunServices", FALSE, FALSE ); start_services_process(); } if (init || update) update_wineprefix( update ); create_volatile_environment_registry_key(); - ProcessRunKeys( HKEY_LOCAL_MACHINE, RunOnceW, TRUE, TRUE ); + ProcessRunKeys( HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE ); if (!init && !restart) { - ProcessRunKeys( HKEY_LOCAL_MACHINE, RunW, FALSE, FALSE ); - ProcessRunKeys( HKEY_CURRENT_USER, RunW, FALSE, FALSE ); + ProcessRunKeys( HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE ); + ProcessRunKeys( HKEY_CURRENT_USER, L"Run", FALSE, FALSE ); ProcessStartupItems(); }