From dea25941569f2a87c2f19b6f7a552f6cd812660c Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 5 Dec 2015 22:48:34 +0100 Subject: [PATCH] Added patch to fix implementation of NtQueryInformationProcess for ProcessDebugFlags. --- README.md | 3 +- ...entation-of-NtQueryInformationProces.patch | 103 ++++++++++++++++++ patches/ntdll-ProcessDebugFlags/definition | 1 + patches/patchinstall.sh | 16 +++ staging/changelog | 2 + 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 patches/ntdll-ProcessDebugFlags/0001-ntdll-Fix-implementation-of-NtQueryInformationProces.patch create mode 100644 patches/ntdll-ProcessDebugFlags/definition diff --git a/README.md b/README.md index fe2a8f7a..8ed60963 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,9 @@ Wine. All those differences are also documented on the Included bug fixes and improvements ----------------------------------- -**Bug fixes and features included in the next upcoming release [3]:** +**Bug fixes and features included in the next upcoming release [4]:** +* Fix implementation of NtQueryInformationProcess for ProcessDebugFlags * Fix possible leak of explorer.exe processes and implement proper desktop refcounting * Properly implement GetLargestConsoleWindowSize ([Wine Bug #10919](https://bugs.winehq.org/show_bug.cgi?id=10919)) * Set LastError to 0 in GetSidIdentifierAuthority diff --git a/patches/ntdll-ProcessDebugFlags/0001-ntdll-Fix-implementation-of-NtQueryInformationProces.patch b/patches/ntdll-ProcessDebugFlags/0001-ntdll-Fix-implementation-of-NtQueryInformationProces.patch new file mode 100644 index 00000000..770f97ee --- /dev/null +++ b/patches/ntdll-ProcessDebugFlags/0001-ntdll-Fix-implementation-of-NtQueryInformationProces.patch @@ -0,0 +1,103 @@ +From 20e3383c70146e8220f08ebc379895139c9eb496 Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Sat, 5 Dec 2015 22:47:17 +0100 +Subject: ntdll: Fix implementation of NtQueryInformationProcess for + ProcessDebugFlags. + +--- + dlls/ntdll/process.c | 5 ++++- + dlls/ntdll/tests/info.c | 12 ++++++++---- + server/process.c | 1 + + server/protocol.def | 3 ++- + 4 files changed, 15 insertions(+), 6 deletions(-) + +diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c +index ca9462a..636c294 100644 +--- a/dlls/ntdll/process.c ++++ b/dlls/ntdll/process.c +@@ -339,7 +339,10 @@ NTSTATUS WINAPI NtQueryInformationProcess( + req->handle = wine_server_obj_handle( ProcessHandle ); + if ((ret = wine_server_call( req )) == STATUS_SUCCESS) + { +- *(DWORD *)ProcessInformation = !reply->debugger_present; ++ if (!reply->debugger_present) ++ *(DWORD *)ProcessInformation = TRUE; ++ else ++ *(DWORD *)ProcessInformation = reply->debug_children; + } + } + SERVER_END_REQ; +diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c +index 21b2e6c..18a73ab 100644 +--- a/dlls/ntdll/tests/info.c ++++ b/dlls/ntdll/tests/info.c +@@ -1271,8 +1271,9 @@ static void test_query_process_debug_object_handle(int argc, char **argv) + ok(ret, "CloseHandle failed with last error %u\n", GetLastError()); + } + +-static void test_query_process_debug_flags(int argc, char **argv) ++static void test_query_process_debug_flags(int argc, char **argv, DWORD flags) + { ++ DWORD expected_flags = !(flags & DEBUG_ONLY_THIS_PROCESS); + DWORD debug_flags = 0xdeadbeef; + char cmdline[MAX_PATH]; + PROCESS_INFORMATION pi; +@@ -1283,7 +1284,7 @@ static void test_query_process_debug_flags(int argc, char **argv) + sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee"); + + si.cb = sizeof(si); +- ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &si, &pi); ++ ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi); + ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError()); + if (!ret) return; + +@@ -1320,7 +1321,8 @@ static void test_query_process_debug_flags(int argc, char **argv) + status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags, + &debug_flags, sizeof(debug_flags), NULL); + ok(!status || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "NtQueryInformationProcess failed, status %#x.\n", status); +- ok(debug_flags == FALSE || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected flag FALSE, got %x.\n", debug_flags); ++ ok(debug_flags == expected_flags || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, ++ "Expected flag %u, got %x.\n", expected_flags, debug_flags); + + for (;;) + { +@@ -1871,7 +1873,9 @@ START_TEST(info) + + /* 0x1F ProcessDebugFlags */ + trace("Starting test_process_debug_flags()\n"); +- test_query_process_debug_flags(argc, argv); ++ test_query_process_debug_flags(argc, argv, DEBUG_PROCESS); ++ test_query_process_debug_flags(argc, argv, DEBUG_ONLY_THIS_PROCESS); ++ test_query_process_debug_flags(argc, argv, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS); + + /* belongs to its own file */ + trace("Starting test_readvirtualmemory()\n"); +diff --git a/server/process.c b/server/process.c +index e00b429..c738de6 100644 +--- a/server/process.c ++++ b/server/process.c +@@ -1359,6 +1359,7 @@ DECL_HANDLER(get_process_info) + reply->end_time = process->end_time; + reply->cpu = process->cpu; + reply->debugger_present = !!process->debugger; ++ reply->debug_children = process->debug_children; + release_object( process ); + } + } +diff --git a/server/protocol.def b/server/protocol.def +index 04814c9..b5f5457 100644 +--- a/server/protocol.def ++++ b/server/protocol.def +@@ -818,7 +818,8 @@ struct rawinput_device + int exit_code; /* process exit code */ + int priority; /* priority class */ + cpu_type_t cpu; /* CPU that this process is running on */ +- int debugger_present; /* process is being debugged */ ++ short int debugger_present; /* process is being debugged */ ++ short int debug_children; /* debug child processes */ + @END + + +-- +2.6.2 + diff --git a/patches/ntdll-ProcessDebugFlags/definition b/patches/ntdll-ProcessDebugFlags/definition new file mode 100644 index 00000000..78e1744c --- /dev/null +++ b/patches/ntdll-ProcessDebugFlags/definition @@ -0,0 +1 @@ +Fixes: Fix implementation of NtQueryInformationProcess for ProcessDebugFlags diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 5639e64d..008af7e6 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -205,6 +205,7 @@ patch_enable_all () enable_ntdll_NtQuerySection="$1" enable_ntdll_NtSetLdtEntries="$1" enable_ntdll_Pipe_SpecialCharacters="$1" + enable_ntdll_ProcessDebugFlags="$1" enable_ntdll_ProcessQuotaLimits="$1" enable_ntdll_Purist_Mode="$1" enable_ntdll_RtlIpStringToAddress="$1" @@ -728,6 +729,9 @@ patch_enable () ntdll-Pipe_SpecialCharacters) enable_ntdll_Pipe_SpecialCharacters="$2" ;; + ntdll-ProcessDebugFlags) + enable_ntdll_ProcessDebugFlags="$2" + ;; ntdll-ProcessQuotaLimits) enable_ntdll_ProcessQuotaLimits="$2" ;; @@ -4362,6 +4366,18 @@ if test "$enable_ntdll_Pipe_SpecialCharacters" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-ProcessDebugFlags +# | +# | Modified files: +# | * dlls/ntdll/process.c, dlls/ntdll/tests/info.c, server/process.c, server/protocol.def +# | +if test "$enable_ntdll_ProcessDebugFlags" -eq 1; then + patch_apply ntdll-ProcessDebugFlags/0001-ntdll-Fix-implementation-of-NtQueryInformationProces.patch + ( + echo '+ { "Sebastian Lackner", "ntdll: Fix implementation of NtQueryInformationProcess for ProcessDebugFlags.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-ProcessQuotaLimits # | # | Modified files: diff --git a/staging/changelog b/staging/changelog index 06098b0e..0feb3b06 100644 --- a/staging/changelog +++ b/staging/changelog @@ -13,6 +13,8 @@ wine-staging (1.8~rc3) UNRELEASED; urgency=low proper desktop refcounting. * Added patch to set LastError to 0 in GetSidIdentifierAuthority. * Added patch to properly implement GetLargestConsoleWindowSize. + * Added patch to fix implementation of NtQueryInformationProcess for + ProcessDebugFlags. -- Sebastian Lackner Tue, 01 Dec 2015 02:35:10 +0100 wine-staging (1.8~rc2) unstable; urgency=low