[PATCH] ntdll: Manually find the address of RtlUserThreadStart.

Huw Davies huw at codeweavers.com
Mon Jun 15 06:31:17 CDT 2020


On i386 macOS allowing the dynamic loader to do so results in eax and ebx
being cleared.

Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/ntdll/unix/thread.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 97b191e1a5b..c337e672acc 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -140,6 +140,7 @@ static void start_thread( TEB *teb )
     struct debug_info debug_info;
     BOOL suspend;
     ULONG_PTR cookie;
+    static void *pRtlUserThreadStart;
 
     debug_info.str_pos = debug_info.out_pos = 0;
     thread_data->debug_info = &debug_info;
@@ -151,7 +152,24 @@ static void start_thread( TEB *teb )
         RtlActivateActivationContext( 0, info->actctx, &cookie );
         RtlReleaseActivationContext( info->actctx );
     }
-    signal_start_thread( info->entry, info->arg, suspend, RtlUserThreadStart, teb );
+
+    if (!pRtlUserThreadStart)
+    {
+        static const WCHAR ntdll[] = {'n','t','d','l','l','.','d','l','l',0};
+        UNICODE_STRING mod_name;
+        ANSI_STRING fn_name;
+        HMODULE module;
+        void *addr;
+
+        RtlInitUnicodeString( &mod_name, ntdll );
+        RtlInitAnsiString( &fn_name, "RtlUserThreadStart" );
+
+        LdrGetDllHandle( NULL, 0, &mod_name, &module );
+        LdrGetProcedureAddress( module, &fn_name, 0, &addr );
+        pRtlUserThreadStart = addr;
+    }
+
+    signal_start_thread( info->entry, info->arg, suspend, pRtlUserThreadStart, teb );
 }
 
 
-- 
2.23.0




More information about the wine-devel mailing list