From 285e594688617fb5b35664f4970863ad48b6f117 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 3 Sep 2020 08:40:02 +1000 Subject: [PATCH] Rebase against 87f41e6b408dd01055ff6a378b90d089d61ec370. --- ...t-HashLinks-field-in-LDR-module-data.patch | 37 ++++++++++--------- ...andle-PAGE_WRITECOPY-protection.-try.patch | 20 +++++----- patches/patchinstall.sh | 2 +- ...ub-implementation-of-Wow64Transition.patch | 16 ++++---- staging/upstream-commit | 2 +- 5 files changed, 39 insertions(+), 38 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 cd42eb4e..d9581630 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,16 +1,16 @@ -From 443896688d090de7b35a794ae6dad87865312dc8 Mon Sep 17 00:00:00 2001 +From 6db04e49d442610e2d1d3c0ffc70d25a0024e1fe 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. --- dlls/kernel32/tests/loader.c | 75 ++++++++++++++++++++++++++++++++++++ - dlls/ntdll/loader.c | 64 ++++++++++++++++++++++++++++++ + dlls/ntdll/loader.c | 65 +++++++++++++++++++++++++++++++ include/winternl.h | 2 +- - 3 files changed, 140 insertions(+), 1 deletion(-) + 3 files changed, 141 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c -index 757a230ae15..466e5a444f4 100644 +index 3dee67d5a91..3623d9d99a1 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c @@ -30,6 +30,7 @@ @@ -21,7 +21,7 @@ index 757a230ae15..466e5a444f4 100644 #include "wine/test.h" #include "delayloadhandler.h" -@@ -3970,6 +3971,79 @@ static void test_LoadPackagedLibrary(void) +@@ -3957,6 +3958,79 @@ static void test_LoadPackagedLibrary(void) h, GetLastError()); } @@ -101,7 +101,7 @@ index 757a230ae15..466e5a444f4 100644 START_TEST(loader) { int argc; -@@ -4042,6 +4116,7 @@ START_TEST(loader) +@@ -4029,6 +4103,7 @@ START_TEST(loader) test_InMemoryOrderModuleList(); test_LoadPackagedLibrary(); test_wow64_redirection(); @@ -110,10 +110,10 @@ index 757a230ae15..466e5a444f4 100644 test_dll_file( "kernel32.dll", TRUE ); test_dll_file( "advapi32.dll", TRUE ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 7370857cfdc..78ae9b26f22 100644 +index 7b301031605..1bb05ebfbac 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -122,6 +122,9 @@ struct file_id +@@ -124,6 +124,9 @@ struct file_id BYTE ObjectId[16]; }; @@ -123,7 +123,7 @@ index 7370857cfdc..78ae9b26f22 100644 /* internal representation of loaded modules */ typedef struct _wine_modref { -@@ -461,6 +464,52 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module ) +@@ -483,6 +486,52 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module ) } } @@ -176,7 +176,7 @@ index 7370857cfdc..78ae9b26f22 100644 /************************************************************************* * get_modref * -@@ -1202,7 +1251,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name +@@ -1224,7 +1273,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name &wm->ldr.InLoadOrderLinks); InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderLinks); @@ -189,7 +189,7 @@ index 7370857cfdc..78ae9b26f22 100644 if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT)) { -@@ -1909,6 +1963,7 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name, +@@ -1955,6 +2009,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); @@ -197,7 +197,7 @@ index 7370857cfdc..78ae9b26f22 100644 /* FIXME: there are several more dangling references * left. Including dlls loaded by this dll before the -@@ -3246,6 +3301,7 @@ static void free_modref( WINE_MODREF *wm ) +@@ -3305,6 +3360,7 @@ static void free_modref( WINE_MODREF *wm ) { RemoveEntryList(&wm->ldr.InLoadOrderLinks); RemoveEntryList(&wm->ldr.InMemoryOrderLinks); @@ -205,7 +205,7 @@ index 7370857cfdc..78ae9b26f22 100644 if (wm->ldr.InInitializationOrderLinks.Flink) RemoveEntryList(&wm->ldr.InInitializationOrderLinks); -@@ -3950,6 +4006,7 @@ static void process_init(void) +@@ -4066,6 +4122,7 @@ static NTSTATUS process_init(void) INITIAL_TEB stack; TEB *teb = NtCurrentTeb(); PEB *peb = teb->Peb; @@ -213,7 +213,7 @@ index 7370857cfdc..78ae9b26f22 100644 peb->LdrData = &ldr; peb->FastPebLock = &peb_lock; -@@ -3988,6 +4045,10 @@ static void process_init(void) +@@ -4105,6 +4162,10 @@ static NTSTATUS process_init(void) load_global_options(); version_init(); @@ -224,21 +224,22 @@ index 7370857cfdc..78ae9b26f22 100644 /* setup the load callback and create ntdll modref */ RtlInitUnicodeString( &nt_name, ntdllW ); NtQueryVirtualMemory( GetCurrentProcess(), process_init, MemoryBasicInformation, -@@ -4073,6 +4134,9 @@ static void process_init(void) +@@ -4199,6 +4260,10 @@ static NTSTATUS process_init(void) teb->Tib.StackBase = stack.StackBase; teb->Tib.StackLimit = stack.StackLimit; teb->DeallocationStack = stack.DeallocationStack; + + /* the windows version was not set yet when ntdll and kernel32 were loaded */ + recompute_hash_map(); ++ + return STATUS_SUCCESS; } - /*********************************************************************** diff --git a/include/winternl.h b/include/winternl.h -index 6c809193977..2d15f95c110 100644 +index 9a087d2848a..c73ec3828bd 100644 --- a/include/winternl.h +++ b/include/winternl.h -@@ -2678,8 +2678,8 @@ typedef struct _LDR_DATA_TABLE_ENTRY +@@ -2679,8 +2679,8 @@ typedef struct _LDR_DATA_TABLE_ENTRY ULONG Flags; SHORT LoadCount; SHORT TlsIndex; diff --git a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch index 024b14bb..0608a14d 100644 --- a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch +++ b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch @@ -1,4 +1,4 @@ -From cf0cdffd0ddaeb7f72f447554247d257608ff53e Mon Sep 17 00:00:00 2001 +From 683ec6017757a1f2cdd33feec608aad6a9022322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 03:22:09 +0200 Subject: [PATCH] ntdll: Properly handle PAGE_WRITECOPY protection. (try 5) @@ -9,10 +9,10 @@ For now, only enable it when a special environment variable is set. 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index d4a8d4d38d5b..f0ec65d12704 100644 +index 54c6b732d0f..cd0e343c46b 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -500,6 +500,21 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T si +@@ -363,6 +363,21 @@ static int mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T s return ret; } @@ -32,9 +32,9 @@ index d4a8d4d38d5b..f0ec65d12704 100644 + return enabled; +} - /*********************************************************************** - * free_ranges_lower_bound -@@ -801,8 +816,19 @@ static int get_unix_prot( BYTE vprot ) + static void reserve_area( void *addr, void *end ) + { +@@ -803,8 +818,19 @@ static int get_unix_prot( BYTE vprot ) { if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; @@ -55,7 +55,7 @@ index d4a8d4d38d5b..f0ec65d12704 100644 if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE; } if (!prot) prot = PROT_NONE; -@@ -1548,7 +1574,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size +@@ -1550,7 +1576,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size { TRACE( "updating watch %p-%p-%p\n", base, (char *)base + accessed_size, (char *)base + size ); /* clear write watch flag on accessed pages */ @@ -64,7 +64,7 @@ index d4a8d4d38d5b..f0ec65d12704 100644 /* restore page protections on the entire range */ mprotect_range( base, size, 0, 0 ); } -@@ -2900,12 +2926,13 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) +@@ -2904,12 +2930,13 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( page, page_size, 0, 0 ); } @@ -82,7 +82,7 @@ index d4a8d4d38d5b..f0ec65d12704 100644 } pthread_mutex_unlock( &virtual_mutex ); return ret; -@@ -2982,11 +3009,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat +@@ -2986,11 +3013,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat { BYTE vprot = get_page_vprot( addr + i ); if (vprot & VPROT_WRITEWATCH) *has_write_watch = TRUE; @@ -101,5 +101,5 @@ index d4a8d4d38d5b..f0ec65d12704 100644 } -- -2.20.1 +2.28.0 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 7228c6e9..ef5d4adb 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "00a0e2cd8c4df240371ddd22516e4e3544a142ce" + echo "87f41e6b408dd01055ff6a378b90d089d61ec370" } # Show version information diff --git a/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch b/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch index 29729674..9b9a53bc 100644 --- a/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch +++ b/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch @@ -1,4 +1,4 @@ -From 20f0c51c7cc6bf2df12463f8e8b98d57fd028d26 Mon Sep 17 00:00:00 2001 +From 85c9586902b2f1d197e0d6dcbde53a36b7803092 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 8 Aug 2018 20:00:15 -0500 Subject: [PATCH] ntdll: Add a stub implementation of Wow64Transition. @@ -9,18 +9,18 @@ Subject: [PATCH] ntdll: Add a stub implementation of Wow64Transition. 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 7370857cfdc..b3830317b11 100644 +index 0eac7fdb939..36c1a467562 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -3929,6 +3929,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) +@@ -4181,6 +4181,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) return TRUE; } +void *Wow64Transition; /*********************************************************************** - * process_init -@@ -3942,7 +3943,7 @@ static void process_init(void) + * restart_winevdm +@@ -4217,7 +4218,7 @@ static NTSTATUS process_init(void) 's','y','s','t','e','m','3','2','\\', 'k','e','r','n','e','l','3','2','.','d','l','l',0}; RTL_USER_PROCESS_PARAMETERS *params; @@ -29,7 +29,7 @@ index 7370857cfdc..b3830317b11 100644 NTSTATUS status; ANSI_STRING func_name; UNICODE_STRING nt_name; -@@ -4001,6 +4002,13 @@ static void process_init(void) +@@ -4282,6 +4283,13 @@ static NTSTATUS process_init(void) MESSAGE( "wine: could not load kernel32.dll, status %x\n", status ); NtTerminateProcess( GetCurrentProcess(), status ); } @@ -44,10 +44,10 @@ index 7370857cfdc..b3830317b11 100644 if ((status = LdrGetProcedureAddress( wm->ldr.DllBase, &func_name, 0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 453c4827572..ad671846cc7 100644 +index c0e9c681e1d..e343e66f4af 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -1123,6 +1123,7 @@ +@@ -1124,6 +1124,7 @@ @ stdcall WinSqmIsOptedIn() @ stdcall WinSqmSetDWORD(ptr long long) @ stdcall WinSqmStartSession(ptr long long) diff --git a/staging/upstream-commit b/staging/upstream-commit index bbf434d4..97253671 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -00a0e2cd8c4df240371ddd22516e4e3544a142ce +87f41e6b408dd01055ff6a378b90d089d61ec370