From 04762b357635d3adb85ccd5e3456e81c23033394 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 5 Apr 2021 12:04:41 +0200 Subject: [PATCH] ntdll: Move the global options initialization to LdrInitializeThunk(). Signed-off-by: Alexandre Julliard --- dlls/ntdll/loader.c | 102 ++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 35cef275e9a..8863a20d67e 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -3484,6 +3484,54 @@ static void process_breakpoint(void) } +/*********************************************************************** + * load_global_options + */ +static void load_global_options(void) +{ + OBJECT_ATTRIBUTES attr; + UNICODE_STRING name_str; + HANDLE hkey; + ULONG value; + + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.ObjectName = &name_str; + attr.Attributes = OBJ_CASE_INSENSITIVE; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + RtlInitUnicodeString( &name_str, L"Machine\\System\\CurrentControlSet\\Control\\Session Manager" ); + + if (!NtOpenKey( &hkey, KEY_QUERY_VALUE, &attr )) + { + query_dword_option( hkey, L"GlobalFlag", &NtCurrentTeb()->Peb->NtGlobalFlag ); + query_dword_option( hkey, L"SafeProcessSearchMode", &path_safe_mode ); + query_dword_option( hkey, L"SafeDllSearchMode", &dll_safe_mode ); + + if (!query_dword_option( hkey, L"CriticalSectionTimeout", &value )) + NtCurrentTeb()->Peb->CriticalSectionTimeout.QuadPart = (ULONGLONG)value * -10000000; + + if (!query_dword_option( hkey, L"HeapSegmentReserve", &value )) + NtCurrentTeb()->Peb->HeapSegmentReserve = value; + + if (!query_dword_option( hkey, L"HeapSegmentCommit", &value )) + NtCurrentTeb()->Peb->HeapSegmentCommit = value; + + if (!query_dword_option( hkey, L"HeapDeCommitTotalFreeThreshold", &value )) + NtCurrentTeb()->Peb->HeapDeCommitTotalFreeThreshold = value; + + if (!query_dword_option( hkey, L"HeapDeCommitFreeBlockThreshold", &value )) + NtCurrentTeb()->Peb->HeapDeCommitFreeBlockThreshold = value; + + NtClose( hkey ); + } + LdrQueryImageFileExecutionOptions( &NtCurrentTeb()->Peb->ProcessParameters->ImagePathName, + L"GlobalFlag", REG_DWORD, &NtCurrentTeb()->Peb->NtGlobalFlag, + sizeof(DWORD), NULL ); + heap_set_debug_flags( GetProcessHeap() ); +} + + #ifndef _WIN64 void *Wow64Transition = NULL; @@ -3568,6 +3616,9 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR ANSI_STRING func_name; WINE_MODREF *kernel32; + init_user_process_params(); + load_global_options(); + version_init(); #ifndef _WIN64 init_wow64(); #endif @@ -3657,54 +3708,6 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR } -/*********************************************************************** - * load_global_options - */ -static void load_global_options(void) -{ - OBJECT_ATTRIBUTES attr; - UNICODE_STRING name_str; - HANDLE hkey; - ULONG value; - - attr.Length = sizeof(attr); - attr.RootDirectory = 0; - attr.ObjectName = &name_str; - attr.Attributes = OBJ_CASE_INSENSITIVE; - attr.SecurityDescriptor = NULL; - attr.SecurityQualityOfService = NULL; - RtlInitUnicodeString( &name_str, L"Machine\\System\\CurrentControlSet\\Control\\Session Manager" ); - - if (!NtOpenKey( &hkey, KEY_QUERY_VALUE, &attr )) - { - query_dword_option( hkey, L"GlobalFlag", &NtCurrentTeb()->Peb->NtGlobalFlag ); - query_dword_option( hkey, L"SafeProcessSearchMode", &path_safe_mode ); - query_dword_option( hkey, L"SafeDllSearchMode", &dll_safe_mode ); - - if (!query_dword_option( hkey, L"CriticalSectionTimeout", &value )) - NtCurrentTeb()->Peb->CriticalSectionTimeout.QuadPart = (ULONGLONG)value * -10000000; - - if (!query_dword_option( hkey, L"HeapSegmentReserve", &value )) - NtCurrentTeb()->Peb->HeapSegmentReserve = value; - - if (!query_dword_option( hkey, L"HeapSegmentCommit", &value )) - NtCurrentTeb()->Peb->HeapSegmentCommit = value; - - if (!query_dword_option( hkey, L"HeapDeCommitTotalFreeThreshold", &value )) - NtCurrentTeb()->Peb->HeapDeCommitTotalFreeThreshold = value; - - if (!query_dword_option( hkey, L"HeapDeCommitFreeBlockThreshold", &value )) - NtCurrentTeb()->Peb->HeapDeCommitFreeBlockThreshold = value; - - NtClose( hkey ); - } - LdrQueryImageFileExecutionOptions( &NtCurrentTeb()->Peb->ProcessParameters->ImagePathName, - L"GlobalFlag", REG_DWORD, &NtCurrentTeb()->Peb->NtGlobalFlag, - sizeof(DWORD), NULL ); - heap_set_debug_flags( GetProcessHeap() ); -} - - /*********************************************************************** * RtlImageDirectoryEntryToData (NTDLL.@) */ @@ -4067,9 +4070,6 @@ static NTSTATUS process_init(void) InitializeListHead( &ldr.InMemoryOrderModuleList ); InitializeListHead( &ldr.InInitializationOrderModuleList ); - init_user_process_params(); - load_global_options(); - version_init(); return STATUS_SUCCESS; }