Commit 4a58b284 authored by Alexandre Julliard's avatar Alexandre Julliard

wineboot: Convert the rest of the code to Unicode.

Fix Windows File Protection handling to use the correct system directory.
parent e34244a3
...@@ -77,6 +77,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineboot); ...@@ -77,6 +77,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineboot);
extern BOOL shutdown_close_windows( BOOL force ); extern BOOL shutdown_close_windows( BOOL force );
extern void kill_processes( BOOL kill_desktop ); extern void kill_processes( BOOL kill_desktop );
static WCHAR windowsdir[MAX_PATH];
/* Performs the rename operations dictated in %SystemRoot%\Wininit.ini. /* Performs the rename operations dictated in %SystemRoot%\Wininit.ini.
* Returns FALSE if there was an error, or otherwise if all is ok. * Returns FALSE if there was an error, or otherwise if all is ok.
...@@ -483,79 +484,81 @@ end: ...@@ -483,79 +484,81 @@ end:
* known good versions. The only programs that should install into this dll * known good versions. The only programs that should install into this dll
* cache are Windows Updates and IE (which is treated like a Windows Update) * cache are Windows Updates and IE (which is treated like a Windows Update)
* *
* Implementing this allows installing ie in win2k mode to actaully install the * Implementing this allows installing ie in win2k mode to actually install the
* system dlls that we expect and need * system dlls that we expect and need
*/ */
static int ProcessWindowsFileProtection(void) static int ProcessWindowsFileProtection(void)
{ {
WIN32_FIND_DATA finddata; static const WCHAR winlogonW[] = {'S','o','f','t','w','a','r','e','\\',
LPSTR custom_dllcache = NULL; 'M','i','c','r','o','s','o','f','t','\\',
static CHAR default_dllcache[] = "C:\\Windows\\System32\\dllcache"; 'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'W','i','n','l','o','g','o','n',0};
static const WCHAR cachedirW[] = {'S','F','C','D','l','l','C','a','c','h','e','D','i','r',0};
static const WCHAR dllcacheW[] = {'\\','d','l','l','c','a','c','h','e','\\','*',0};
static const WCHAR wildcardW[] = {'\\','*',0};
WIN32_FIND_DATAW finddata;
HANDLE find_handle; HANDLE find_handle;
BOOL find_rc; BOOL find_rc;
DWORD rc; DWORD rc;
HKEY hkey; HKEY hkey;
LPSTR dllcache; LPWSTR dllcache = NULL;
CHAR find_string[MAX_PATH];
CHAR windowsdir[MAX_PATH];
rc = RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", &hkey ); if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, winlogonW, &hkey ))
if (rc == ERROR_SUCCESS)
{ {
DWORD sz = 0; DWORD sz = 0;
rc = RegQueryValueEx( hkey, "SFCDllCacheDir", 0, NULL, NULL, &sz); if (!RegQueryValueExW( hkey, cachedirW, 0, NULL, NULL, &sz))
if (rc == ERROR_MORE_DATA)
{ {
sz++; sz += sizeof(WCHAR);
custom_dllcache = HeapAlloc(GetProcessHeap(),0,sz); dllcache = HeapAlloc(GetProcessHeap(),0,sz + sizeof(wildcardW));
RegQueryValueEx( hkey, "SFCDllCacheDir", 0, NULL, (LPBYTE)custom_dllcache, &sz); RegQueryValueExW( hkey, cachedirW, 0, NULL, (LPBYTE)dllcache, &sz);
strcatW( dllcache, wildcardW );
} }
} }
RegCloseKey(hkey); RegCloseKey(hkey);
if (custom_dllcache) if (!dllcache)
dllcache = custom_dllcache; {
else DWORD sz = GetSystemDirectoryW( NULL, 0 );
dllcache = default_dllcache; dllcache = HeapAlloc( GetProcessHeap(), 0, sz * sizeof(WCHAR) + sizeof(dllcacheW));
GetSystemDirectoryW( dllcache, sz );
strcpy(find_string,dllcache); strcatW( dllcache, dllcacheW );
strcat(find_string,"\\*.*"); }
GetWindowsDirectory(windowsdir,MAX_PATH);
find_handle = FindFirstFile(find_string,&finddata); find_handle = FindFirstFileW(dllcache,&finddata);
find_rc = find_handle != INVALID_HANDLE_VALUE; find_rc = find_handle != INVALID_HANDLE_VALUE;
while (find_rc) while (find_rc)
{ {
CHAR targetpath[MAX_PATH]; static const WCHAR dotW[] = {'.',0};
CHAR currentpath[MAX_PATH]; static const WCHAR dotdotW[] = {'.','.',0};
WCHAR targetpath[MAX_PATH];
WCHAR currentpath[MAX_PATH];
UINT sz; UINT sz;
UINT sz2; UINT sz2;
CHAR tempfile[MAX_PATH]; WCHAR tempfile[MAX_PATH];
if (strcmp(finddata.cFileName,".") == 0 || if (strcmpW(finddata.cFileName,dotW) == 0 || strcmpW(finddata.cFileName,dotdotW) == 0)
strcmp(finddata.cFileName,"..") == 0)
{ {
find_rc = FindNextFile(find_handle,&finddata); find_rc = FindNextFileW(find_handle,&finddata);
continue; continue;
} }
sz = MAX_PATH; sz = MAX_PATH;
sz2 = MAX_PATH; sz2 = MAX_PATH;
VerFindFile(VFFF_ISSHAREDFILE, finddata.cFileName, windowsdir, VerFindFileW(VFFF_ISSHAREDFILE, finddata.cFileName, windowsdir,
windowsdir, currentpath, &sz, targetpath,&sz2); windowsdir, currentpath, &sz, targetpath, &sz2);
sz = MAX_PATH; sz = MAX_PATH;
rc = VerInstallFile(0, finddata.cFileName, finddata.cFileName, rc = VerInstallFileW(0, finddata.cFileName, finddata.cFileName,
dllcache, targetpath, currentpath, tempfile,&sz); dllcache, targetpath, currentpath, tempfile, &sz);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
{ {
WINE_ERR("WFP: %s error 0x%x\n",finddata.cFileName,rc); WINE_ERR("WFP: %s error 0x%x\n",wine_dbgstr_w(finddata.cFileName),rc);
DeleteFile(tempfile); DeleteFileW(tempfile);
} }
find_rc = FindNextFile(find_handle,&finddata); find_rc = FindNextFileW(find_handle,&finddata);
} }
FindClose(find_handle); FindClose(find_handle);
HeapFree(GetProcessHeap(),0,custom_dllcache); HeapFree(GetProcessHeap(),0,dllcache);
return 1; return 1;
} }
...@@ -714,36 +717,16 @@ static const struct option long_options[] = ...@@ -714,36 +717,16 @@ static const struct option long_options[] =
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
/* First, set the current directory to SystemRoot */ /* First, set the current directory to SystemRoot */
TCHAR gen_path[MAX_PATH];
DWORD res;
int optc; int optc;
int end_session = 0, force = 0, kill = 0, restart = 0, shutdown = 0; int end_session = 0, force = 0, kill = 0, restart = 0, shutdown = 0;
res=GetWindowsDirectory( gen_path, sizeof(gen_path) ); GetWindowsDirectoryW( windowsdir, MAX_PATH );
if( !SetCurrentDirectoryW( windowsdir ) )
if( res==0 )
{ {
WINE_ERR("Couldn't get the windows directory - error %d\n", WINE_ERR("Cannot set the dir to %s (%d)\n", wine_dbgstr_w(windowsdir), GetLastError() );
GetLastError() );
return 100;
}
if( res>=sizeof(gen_path) )
{
WINE_ERR("Windows path too long (%d)\n", res );
return 100;
}
if( !SetCurrentDirectory( gen_path ) )
{
WINE_ERR("Cannot set the dir to %s (%d)\n", gen_path, GetLastError() );
return 100; return 100;
} }
while ((optc = getopt_long(argc, argv, short_options, long_options, NULL )) != -1) while ((optc = getopt_long(argc, argv, short_options, long_options, NULL )) != -1)
{ {
switch(optc) switch(optc)
......
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