From cc8133fd8cbe63b578e3f36ee4b94afc42ba3da4 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 5 Feb 2017 14:25:56 +0100 Subject: [PATCH] Added patch to implement ProcessPriorityClass in NtQueryInformationProcess. --- ...ProcessPriorityClass-in-NtQueryInfor.patch | 116 ++++++++++++++++++ patches/ntdll-ProcessPriorityClass/definition | 1 + patches/patchinstall.sh | 16 +++ 3 files changed, 133 insertions(+) create mode 100644 patches/ntdll-ProcessPriorityClass/0001-ntdll-Implement-ProcessPriorityClass-in-NtQueryInfor.patch create mode 100644 patches/ntdll-ProcessPriorityClass/definition diff --git a/patches/ntdll-ProcessPriorityClass/0001-ntdll-Implement-ProcessPriorityClass-in-NtQueryInfor.patch b/patches/ntdll-ProcessPriorityClass/0001-ntdll-Implement-ProcessPriorityClass-in-NtQueryInfor.patch new file mode 100644 index 00000000..a5942a05 --- /dev/null +++ b/patches/ntdll-ProcessPriorityClass/0001-ntdll-Implement-ProcessPriorityClass-in-NtQueryInfor.patch @@ -0,0 +1,116 @@ +From 04a7eb12b90c7361e5c71b7bea7e6ad53442c45d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Thu, 2 Feb 2017 22:05:37 +0100 +Subject: ntdll: Implement ProcessPriorityClass in NtQueryInformationProcess. + +--- + dlls/ntdll/process.c | 29 ++++++++++++++++++++++++++++- + dlls/ntdll/tests/info.c | 38 ++++++++++++++++++++++++++++++++++++++ + 2 files changed, 66 insertions(+), 1 deletion(-) + +diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c +index 0cdd1e09b50..a14b6707167 100644 +--- a/dlls/ntdll/process.c ++++ b/dlls/ntdll/process.c +@@ -173,7 +173,6 @@ NTSTATUS WINAPI NtQueryInformationProcess( + UNIMPLEMENTED_INFO_CLASS(ProcessWorkingSetWatch); + UNIMPLEMENTED_INFO_CLASS(ProcessUserModeIOPL); + UNIMPLEMENTED_INFO_CLASS(ProcessEnableAlignmentFaultFixup); +- UNIMPLEMENTED_INFO_CLASS(ProcessPriorityClass); + UNIMPLEMENTED_INFO_CLASS(ProcessWx86Information); + UNIMPLEMENTED_INFO_CLASS(ProcessPriorityBoost); + UNIMPLEMENTED_INFO_CLASS(ProcessDeviceMap); +@@ -526,6 +525,34 @@ NTSTATUS WINAPI NtQueryInformationProcess( + else + ret = STATUS_INFO_LENGTH_MISMATCH; + break; ++ case ProcessPriorityClass: ++ len = sizeof(PROCESS_PRIORITY_CLASS); ++ if (ProcessInformationLength == len) ++ { ++ if (!ProcessInformation) ++ ret = STATUS_ACCESS_VIOLATION; ++ else if (!ProcessHandle) ++ ret = STATUS_INVALID_HANDLE; ++ else ++ { ++ PROCESS_PRIORITY_CLASS *priority = ProcessInformation; ++ ++ SERVER_START_REQ(get_process_info) ++ { ++ req->handle = wine_server_obj_handle( ProcessHandle ); ++ if ((ret = wine_server_call( req )) == STATUS_SUCCESS) ++ { ++ priority->PriorityClass = reply->priority; ++ /* FIXME: Not yet supported by the wineserver */ ++ priority->Foreground = FALSE; ++ } ++ } ++ SERVER_END_REQ; ++ } ++ } ++ else ++ ret = STATUS_INFO_LENGTH_MISMATCH; ++ break; + default: + FIXME("(%p,info_class=%d,%p,0x%08x,%p) Unknown information class\n", + ProcessHandle,ProcessInformationClass, +diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c +index 448bc64c28a..6652409eaca 100644 +--- a/dlls/ntdll/tests/info.c ++++ b/dlls/ntdll/tests/info.c +@@ -1253,6 +1253,40 @@ static void test_query_process_debug_port(int argc, char **argv) + ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError()); + } + ++static void test_query_process_priority(void) ++{ ++ PROCESS_PRIORITY_CLASS priority[2]; ++ ULONG ReturnLength; ++ DWORD orig_priority; ++ NTSTATUS status; ++ BOOL ret; ++ ++ status = pNtQueryInformationProcess(NULL, ProcessPriorityClass, NULL, sizeof(priority[0]), NULL); ++ ok(status == STATUS_ACCESS_VIOLATION || broken(status == STATUS_INVALID_HANDLE) /* w2k3 */, ++ "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status); ++ ++ status = pNtQueryInformationProcess(NULL, ProcessPriorityClass, &priority, sizeof(priority[0]), NULL); ++ ok(status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status); ++ ++ status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessPriorityClass, &priority, 1, &ReturnLength); ++ ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); ++ ++ status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessPriorityClass, &priority, sizeof(priority), &ReturnLength); ++ ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); ++ ++ orig_priority = GetPriorityClass(GetCurrentProcess()); ++ ret = SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); ++ ok(ret, "Failed to set priority class: %u\n", GetLastError()); ++ ++ status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessPriorityClass, &priority, sizeof(priority[0]), &ReturnLength); ++ ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); ++ ok(priority[0].PriorityClass == PROCESS_PRIOCLASS_BELOW_NORMAL, ++ "Expected PROCESS_PRIOCLASS_BELOW_NORMAL, got %u\n", priority[0].PriorityClass); ++ ++ ret = SetPriorityClass(GetCurrentProcess(), orig_priority); ++ ok(ret, "Failed to reset priority class: %u\n", GetLastError()); ++} ++ + static void test_query_process_handlecount(void) + { + NTSTATUS status; +@@ -2107,6 +2141,10 @@ START_TEST(info) + trace("Starting test_process_debug_port()\n"); + test_query_process_debug_port(argc, argv); + ++ /* 0x12 ProcessPriorityClass */ ++ trace("Starting test_query_process_priority()\n"); ++ test_query_process_priority(); ++ + /* 0x14 ProcessHandleCount */ + trace("Starting test_query_process_handlecount()\n"); + test_query_process_handlecount(); +-- +2.11.0 + diff --git a/patches/ntdll-ProcessPriorityClass/definition b/patches/ntdll-ProcessPriorityClass/definition new file mode 100644 index 00000000..64066bee --- /dev/null +++ b/patches/ntdll-ProcessPriorityClass/definition @@ -0,0 +1 @@ +Fixes: Implement ProcessPriorityClass in NtQueryInformationProcess diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 30dc3d97..8e63c36d 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -243,6 +243,7 @@ patch_enable_all () enable_ntdll_NtSetInformationToken="$1" enable_ntdll_NtSetLdtEntries="$1" enable_ntdll_Pipe_SpecialCharacters="$1" + enable_ntdll_ProcessPriorityClass="$1" enable_ntdll_ProcessQuotaLimits="$1" enable_ntdll_Purist_Mode="$1" enable_ntdll_RtlCaptureStackBackTrace="$1" @@ -939,6 +940,9 @@ patch_enable () ntdll-Pipe_SpecialCharacters) enable_ntdll_Pipe_SpecialCharacters="$2" ;; + ntdll-ProcessPriorityClass) + enable_ntdll_ProcessPriorityClass="$2" + ;; ntdll-ProcessQuotaLimits) enable_ntdll_ProcessQuotaLimits="$2" ;; @@ -5530,6 +5534,18 @@ if test "$enable_ntdll_Pipe_SpecialCharacters" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-ProcessPriorityClass +# | +# | Modified files: +# | * dlls/ntdll/process.c, dlls/ntdll/tests/info.c +# | +if test "$enable_ntdll_ProcessPriorityClass" -eq 1; then + patch_apply ntdll-ProcessPriorityClass/0001-ntdll-Implement-ProcessPriorityClass-in-NtQueryInfor.patch + ( + printf '%s\n' '+ { "Michael Müller", "ntdll: Implement ProcessPriorityClass in NtQueryInformationProcess.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-ProcessQuotaLimits # | # | Modified files: