Alexandre Julliard : ntdll: Initialize earlier things that need the executable name.
Alexandre Julliard
julliard at winehq.org
Thu Nov 7 16:16:04 CST 2019
Module: wine
Branch: master
Commit: b7db0b52cee65a008f503ce727befcad3ba8d28a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b7db0b52cee65a008f503ce727befcad3ba8d28a
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Nov 7 16:54:31 2019 +0100
ntdll: Initialize earlier things that need the executable name.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/loader.c | 45 ++++++++++++++++++++++-----------------------
dlls/ntdll/ntdll_misc.h | 2 +-
dlls/ntdll/version.c | 33 +++++++++++++++------------------
3 files changed, 38 insertions(+), 42 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index cc7bf6900b..b16d646bdd 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3832,28 +3832,33 @@ static void load_global_options(void)
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &name_str, sessionW );
- if (NtOpenKey( &hkey, KEY_QUERY_VALUE, &attr )) return;
-
- query_dword_option( hkey, globalflagW, &NtCurrentTeb()->Peb->NtGlobalFlag );
- query_dword_option( hkey, safesearchW, &path_safe_mode );
- query_dword_option( hkey, safedllmodeW, &dll_safe_mode );
+ if (!NtOpenKey( &hkey, KEY_QUERY_VALUE, &attr ))
+ {
+ query_dword_option( hkey, globalflagW, &NtCurrentTeb()->Peb->NtGlobalFlag );
+ query_dword_option( hkey, safesearchW, &path_safe_mode );
+ query_dword_option( hkey, safedllmodeW, &dll_safe_mode );
- if (!query_dword_option( hkey, critsectW, &value ))
- NtCurrentTeb()->Peb->CriticalSectionTimeout.QuadPart = (ULONGLONG)value * -10000000;
+ if (!query_dword_option( hkey, critsectW, &value ))
+ NtCurrentTeb()->Peb->CriticalSectionTimeout.QuadPart = (ULONGLONG)value * -10000000;
- if (!query_dword_option( hkey, heapresW, &value ))
- NtCurrentTeb()->Peb->HeapSegmentReserve = value;
+ if (!query_dword_option( hkey, heapresW, &value ))
+ NtCurrentTeb()->Peb->HeapSegmentReserve = value;
- if (!query_dword_option( hkey, heapcommitW, &value ))
- NtCurrentTeb()->Peb->HeapSegmentCommit = value;
+ if (!query_dword_option( hkey, heapcommitW, &value ))
+ NtCurrentTeb()->Peb->HeapSegmentCommit = value;
- if (!query_dword_option( hkey, decommittotalW, &value ))
- NtCurrentTeb()->Peb->HeapDeCommitTotalFreeThreshold = value;
+ if (!query_dword_option( hkey, decommittotalW, &value ))
+ NtCurrentTeb()->Peb->HeapDeCommitTotalFreeThreshold = value;
- if (!query_dword_option( hkey, decommitfreeW, &value ))
- NtCurrentTeb()->Peb->HeapDeCommitFreeBlockThreshold = value;
+ if (!query_dword_option( hkey, decommitfreeW, &value ))
+ NtCurrentTeb()->Peb->HeapDeCommitFreeBlockThreshold = value;
- NtClose( hkey );
+ NtClose( hkey );
+ }
+ LdrQueryImageFileExecutionOptions( &NtCurrentTeb()->Peb->ProcessParameters->ImagePathName,
+ globalflagW, REG_DWORD, &NtCurrentTeb()->Peb->NtGlobalFlag,
+ sizeof(DWORD), NULL );
+ heap_set_debug_flags( GetProcessHeap() );
}
@@ -4223,8 +4228,6 @@ void __wine_process_init(void)
static const WCHAR kernel32W[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\',
'k','e','r','n','e','l','3','2','.','d','l','l',0};
- static const WCHAR globalflagW[] = {'G','l','o','b','a','l','F','l','a','g',0};
-
WINE_MODREF *wm;
NTSTATUS status;
ANSI_STRING func_name;
@@ -4239,6 +4242,7 @@ void __wine_process_init(void)
umask( FILE_umask );
load_global_options();
+ version_init();
/* setup the load callback and create ntdll modref */
wine_dll_set_callback( load_builtin_callback );
@@ -4268,13 +4272,8 @@ void __wine_process_init(void)
}
NtCurrentTeb()->Peb->LoaderLock = &loader_section;
- version_init( wm->ldr.FullDllName.Buffer );
virtual_set_large_address_space();
- LdrQueryImageFileExecutionOptions( &wm->ldr.FullDllName, globalflagW, REG_DWORD,
- &NtCurrentTeb()->Peb->NtGlobalFlag, sizeof(DWORD), NULL );
- heap_set_debug_flags( GetProcessHeap() );
-
/* the main exe needs to be the first in the load order list */
RemoveEntryList( &wm->ldr.InLoadOrderModuleList );
InsertHeadList( &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList );
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index e2280dea84..074792ff2a 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -77,7 +77,7 @@ extern void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL s
extern void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_exit_thread( int status ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_exit_process( int status ) DECLSPEC_HIDDEN;
-extern void version_init( const WCHAR *appname ) DECLSPEC_HIDDEN;
+extern void version_init(void) DECLSPEC_HIDDEN;
extern void debug_init(void) DECLSPEC_HIDDEN;
extern void thread_init(void) DECLSPEC_HIDDEN;
extern void actctx_init(void) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c
index 9c9f2cc8cd..bd03382899 100644
--- a/dlls/ntdll/version.c
+++ b/dlls/ntdll/version.c
@@ -485,7 +485,7 @@ static BOOL parse_win_version( HANDLE hkey )
/**********************************************************************
* version_init
*/
-void version_init( const WCHAR *appname )
+void version_init(void)
{
static const WCHAR configW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
static const WCHAR appdefaultsW[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
@@ -493,6 +493,8 @@ void version_init( const WCHAR *appname )
UNICODE_STRING nameW;
HANDLE root, hkey, config_key;
BOOL got_win_ver = FALSE;
+ const WCHAR *p, *appname = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
+ WCHAR appversion[MAX_PATH+20];
current_version = &VersionData[WIN7];
@@ -511,26 +513,21 @@ void version_init( const WCHAR *appname )
if (!config_key) goto done;
/* open AppDefaults\\appname key */
- if (appname && *appname)
- {
- const WCHAR *p;
- WCHAR appversion[MAX_PATH+20];
- if ((p = strrchrW( appname, '/' ))) appname = p + 1;
- if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
+ if ((p = strrchrW( appname, '/' ))) appname = p + 1;
+ if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
- strcpyW( appversion, appdefaultsW );
- strcatW( appversion, appname );
- RtlInitUnicodeString( &nameW, appversion );
- attr.RootDirectory = config_key;
+ strcpyW( appversion, appdefaultsW );
+ strcatW( appversion, appname );
+ RtlInitUnicodeString( &nameW, appversion );
+ attr.RootDirectory = config_key;
- /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe */
- if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
- {
- TRACE( "getting version from %s\n", debugstr_w(appversion) );
- got_win_ver = parse_win_version( hkey );
- NtClose( hkey );
- }
+ /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe */
+ if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
+ {
+ TRACE( "getting version from %s\n", debugstr_w(appversion) );
+ got_win_ver = parse_win_version( hkey );
+ NtClose( hkey );
}
if (!got_win_ver)
More information about the wine-cvs
mailing list