diff --git a/patches/advapi32-Token_Integrity_Level/0008-ntdll-Implement-process-token-elevation-through-mani.patch b/patches/advapi32-Token_Integrity_Level/0008-ntdll-Implement-process-token-elevation-through-mani.patch index e5e57657..60c16278 100644 --- a/patches/advapi32-Token_Integrity_Level/0008-ntdll-Implement-process-token-elevation-through-mani.patch +++ b/patches/advapi32-Token_Integrity_Level/0008-ntdll-Implement-process-token-elevation-through-mani.patch @@ -1,4 +1,4 @@ -From 2f03ded51b6f537ac6a4f3bfb51e1d0998a27c48 Mon Sep 17 00:00:00 2001 +From 0e9d9a6aa1b65dae1c8dc34d6d5fb27aa73f96ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 5 Aug 2017 03:39:55 +0200 Subject: [PATCH] ntdll: Implement process token elevation through manifests. @@ -12,10 +12,10 @@ Subject: [PATCH] ntdll: Implement process token elevation through manifests. 5 files changed, 67 insertions(+) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 38c893e3eb4..d32b57612d5 100644 +index 51addaaf983..71efed5fa32 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -4045,6 +4045,32 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, void **entry, ULONG_PTR unknow +@@ -3903,6 +3903,32 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, void **entry, ULONG_PTR unknow } @@ -48,7 +48,7 @@ index 38c893e3eb4..d32b57612d5 100644 /*********************************************************************** * load_global_options */ -@@ -4478,6 +4504,7 @@ void __wine_process_init(void) +@@ -4363,6 +4389,7 @@ void __wine_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; @@ -56,9 +56,9 @@ index 38c893e3eb4..d32b57612d5 100644 WINE_MODREF *wm; NTSTATUS status; ANSI_STRING func_name; -@@ -4575,6 +4602,16 @@ void __wine_process_init(void) +@@ -4466,6 +4493,16 @@ void __wine_process_init(void) - virtual_set_large_address_space(); + unix_funcs->virtual_set_large_address_space(); + /* elevate process if necessary */ + status = RtlQueryInformationActivationContext( 0, NULL, 0, RunlevelInformationInActivationContext, @@ -74,10 +74,10 @@ index 38c893e3eb4..d32b57612d5 100644 RemoveEntryList( &wm->ldr.InLoadOrderLinks ); InsertHeadList( &peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderLinks ); diff --git a/server/process.c b/server/process.c -index 4c7da9223c1..d6f71a774f3 100644 +index 80a091b0c72..34010b301c3 100644 --- a/server/process.c +++ b/server/process.c -@@ -1107,6 +1107,14 @@ struct process_snapshot *process_snap( int *count ) +@@ -1112,6 +1112,14 @@ struct process_snapshot *process_snap( int *count ) return snapshot; } @@ -105,7 +105,7 @@ index 5b83e111a6f..dfe5c4e52d8 100644 /* console functions */ extern void inherit_console( struct thread *parent_thread, struct process *parent, diff --git a/server/protocol.def b/server/protocol.def -index 68c66bc2fcb..55c821ac1e2 100644 +index d8618a5c964..89adc93305c 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -3762,6 +3762,13 @@ struct handle_info @@ -145,5 +145,5 @@ index 970ed1838da..1c1d49989b3 100644 + } +} -- -2.26.0 +2.26.2 diff --git a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch index cef9bed6..9c3036ca 100644 --- a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch +++ b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch @@ -1,19 +1,19 @@ -From ce12fa75ca18eeea3f0ec53788353d07ec683e95 Mon Sep 17 00:00:00 2001 +From be204ab84d031b7efb223ac7c4962246549c8eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 1 Jun 2017 06:04:53 +0200 Subject: [PATCH] ntdll: Fix holes in ELF mappings. (v2) Based on a patch by Andrew Wesie. --- - dlls/ntdll/virtual.c | 23 +++++++++++++++++++++++ + dlls/ntdll/unix/virtual.c | 23 +++++++++++++++++++++++ dlls/psapi/tests/psapi_main.c | 14 +++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 6cb47f2cae8..2ba116c4e92 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -485,6 +485,16 @@ static inline BOOL is_write_watch_range( const void *addr, size_t size ) +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index e824b9ced25..90143f5c07b 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -966,6 +966,16 @@ static inline BOOL is_write_watch_range( const void *addr, size_t size ) } @@ -22,7 +22,7 @@ index 6cb47f2cae8..2ba116c4e92 100644 + */ +static inline BOOL is_system_range( const void *addr, size_t size ) +{ -+ struct file_view *view = VIRTUAL_FindView( addr, size ); ++ struct file_view *view = find_view( addr, size ); + return view && (view->protect & VPROT_SYSTEM); +} + @@ -30,13 +30,13 @@ index 6cb47f2cae8..2ba116c4e92 100644 /*********************************************************************** * find_view_range * -@@ -2386,6 +2396,19 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -2812,6 +2822,19 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta /* ignore fault if page is writable now */ - if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; + if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS; } -+ else if (!err && (VIRTUAL_GetUnixProt( vprot ) & PROT_READ) && is_system_range( page, page_size )) ++ else if (!err && (get_unix_prot( vprot ) & PROT_READ) && is_system_range( page, page_size )) + { -+ int unix_prot = VIRTUAL_GetUnixProt( vprot ); ++ int unix_prot = get_unix_prot( vprot ); + unsigned char vec; + + mprotect_range( page, page_size, 0, 0 ); diff --git a/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch b/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch index f4213c6c..ab2d0968 100644 --- a/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch +++ b/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch @@ -1,19 +1,20 @@ -From a01aaa21d4709e52a01198167b49c9519090a4e3 Mon Sep 17 00:00:00 2001 +From 7ecb980c3b1d3ee2b5ce2ad6419adf5782b85c7a Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 21 Aug 2015 06:39:47 +0800 Subject: [PATCH] ntdll: Do not allow to deallocate thread stack for current thread. --- - dlls/ntdll/ntdll_misc.h | 1 + - dlls/ntdll/virtual.c | 12 ++++++++++++ - 2 files changed, 13 insertions(+) + dlls/ntdll/ntdll_misc.h | 1 + + dlls/ntdll/unix/unix_private.h | 1 + + dlls/ntdll/unix/virtual.c | 12 ++++++++++++ + 3 files changed, 14 insertions(+) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index f847503307b..2d037e0d7cb 100644 +index e9a3230e814..e7a74131c30 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -240,6 +240,7 @@ struct ntdll_thread_data +@@ -249,6 +249,7 @@ struct ntdll_thread_data int wait_fd[2]; /* fd for sleeping server requests */ BOOL wow64_redir; /* Wow64 filesystem redirection flag */ pthread_t pthread_id; /* pthread thread id */ @@ -21,11 +22,23 @@ index f847503307b..2d037e0d7cb 100644 }; C_ASSERT( sizeof(struct ntdll_thread_data) <= sizeof(((TEB *)0)->GdiTebBatch) ); -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 5c12d87d297..f7bac9eac91 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -1986,6 +1986,8 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SI +diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h +index 8562efb7dd4..b34adf2f07f 100644 +--- a/dlls/ntdll/unix/unix_private.h ++++ b/dlls/ntdll/unix/unix_private.h +@@ -41,6 +41,7 @@ struct ntdll_thread_data + int wait_fd[2]; /* fd for sleeping server requests */ + BOOL wow64_redir; /* Wow64 filesystem redirection flag */ + pthread_t pthread_id; /* pthread thread id */ ++ void *pthread_stack; /* pthread stack */ + }; + + C_ASSERT( sizeof(struct ntdll_thread_data) <= sizeof(((TEB *)0)->GdiTebBatch) ); +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 0346d0d9753..5e995338a08 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -2715,6 +2715,8 @@ NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_si stack->DeallocationStack = view->base; stack->StackBase = (char *)view->base + view->size; stack->StackLimit = (char *)view->base + 2 * page_size; @@ -34,7 +47,7 @@ index 5c12d87d297..f7bac9eac91 100644 done: server_leave_uninterrupted_section( &csVirtual, &sigset ); return status; -@@ -2703,6 +2705,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si +@@ -3374,6 +3376,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si /* Free the pages */ if (size || (base != view->base)) status = STATUS_INVALID_PARAMETER; @@ -52,5 +65,5 @@ index 5c12d87d297..f7bac9eac91 100644 { delete_view( view ); -- -2.17.1 +2.26.2 diff --git a/patches/ntdll-Fix_Alignment/0001-ntdll-Move-NtProtectVirtualMemory-and-NtCreateSectio.patch b/patches/ntdll-Fix_Alignment/0001-ntdll-Move-NtProtectVirtualMemory-and-NtCreateSectio.patch index 270c82fd..f62b97a0 100644 --- a/patches/ntdll-Fix_Alignment/0001-ntdll-Move-NtProtectVirtualMemory-and-NtCreateSectio.patch +++ b/patches/ntdll-Fix_Alignment/0001-ntdll-Move-NtProtectVirtualMemory-and-NtCreateSectio.patch @@ -1,18 +1,18 @@ -From 554f37a5ee79939ba9368e9bd7ea408860a32803 Mon Sep 17 00:00:00 2001 +From 9a7a3037b16670d121465036e7da2c4db6f18182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Wed, 20 Aug 2014 19:21:18 +0200 Subject: [PATCH] ntdll: Move NtProtectVirtualMemory and NtCreateSection to separate pages on x86. (try 2) --- - dlls/ntdll/virtual.c | 8 ++++++++ + dlls/ntdll/unix/virtual.c | 8 ++++++++ 1 file changed, 8 insertions(+) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index cfe30bbe710..6173846cfb4 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -366,6 +366,14 @@ static void free_ranges_remove_view( struct file_view *view ) +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 0346d0d9753..ab321a989dd 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -660,6 +660,14 @@ static void free_ranges_remove_view( struct file_view *view ) } diff --git a/patches/ntdll-ForceBottomUpAlloc/0001-ntdll-Stop-search-on-mmap-error-in-try_map_free_area.patch b/patches/ntdll-ForceBottomUpAlloc/0001-ntdll-Stop-search-on-mmap-error-in-try_map_free_area.patch index 26b0385a..7aa2337e 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0001-ntdll-Stop-search-on-mmap-error-in-try_map_free_area.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0001-ntdll-Stop-search-on-mmap-error-in-try_map_free_area.patch @@ -1,4 +1,4 @@ -From 7dd611828bb181c29d20544c7dcae8f52215ae70 Mon Sep 17 00:00:00 2001 +From ca116113c19ee17d2e8283abe4edf27f76df2148 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 9 Jan 2020 15:05:09 +0300 Subject: [PATCH] ntdll: Stop search on mmap() error in try_map_free_area(). @@ -6,14 +6,14 @@ Subject: [PATCH] ntdll: Stop search on mmap() error in try_map_free_area(). The anon mmap errors do not depend on start address hint. Ignoring them makes the search take incredible time until it fails. --- - dlls/ntdll/virtual.c | 10 ++++++++-- + dlls/ntdll/unix/virtual.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index c6f3c1685e0..37f83efa8fc 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -767,8 +767,14 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 0346d0d9753..c29f695d694 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -1016,8 +1016,14 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, return start; TRACE( "Found free area is already mapped, start %p.\n", start ); diff --git a/patches/ntdll-ForceBottomUpAlloc/0002-ntdll-Use-MAP_FIXED_NOREPLACE-flag-in-try_map_free_a.patch b/patches/ntdll-ForceBottomUpAlloc/0002-ntdll-Use-MAP_FIXED_NOREPLACE-flag-in-try_map_free_a.patch index 120fdcf6..6672d646 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0002-ntdll-Use-MAP_FIXED_NOREPLACE-flag-in-try_map_free_a.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0002-ntdll-Use-MAP_FIXED_NOREPLACE-flag-in-try_map_free_a.patch @@ -1,4 +1,4 @@ -From dae806ca4aa1d25e65539f33b784791a9b357a77 Mon Sep 17 00:00:00 2001 +From b2c9894cd6a81eaa9f7dd4bce3f9cbfbec17d021 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 16 Jan 2020 16:09:24 +0300 Subject: [PATCH] ntdll: Use MAP_FIXED_NOREPLACE flag in try_map_free_area() if @@ -7,14 +7,14 @@ Subject: [PATCH] ntdll: Use MAP_FIXED_NOREPLACE flag in try_map_free_area() if Avoids actual mapping followed by unmapping back if the memory range is already mapped. --- - dlls/ntdll/virtual.c | 12 +++++++++--- + dlls/ntdll/unix/virtual.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 37f83efa8fc..4ee30af6548 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -759,22 +759,28 @@ static struct wine_rb_entry *find_view_inside_range( void **base_ptr, void **end +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index c29f695d694..8d3e25481ec 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -1008,22 +1008,28 @@ static struct wine_rb_entry *find_view_inside_range( void **base_ptr, void **end static void* try_map_free_area( void *base, void *end, ptrdiff_t step, void *start, size_t size, int unix_prot ) { diff --git a/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-bottom-up-allocation-order-for-64-bit-ar.patch b/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-bottom-up-allocation-order-for-64-bit-ar.patch index db1b99ec..44980f11 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-bottom-up-allocation-order-for-64-bit-ar.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-bottom-up-allocation-order-for-64-bit-ar.patch @@ -1,4 +1,4 @@ -From 15fdb467ef17b05df48abe7f5f23e718ce876d57 Mon Sep 17 00:00:00 2001 +From 9f7320fe58c85f1b53301c2c9a2a80fa8d4ed228 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 25 Nov 2019 12:19:20 +0300 Subject: [PATCH] ntdll: Force bottom up allocation order for 64 bit arch @@ -7,14 +7,14 @@ Subject: [PATCH] ntdll: Force bottom up allocation order for 64 bit arch Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48175 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46568 --- - dlls/ntdll/virtual.c | 12 ++++++++++-- + dlls/ntdll/unix/virtual.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 4ee30af6548..ba9ecd5a5b1 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -1492,13 +1492,19 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 8d3e25481ec..dc20e827141 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -1715,13 +1715,19 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, } else { @@ -32,10 +32,10 @@ index 4ee30af6548..ba9ecd5a5b1 100644 + alloc.limit = min(alloc.limit, (void *)0x7ffffe000000); + } + - if (unix_funcs->mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) + if (mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) { ptr = alloc.result; -@@ -1508,7 +1514,7 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1731,7 +1737,7 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, goto done; } @@ -43,8 +43,8 @@ index 4ee30af6548..ba9ecd5a5b1 100644 + if (is_win64 || zero_bits_64) { if (!(ptr = map_free_area( address_space_start, alloc.limit, size, - top_down, VIRTUAL_GetUnixProt(vprot) ))) -@@ -1517,6 +1523,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, + top_down, get_unix_prot(vprot) ))) +@@ -1740,6 +1746,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, goto done; } @@ -52,7 +52,7 @@ index 4ee30af6548..ba9ecd5a5b1 100644 + for (;;) { - if ((ptr = wine_anon_mmap( NULL, view_size, VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1) + if ((ptr = wine_anon_mmap( NULL, view_size, get_unix_prot(vprot), 0 )) == (void *)-1) -- 2.26.2 diff --git a/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Increase-step-after-failed-map-attempt-in-try_.patch b/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Increase-step-after-failed-map-attempt-in-try_.patch index 7a5de496..9361f093 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Increase-step-after-failed-map-attempt-in-try_.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Increase-step-after-failed-map-attempt-in-try_.patch @@ -1,18 +1,18 @@ -From a95074355fd65c1396ac0fbd9fbc1c2c151b434b Mon Sep 17 00:00:00 2001 +From e521333684d1286fff7b6625515d13ad6f3fcba3 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 14 Jan 2020 21:39:23 +0300 Subject: [PATCH] ntdll: Increase step after failed map attempt in try_map_free_area(). --- - dlls/ntdll/virtual.c | 1 + + dlls/ntdll/unix/virtual.c | 1 + 1 file changed, 1 insertion(+) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index ba9ecd5a5b1..86062cd4546 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -787,6 +787,7 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index dc20e827141..720d45ecb9f 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -1036,6 +1036,7 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, step == 0) break; start = (char *)start + step; diff --git a/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch b/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch index 08d32ea7..569bf3e6 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch @@ -1,17 +1,17 @@ -From d757532f375dee8d7b717e546ef14406ebbc3653 Mon Sep 17 00:00:00 2001 +From df7b650d5e17afa411024b88d1920d0910947a6b Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 14 Jan 2020 21:42:21 +0300 Subject: [PATCH] ntdll: Use free area list for virtual memory allocation. --- - dlls/ntdll/virtual.c | 319 +++++++++++++++++++++++++++---------------- - 1 file changed, 204 insertions(+), 115 deletions(-) + dlls/ntdll/unix/virtual.c | 318 ++++++++++++++++++++++++-------------- + 1 file changed, 204 insertions(+), 114 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 86062cd4546..81592a84715 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -190,7 +190,11 @@ static BYTE *pages_vprot; +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 720d45ecb9f..e323f4290bf 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -192,7 +192,11 @@ static BYTE *pages_vprot; #endif static struct file_view *view_block_start, *view_block_end, *next_free_view; @@ -23,7 +23,7 @@ index 86062cd4546..81592a84715 100644 static void *preload_reserve_start; static void *preload_reserve_end; static BOOL use_locks; -@@ -235,13 +239,13 @@ static struct range_entry *free_ranges_lower_bound( void *addr ) +@@ -528,13 +532,13 @@ static struct range_entry *free_ranges_lower_bound( void *addr ) * * Updates the free_ranges after a new view has been created. */ @@ -40,7 +40,7 @@ index 86062cd4546..81592a84715 100644 /* free_ranges initial value is such that the view is either inside range or before another one. */ assert( range != free_ranges_end ); assert( range->end > view_base || next != free_ranges_end ); -@@ -252,7 +256,7 @@ static void free_ranges_insert_view( struct file_view *view ) +@@ -545,7 +549,7 @@ static void free_ranges_insert_view( struct file_view *view ) (range->end == view_base && next->base >= view_end)) { /* on Win64, assert that it's correctly aligned so we're not going to be in trouble later */ @@ -49,7 +49,7 @@ index 86062cd4546..81592a84715 100644 WARN( "range %p - %p is already mapped\n", view_base, view_end ); return; } -@@ -292,6 +296,12 @@ static void free_ranges_insert_view( struct file_view *view ) +@@ -585,6 +589,12 @@ static void free_ranges_insert_view( struct file_view *view ) } } @@ -62,7 +62,7 @@ index 86062cd4546..81592a84715 100644 /*********************************************************************** * free_ranges_remove_view -@@ -322,6 +332,7 @@ static void free_ranges_remove_view( struct file_view *view ) +@@ -615,6 +625,7 @@ static void free_ranges_remove_view( struct file_view *view ) return; } #endif @@ -70,7 +70,7 @@ index 86062cd4546..81592a84715 100644 /* free_ranges initial value is such that the view is either inside range or before another one. */ assert( range != free_ranges_end ); -@@ -712,44 +723,6 @@ static struct file_view *find_view_range( const void *addr, size_t size ) +@@ -961,44 +972,6 @@ static struct file_view *find_view_range( const void *addr, size_t size ) } @@ -115,7 +115,7 @@ index 86062cd4546..81592a84715 100644 /*********************************************************************** * try_map_free_area * -@@ -793,65 +766,11 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, +@@ -1042,65 +1015,11 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, return NULL; } @@ -181,27 +181,27 @@ index 86062cd4546..81592a84715 100644 */ static void *find_reserved_free_area( void *base, void *end, size_t size, int top_down ) { -@@ -1065,8 +984,7 @@ static void delete_view( struct file_view *view ) /* [in] View */ +@@ -1314,8 +1233,7 @@ static void delete_view( struct file_view *view ) /* [in] View */ { if (!(view->protect & VPROT_SYSTEM)) unmap_area( view->base, view->size ); set_page_vprot( view->base, view->size, 0 ); -- if (unix_funcs->mmap_is_in_reserved_area( view->base, view->size )) +- if (mmap_is_in_reserved_area( view->base, view->size )) - free_ranges_remove_view( view ); + free_ranges_remove_view( view ); wine_rb_remove( &views_tree, &view->entry ); *(struct file_view **)view = next_free_view; next_free_view = view; -@@ -1114,8 +1032,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz +@@ -1363,8 +1281,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz set_page_vprot( base, size, vprot ); wine_rb_put( &views_tree, view->base, &view->entry ); -- if (unix_funcs->mmap_is_in_reserved_area( view->base, view->size )) +- if (mmap_is_in_reserved_area( view->base, view->size )) - free_ranges_insert_view( view ); + free_ranges_insert_view( view ); *view_ret = view; -@@ -1373,6 +1290,7 @@ struct alloc_area +@@ -1596,6 +1513,7 @@ struct alloc_area int top_down; void *limit; void *result; @@ -209,7 +209,7 @@ index 86062cd4546..81592a84715 100644 }; /*********************************************************************** -@@ -1414,6 +1332,179 @@ static int CDECL alloc_reserved_area_callback( void *start, SIZE_T size, void *a +@@ -1637,6 +1555,179 @@ static int CDECL alloc_reserved_area_callback( void *start, SIZE_T size, void *a return 0; } @@ -357,7 +357,7 @@ index 86062cd4546..81592a84715 100644 + if (!start || start >= end || (char *)end - (char *)start < size) + continue; + } -+ unix_funcs->mmap_enum_reserved_areas( alloc_area_in_reserved_or_between_callback, &area, top_down ); ++ mmap_enum_reserved_areas( alloc_area_in_reserved_or_between_callback, &area, top_down ); + if (area.result) + return area.result; + @@ -389,11 +389,11 @@ index 86062cd4546..81592a84715 100644 /*********************************************************************** * map_fixed_area * -@@ -1499,11 +1590,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1722,11 +1813,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, alloc.size = size; alloc.top_down = top_down; alloc.limit = (void*)(get_zero_bits_64_mask( zero_bits_64 ) & (UINT_PTR)user_space_limit); -+ alloc.unix_prot = VIRTUAL_GetUnixProt(vprot); ++ alloc.unix_prot = get_unix_prot( vprot ); - if (is_win64 && !top_down) + if (is_win64 || zero_bits_64) @@ -407,16 +407,15 @@ index 86062cd4546..81592a84715 100644 + goto done; } - if (unix_funcs->mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) -@@ -1514,16 +1609,6 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, - return STATUS_INVALID_PARAMETER; + if (mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) +@@ -1738,15 +1833,6 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, goto done; } -- + - if (is_win64 || zero_bits_64) - { - if (!(ptr = map_free_area( address_space_start, alloc.limit, size, -- top_down, VIRTUAL_GetUnixProt(vprot) ))) +- top_down, get_unix_prot(vprot) ))) - return STATUS_NO_MEMORY; - TRACE( "got mem with map_free_area %p-%p\n", ptr, (char *)ptr + size ); - goto done; @@ -425,7 +424,7 @@ index 86062cd4546..81592a84715 100644 view_size = size + granularity_mask + 1; for (;;) -@@ -2256,10 +2341,14 @@ void virtual_init(void) +@@ -2466,10 +2552,14 @@ void virtual_init(void) pages_vprot = (void *)((char *)alloc_views.base + 2 * view_block_size); wine_rb_init( &views_tree, compare_view ); @@ -441,7 +440,7 @@ index 86062cd4546..81592a84715 100644 + /* make the DOS area accessible (except the low 64K) to hide bugs in broken apps like Excel 2003 */ size = (char *)address_space_start - (char *)0x10000; - if (size && unix_funcs->mmap_is_in_reserved_area( (void*)0x10000, size ) == 1) + if (size && mmap_is_in_reserved_area( (void*)0x10000, size ) == 1) -- 2.26.2 diff --git a/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch b/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch index ad2f44b3..8cf896f8 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch @@ -1,18 +1,18 @@ -From 0c26b2508ad1fc3c5bfb8eb775fb21febfeb4c0e Mon Sep 17 00:00:00 2001 +From 81a8c626f834f3b2195980e84e2f5fc0a5b1e0e6 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 2 Jun 2020 21:06:33 +0300 Subject: [PATCH] ntdll: Permanently exclude natively mapped areas from free areas list. --- - dlls/ntdll/virtual.c | 25 +++++++++++++++++++++++++ + dlls/ntdll/unix/virtual.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 81592a84715..6c6efea0285 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -112,6 +112,9 @@ static const BYTE VIRTUAL_Win32Flags[16] = +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index e323f4290bf..778f5d8c3b8 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -123,6 +123,9 @@ static const BYTE VIRTUAL_Win32Flags[16] = static struct wine_rb_tree views_tree; @@ -22,7 +22,7 @@ index 81592a84715..6c6efea0285 100644 static RTL_CRITICAL_SECTION csVirtual; static RTL_CRITICAL_SECTION_DEBUG critsect_debug = { -@@ -755,6 +758,13 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, +@@ -1004,6 +1007,13 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, if (ptr != (void *)-1) munmap( ptr, size ); @@ -36,7 +36,7 @@ index 81592a84715..6c6efea0285 100644 if ((step > 0 && (char *)end - (char *)start < step) || (step < 0 && (char *)start - (char *)base < -step) || step == 0) -@@ -1594,9 +1604,24 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1817,9 +1827,24 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, if (is_win64 || zero_bits_64) { diff --git a/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch b/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch index f7f20075..91aec80f 100644 --- a/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch +++ b/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch @@ -1,4 +1,4 @@ -From 6c463b0bd58fb0830271582e5dd916f936084daf Mon Sep 17 00:00:00 2001 +From 463baa9359f163b4e152f681a3703e602347ab04 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 30 May 2015 02:23:15 +0200 Subject: [PATCH] ntdll: Add support for hiding wine version information from @@ -10,10 +10,10 @@ Subject: [PATCH] ntdll: Add support for hiding wine version information from 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 926098ebf50a..4cf7fed9e1b2 100644 +index 71efed5fa32..ec9ddc73e9c 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -78,6 +78,7 @@ const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\', +@@ -77,6 +77,7 @@ const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\', const WCHAR syswow64_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','w','o','w','6','4','\\',0}; @@ -21,7 +21,7 @@ index 926098ebf50a..4cf7fed9e1b2 100644 /* system search path */ static const WCHAR system_path[] = {'C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m','3','2',';', -@@ -86,6 +87,9 @@ static const WCHAR system_path[] = +@@ -85,6 +86,9 @@ static const WCHAR system_path[] = static const WCHAR dotW[] = {'.',0}; @@ -31,7 +31,7 @@ index 926098ebf50a..4cf7fed9e1b2 100644 static BOOL imports_fixup_done = FALSE; /* set once the imports have been fixed up, before attaching them */ static BOOL process_detaching = FALSE; /* set on process detach to avoid deadlocks with thread detach */ static int free_lib_count; /* recursion depth of LdrUnloadDll calls */ -@@ -102,6 +106,8 @@ struct dll_dir_entry +@@ -101,6 +105,8 @@ struct dll_dir_entry static struct list dll_dir_list = LIST_INIT( dll_dir_list ); /* extra dirs from LdrAddDllDirectory */ @@ -40,7 +40,7 @@ index 926098ebf50a..4cf7fed9e1b2 100644 struct ldr_notification { struct list entry; -@@ -1872,6 +1878,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic ) +@@ -1810,6 +1816,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic ) } @@ -137,7 +137,7 @@ index 926098ebf50a..4cf7fed9e1b2 100644 /****************************************************************** * LdrGetProcedureAddress (NTDLL.@) */ -@@ -1892,7 +1988,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, +@@ -1830,7 +1926,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer; void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, load_path ) : find_ordinal_export( module, exports, exp_size, ord - exports->Base, load_path ); @@ -146,20 +146,20 @@ index 926098ebf50a..4cf7fed9e1b2 100644 { *address = proc; ret = STATUS_SUCCESS; -@@ -4739,6 +4835,8 @@ void __wine_process_init(void) +@@ -4491,6 +4587,8 @@ void __wine_process_init(void) NtTerminateProcess( GetCurrentProcess(), status ); } + hidden_exports_init( wm->ldr.FullDllName.Buffer ); + - virtual_set_large_address_space(); + unix_funcs->virtual_set_large_address_space(); /* elevate process if necessary */ diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 7d631cb33ddb..8256ec710a00 100644 +index dbd9a826429..b4666d82c8b 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -347,6 +347,11 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR); +@@ -283,6 +283,11 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR); #define InterlockedCompareExchange64(dest,xchg,cmp) RtlInterlockedCompareExchange64(dest,xchg,cmp) #endif diff --git a/patches/ntdll-NtQueryVirtualMemory/0003-ntdll-Implement-NtQueryVirtualMemory-MemorySectionNa.patch b/patches/ntdll-NtQueryVirtualMemory/0003-ntdll-Implement-NtQueryVirtualMemory-MemorySectionNa.patch index 503b5c5b..17522de4 100644 --- a/patches/ntdll-NtQueryVirtualMemory/0003-ntdll-Implement-NtQueryVirtualMemory-MemorySectionNa.patch +++ b/patches/ntdll-NtQueryVirtualMemory/0003-ntdll-Implement-NtQueryVirtualMemory-MemorySectionNa.patch @@ -1,21 +1,22 @@ -From e718ef3521d76d455dbfd1088cc83e47121d987c Mon Sep 17 00:00:00 2001 +From fb9c617c12858107700c919aec3dfa5fbf0a65dc Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Sun, 28 May 2017 05:19:30 +0200 -Subject: ntdll: Implement NtQueryVirtualMemory(MemorySectionName). (v3) +Subject: [PATCH] ntdll: Implement NtQueryVirtualMemory(MemorySectionName). + (v3) Contains several improvements by Sebastian Lackner . --- - dlls/ntdll/virtual.c | 91 ++++++++++++++++++++++++++++++++++- + dlls/ntdll/unix/virtual.c | 91 ++++++++++++++++++++++++++++++++++- dlls/psapi/tests/psapi_main.c | 8 +-- server/mapping.c | 29 +++++++++++ server/protocol.def | 9 ++++ 4 files changed, 129 insertions(+), 8 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 6ad2d21e0..f49127c3e 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -3192,6 +3192,93 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr, +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 0346d0d9753..06796f441ae 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -3695,6 +3695,93 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr, return STATUS_SUCCESS; } @@ -109,7 +110,7 @@ index 6ad2d21e0..f49127c3e 100644 #define UNIMPLEMENTED_INFO_CLASS(c) \ case c: \ FIXME("(process=%p,addr=%p) Unimplemented information class: " #c "\n", process, addr); \ -@@ -3216,8 +3303,10 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr, +@@ -3719,8 +3806,10 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr, case MemoryWorkingSetExInformation: return get_working_set_ex( process, addr, buffer, len, res_len ); @@ -122,10 +123,10 @@ index 6ad2d21e0..f49127c3e 100644 default: diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c -index 0df247e9b..1cc0455aa 100644 +index da7524dd60a..bfe14231a9b 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c -@@ -375,14 +375,7 @@ static BOOL nt_get_mapped_file_name(HANDLE process, LPVOID addr, LPWSTR name, DW +@@ -372,14 +372,7 @@ static BOOL nt_get_mapped_file_name(HANDLE process, LPVOID addr, LPWSTR name, DW ret_len = 0xdeadbeef; status = pNtQueryVirtualMemory(process, addr, MemorySectionName, buf, buf_len, &ret_len); @@ -140,7 +141,7 @@ index 0df247e9b..1cc0455aa 100644 section_name = (MEMORY_SECTION_NAME *)buf; ok(ret_len == section_name->SectionFileName.MaximumLength + sizeof(*section_name), "got %lu, %u\n", -@@ -504,6 +497,7 @@ todo_wine { +@@ -501,6 +494,7 @@ todo_wine { { ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name); WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL); @@ -149,10 +150,10 @@ index 0df247e9b..1cc0455aa 100644 } diff --git a/server/mapping.c b/server/mapping.c -index 6990a1913..ca28e8909 100644 +index 0941dd87c05..487cd2a6131 100644 --- a/server/mapping.c +++ b/server/mapping.c -@@ -1064,6 +1064,35 @@ DECL_HANDLER(unmap_view) +@@ -1091,6 +1091,35 @@ DECL_HANDLER(unmap_view) if (view) free_memory_view( view ); } @@ -189,10 +190,10 @@ index 6990a1913..ca28e8909 100644 DECL_HANDLER(get_mapping_committed_range) { diff --git a/server/protocol.def b/server/protocol.def -index 6c44b2b43..e7753f8b7 100644 +index 632c996dc0e..223b45db1a8 100644 --- a/server/protocol.def +++ b/server/protocol.def -@@ -1838,6 +1838,15 @@ enum char_info_mode +@@ -1849,6 +1849,15 @@ enum char_info_mode @END @@ -209,5 +210,5 @@ index 6c44b2b43..e7753f8b7 100644 @REQ(get_mapping_committed_range) client_ptr_t base; /* view base address */ -- -2.25.0 +2.26.2 diff --git a/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch b/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch index 81e23dc8..0ef87c87 100644 --- a/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch +++ b/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch @@ -1,4 +1,4 @@ -From bc7e6ddf9534dd8afced865788a3d6ce8d068a47 Mon Sep 17 00:00:00 2001 +From 02ea4a27a1d6598e3d6a1ab5c2a25d5459e5390c Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 28 May 2017 11:17:26 +0200 Subject: [PATCH] ntdll: Resolve drive symlinks before returning section name. @@ -6,15 +6,15 @@ Subject: [PATCH] ntdll: Resolve drive symlinks before returning section name. --- dlls/ntdll/directory.c | 2 +- dlls/ntdll/ntdll_misc.h | 1 + - dlls/ntdll/virtual.c | 37 +++++++++++++++++++++++++++++------ + dlls/ntdll/unix/virtual.c | 37 +++++++++++++++++++++++++++++------ dlls/psapi/tests/psapi_main.c | 6 +----- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c -index 7a9de26ccb0..1062e35e009 100644 +index 453568d641e..12da4316e88 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c -@@ -2806,7 +2806,7 @@ static NTSTATUS nt_to_unix_file_name_internal( const UNICODE_STRING *nameW, ANSI +@@ -2798,7 +2798,7 @@ static NTSTATUS nt_to_unix_file_name_internal( const UNICODE_STRING *nameW, ANSI } /* read the contents of an NT symlink object */ @@ -24,10 +24,10 @@ index 7a9de26ccb0..1062e35e009 100644 OBJECT_ATTRIBUTES attr; UNICODE_STRING targetW; diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index b6507599a92..b7822c54ad0 100644 +index e9a3230e814..750b01bd059 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -182,6 +182,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S +@@ -175,6 +175,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S UINT disposition ) DECLSPEC_HIDDEN; /* virtual memory */ @@ -35,11 +35,11 @@ index b6507599a92..b7822c54ad0 100644 extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsigned short zero_bits_64, SIZE_T commit_size, const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type, ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN; -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index cc1d6e5d6f2..3d53b92cb8e 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -192,6 +192,8 @@ static BYTE **pages_vprot; +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 97244822082..15b4697c441 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -194,6 +194,8 @@ static BYTE **pages_vprot; static BYTE *pages_vprot; #endif @@ -48,7 +48,7 @@ index cc1d6e5d6f2..3d53b92cb8e 100644 static struct file_view *view_block_start, *view_block_end, *next_free_view; #ifdef _WIN64 static const size_t view_block_size = 0x200000; -@@ -3713,12 +3715,15 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -3836,12 +3838,15 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, MEMORY_SECTION_NAME *info, SIZE_T len, SIZE_T *res_len ) { @@ -65,7 +65,7 @@ index cc1d6e5d6f2..3d53b92cb8e 100644 if (!addr || !info || !res_len) return STATUS_INVALID_PARAMETER; -@@ -3777,14 +3782,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -3900,14 +3905,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, } found: @@ -106,10 +106,10 @@ index cc1d6e5d6f2..3d53b92cb8e 100644 else status = (len < sizeof(MEMORY_SECTION_NAME)) ? STATUS_INFO_LENGTH_MISMATCH : STATUS_BUFFER_OVERFLOW; diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c -index 99e87db9543..3984805d2b9 100644 +index f6a7b69eca0..a8263a2f44b 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c -@@ -488,7 +488,6 @@ static void test_GetMappedFileName(void) +@@ -476,7 +476,6 @@ static void test_GetMappedFileName(void) ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name)); ok(ret, "GetMappedFileName error %d\n", GetLastError()); ok(ret > strlen(device_name), "map_name should be longer than device_name\n"); @@ -117,7 +117,7 @@ index 99e87db9543..3984805d2b9 100644 ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); SetLastError(0xdeadbeef); -@@ -501,7 +500,6 @@ todo_wine { +@@ -489,7 +488,6 @@ todo_wine { { ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name); WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL); @@ -125,7 +125,7 @@ index 99e87db9543..3984805d2b9 100644 ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); } -@@ -514,7 +512,6 @@ todo_wine +@@ -502,7 +500,6 @@ todo_wine { ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name); WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL); @@ -133,7 +133,7 @@ index 99e87db9543..3984805d2b9 100644 ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); } -@@ -522,7 +519,6 @@ todo_wine +@@ -510,7 +507,6 @@ todo_wine ret = GetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name, sizeof(map_name)); ok(ret, "GetMappedFileName error %d\n", GetLastError()); ok(ret > strlen(device_name), "map_name should be longer than device_name\n"); @@ -141,7 +141,7 @@ index 99e87db9543..3984805d2b9 100644 ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); SetLastError(0xdeadbeef); -@@ -604,7 +600,7 @@ static void test_GetProcessImageFileName(void) +@@ -592,7 +588,7 @@ static void test_GetProcessImageFileName(void) { /* Windows returns 2*strlen-1 */ ok(ret >= strlen(szImgPath), "szImgPath=\"%s\" ret=%d\n", szImgPath, ret); diff --git a/patches/ntdll-NtQueryVirtualMemory/definition b/patches/ntdll-NtQueryVirtualMemory/definition index 06825174..b33d61ea 100644 --- a/patches/ntdll-NtQueryVirtualMemory/definition +++ b/patches/ntdll-NtQueryVirtualMemory/definition @@ -1,3 +1,6 @@ Fixes: [23999] Implement MemorySectionName class in NtQueryVirtualMemory Fixes: [27248] Implement K32GetMappedFileName Depends: ntdll-NtDevicePath +Depends: ntdll-ForceBottomUpAlloc +# Disable for now, until some other things are moved down to ntdll.so. +Disabled: true diff --git a/patches/ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch b/patches/ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch index 1f72cb10..53b9152b 100644 --- a/patches/ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch +++ b/patches/ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch @@ -1,4 +1,4 @@ -From 5ea68740395cd0ae34fb4d74d540b30170645ac3 Mon Sep 17 00:00:00 2001 +From 78a7689c0360fbf9ab6e494cc7113da5f73510fe Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 4 Oct 2014 02:35:44 +0200 Subject: [PATCH] ntdll: Trigger write watches before passing userdata pointer @@ -6,8 +6,8 @@ Subject: [PATCH] ntdll: Trigger write watches before passing userdata pointer --- dlls/advapi32/tests/security.c | 1 - - dlls/ntdll/server.c | 9 +++++++++ - 2 files changed, 9 insertions(+), 1 deletion(-) + dlls/ntdll/unix/server.c | 8 ++++++++ + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c index 825f8451904..b414401634a 100644 @@ -21,16 +21,18 @@ index 825f8451904..b414401634a 100644 ok(Access == 0x1abe11ed && AccessStatus == 0x1abe11ed, "Access and/or AccessStatus were changed!\n"); -diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c -index ed4e3f25531..921dec86c82 100644 ---- a/dlls/ntdll/server.c -+++ b/dlls/ntdll/server.c -@@ -166,6 +166,15 @@ static DECLSPEC_NORETURN void server_protocol_perror( const char *err ) +diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c +index 17b23e58d28..91155a1663d 100644 +--- a/dlls/ntdll/unix/server.c ++++ b/dlls/ntdll/unix/server.c +@@ -304,9 +304,17 @@ unsigned int server_call_unlocked( void *req_ptr ) */ unsigned int CDECL wine_server_call( void *req_ptr ) { + struct __server_request_info * const req = req_ptr; -+ + sigset_t old_set; + unsigned int ret; + + /* trigger write watches, otherwise read() might return EFAULT */ + if (req->u.req.request_header.reply_size && + !virtual_check_buffer_for_write( req->reply_data, req->u.req.request_header.reply_size )) @@ -38,9 +40,9 @@ index ed4e3f25531..921dec86c82 100644 + return STATUS_ACCESS_VIOLATION; + } + - return unix_funcs->server_call( req_ptr ); - } - + pthread_sigmask( SIG_BLOCK, &server_block_set, &old_set ); + ret = server_call_unlocked( req_ptr ); + pthread_sigmask( SIG_SETMASK, &old_set, NULL ); -- 2.26.2 diff --git a/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch b/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch index c5f33485..c4811447 100644 --- a/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch +++ b/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch @@ -1,4 +1,4 @@ -From dcd95cc3f7ef19b34669ebfeb92c29da16ac2387 Mon Sep 17 00:00:00 2001 +From 6fa954cc5fd6840c9207abf4f41e53be0dbf8728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 02:53:22 +0200 Subject: [PATCH] ntdll: Setup a temporary signal handler during process @@ -15,10 +15,10 @@ Subject: [PATCH] ntdll: Setup a temporary signal handler during process 7 files changed, 79 insertions(+) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 427cdaad441..562f5ec8d4c 100644 +index e9a3230e814..04aee675e55 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -80,6 +80,7 @@ extern LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa) DECLSPEC_HI +@@ -78,6 +78,7 @@ extern LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa) DECLSPEC_HI extern SIZE_T signal_stack_size DECLSPEC_HIDDEN; extern SIZE_T signal_stack_mask DECLSPEC_HIDDEN; extern void signal_init_process(void) DECLSPEC_HIDDEN; @@ -27,10 +27,10 @@ index 427cdaad441..562f5ec8d4c 100644 extern void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) DECLSPEC_HIDDEN; extern void version_init(void) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c -index e66cf922f91..dcfdeaa83ad 100644 +index b7e387babf1..bb329f888ce 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c -@@ -988,6 +988,12 @@ void signal_init_process(void) +@@ -774,6 +774,12 @@ void signal_init_process(void) exit(1); } @@ -44,10 +44,10 @@ index e66cf922f91..dcfdeaa83ad 100644 /*********************************************************************** * RtlUnwind (NTDLL.@) diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c -index c87f99f0c4c..fed76574dbc 100644 +index c2dd129a569..22d4983d5c6 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c -@@ -1303,6 +1303,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) +@@ -1101,6 +1101,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) return 0; } @@ -61,10 +61,10 @@ index c87f99f0c4c..fed76574dbc 100644 /********************************************************************** * signal_init_process diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index 2f2db70b57f..12771552a5d 100644 +index 78d03f669d7..e3dc2c0d1c8 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c -@@ -1988,6 +1988,31 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, st +@@ -1737,6 +1737,31 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, st } @@ -83,7 +83,7 @@ index 2f2db70b57f..12771552a5d 100644 + switch(get_trap_code(context)) + { + case TRAP_x86_PAGEFLT: /* Page fault */ -+ if (!virtual_handle_fault( siginfo->si_addr, (get_error_code(context) >> 1) & 0x09, TRUE )) ++ if (!unix_funcs->virtual_handle_fault( siginfo->si_addr, (get_error_code(context) >> 1) & 0x09, TRUE )) + return; + /* fall-through */ + default: @@ -96,7 +96,7 @@ index 2f2db70b57f..12771552a5d 100644 /********************************************************************** * segv_handler * -@@ -2315,6 +2340,34 @@ void signal_init_process(void) +@@ -2064,6 +2089,34 @@ void signal_init_process(void) exit(1); } @@ -132,10 +132,10 @@ index 2f2db70b57f..12771552a5d 100644 /******************************************************************* * RtlUnwind (NTDLL.@) diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c -index a23f6b6e4d5..c3b4b6ffd42 100644 +index 75b18e1e933..314a0677d92 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c -@@ -1009,6 +1009,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) +@@ -638,6 +638,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) return 0; } @@ -149,10 +149,10 @@ index a23f6b6e4d5..c3b4b6ffd42 100644 /********************************************************************** * signal_init_process diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c -index d42438f88af..b4c11ed66ed 100644 +index 7cefd1403f3..0eb58d3d149 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c -@@ -3141,6 +3141,12 @@ void signal_init_process(void) +@@ -2850,6 +2850,12 @@ void signal_init_process(void) exit(1); } @@ -166,7 +166,7 @@ index d42438f88af..b4c11ed66ed 100644 static ULONG64 get_int_reg( CONTEXT *context, int reg ) { diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index bb11521cf69..ff18b119232 100644 +index f9ea9203ed8..31213614911 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -228,6 +228,7 @@ TEB *thread_init(void) 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 4b395812..6c4b17de 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,19 +1,19 @@ -From 8c8e2422bea9485bdcda98cea703983bb01f6e41 Mon Sep 17 00:00:00 2001 +From f5019b4f92b14ef22e7e96a38442f7f864488b10 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) For now, only enable it when a special environment variable is set. --- - dlls/ntdll/virtual.c | 46 +++++++++++++++++++++++++++++++++++++------- + dlls/ntdll/unix/virtual.c | 46 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 328bc40a92f..3533a087d88 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -321,6 +321,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) - return buffer; +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 0346d0d9753..5a8ba8bae2a 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -498,6 +498,21 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T si + return ret; } +/* This might look like a hack, but it actually isn't - the 'experimental' version @@ -33,8 +33,8 @@ index 328bc40a92f..3533a087d88 100644 +} /*********************************************************************** - * VIRTUAL_GetUnixProt -@@ -334,8 +349,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) + * free_ranges_lower_bound +@@ -799,8 +814,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 328bc40a92f..3533a087d88 100644 if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE; } if (!prot) prot = PROT_NONE; -@@ -1080,7 +1106,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size +@@ -1539,7 +1565,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,12 +64,12 @@ index 328bc40a92f..3533a087d88 100644 /* restore page protections on the entire range */ mprotect_range( base, size, 0, 0 ); } -@@ -2340,12 +2366,13 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -2746,12 +2772,13 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( page, page_size, 0, 0 ); } - /* ignore fault if page is writable now */ -- if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) +- if (get_unix_prot( get_page_vprot( page )) & PROT_WRITE) + if (vprot & VPROT_WRITECOPY) { - if ((vprot & VPROT_WRITEWATCH) || is_write_watch_range( page, page_size )) @@ -78,11 +78,11 @@ index 328bc40a92f..3533a087d88 100644 + mprotect_range( page, page_size, 0, 0 ); } + /* ignore fault if page is writable now */ -+ if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; ++ if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS; } server_leave_uninterrupted_section( &csVirtual, &sigset ); return ret; -@@ -2367,11 +2394,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat +@@ -2773,11 +2800,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; @@ -91,7 +91,7 @@ index 328bc40a92f..3533a087d88 100644 + vprot = (vprot & ~VPROT_WRITECOPY) | VPROT_WRITE; + *has_write_watch = TRUE; + } - if (!(VIRTUAL_GetUnixProt( vprot & ~VPROT_WRITEWATCH ) & PROT_WRITE)) + if (!(get_unix_prot( vprot & ~VPROT_WRITEWATCH ) & PROT_WRITE)) return STATUS_INVALID_USER_BUFFER; } if (*has_write_watch) diff --git a/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch b/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch index 8022ad63..4e32ba6f 100644 --- a/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch +++ b/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch @@ -1,4 +1,4 @@ -From c38118527458007162f8cbe38bec0dd02b9de6e7 Mon Sep 17 00:00:00 2001 +From 6836700fb6d9e0221de770c8b020822b6f4c9b55 Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:14 -0500 Subject: [PATCH] ntdll: Track if a WRITECOPY page has been modified. @@ -8,14 +8,14 @@ read-write page. Signed-off-by: Andrew Wesie --- - dlls/ntdll/virtual.c | 25 +++++++++++++++++++------ + dlls/ntdll/unix/virtual.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 3533a087d88..75219ae2376 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -85,6 +85,7 @@ struct file_view +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 5a8ba8bae2a..c81104bd266 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -97,6 +97,7 @@ struct file_view #define VPROT_GUARD 0x10 #define VPROT_COMMITTED 0x20 #define VPROT_WRITEWATCH 0x40 @@ -23,7 +23,7 @@ index 3533a087d88..75219ae2376 100644 /* per-mapping protection flags */ #define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */ -@@ -353,7 +354,7 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) +@@ -818,7 +819,7 @@ static int get_unix_prot( BYTE vprot ) #if defined(__i386__) if (vprot & VPROT_WRITECOPY) { @@ -32,9 +32,9 @@ index 3533a087d88..75219ae2376 100644 prot = (prot & ~PROT_WRITE) | PROT_READ; else prot |= PROT_WRITE | PROT_READ; -@@ -925,7 +926,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz +@@ -1397,7 +1398,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz */ - static DWORD VIRTUAL_GetWin32Prot( BYTE vprot, unsigned int map_prot ) + static DWORD get_win32_prot( BYTE vprot, unsigned int map_prot ) { - DWORD ret = VIRTUAL_Win32Flags[vprot & 0x0f]; + DWORD ret; @@ -45,7 +45,7 @@ index 3533a087d88..75219ae2376 100644 if (vprot & VPROT_GUARD) ret |= PAGE_GUARD; if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE; return ret; -@@ -1049,7 +1054,7 @@ static BOOL VIRTUAL_SetProt( struct file_view *view, /* [in] Pointer to view */ +@@ -1508,7 +1513,7 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr if (view->protect & VPROT_WRITEWATCH) { /* each page may need different protections depending on write watch flag */ @@ -54,7 +54,7 @@ index 3533a087d88..75219ae2376 100644 mprotect_range( base, size, 0, 0 ); return TRUE; } -@@ -1065,10 +1070,18 @@ static BOOL VIRTUAL_SetProt( struct file_view *view, /* [in] Pointer to view */ +@@ -1524,10 +1529,18 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr return TRUE; } @@ -74,7 +74,7 @@ index 3533a087d88..75219ae2376 100644 return TRUE; } -@@ -2368,7 +2381,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -2774,7 +2787,7 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta } if (vprot & VPROT_WRITECOPY) { @@ -83,7 +83,7 @@ index 3533a087d88..75219ae2376 100644 mprotect_range( page, page_size, 0, 0 ); } /* ignore fault if page is writable now */ -@@ -3272,7 +3285,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr, +@@ -3660,7 +3673,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr, else if (view->protect & (SEC_FILE | SEC_RESERVE | SEC_COMMIT)) info->Type = MEM_MAPPED; else info->Type = MEM_PRIVATE; for (ptr = base; ptr < base + range_size; ptr += page_size) diff --git a/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch b/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch index 18332474..ad417ed9 100644 --- a/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch +++ b/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch @@ -1,4 +1,4 @@ -From d92ad57aa5a51f41f1d01d39e8585e4398770893 Mon Sep 17 00:00:00 2001 +From aae6e8d097aaa6665a65ec6f896e37b445c371ea Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:15 -0500 Subject: [PATCH] ntdll: Support WRITECOPY on x64. @@ -6,14 +6,14 @@ Subject: [PATCH] ntdll: Support WRITECOPY on x64. Signed-off-by: Andrew Wesie --- dlls/ntdll/signal_x86_64.c | 40 ++++++++++++++++++++++++++++++++++++++ - dlls/ntdll/virtual.c | 2 +- + dlls/ntdll/unix/virtual.c | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c -index 29829bfb1c6..89a8e36410d 100644 +index 0eb58d3d149..8fdb800984c 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c -@@ -2871,6 +2871,29 @@ static inline BOOL handle_interrupt( ucontext_t *sigcontext, struct stack_layout +@@ -2575,6 +2575,29 @@ static inline BOOL handle_interrupt( ucontext_t *sigcontext, struct stack_layout } @@ -30,7 +30,7 @@ index 29829bfb1c6..89a8e36410d 100644 + switch(TRAP_sig(ucontext)) + { + case TRAP_x86_PAGEFLT: /* Page fault */ -+ if (!virtual_handle_fault( siginfo->si_addr, (ERROR_sig(ucontext) >> 1) & 0x09, TRUE )) ++ if (!unix_funcs->virtual_handle_fault( siginfo->si_addr, (ERROR_sig(ucontext) >> 1) & 0x09, TRUE )) + return; + /* fall-through */ + default: @@ -43,7 +43,7 @@ index 29829bfb1c6..89a8e36410d 100644 /********************************************************************** * segv_handler * -@@ -3291,6 +3314,23 @@ void signal_init_process(void) +@@ -2855,6 +2878,23 @@ void signal_init_process(void) */ void signal_init_early(void) { @@ -67,11 +67,11 @@ index 29829bfb1c6..89a8e36410d 100644 } static ULONG64 get_int_reg( CONTEXT *context, int reg ) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 75219ae2376..df77f55a9e7 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -351,7 +351,7 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index c81104bd266..1072907ffdd 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -816,7 +816,7 @@ static int get_unix_prot( BYTE vprot ) if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; if (vprot & VPROT_EXEC) prot |= PROT_EXEC | PROT_READ; diff --git a/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch b/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch index fd45e5b5..5805bf6b 100644 --- a/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch +++ b/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch @@ -1,4 +1,4 @@ -From b2ce2a421031982e0e0923d84bdbe767b14747b9 Mon Sep 17 00:00:00 2001 +From 262cfe702345c97ebb32a651cef272fe74e98322 Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:17 -0500 Subject: [PATCH] ntdll: Report unmodified WRITECOPY pages as shared. @@ -9,14 +9,14 @@ match the behavior of Windows. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48665 Signed-off-by: Andrew Wesie --- - dlls/ntdll/virtual.c | 4 +++- + dlls/ntdll/unix/virtual.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index df77f55a9e7..b329a9024d8 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -1737,6 +1737,8 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, int top_ +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 1072907ffdd..9a576de4930 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -2188,6 +2188,8 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, int top_ ptr + sec->VirtualAddress + file_size, ptr + sec->VirtualAddress + end ); memset( ptr + sec->VirtualAddress + file_size, 0, end - file_size ); @@ -25,7 +25,7 @@ index df77f55a9e7..b329a9024d8 100644 } } -@@ -3336,7 +3338,7 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr, +@@ -3724,7 +3726,7 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr, (vprot & VPROT_COMMITTED)) { p->VirtualAttributes.Valid = !(vprot & VPROT_GUARD) && (vprot & 0x0f) && (pagemap >> 63); diff --git a/patches/ntdll-WRITECOPY/0008-ntdll-Fallback-to-copy-pages-for-WRITECOPY.patch b/patches/ntdll-WRITECOPY/0008-ntdll-Fallback-to-copy-pages-for-WRITECOPY.patch index 384e6f8f..d620b2be 100644 --- a/patches/ntdll-WRITECOPY/0008-ntdll-Fallback-to-copy-pages-for-WRITECOPY.patch +++ b/patches/ntdll-WRITECOPY/0008-ntdll-Fallback-to-copy-pages-for-WRITECOPY.patch @@ -1,4 +1,4 @@ -From e7d46415e6361015c969027ade253a03e620cd66 Mon Sep 17 00:00:00 2001 +From 560a608432d8d4df920370e4bd50113c1db87b1f Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Tue, 28 Apr 2020 03:27:16 -0500 Subject: [PATCH] ntdll: Fallback to copy pages for WRITECOPY. @@ -12,14 +12,14 @@ then copy the contents to the new page. Signed-off-by: Andrew Wesie --- - dlls/ntdll/virtual.c | 25 +++++++++++++++++++++---- + dlls/ntdll/unix/virtual.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index b329a9024d8..e68ca274ca4 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -1070,8 +1070,9 @@ static BOOL VIRTUAL_SetProt( struct file_view *view, /* [in] Pointer to view */ +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index 9a576de4930..e824b9ced25 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -1529,8 +1529,9 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr return TRUE; } @@ -31,14 +31,14 @@ index b329a9024d8..e68ca274ca4 100644 unix_prot |= PROT_WRITE; if (mprotect_exec( base, size, unix_prot )) /* FIXME: last error */ -@@ -2381,10 +2382,26 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -2787,10 +2788,26 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( page, page_size, 0, 0 ); } - if (vprot & VPROT_WRITECOPY) + if ((vprot & VPROT_WRITECOPY) && (vprot & VPROT_COMMITTED)) { -+ struct file_view *view = VIRTUAL_FindView( page, 0 ); ++ struct file_view *view = find_view( page, 0 ); + set_page_vprot_bits( page, page_size, VPROT_WRITE | VPROT_WRITTEN, VPROT_WRITECOPY ); - mprotect_range( page, page_size, 0, 0 ); @@ -54,12 +54,12 @@ index b329a9024d8..e68ca274ca4 100644 + + /* original mapping is shared, replace with a private page */ + memcpy( temp_page, page, page_size ); -+ wine_anon_mmap( page, page_size, VIRTUAL_GetUnixProt(vprot | VPROT_WRITE | VPROT_WRITTEN), MAP_FIXED ); ++ wine_anon_mmap( page, page_size, get_unix_prot( vprot | VPROT_WRITE | VPROT_WRITTEN ), MAP_FIXED ); + memcpy( page, temp_page, page_size ); + } } /* ignore fault if page is writable now */ - if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; + if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS; -- 2.26.2 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 752ef3b8..e9802599 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "3c86adab766e3bc7c91da088c2dd6bc41a917055" + echo "48020f4846cca1a02f4e1dc037e2cc2068df5e9c" } # Show version information @@ -187,7 +187,6 @@ patch_enable_all () enable_ntdll_NtDevicePath="$1" enable_ntdll_NtQueryEaFile="$1" enable_ntdll_NtQuerySection="$1" - enable_ntdll_NtQueryVirtualMemory="$1" enable_ntdll_NtSetLdtEntries="$1" enable_ntdll_Pipe_SpecialCharacters="$1" enable_ntdll_ProcessQuotaLimits="$1" @@ -662,9 +661,6 @@ patch_enable () ntdll-NtQuerySection) enable_ntdll_NtQuerySection="$2" ;; - ntdll-NtQueryVirtualMemory) - enable_ntdll_NtQueryVirtualMemory="$2" - ;; ntdll-NtSetLdtEntries) enable_ntdll_NtSetLdtEntries="$2" ;; @@ -1687,13 +1683,6 @@ if test "$enable_ntdll_RtlCreateUserThread" -eq 1; then enable_winebuild_Fake_Dlls=1 fi -if test "$enable_ntdll_NtQueryVirtualMemory" -eq 1; then - if test "$enable_ntdll_NtDevicePath" -gt 1; then - abort "Patchset ntdll-NtDevicePath disabled, but ntdll-NtQueryVirtualMemory depends on that." - fi - enable_ntdll_NtDevicePath=1 -fi - if test "$enable_ntdll_NtQueryEaFile" -eq 1; then if test "$enable_ntdll_Junction_Points" -gt 1; then abort "Patchset ntdll-Junction_Points disabled, but ntdll-NtQueryEaFile depends on that." @@ -3677,8 +3666,8 @@ fi # | # | Modified files: # | * dlls/advapi32/crypt.c, dlls/advapi32/tests/security.c, dlls/kernel32/tests/virtual.c, dlls/ntdll/ntdll_misc.h, -# | dlls/ntdll/server.c, dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c, -# | dlls/ntdll/signal_powerpc.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/thread.c, dlls/ntdll/virtual.c, +# | dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c, dlls/ntdll/signal_powerpc.c, +# | dlls/ntdll/signal_x86_64.c, dlls/ntdll/thread.c, dlls/ntdll/unix/server.c, dlls/ntdll/unix/virtual.c, # | dlls/psapi/tests/psapi_main.c # | if test "$enable_ntdll_WRITECOPY" -eq 1; then @@ -3713,7 +3702,7 @@ fi # | * [#44650] Fix holes in ELF mappings # | # | Modified files: -# | * dlls/ntdll/virtual.c, dlls/psapi/tests/psapi_main.c +# | * dlls/ntdll/unix/virtual.c, dlls/psapi/tests/psapi_main.c # | if test "$enable_ntdll_Builtin_Prot" -eq 1; then patch_apply ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch @@ -3775,7 +3764,7 @@ fi # Patchset ntdll-Dealloc_Thread_Stack # | # | Modified files: -# | * dlls/ntdll/ntdll_misc.h, dlls/ntdll/virtual.c +# | * dlls/ntdll/ntdll_misc.h, dlls/ntdll/unix/unix_private.h, dlls/ntdll/unix/virtual.c # | if test "$enable_ntdll_Dealloc_Thread_Stack" -eq 1; then patch_apply ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch @@ -3858,7 +3847,7 @@ fi # | * [#33162] Ensure NtProtectVirtualMemory and NtCreateSection are on separate pages # | # | Modified files: -# | * dlls/ntdll/virtual.c +# | * dlls/ntdll/unix/virtual.c # | if test "$enable_ntdll_Fix_Alignment" -eq 1; then patch_apply ntdll-Fix_Alignment/0001-ntdll-Move-NtProtectVirtualMemory-and-NtCreateSectio.patch @@ -3875,7 +3864,7 @@ fi # | 44-bit user-mode VA limitation from Windows < 8.1) # | # | Modified files: -# | * dlls/ntdll/virtual.c +# | * dlls/ntdll/unix/virtual.c # | if test "$enable_ntdll_ForceBottomUpAlloc" -eq 1; then patch_apply ntdll-ForceBottomUpAlloc/0001-ntdll-Stop-search-on-mmap-error-in-try_map_free_area.patch @@ -4114,36 +4103,6 @@ if test "$enable_ntdll_NtQuerySection" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-NtQueryVirtualMemory -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-Pipe_SpecialCharacters, ntdll-NtDevicePath -# | -# | This patchset fixes the following Wine bugs: -# | * [#23999] Implement MemorySectionName class in NtQueryVirtualMemory -# | * [#27248] Implement K32GetMappedFileName -# | -# | Modified files: -# | * dlls/kernelbase/debug.c, dlls/ntdll/directory.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/tests/info.c, dlls/ntdll/virtual.c, -# | dlls/psapi/tests/psapi_main.c, server/mapping.c, server/protocol.def -# | -if test "$enable_ntdll_NtQueryVirtualMemory" -eq 1; then - patch_apply ntdll-NtQueryVirtualMemory/0003-ntdll-Implement-NtQueryVirtualMemory-MemorySectionNa.patch - patch_apply ntdll-NtQueryVirtualMemory/0004-ntdll-tests-Add-tests-for-NtQueryVirtualMemory-Memor.patch - patch_apply ntdll-NtQueryVirtualMemory/0005-ntdll-tests-Add-test-to-ensure-section-name-is-full-.patch - patch_apply ntdll-NtQueryVirtualMemory/0006-ntdll-Allow-to-query-section-names-from-other-proces.patch - patch_apply ntdll-NtQueryVirtualMemory/0007-kernel32-Implement-K32GetMappedFileName.-v2.patch - patch_apply ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch - ( - printf '%s\n' '+ { "Dmitry Timoshkov", "ntdll: Implement NtQueryVirtualMemory(MemorySectionName).", 3 },'; - printf '%s\n' '+ { "Dmitry Timoshkov", "ntdll/tests: Add tests for NtQueryVirtualMemory(MemorySectionName).", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll/tests: Add test to ensure section name is full path.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Allow to query section names from other processes.", 2 },'; - printf '%s\n' '+ { "Dmitry Timoshkov", "kernel32: Implement K32GetMappedFileName.", 2 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Resolve drive symlinks before returning section name.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-NtSetLdtEntries # | # | Modified files: diff --git a/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch b/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch index 8203ef16..91188a82 100644 --- a/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch +++ b/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch @@ -1,4 +1,4 @@ -From 505b2a7167d4b0ea533663ef30663f21b0ab9863 Mon Sep 17 00:00:00 2001 +From 3b9456b9e0bc870281df2144b67d42112baad4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 11 May 2017 05:32:55 +0200 Subject: [PATCH] winebuild: Generate syscall thunks for ntdll exports. @@ -18,7 +18,7 @@ Based on a patch by Erich E. Hoover. 10 files changed, 208 insertions(+), 27 deletions(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index 5fd54071ffd..950408cbc38 100644 +index eb6c87bce4d..d3cbfe63f1c 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -449,6 +449,8 @@ static ULONG first_ldt_entry = 32; @@ -30,15 +30,15 @@ index 5fd54071ffd..950408cbc38 100644 enum i386_trap_code { TRAP_x86_UNKNOWN = -1, /* Unknown fault (TRAP_sig not defined) */ -@@ -1487,7 +1489,7 @@ NTSTATUS CDECL DECLSPEC_HIDDEN __regs_NtGetContextThread( DWORD edi, DWORD esi, - { - context->Ebp = ebp; - context->Esp = (DWORD)&retaddr; -- context->Eip = *(&edi - 1); -+ context->Eip = (DWORD)__syscall_NtGetContextThread + 18; - context->SegCs = get_cs(); - context->SegSs = get_ds(); - context->EFlags = eflags; +@@ -1275,7 +1277,7 @@ NTSTATUS CDECL DECLSPEC_HIDDEN __regs_NtGetContextThread( DWORD edi, DWORD esi, + { + context->Ebp = ebp; + context->Esp = (DWORD)&retaddr; +- context->Eip = *(&edi - 1); ++ context->Eip = (DWORD)__syscall_NtGetContextThread + 18; + context->EFlags = eflags; + } + return unix_funcs->NtGetContextThread( handle, context ); diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index a5e6faa461a..51938bf84cc 100644 --- a/dlls/ntdll/tests/exception.c @@ -53,7 +53,7 @@ index a5e6faa461a..51938bf84cc 100644 ok( context.SegCs == LOWORD(expect.SegCs), "wrong SegCs %08x/%08x\n", context.SegCs, expect.SegCs ); ok( context.SegDs == LOWORD(expect.SegDs), "wrong SegDs %08x/%08x\n", context.SegDs, expect.SegDs ); diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index bb11521cf69..edd6c4dfa99 100644 +index f9ea9203ed8..7e435c4ccb3 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -212,6 +212,8 @@ void map_user_shared_data(void) @@ -65,15 +65,15 @@ index bb11521cf69..edd6c4dfa99 100644 /*********************************************************************** * thread_init * -@@ -248,6 +250,7 @@ TEB *thread_init(void) +@@ -246,6 +248,7 @@ TEB *thread_init(void) + + teb = unix_funcs->virtual_alloc_first_teb(); unix_funcs->init_threading( &nb_threads, &__wine_ldt_copy ); - unix_funcs->alloc_thread( teb ); - unix_funcs->init_thread( teb ); + teb->WOW32Reserved = __wine_syscall_dispatcher; peb = teb->Peb; peb->FastPebLock = &peb_lock; -@@ -493,6 +496,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, +@@ -491,6 +494,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, teb->Tib.StackBase = stack.StackBase; teb->Tib.StackLimit = stack.StackLimit; teb->DeallocationStack = stack.DeallocationStack; diff --git a/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch b/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch index edbed0e5..883ca5ee 100644 --- a/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch +++ b/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch @@ -1,4 +1,4 @@ -From 22a245956909fc1cd3a733d460441bb05d09c775 Mon Sep 17 00:00:00 2001 +From 724fec1afabf68217dc161e0f784a8b65c2c5854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 15 May 2017 16:27:56 +0200 Subject: [PATCH] winebuild: Add stub functions in fake dlls. @@ -61,7 +61,7 @@ index 926fa913866..902907329c0 100644 CloseHandle(map); CloseHandle(file); diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index edd6c4dfa99..678af513264 100644 +index 7e435c4ccb3..5148445ce3a 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -214,6 +214,39 @@ void map_user_shared_data(void) @@ -104,15 +104,15 @@ index edd6c4dfa99..678af513264 100644 /*********************************************************************** * thread_init * -@@ -251,6 +284,7 @@ TEB *thread_init(void) - unix_funcs->alloc_thread( teb ); - unix_funcs->init_thread( teb ); +@@ -249,6 +282,7 @@ TEB *thread_init(void) + teb = unix_funcs->virtual_alloc_first_teb(); + unix_funcs->init_threading( &nb_threads, &__wine_ldt_copy ); teb->WOW32Reserved = __wine_syscall_dispatcher; + teb->Spare2 = (ULONG_PTR)__wine_fakedll_dispatcher; peb = teb->Peb; peb->FastPebLock = &peb_lock; -@@ -497,6 +531,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, +@@ -495,6 +529,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, teb->Tib.StackLimit = stack.StackLimit; teb->DeallocationStack = stack.DeallocationStack; teb->WOW32Reserved = __wine_syscall_dispatcher; diff --git a/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch b/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch index eac18791..2d38ff3c 100644 --- a/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch +++ b/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch @@ -1,4 +1,4 @@ -From fa2f2b41cb6af594457b76ba90c042387c368ef6 Mon Sep 17 00:00:00 2001 +From 253d27816a1eb43b54834a12aa4c55442b0b1062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 7 Sep 2017 00:38:09 +0200 Subject: [PATCH] tools/winebuild: Add syscall thunks for 64 bit. @@ -40,7 +40,7 @@ index 95939ba6bde..ae5462f6e55 100644 todo_wine ok(0, "%s: Export is a stub-function, skipping\n", func_name); continue; diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 678af513264..297893d8898 100644 +index 5148445ce3a..c9a2240a4da 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -54,6 +54,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread); @@ -77,7 +77,7 @@ index 678af513264..297893d8898 100644 + /* allocate and initialize the PEB and initial TEB */ - teb = virtual_alloc_first_teb(); + teb = unix_funcs->virtual_alloc_first_teb(); diff --git a/libs/wine/loader.c b/libs/wine/loader.c index 4597a6cb324..3d0d75e9c6d 100644 --- a/libs/wine/loader.c diff --git a/patches/ws2_32-WSACleanup/0002-ws2_32-Invalidate-client-side-file-descriptor-cache-.patch b/patches/ws2_32-WSACleanup/0002-ws2_32-Invalidate-client-side-file-descriptor-cache-.patch index 8d92e376..95c2d9b8 100644 --- a/patches/ws2_32-WSACleanup/0002-ws2_32-Invalidate-client-side-file-descriptor-cache-.patch +++ b/patches/ws2_32-WSACleanup/0002-ws2_32-Invalidate-client-side-file-descriptor-cache-.patch @@ -1,4 +1,4 @@ -From 9d0ef7cd2af3c8ca34f24247a7927c24c7086741 Mon Sep 17 00:00:00 2001 +From 88f8d0382e55cbe97ae5d7937a63bd801f277f25 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 6 Sep 2015 12:41:17 +0200 Subject: [PATCH] ws2_32: Invalidate client-side file descriptor cache in @@ -48,10 +48,10 @@ index c7788b99e2d..54291d0a909 100644 /*********************************************************************** * server_init_process diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c -index aa020845bb9..0ef08edc474 100644 +index 0f342e8277e..4c7a5c488dc 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c -@@ -1014,6 +1014,7 @@ static struct unix_funcs unix_funcs = +@@ -1045,6 +1045,7 @@ static struct unix_funcs unix_funcs = server_wait, server_queue_process_apc, server_send_fd, @@ -60,7 +60,7 @@ index aa020845bb9..0ef08edc474 100644 server_fd_to_handle, server_handle_to_fd, diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c -index 8889c5d4b12..929ff354d65 100644 +index 17b23e58d28..f7d172cf324 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -983,6 +983,26 @@ static int remove_fd_from_cache( HANDLE handle ) @@ -91,10 +91,10 @@ index 8889c5d4b12..929ff354d65 100644 /*********************************************************************** * server_get_unix_fd diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h -index 0694426dddb..5c13dce0b0a 100644 +index 8562efb7dd4..ee2bd47ad70 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h -@@ -68,6 +68,7 @@ extern unsigned int CDECL server_wait( const select_op_t *select_op, data_size_t +@@ -90,6 +90,7 @@ extern unsigned int CDECL server_wait( const select_op_t *select_op, data_size_t const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN; extern unsigned int CDECL server_queue_process_apc( HANDLE process, const apc_call_t *call, apc_result_t *result ) DECLSPEC_HIDDEN; extern void CDECL server_send_fd( int fd ) DECLSPEC_HIDDEN; @@ -103,19 +103,19 @@ index 0694426dddb..5c13dce0b0a 100644 int *needs_close, enum server_fd_type *type, unsigned int *options ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h -index 323141d3840..0189c247b7a 100644 +index fb755373f07..7df35f0eee1 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h -@@ -27,7 +27,7 @@ - struct ldt_copy; +@@ -28,7 +28,7 @@ struct ldt_copy; + struct msghdr; /* increment this when you change the function table */ --#define NTDLL_UNIXLIB_VERSION 13 -+#define NTDLL_UNIXLIB_VERSION 14 +-#define NTDLL_UNIXLIB_VERSION 16 ++#define NTDLL_UNIXLIB_VERSION 17 struct unix_funcs { -@@ -80,6 +80,7 @@ struct unix_funcs +@@ -127,6 +127,7 @@ struct unix_funcs const LARGE_INTEGER *timeout ); unsigned int (CDECL *server_queue_process_apc)( HANDLE process, const apc_call_t *call, apc_result_t *result ); void (CDECL *server_send_fd)( int fd ); diff --git a/staging/upstream-commit b/staging/upstream-commit index f6aa5e47..b36cf9b1 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -3c86adab766e3bc7c91da088c2dd6bc41a917055 +48020f4846cca1a02f4e1dc037e2cc2068df5e9c