Commit ab3c0a3e authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

ntdll: Implement ProcessPriorityClass in NtQueryInformationProcess.

Allows Process Hacker to show process priority. Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 09cd2787
......@@ -205,7 +205,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);
......@@ -545,6 +544,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,
......
......@@ -1334,6 +1334,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;
......@@ -2192,6 +2226,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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment