mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTOSKRNL] Implement KeQueryValuesProcess().
And make use of it.
This commit is contained in:
parent
b0b7437882
commit
f15afdbc43
4 changed files with 80 additions and 17 deletions
|
@ -36,6 +36,13 @@ typedef struct _DISPATCH_INFO
|
||||||
PKINTERRUPT_ROUTINE *FlatDispatch;
|
PKINTERRUPT_ROUTINE *FlatDispatch;
|
||||||
} DISPATCH_INFO, *PDISPATCH_INFO;
|
} DISPATCH_INFO, *PDISPATCH_INFO;
|
||||||
|
|
||||||
|
typedef struct _PROCESS_VALUES
|
||||||
|
{
|
||||||
|
LARGE_INTEGER TotalKernelTime;
|
||||||
|
LARGE_INTEGER TotalUserTime;
|
||||||
|
IO_COUNTERS IoInfo;
|
||||||
|
} PROCESS_VALUES, *PPROCESS_VALUES;
|
||||||
|
|
||||||
typedef struct _DEFERRED_REVERSE_BARRIER
|
typedef struct _DEFERRED_REVERSE_BARRIER
|
||||||
{
|
{
|
||||||
ULONG Barrier;
|
ULONG Barrier;
|
||||||
|
@ -710,6 +717,11 @@ NTAPI
|
||||||
KeQueryRuntimeProcess(IN PKPROCESS Process,
|
KeQueryRuntimeProcess(IN PKPROCESS Process,
|
||||||
OUT PULONG UserTime);
|
OUT PULONG UserTime);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
KeQueryValuesProcess(IN PKPROCESS Process,
|
||||||
|
PPROCESS_VALUES Values);
|
||||||
|
|
||||||
/* INITIALIZATION FUNCTIONS *************************************************/
|
/* INITIALIZATION FUNCTIONS *************************************************/
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
|
|
@ -517,6 +517,58 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
|
||||||
return OldPriority;
|
return OldPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
KeQueryValuesProcess(IN PKPROCESS Process,
|
||||||
|
PPROCESS_VALUES Values)
|
||||||
|
{
|
||||||
|
PEPROCESS EProcess;
|
||||||
|
PLIST_ENTRY NextEntry;
|
||||||
|
ULONG TotalKernel, TotalUser;
|
||||||
|
KLOCK_QUEUE_HANDLE ProcessLock;
|
||||||
|
|
||||||
|
ASSERT_PROCESS(Process);
|
||||||
|
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
|
||||||
|
|
||||||
|
/* Lock the process */
|
||||||
|
KiAcquireProcessLock(Process, &ProcessLock);
|
||||||
|
|
||||||
|
/* Initialize user and kernel times */
|
||||||
|
TotalKernel = Process->KernelTime;
|
||||||
|
TotalUser = Process->UserTime;
|
||||||
|
|
||||||
|
/* Copy the IO_COUNTERS from the process */
|
||||||
|
EProcess = (PEPROCESS)Process;
|
||||||
|
Values->IoInfo.ReadOperationCount = EProcess->ReadOperationCount.QuadPart;
|
||||||
|
Values->IoInfo.WriteOperationCount = EProcess->WriteOperationCount.QuadPart;
|
||||||
|
Values->IoInfo.OtherOperationCount = EProcess->OtherOperationCount.QuadPart;
|
||||||
|
Values->IoInfo.ReadTransferCount = EProcess->ReadTransferCount.QuadPart;
|
||||||
|
Values->IoInfo.WriteTransferCount = EProcess->WriteTransferCount.QuadPart;
|
||||||
|
Values->IoInfo.OtherTransferCount = EProcess->OtherTransferCount.QuadPart;
|
||||||
|
|
||||||
|
/* Loop all child threads and sum up their times */
|
||||||
|
for (NextEntry = Process->ThreadListHead.Flink;
|
||||||
|
NextEntry != &Process->ThreadListHead;
|
||||||
|
NextEntry = NextEntry->Flink)
|
||||||
|
{
|
||||||
|
PKTHREAD Thread;
|
||||||
|
|
||||||
|
/* Get the thread */
|
||||||
|
Thread = CONTAINING_RECORD(NextEntry, KTHREAD, ThreadListEntry);
|
||||||
|
|
||||||
|
/* Sum up times */
|
||||||
|
TotalKernel += Thread->KernelTime;
|
||||||
|
TotalUser += Thread->UserTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the process lock */
|
||||||
|
KiReleaseProcessLock(&ProcessLock);
|
||||||
|
|
||||||
|
/* Compute total times */
|
||||||
|
Values->TotalKernelTime.QuadPart = TotalKernel * (LONGLONG)KeMaximumIncrement;
|
||||||
|
Values->TotalUserTime.QuadPart = TotalUser * (LONGLONG)KeMaximumIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS **********************************************************/
|
/* PUBLIC FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -631,16 +631,17 @@ NtQueryInformationJobObject (
|
||||||
Process = CONTAINING_RECORD(NextEntry, EPROCESS, JobLinks);
|
Process = CONTAINING_RECORD(NextEntry, EPROCESS, JobLinks);
|
||||||
if (!BooleanFlagOn(Process->JobStatus, 2))
|
if (!BooleanFlagOn(Process->JobStatus, 2))
|
||||||
{
|
{
|
||||||
/* FIXME: Call KeQueryValuesProcess()
|
PROCESS_VALUES Values;
|
||||||
* We should sum BasicInfo values here,
|
|
||||||
* but we don't have them
|
KeQueryValuesProcess(&Process->Pcb, &Values);
|
||||||
*/
|
BasicAndIo.BasicInfo.TotalUserTime.QuadPart += Values.TotalUserTime.QuadPart;
|
||||||
BasicAndIo.IoInfo.ReadOperationCount += Process->ReadOperationCount.QuadPart;
|
BasicAndIo.BasicInfo.TotalKernelTime.QuadPart += Values.TotalKernelTime.QuadPart;
|
||||||
BasicAndIo.IoInfo.WriteOperationCount += Process->WriteOperationCount.QuadPart;
|
BasicAndIo.IoInfo.ReadOperationCount += Values.IoInfo.ReadOperationCount;
|
||||||
BasicAndIo.IoInfo.OtherOperationCount += Process->OtherOperationCount.QuadPart;
|
BasicAndIo.IoInfo.WriteOperationCount += Values.IoInfo.WriteOperationCount;
|
||||||
BasicAndIo.IoInfo.ReadTransferCount += Process->ReadTransferCount.QuadPart;
|
BasicAndIo.IoInfo.OtherOperationCount += Values.IoInfo.OtherOperationCount;
|
||||||
BasicAndIo.IoInfo.WriteTransferCount += Process->WriteTransferCount.QuadPart;
|
BasicAndIo.IoInfo.ReadTransferCount += Values.IoInfo.ReadTransferCount;
|
||||||
BasicAndIo.IoInfo.OtherTransferCount += Process->OtherTransferCount.QuadPart;
|
BasicAndIo.IoInfo.WriteTransferCount += Values.IoInfo.WriteTransferCount;
|
||||||
|
BasicAndIo.IoInfo.OtherTransferCount += Values.IoInfo.OtherTransferCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
PUNICODE_STRING ImageName;
|
PUNICODE_STRING ImageName;
|
||||||
ULONG Cookie, ExecuteOptions = 0;
|
ULONG Cookie, ExecuteOptions = 0;
|
||||||
ULONG_PTR Wow64 = 0;
|
ULONG_PTR Wow64 = 0;
|
||||||
|
PROCESS_VALUES ProcessValues;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Check for user-mode caller */
|
/* Check for user-mode caller */
|
||||||
|
@ -251,15 +252,12 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status)) break;
|
if (!NT_SUCCESS(Status)) break;
|
||||||
|
|
||||||
|
/* Query IO counters from the process */
|
||||||
|
KeQueryValuesProcess(&Process->Pcb, &ProcessValues);
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
/* FIXME: Call KeQueryValuesProcess */
|
RtlCopyMemory(IoCounters, &ProcessValues.IoInfo, sizeof(IO_COUNTERS));
|
||||||
IoCounters->ReadOperationCount = Process->ReadOperationCount.QuadPart;
|
|
||||||
IoCounters->ReadTransferCount = Process->ReadTransferCount.QuadPart;
|
|
||||||
IoCounters->WriteOperationCount = Process->WriteOperationCount.QuadPart;
|
|
||||||
IoCounters->WriteTransferCount = Process->WriteTransferCount.QuadPart;
|
|
||||||
IoCounters->OtherOperationCount = Process->OtherOperationCount.QuadPart;
|
|
||||||
IoCounters->OtherTransferCount = Process->OtherTransferCount.QuadPart;
|
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue