kernelbase: Implement and add tests for QueryProcessCycleTime.

This commit is contained in:
Brendan Shanks 2023-01-13 14:49:29 -08:00 committed by Alexandre Julliard
parent c0ffd587b5
commit edc479eea9
3 changed files with 24 additions and 4 deletions

View file

@ -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;
}

View file

@ -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();
}

View file

@ -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);