From 7b0d44f8873aa9eec58716057b36d8d060fc04c3 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 25 Feb 2023 19:56:00 +1100 Subject: [PATCH] Rebase against 3fb2a5d55e948670222170075f0054a2aabf8d7e. --- ...t-HashLinks-field-in-LDR-module-data.patch | 24 +++++++++---------- ...Allow-to-modify-reserved-LDT-entries.patch | 23 ------------------ staging/upstream-commit | 2 +- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/patches/ntdll-HashLinks/0001-ntdll-Implement-HashLinks-field-in-LDR-module-data.patch b/patches/ntdll-HashLinks/0001-ntdll-Implement-HashLinks-field-in-LDR-module-data.patch index 688313b3..f0785c80 100644 --- a/patches/ntdll-HashLinks/0001-ntdll-Implement-HashLinks-field-in-LDR-module-data.patch +++ b/patches/ntdll-HashLinks/0001-ntdll-Implement-HashLinks-field-in-LDR-module-data.patch @@ -1,4 +1,4 @@ -From c933925dbe192c65d00bfa9bccc26bb7b21984fa Mon Sep 17 00:00:00 2001 +From eb96135501ef2822072e8f774868dd55ab3935ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 3 Apr 2017 05:30:27 +0200 Subject: [PATCH] ntdll: Implement HashLinks field in LDR module data. @@ -109,10 +109,10 @@ index 365f4465fc7..aca2b0f24cb 100644 test_dll_file( "kernel32.dll" ); test_dll_file( "advapi32.dll" ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 7661227e951..1087cf72d99 100644 +index cbd2fa2d384..693ba94dc71 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -128,6 +128,9 @@ struct file_id +@@ -129,6 +129,9 @@ struct file_id BYTE ObjectId[16]; }; @@ -122,7 +122,7 @@ index 7661227e951..1087cf72d99 100644 /* internal representation of loaded modules */ typedef struct _wine_modref { -@@ -497,6 +500,33 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module ) +@@ -498,6 +501,33 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module ) } } @@ -156,7 +156,7 @@ index 7661227e951..1087cf72d99 100644 /************************************************************************* * get_modref * -@@ -1476,7 +1506,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name +@@ -1477,7 +1507,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name &wm->ldr.InLoadOrderLinks); InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderLinks); @@ -169,7 +169,7 @@ index 7661227e951..1087cf72d99 100644 if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT)) { -@@ -2154,6 +2189,7 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name, +@@ -2155,6 +2190,7 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name, /* the module has only be inserted in the load & memory order lists */ RemoveEntryList(&wm->ldr.InLoadOrderLinks); RemoveEntryList(&wm->ldr.InMemoryOrderLinks); @@ -177,7 +177,7 @@ index 7661227e951..1087cf72d99 100644 /* FIXME: there are several more dangling references * left. Including dlls loaded by this dll before the -@@ -3749,6 +3785,7 @@ static void free_modref( WINE_MODREF *wm ) +@@ -3796,6 +3832,7 @@ static void free_modref( WINE_MODREF *wm ) RemoveEntryList(&wm->ldr.InLoadOrderLinks); RemoveEntryList(&wm->ldr.InMemoryOrderLinks); @@ -185,7 +185,7 @@ index 7661227e951..1087cf72d99 100644 if (wm->ldr.InInitializationOrderLinks.Flink) RemoveEntryList(&wm->ldr.InInitializationOrderLinks); -@@ -4117,6 +4154,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR +@@ -4167,6 +4204,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR ANSI_STRING ctrl_routine = RTL_CONSTANT_STRING( "CtrlRoutine" ); WINE_MODREF *kernel32; PEB *peb = NtCurrentTeb()->Peb; @@ -193,9 +193,9 @@ index 7661227e951..1087cf72d99 100644 NtQueryVirtualMemory( GetCurrentProcess(), LdrInitializeThunk, MemoryBasicInformation, &meminfo, sizeof(meminfo), NULL ); -@@ -4135,6 +4173,10 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR - sizeof(peb->TlsExpansionBitmapBits) * 8 ); - RtlSetBits( peb->TlsBitmap, 0, 1 ); /* TLS index 0 is reserved and should be initialized to NULL. */ +@@ -4184,6 +4222,10 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR + /* TLS index 0 is always reserved, and wow64 reserves extra TLS entries */ + RtlSetBits( peb->TlsBitmap, 0, NtCurrentTeb()->WowTebOffset ? WOW64_TLS_MAX_NUMBER : 1 ); + /* initialize hash table */ + for (i = 0; i < HASH_MAP_SIZE; i++) @@ -205,5 +205,5 @@ index 7661227e951..1087cf72d99 100644 load_global_options(); version_init(); -- -2.39.0 +2.39.2 diff --git a/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch b/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch index 1be49d6d..65b68938 100644 --- a/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch +++ b/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch @@ -18,7 +18,6 @@ fails. --- dlls/kernel32/tests/thread.c | 4 ---- dlls/ntdll/unix/signal_i386.c | 2 -- - libs/wine/ldt.c | 4 +--- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c @@ -55,28 +54,6 @@ index 30f1aee4d62..0ab09c1b4df 100644 server_enter_uninterrupted_section( &ldt_mutex, &sigset ); if (sel1) ldt_set_entry( sel1, entry1 ); -diff --git a/libs/wine/ldt.c b/libs/wine/ldt.c -index 18b0b9be9bf..30d9b945f73 100644 ---- a/libs/wine/ldt.c -+++ b/libs/wine/ldt.c -@@ -200,8 +200,6 @@ static int internal_set_entry( unsigned short sel, const LDT_ENTRY *entry ) - { - int ret = 0, index = sel >> 3; - -- if (index < LDT_FIRST_ENTRY) return 0; /* cannot modify reserved entries */ -- - #ifdef linux - { - struct modify_ldt_s ldt_info; -@@ -253,7 +251,7 @@ static int internal_set_entry( unsigned short sel, const LDT_ENTRY *entry ) - wine_ldt_copy_obsolete.limit[index] = wine_ldt_get_limit(entry); - wine_ldt_copy_obsolete.flags[index] = (entry->HighWord.Bits.Type | - (entry->HighWord.Bits.Default_Big ? WINE_LDT_FLAGS_32BIT : 0) | -- (wine_ldt_copy_obsolete.flags[index] & WINE_LDT_FLAGS_ALLOCATED)); -+ WINE_LDT_FLAGS_ALLOCATED); - } - return ret; - } -- 2.27.0 diff --git a/staging/upstream-commit b/staging/upstream-commit index 28d2dd29..0c58a34f 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -4d0d7e49b9b33bba023ba67add84486ba4cc8efd +3fb2a5d55e948670222170075f0054a2aabf8d7e