From 04888232056311dacfb6c5b224cfa885bc485f75 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 31 Oct 2015 03:16:31 +0100 Subject: [PATCH] Added patch to use close_handle instead of NtClose for internal memory management functions. --- debian/changelog | 2 + .../0001-ntdll-Implement-NtQuerySection.patch | 12 ++--- ...handle-instead-of-NtClose-for-intern.patch | 44 +++++++++++++++++++ patches/patchinstall.sh | 2 + 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 patches/ntdll-Syscall_Wrappers/0006-ntdll-Use-close_handle-instead-of-NtClose-for-intern.patch diff --git a/debian/changelog b/debian/changelog index f19b5fbc..2a476f95 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,8 @@ wine-staging (1.7.54) UNRELEASED; urgency=low * Added patch to fix build failure (introduced by makefile rewrite). * Added patch to pass '-read_only_relocs suppress' to the linker on OSX and enable patchset to use Nt* function wrappers. + * Added patch to use close_handle instead of NtClose for internal memory + management functions. * Removed patch to implement kernel32.GetPhysicallyInstalledSystemMemory (accepted upstream). * Partially removed patches for ws2_32 TransmitFile (accepted upstream). diff --git a/patches/ntdll-NtQuerySection/0001-ntdll-Implement-NtQuerySection.patch b/patches/ntdll-NtQuerySection/0001-ntdll-Implement-NtQuerySection.patch index 5748a89e..57521195 100644 --- a/patches/ntdll-NtQuerySection/0001-ntdll-Implement-NtQuerySection.patch +++ b/patches/ntdll-NtQuerySection/0001-ntdll-Implement-NtQuerySection.patch @@ -1,4 +1,4 @@ -From 7d4dbe4eccb1c132d31486780bdd3b892ccb08a6 Mon Sep 17 00:00:00 2001 +From 98455537b8e39281df59357bf1a2628350026c27 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 16 Oct 2014 23:24:37 +0200 Subject: ntdll: Implement NtQuerySection. (try 2) @@ -14,7 +14,7 @@ Some small modifications by Sebastian Lackner 6 files changed, 148 insertions(+), 23 deletions(-) diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c -index e48e6d4..36e3704 100644 +index a0d8909..a53e0bb 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -656,26 +656,6 @@ NTSTATUS WINAPI SYSCALL(NtPrivilegeCheck)( @@ -67,7 +67,7 @@ index 38422ae..73ae405 100644 @ stdcall ZwQuerySemaphore(long long ptr long ptr) NtQuerySemaphore @ stdcall ZwQuerySymbolicLinkObject(long ptr ptr) NtQuerySymbolicLinkObject diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index f30d94a..2145b53 100644 +index 54c4cf4..f29084f 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -2539,6 +2539,102 @@ NTSTATUS WINAPI SYSCALL(NtOpenSection)( HANDLE *handle, ACCESS_MASK access, cons @@ -128,8 +128,8 @@ index f30d94a..2145b53 100644 + SERVER_END_REQ; + if (res) return res; + -+ if (dup_mapping) NtClose( dup_mapping ); -+ if (shared_file) NtClose( shared_file ); ++ if (dup_mapping) close_handle( dup_mapping ); ++ if (shared_file) close_handle( shared_file ); + + if (info_class == SectionBasicInformation) + { @@ -272,7 +272,7 @@ index 16e7c1c..ba26d1e 100644 if ((fd = get_obj_fd( &mapping->obj ))) { diff --git a/server/protocol.def b/server/protocol.def -index c313006..4e07c10 100644 +index 5b45078..0d9b090 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1674,6 +1674,13 @@ enum char_info_mode diff --git a/patches/ntdll-Syscall_Wrappers/0006-ntdll-Use-close_handle-instead-of-NtClose-for-intern.patch b/patches/ntdll-Syscall_Wrappers/0006-ntdll-Use-close_handle-instead-of-NtClose-for-intern.patch new file mode 100644 index 00000000..711a61f1 --- /dev/null +++ b/patches/ntdll-Syscall_Wrappers/0006-ntdll-Use-close_handle-instead-of-NtClose-for-intern.patch @@ -0,0 +1,44 @@ +From a3e9e92ee5c436b3704b505ae4ea4cc076526b0e Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Sat, 31 Oct 2015 02:41:47 +0100 +Subject: ntdll: Use close_handle instead of NtClose for internal memory + management functions. + +--- + dlls/ntdll/virtual.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c +index f30d94a..54c4cf4 100644 +--- a/dlls/ntdll/virtual.c ++++ b/dlls/ntdll/virtual.c +@@ -1279,7 +1279,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz + error: + if (view) delete_view( view ); + server_leave_uninterrupted_section( &csVirtual, &sigset ); +- if (dup_mapping) NtClose( dup_mapping ); ++ if (dup_mapping) close_handle( dup_mapping ); + return status; + } + +@@ -2663,7 +2663,7 @@ NTSTATUS WINAPI SYSCALL(NtMapViewOfSection)( HANDLE handle, HANDLE process, PVOI + res = map_image( handle, unix_handle, base, size, mask, header_size, + shared_fd, dup_mapping, map_vprot, addr_ptr ); + if (shared_needs_close) close( shared_fd ); +- NtClose( shared_file ); ++ close_handle( shared_file ); + } + else + { +@@ -2731,7 +2731,7 @@ NTSTATUS WINAPI SYSCALL(NtMapViewOfSection)( HANDLE handle, HANDLE process, PVOI + server_leave_uninterrupted_section( &csVirtual, &sigset ); + + done: +- if (dup_mapping) NtClose( dup_mapping ); ++ if (dup_mapping) close_handle( dup_mapping ); + if (needs_close) close( unix_handle ); + return res; + } +-- +2.6.1 + diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 7634a041..8427e028 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -3854,12 +3854,14 @@ if test "$enable_ntdll_Syscall_Wrappers" -eq 1; then patch_apply ntdll-Syscall_Wrappers/0003-ntdll-APCs-should-call-the-implementation-instead-of.patch patch_apply ntdll-Syscall_Wrappers/0004-ntdll-Syscalls-should-not-call-Nt-Ex-thunk-wrappers.patch patch_apply ntdll-Syscall_Wrappers/0005-ntdll-Run-directory-initialization-function-early-du.patch + patch_apply ntdll-Syscall_Wrappers/0006-ntdll-Use-close_handle-instead-of-NtClose-for-intern.patch ( echo '+ { "Sebastian Lackner", "winegcc: Pass '\''-read_only_relocs suppress'\'' to the linker on OSX.", 1 },'; echo '+ { "Sebastian Lackner", "ntdll: Use wrapper functions for syscalls.", 1 },'; echo '+ { "Sebastian Lackner", "ntdll: APCs should call the implementation instead of the syscall thunk.", 1 },'; echo '+ { "Sebastian Lackner", "ntdll: Syscalls should not call Nt*Ex thunk wrappers.", 1 },'; echo '+ { "Sebastian Lackner", "ntdll: Run directory initialization function early during the process startup.", 1 },'; + echo '+ { "Sebastian Lackner", "ntdll: Use close_handle instead of NtClose for internal memory management functions.", 1 },'; ) >> "$patchlist" fi