kernel32: If necessary reload the environment after wineboot has run.

This commit is contained in:
Alexandre Julliard 2008-04-24 11:53:45 +02:00
parent 2f0b111243
commit 4073805aeb

View File

@ -372,7 +372,7 @@ static void set_registry_variables( HANDLE hkey, ULONG type )
* %SystemRoot% which are predefined. But Wine defines these in the * %SystemRoot% which are predefined. But Wine defines these in the
* registry, so we need two passes. * registry, so we need two passes.
*/ */
static void set_registry_environment(void) static BOOL set_registry_environment(void)
{ {
static const WCHAR env_keyW[] = {'M','a','c','h','i','n','e','\\', static const WCHAR env_keyW[] = {'M','a','c','h','i','n','e','\\',
'S','y','s','t','e','m','\\', 'S','y','s','t','e','m','\\',
@ -385,6 +385,7 @@ static void set_registry_environment(void)
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW; UNICODE_STRING nameW;
HANDLE hkey; HANDLE hkey;
BOOL ret = FALSE;
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
@ -400,10 +401,11 @@ static void set_registry_environment(void)
set_registry_variables( hkey, REG_SZ ); set_registry_variables( hkey, REG_SZ );
set_registry_variables( hkey, REG_EXPAND_SZ ); set_registry_variables( hkey, REG_EXPAND_SZ );
NtClose( hkey ); NtClose( hkey );
ret = TRUE;
} }
/* then the ones for the current user */ /* then the ones for the current user */
if (RtlOpenCurrentUser( KEY_ALL_ACCESS, &attr.RootDirectory ) != STATUS_SUCCESS) return; if (RtlOpenCurrentUser( KEY_ALL_ACCESS, &attr.RootDirectory ) != STATUS_SUCCESS) return ret;
RtlInitUnicodeString( &nameW, envW ); RtlInitUnicodeString( &nameW, envW );
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) == STATUS_SUCCESS) if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) == STATUS_SUCCESS)
{ {
@ -412,6 +414,7 @@ static void set_registry_environment(void)
NtClose( hkey ); NtClose( hkey );
} }
NtClose( attr.RootDirectory ); NtClose( attr.RootDirectory );
return ret;
} }
/*********************************************************************** /***********************************************************************
@ -730,45 +733,6 @@ static void init_windows_dirs(void)
} }
/***********************************************************************
* process_init
*
* Main process initialisation code
*/
static BOOL process_init(void)
{
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
PEB *peb = NtCurrentTeb()->Peb;
RTL_USER_PROCESS_PARAMETERS *params = peb->ProcessParameters;
PTHREAD_Init();
setbuf(stdout,NULL);
setbuf(stderr,NULL);
kernel32_handle = GetModuleHandleW(kernel32W);
LOCALE_Init();
if (!params->Environment)
{
/* Copy the parent environment */
if (!build_initial_environment( __wine_main_environ )) return FALSE;
/* convert old configuration to new format */
convert_old_config();
set_registry_environment();
set_additional_environment();
}
init_windows_dirs();
init_current_directory( &params->CurrentDirectory );
return TRUE;
}
/*********************************************************************** /***********************************************************************
* start_wineboot * start_wineboot
* *
@ -893,15 +857,41 @@ static void set_process_name( int argc, char *argv[] )
*/ */
void __wine_kernel_init(void) void __wine_kernel_init(void)
{ {
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
static const WCHAR dotW[] = {'.',0}; static const WCHAR dotW[] = {'.',0};
static const WCHAR exeW[] = {'.','e','x','e',0}; static const WCHAR exeW[] = {'.','e','x','e',0};
WCHAR *p, main_exe_name[MAX_PATH+1]; WCHAR *p, main_exe_name[MAX_PATH+1];
PEB *peb = NtCurrentTeb()->Peb; PEB *peb = NtCurrentTeb()->Peb;
RTL_USER_PROCESS_PARAMETERS *params = peb->ProcessParameters;
HANDLE boot_event = 0; HANDLE boot_event = 0;
BOOL got_environment = TRUE;
/* Initialize everything */ /* Initialize everything */
if (!process_init()) exit(1);
PTHREAD_Init();
setbuf(stdout,NULL);
setbuf(stderr,NULL);
kernel32_handle = GetModuleHandleW(kernel32W);
LOCALE_Init();
if (!params->Environment)
{
/* Copy the parent environment */
if (!build_initial_environment( __wine_main_environ )) exit(1);
/* convert old configuration to new format */
convert_old_config();
got_environment = set_registry_environment();
set_additional_environment();
}
init_windows_dirs();
init_current_directory( &params->CurrentDirectory );
set_process_name( __wine_main_argc, __wine_main_argv ); set_process_name( __wine_main_argc, __wine_main_argv );
set_library_wargv( __wine_main_argv ); set_library_wargv( __wine_main_argv );
@ -954,6 +944,8 @@ void __wine_kernel_init(void)
{ {
if (WaitForSingleObject( boot_event, 30000 )) WARN( "boot event wait timed out\n" ); if (WaitForSingleObject( boot_event, 30000 )) WARN( "boot event wait timed out\n" );
CloseHandle( boot_event ); CloseHandle( boot_event );
/* if we didn't find environment section, try again now that wineboot has run */
if (!got_environment) set_registry_environment();
} }
LdrInitializeThunk( 0, 0, 0, 0 ); LdrInitializeThunk( 0, 0, 0, 0 );