Alexandre Julliard : kernel32: If necessary reload the environment after wineboot has run.
Alexandre Julliard
julliard at winehq.org
Thu Apr 24 06:23:43 CDT 2008
Module: wine
Branch: master
Commit: 4073805aeb2900a1e2032115bd18859b9740a54e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4073805aeb2900a1e2032115bd18859b9740a54e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 24 11:53:45 2008 +0200
kernel32: If necessary reload the environment after wineboot has run.
---
dlls/kernel32/process.c | 76 +++++++++++++++++++++--------------------------
1 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index fe523d6..59fd1f5 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -372,7 +372,7 @@ static void set_registry_variables( HANDLE hkey, ULONG type )
* %SystemRoot% which are predefined. But Wine defines these in the
* 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','\\',
'S','y','s','t','e','m','\\',
@@ -385,6 +385,7 @@ static void set_registry_environment(void)
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
HANDLE hkey;
+ BOOL ret = FALSE;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
@@ -400,10 +401,11 @@ static void set_registry_environment(void)
set_registry_variables( hkey, REG_SZ );
set_registry_variables( hkey, REG_EXPAND_SZ );
NtClose( hkey );
+ ret = TRUE;
}
/* 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 );
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) == STATUS_SUCCESS)
{
@@ -412,6 +414,7 @@ static void set_registry_environment(void)
NtClose( hkey );
}
NtClose( attr.RootDirectory );
+ return ret;
}
/***********************************************************************
@@ -731,45 +734,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( ¶ms->CurrentDirectory );
-
- return TRUE;
-}
-
-
-/***********************************************************************
* start_wineboot
*
* Start the wineboot process if necessary. Return the event to wait on.
@@ -893,15 +857,41 @@ static void set_process_name( int argc, char *argv[] )
*/
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 exeW[] = {'.','e','x','e',0};
WCHAR *p, main_exe_name[MAX_PATH+1];
PEB *peb = NtCurrentTeb()->Peb;
+ RTL_USER_PROCESS_PARAMETERS *params = peb->ProcessParameters;
HANDLE boot_event = 0;
+ BOOL got_environment = TRUE;
/* 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( ¶ms->CurrentDirectory );
+
set_process_name( __wine_main_argc, __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" );
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 );
More information about the wine-cvs
mailing list