Chromium uses this, and debug builds assert if it fails.
-- v2: kernelbase: Implement and add tests for QueryProcessCycleTime. ntdll: Add stub for NtQueryInformationProcess(ProcessCycleTime).
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/kernel32/tests/process.c | 3 ++- dlls/ntdll/unix/process.c | 19 +++++++++++++++++++ dlls/wow64/process.c | 1 + include/winternl.h | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 5ac6ed57bbe..1e30ba73bbf 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -3710,7 +3710,7 @@ static void test_process_info(HANDLE hproc) 0 /* FIXME: sizeof(?) ProcessTlsInformation */, sizeof(ULONG) /* ProcessCookie */, sizeof(SECTION_IMAGE_INFORMATION) /* ProcessImageInformation */, - 0 /* FIXME: sizeof(PROCESS_CYCLE_TIME_INFORMATION) ProcessCycleTime */, + sizeof(PROCESS_CYCLE_TIME_INFORMATION) /* ProcessCycleTime */, sizeof(ULONG) /* ProcessPagePriority */, 40 /* ProcessInstrumentationCallback */, 0 /* FIXME: sizeof(PROCESS_STACK_ALLOCATION_INFORMATION) ProcessThreadStackAllocation */, @@ -3780,6 +3780,7 @@ static void test_process_info(HANDLE hproc) case ProcessHandleCount: case ProcessImageFileName: case ProcessImageInformation: + case ProcessCycleTime: case ProcessPagePriority: case ProcessImageFileNameWin32: ok(status == STATUS_SUCCESS, "for info %lu expected STATUS_SUCCESS, got %08lx (ret_len %lu)\n", i, status, ret_len); diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 4b9c42467e7..9f2c5ffb29c 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -1506,6 +1506,25 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class else ret = STATUS_INFO_LENGTH_MISMATCH; break;
+ case ProcessCycleTime: + len = sizeof(PROCESS_CYCLE_TIME_INFORMATION); + if (size == len) + { + if (!info) ret = STATUS_ACCESS_VIOLATION; + else + { + PROCESS_CYCLE_TIME_INFORMATION cycles; + + FIXME( "ProcessCycleTime (%p,%p,0x%08x,%p) stub\n", handle, info, (int)size, ret_len ); + cycles.AccumulatedCycles = 0; + cycles.CurrentCycleCount = 0; + + memcpy(info, &cycles, sizeof(PROCESS_CYCLE_TIME_INFORMATION)); + } + } + else ret = STATUS_INFO_LENGTH_MISMATCH; + break; + case ProcessWineLdtCopy: if (handle == NtCurrentProcess()) { diff --git a/dlls/wow64/process.c b/dlls/wow64/process.c index 97dbfdef761..c51da4004c1 100644 --- a/dlls/wow64/process.c +++ b/dlls/wow64/process.c @@ -774,6 +774,7 @@ NTSTATUS WINAPI wow64_NtQueryInformationProcess( UINT *args ) case ProcessDebugFlags: /* ULONG */ case ProcessExecuteFlags: /* ULONG */ case ProcessCookie: /* ULONG */ + case ProcessCycleTime: /* PROCESS_CYCLE_TIME_INFORMATION */ /* FIXME: check buffer alignment */ return NtQueryInformationProcess( handle, class, ptr, len, retlen );
diff --git a/include/winternl.h b/include/winternl.h index de5630ecf49..87d390308af 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2272,6 +2272,11 @@ typedef struct _PROCESS_PRIORITY_CLASS { UCHAR PriorityClass; } PROCESS_PRIORITY_CLASS, *PPROCESS_PRIORITY_CLASS;
+typedef struct _PROCESS_CYCLE_TIME_INFORMATION { + ULONGLONG AccumulatedCycles; + ULONGLONG CurrentCycleCount; +} PROCESS_CYCLE_TIME_INFORMATION, *PPROCESS_CYCLE_TIME_INFORMATION; + typedef struct _PROCESS_STACK_ALLOCATION_INFORMATION { SIZE_T ReserveSize;
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/kernelbase/process.c | 11 +++++++---- dlls/kernelbase/tests/process.c | 16 ++++++++++++++++ include/winbase.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index 39de15066d4..837bdfd5e87 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -1074,10 +1074,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH ProcessIdToSessionId( DWORD pid, DWORD *id ) */ BOOL WINAPI DECLSPEC_HOTPATCH QueryProcessCycleTime( HANDLE process, ULONG64 *cycle ) { - static int once; - if (!once++) FIXME( "(%p,%p): stub!\n", process, cycle ); - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; + PROCESS_CYCLE_TIME_INFORMATION time; + + if (!set_ntstatus( NtQueryInformationProcess( process, ProcessCycleTime, &time, sizeof(time), NULL ) )) + return FALSE; + + *cycle = time.AccumulatedCycles; + return TRUE; }
diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c index ed213f1f7b6..b8c3bbb7276 100644 --- a/dlls/kernelbase/tests/process.c +++ b/dlls/kernelbase/tests/process.c @@ -421,6 +421,21 @@ static void test_MapViewOfFileFromApp(void) ok(ret, "Failed to delete a test file.\n"); }
+static void test_QueryProcessCycleTime(void) +{ + ULONG64 cycles1, cycles2; + BOOL ret; + + ret = QueryProcessCycleTime( GetCurrentProcess(), &cycles1 ); + ok( ret, "QueryProcessCycleTime failed, error %lu.\n", GetLastError() ); + + ret = QueryProcessCycleTime( GetCurrentProcess(), &cycles2 ); + ok( ret, "QueryProcessCycleTime failed, error %lu.\n", GetLastError() ); + + todo_wine + ok( cycles2 > cycles1, "CPU cycles used by process should be increasing.\n" ); +} + static void init_funcs(void) { HMODULE hmod = GetModuleHandleA("kernelbase.dll"); @@ -453,4 +468,5 @@ START_TEST(process) test_OpenFileMappingFromApp(); test_CreateFileMappingFromApp(); test_MapViewOfFileFromApp(); + test_QueryProcessCycleTime(); } diff --git a/include/winbase.h b/include/winbase.h index 45492782cd5..8826251914d 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -2605,6 +2605,7 @@ WINBASEAPI BOOL WINAPI QueryInformationJobObject(HANDLE,JOBOBJECTINFOCLAS WINBASEAPI BOOL WINAPI QueryMemoryResourceNotification(HANDLE,PBOOL); WINBASEAPI BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER*); WINBASEAPI BOOL WINAPI QueryPerformanceFrequency(LARGE_INTEGER*); +WINBASEAPI BOOL WINAPI QueryProcessCycleTime(HANDLE,PULONG64); WINBASEAPI BOOL WINAPI QueryThreadCycleTime(HANDLE,PULONG64); WINBASEAPI BOOL WINAPI QueryUmsThreadInformation(PUMS_CONTEXT,UMS_THREAD_INFO_CLASS,PVOID,ULONG,PULONG); WINBASEAPI DWORD WINAPI QueueUserAPC(PAPCFUNC,HANDLE,ULONG_PTR);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=129013
Your paranoid android.
=== w10pro64_ar (64 bit report) ===
kernel32: process.c:2741: Test failed: Expected basic_accounting_info.ActiveProcesses to be 2 (2) is 3