Alexandre Julliard : ntdll: Support loading ntdll without a constructor.

Alexandre Julliard julliard at winehq.org
Tue Apr 21 15:59:46 CDT 2020


Module: wine
Branch: master
Commit: 3872dc55ef3825182fcf88afce719aca1af4ef2e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3872dc55ef3825182fcf88afce719aca1af4ef2e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Apr 21 11:27:11 2020 +0200

ntdll: Support loading ntdll without a constructor.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/loader.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 4868919b0b..65f9d3f298 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -4469,6 +4469,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
  */
 void __wine_process_init(void)
 {
+    extern IMAGE_NT_HEADERS __wine_spec_nt_header;
     static const WCHAR ntdllW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
                                    's','y','s','t','e','m','3','2','\\',
                                    'n','t','d','l','l','.','d','l','l',0};
@@ -4480,6 +4481,7 @@ void __wine_process_init(void)
     NTSTATUS status;
     ANSI_STRING func_name;
     UNICODE_STRING nt_name;
+    HMODULE ntdll_module;
     INITIAL_TEB stack;
     BOOL suspend;
     SIZE_T info_size;
@@ -4496,6 +4498,7 @@ void __wine_process_init(void)
     init_unix_codepage();
     init_directories();
     init_user_process_params( info_size );
+    params = peb->ProcessParameters;
 
     NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
 
@@ -4510,9 +4513,16 @@ void __wine_process_init(void)
     RtlInitUnicodeString( &nt_name, ntdllW );
     default_load_info.filename = &nt_name;
     wine_dll_set_callback( load_builtin_callback );
+    ntdll_module = (HMODULE)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff);
+    if (!get_modref( ntdll_module ))
+    {
+        map_so_dll( &__wine_spec_nt_header, ntdll_module );
+        status = build_so_dll_module( params->DllPath.Buffer, &nt_name, ntdll_module, 0, &wm );
+        assert( !status );
+    }
 
     RtlInitUnicodeString( &nt_name, kernel32W );
-    if ((status = load_builtin_dll( NULL, &nt_name, NULL, 0, &wm )) != STATUS_SUCCESS)
+    if ((status = load_builtin_dll( params->DllPath.Buffer, &nt_name, NULL, 0, &wm )) != STATUS_SUCCESS)
     {
         MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
         exit(1);
@@ -4527,7 +4537,6 @@ void __wine_process_init(void)
 
     init_locale( wm->ldr.BaseAddress );
 
-    params = peb->ProcessParameters;
     if (!(status = load_dll( params->DllPath.Buffer, params->ImagePathName.Buffer, NULL,
                              DONT_RESOLVE_DLL_REFERENCES, &wm )))
     {




More information about the wine-cvs mailing list