wine-staging/patches/ntdll-WRITECOPY/0003-ntdll-Install-signal-handlers-a-bit-earlier.patch

64 lines
2.6 KiB
Diff

From 96831bd0bda656192510397cd18cb2c4bff5d8f4 Mon Sep 17 00:00:00 2001
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Thu, 22 Aug 2024 18:42:33 -0500
Subject: [PATCH 03/10] ntdll: Install signal handlers a bit earlier.
The wine-staging WRITECOPY implementation needs to be able to handle write faults while relocating builtin modules loaded during process initialization.
Note that the comment about debug events isn't relevant anymore because these exceptions all happen on the Unix stack anyway.
Probably there's a better solution involving simply not write-protecting these pages until we get to PE code, but that's not worth writing when this whole patch set is moribund anyway.
---
dlls/ntdll/unix/loader.c | 1 +
dlls/ntdll/unix/server.c | 5 -----
dlls/ntdll/unix/signal_i386.c | 5 ++++-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 92f2e2eb3a3..a6ea16bb7bb 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1866,6 +1866,7 @@ static void start_main_thread(void)
set_load_order_app_name( main_wargv[0] );
init_thread_stack( teb, 0, 0, 0 );
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
+ signal_init_process();
load_ntdll();
load_wow64_ntdll( main_image_info.Machine );
load_apiset_dll();
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 27dbf1331aa..80504e3459c 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -1674,11 +1674,6 @@ void server_init_process_done(void)
send_server_task_port();
#endif
- /* Install signal handlers; this cannot be done earlier, since we cannot
- * send exceptions to the debugger before the create process event that
- * is sent by init_process_done */
- signal_init_process();
-
/* always send the native TEB */
if (!(teb = NtCurrentTeb64())) teb = NtCurrentTeb();
diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c
index 61d41ec3589..b838a7a8669 100644
--- a/dlls/ntdll/unix/signal_i386.c
+++ b/dlls/ntdll/unix/signal_i386.c
@@ -719,7 +719,10 @@ static inline void *init_handler( const ucontext_t *sigcontext )
{
struct x86_thread_data *thread_data = (struct x86_thread_data *)&teb->GdiTebBatch;
set_fs( thread_data->fs );
- set_gs( thread_data->gs );
+ /* FIXME ZF: This is a bit of a hack, but it doesn't matter,
+ * since this patch set goes in the wrong direction anyway. */
+ if (thread_data->gs)
+ set_gs( thread_data->gs );
}
#endif
--
2.45.2