ntdll: Export the LDT copy from ntdll instead of libwine.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Alexandre Julliard 2020-04-01 22:57:51 +02:00
parent b544836952
commit 9d588819fe
4 changed files with 20 additions and 9 deletions

View File

@ -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" );
}
/***********************************************************************

View File

@ -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)

View File

@ -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);

View File

@ -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();
}