From 9cca205cc2e024ae786fdebe398b900a119f197d Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 3 Jul 2020 18:23:02 -0500 Subject: [PATCH] ntdll-NtQueryVirtualMemory: Rebase and re-enable. --- ...ive-symlinks-before-returning-sectio.patch | 52 +++++++++---------- patches/ntdll-NtQueryVirtualMemory/definition | 2 - patches/patchinstall.sh | 45 ++++++++++++++++ 3 files changed, 71 insertions(+), 28 deletions(-) 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 0ef87c87..8bc31e86 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,20 +1,20 @@ -From 02ea4a27a1d6598e3d6a1ab5c2a25d5459e5390c Mon Sep 17 00:00:00 2001 +From 01031e9eb282bffce2449891e68eb9efeded1ee9 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. --- - dlls/ntdll/directory.c | 2 +- - dlls/ntdll/ntdll_misc.h | 1 + - dlls/ntdll/unix/virtual.c | 37 +++++++++++++++++++++++++++++------ - dlls/psapi/tests/psapi_main.c | 6 +----- + dlls/ntdll/unix/file.c | 2 +- + dlls/ntdll/unix/unix_private.h | 1 + + 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 453568d641e..12da4316e88 100644 ---- a/dlls/ntdll/directory.c -+++ b/dlls/ntdll/directory.c -@@ -2798,7 +2798,7 @@ static NTSTATUS nt_to_unix_file_name_internal( const UNICODE_STRING *nameW, ANSI +diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c +index 551d0450584..65ddf0df4a2 100644 +--- a/dlls/ntdll/unix/file.c ++++ b/dlls/ntdll/unix/file.c +@@ -3425,7 +3425,7 @@ static NTSTATUS nt_to_unix_file_name_internal( const UNICODE_STRING *nameW, ANSI } /* read the contents of an NT symlink object */ @@ -23,23 +23,23 @@ index 453568d641e..12da4316e88 100644 { OBJECT_ATTRIBUTES attr; UNICODE_STRING targetW; -diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index e9a3230e814..750b01bd059 100644 ---- a/dlls/ntdll/ntdll_misc.h -+++ b/dlls/ntdll/ntdll_misc.h -@@ -175,6 +175,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S - UINT disposition ) DECLSPEC_HIDDEN; - - /* virtual memory */ +diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h +index e14da3ff7ec..5410248e8a7 100644 +--- a/dlls/ntdll/unix/unix_private.h ++++ b/dlls/ntdll/unix/unix_private.h +@@ -103,6 +103,7 @@ extern void CDECL get_initial_directory( UNICODE_STRING *dir ) DECLSPEC_HIDDEN; + extern void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, HANDLE *std_err ) DECLSPEC_HIDDEN; + extern USHORT * CDECL get_unix_codepage_data(void) DECLSPEC_HIDDEN; + extern void CDECL get_locales( WCHAR *sys, WCHAR *user ) DECLSPEC_HIDDEN; +extern NTSTATUS read_nt_symlink( HANDLE root, UNICODE_STRING *name, WCHAR *target, size_t length ) DECLSPEC_HIDDEN; - 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; + extern NTSTATUS CDECL 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/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 97244822082..15b4697c441 100644 +index 1515963b9c7..5cee0da5d24 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -194,6 +194,8 @@ static BYTE **pages_vprot; +@@ -188,6 +188,8 @@ static BYTE **pages_vprot; static BYTE *pages_vprot; #endif @@ -48,7 +48,7 @@ index 97244822082..15b4697c441 100644 static struct file_view *view_block_start, *view_block_end, *next_free_view; #ifdef _WIN64 static const size_t view_block_size = 0x200000; -@@ -3836,12 +3838,15 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -4016,12 +4018,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 97244822082..15b4697c441 100644 if (!addr || !info || !res_len) return STATUS_INVALID_PARAMETER; -@@ -3900,14 +3905,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -4080,14 +4085,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, } found: @@ -151,5 +151,5 @@ index f6a7b69eca0..a8263a2f44b 100644 SetLastError(0xdeadbeef); -- -2.26.2 +2.27.0 diff --git a/patches/ntdll-NtQueryVirtualMemory/definition b/patches/ntdll-NtQueryVirtualMemory/definition index b33d61ea..ba268533 100644 --- a/patches/ntdll-NtQueryVirtualMemory/definition +++ b/patches/ntdll-NtQueryVirtualMemory/definition @@ -2,5 +2,3 @@ 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/patchinstall.sh b/patches/patchinstall.sh index 953e5230..95d7fad7 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -183,6 +183,7 @@ patch_enable_all () enable_ntdll_NtAccessCheck="$1" enable_ntdll_NtDevicePath="$1" enable_ntdll_NtQuerySection="$1" + enable_ntdll_NtQueryVirtualMemory="$1" enable_ntdll_NtSetLdtEntries="$1" enable_ntdll_Pipe_SpecialCharacters="$1" enable_ntdll_ProcessQuotaLimits="$1" @@ -640,6 +641,9 @@ patch_enable () ntdll-NtQuerySection) enable_ntdll_NtQuerySection="$2" ;; + ntdll-NtQueryVirtualMemory) + enable_ntdll_NtQueryVirtualMemory="$2" + ;; ntdll-NtSetLdtEntries) enable_ntdll_NtSetLdtEntries="$2" ;; @@ -1628,6 +1632,17 @@ if test "$enable_ntdll_SystemCodeIntegrityInformation" -eq 1; then enable_ntdll_SystemExtendedProcessInformation=1 fi +if test "$enable_ntdll_NtQueryVirtualMemory" -eq 1; then + if test "$enable_ntdll_ForceBottomUpAlloc" -gt 1; then + abort "Patchset ntdll-ForceBottomUpAlloc disabled, but ntdll-NtQueryVirtualMemory depends on that." + fi + if test "$enable_ntdll_NtDevicePath" -gt 1; then + abort "Patchset ntdll-NtDevicePath disabled, but ntdll-NtQueryVirtualMemory depends on that." + fi + enable_ntdll_ForceBottomUpAlloc=1 + enable_ntdll_NtDevicePath=1 +fi + if test "$enable_ntdll_NtDevicePath" -eq 1; then if test "$enable_ntdll_Pipe_SpecialCharacters" -gt 1; then abort "Patchset ntdll-Pipe_SpecialCharacters disabled, but ntdll-NtDevicePath depends on that." @@ -3813,6 +3828,36 @@ if test "$enable_ntdll_NtQuerySection" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-NtQueryVirtualMemory +# | +# | This patchset has the following (direct or indirect) dependencies: +# | * ntdll-ForceBottomUpAlloc, 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/tests/info.c, dlls/ntdll/unix/file.c, dlls/ntdll/unix/unix_private.h, +# | dlls/ntdll/unix/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: