Module: wine Branch: master Commit: 9d588819febfa6483a90900bf570b0e2cc09a4d3 URL: https://source.winehq.org/git/wine.git/?a=commit;h=9d588819febfa6483a90900bf...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Apr 1 22:57:51 2020 +0200
ntdll: Export the LDT copy from ntdll instead of libwine.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/krnl386.exe16/selector.c | 2 +- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/server.c | 5 ++++- dlls/ntdll/signal_i386.c | 21 ++++++++++++++------- 4 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/dlls/krnl386.exe16/selector.c b/dlls/krnl386.exe16/selector.c index 5702b25999..73284cf073 100644 --- a/dlls/krnl386.exe16/selector.c +++ b/dlls/krnl386.exe16/selector.c @@ -75,7 +75,7 @@ void init_selectors(void) if (!is_gdt_sel( wine_get_gs() )) first_ldt_entry += 512; if (!is_gdt_sel( wine_get_fs() )) first_ldt_entry += 512; RtlSetBits( &ldt_bitmap, 0, first_ldt_entry ); - ldt_copy = (struct ldt_copy *)&wine_ldt_copy; + ldt_copy = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "__wine_ldt_copy" ); }
/*********************************************************************** diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 13b0317744..873eef55d0 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1558,6 +1558,7 @@ @ cdecl wine_server_release_fd(long long) @ cdecl wine_server_send_fd(long) @ cdecl __wine_make_process_system() +@ extern -arch=i386 __wine_ldt_copy
# Debugging @ cdecl -norelay __wine_dbg_get_channel_flags(ptr) diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index 4facdc08a7..df847d09a2 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -1448,6 +1448,9 @@ void server_init_process(void) */ void server_init_process_done(void) { +#ifdef __i386__ + extern struct ldt_copy __wine_ldt_copy; +#endif PEB *peb = NtCurrentTeb()->Peb; IMAGE_NT_HEADERS *nt = RtlImageNtHeader( peb->ImageBaseAddress ); void *entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint; @@ -1471,7 +1474,7 @@ void server_init_process_done(void) { req->module = wine_server_client_ptr( peb->ImageBaseAddress ); #ifdef __i386__ - req->ldt_copy = wine_server_client_ptr( &wine_ldt_copy ); + req->ldt_copy = wine_server_client_ptr( &__wine_ldt_copy ); #endif req->entry = wine_server_client_ptr( entry ); req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI); diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index e812f634ff..0e033d53ba 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -2306,6 +2306,13 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) #define LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */ #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated */
+struct ldt_copy +{ + void *base[LDT_SIZE]; + unsigned int limit[LDT_SIZE]; + unsigned char flags[LDT_SIZE]; +} __wine_ldt_copy; + static WORD gdt_fs_sel;
static RTL_CRITICAL_SECTION ldt_section; @@ -2417,11 +2424,11 @@ static void ldt_set_entry( WORD sel, LDT_ENTRY entry ) exit(1); #endif
- wine_ldt_copy.base[index] = ldt_get_base( entry ); - wine_ldt_copy.limit[index] = ldt_get_limit( entry ); - wine_ldt_copy.flags[index] = (entry.HighWord.Bits.Type | - (entry.HighWord.Bits.Default_Big ? LDT_FLAGS_32BIT : 0) | - LDT_FLAGS_ALLOCATED); + __wine_ldt_copy.base[index] = ldt_get_base( entry ); + __wine_ldt_copy.limit[index] = ldt_get_limit( entry ); + __wine_ldt_copy.flags[index] = (entry.HighWord.Bits.Type | + (entry.HighWord.Bits.Default_Big ? LDT_FLAGS_32BIT : 0) | + LDT_FLAGS_ALLOCATED); }
static void ldt_init(void) @@ -2464,7 +2471,7 @@ WORD ldt_alloc_fs( TEB *teb, int first_thread ) ldt_lock(); for (idx = first_ldt_entry; idx < LDT_SIZE; idx++) { - if (wine_ldt_copy.flags[idx]) continue; + if (__wine_ldt_copy.flags[idx]) continue; ldt_set_entry( (idx << 3) | 7, entry ); break; } @@ -2479,7 +2486,7 @@ static void ldt_free_fs( WORD sel ) if (sel == gdt_fs_sel) return;
ldt_lock(); - wine_ldt_copy.flags[sel >> 3] = 0; + __wine_ldt_copy.flags[sel >> 3] = 0; ldt_unlock(); }