mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 23:46:50 +00:00
- Change of names of variables
- Move all variables declaration to top svn path=/trunk/; revision=38567
This commit is contained in:
parent
6c670fb344
commit
78c8f3ca5f
|
@ -701,10 +701,16 @@ QSI_DEF(SystemPathInformation)
|
||||||
/* Class 5 - Process Information */
|
/* Class 5 - Process Information */
|
||||||
QSI_DEF(SystemProcessInformation)
|
QSI_DEF(SystemProcessInformation)
|
||||||
{
|
{
|
||||||
ULONG ovlSize = 0, nThreads;
|
PSYSTEM_PROCESS_INFORMATION SpiCurrent;
|
||||||
PEPROCESS pr = NULL, syspr;
|
PSYSTEM_THREAD_INFORMATION ThreadInfo;
|
||||||
PUCHAR pCur;
|
PEPROCESS Process = NULL, SystemProcess;
|
||||||
|
PETHREAD CurrentThread;
|
||||||
|
ANSI_STRING ImageName;
|
||||||
|
int CurrentSize, ImageNameLength = 32; // image name len in bytes
|
||||||
|
PLIST_ENTRY CurrentEntry;
|
||||||
|
ULONG TotalSize = 0, ThreadsCount;
|
||||||
ULONG TotalUser, TotalKernel;
|
ULONG TotalUser, TotalKernel;
|
||||||
|
PUCHAR Current;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
|
@ -722,133 +728,125 @@ QSI_DEF(SystemProcessInformation)
|
||||||
}
|
}
|
||||||
RtlZeroMemory(Spi, Size);
|
RtlZeroMemory(Spi, Size);
|
||||||
|
|
||||||
syspr = PsIdleProcess;
|
SystemProcess = PsIdleProcess;
|
||||||
pr = syspr;
|
Process = SystemProcess;
|
||||||
pCur = (unsigned char *)Spi;
|
Current = (PUCHAR) Spi;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
PSYSTEM_PROCESS_INFORMATION SpiCur;
|
SpiCurrent = (PSYSTEM_PROCESS_INFORMATION) Current;
|
||||||
int curSize;
|
|
||||||
ANSI_STRING imgName;
|
|
||||||
int inLen = 32; // image name len in bytes
|
|
||||||
PLIST_ENTRY current_entry;
|
|
||||||
PETHREAD current;
|
|
||||||
PSYSTEM_THREAD_INFORMATION ThreadInfo;
|
|
||||||
|
|
||||||
SpiCur = (PSYSTEM_PROCESS_INFORMATION)pCur;
|
ThreadsCount = 0;
|
||||||
|
CurrentEntry = Process->ThreadListHead.Flink;
|
||||||
nThreads = 0;
|
while (CurrentEntry != &Process->ThreadListHead)
|
||||||
current_entry = pr->ThreadListHead.Flink;
|
|
||||||
while (current_entry != &pr->ThreadListHead)
|
|
||||||
{
|
{
|
||||||
nThreads++;
|
ThreadsCount++;
|
||||||
current_entry = current_entry->Flink;
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
// size of the structure for every process
|
// size of the structure for every process
|
||||||
curSize = sizeof(SYSTEM_PROCESS_INFORMATION)+sizeof(SYSTEM_THREAD_INFORMATION)*nThreads;
|
CurrentSize = sizeof(SYSTEM_PROCESS_INFORMATION) + sizeof(SYSTEM_THREAD_INFORMATION) * ThreadsCount;
|
||||||
ovlSize += curSize+inLen;
|
TotalSize += CurrentSize + ImageNameLength;
|
||||||
|
|
||||||
if (ovlSize > Size)
|
if (TotalSize > Size)
|
||||||
{
|
{
|
||||||
*ReqSize = ovlSize;
|
*ReqSize = TotalSize;
|
||||||
ObDereferenceObject(pr);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
_SEH2_YIELD(return STATUS_INFO_LENGTH_MISMATCH); // in case buffer size is too small
|
_SEH2_YIELD(return STATUS_INFO_LENGTH_MISMATCH); // in case buffer size is too small
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill system information
|
// fill system information
|
||||||
SpiCur->NextEntryOffset = curSize+inLen; // relative offset to the beginnnig of the next structure
|
SpiCurrent->NextEntryOffset = CurrentSize + ImageNameLength; // relative offset to the beginnnig of the next structure
|
||||||
SpiCur->NumberOfThreads = nThreads;
|
SpiCurrent->NumberOfThreads = ThreadsCount;
|
||||||
SpiCur->CreateTime = pr->CreateTime;
|
SpiCurrent->CreateTime = Process->CreateTime;
|
||||||
SpiCur->ImageName.Length = strlen(pr->ImageFileName) * sizeof(WCHAR);
|
SpiCurrent->ImageName.Length = strlen(Process->ImageFileName) * sizeof(WCHAR);
|
||||||
SpiCur->ImageName.MaximumLength = (USHORT)inLen;
|
SpiCurrent->ImageName.MaximumLength = (USHORT)ImageNameLength;
|
||||||
SpiCur->ImageName.Buffer = (void*)(pCur+curSize);
|
SpiCurrent->ImageName.Buffer = (void*)(Current + CurrentSize);
|
||||||
|
|
||||||
// copy name to the end of the struct
|
// copy name to the end of the struct
|
||||||
if(pr != PsIdleProcess)
|
if(Process != PsIdleProcess)
|
||||||
{
|
{
|
||||||
RtlInitAnsiString(&imgName, pr->ImageFileName);
|
RtlInitAnsiString(&ImageName, Process->ImageFileName);
|
||||||
RtlAnsiStringToUnicodeString(&SpiCur->ImageName, &imgName, FALSE);
|
RtlAnsiStringToUnicodeString(&SpiCurrent->ImageName, &ImageName, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&SpiCur->ImageName, NULL);
|
RtlInitUnicodeString(&SpiCurrent->ImageName, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpiCur->BasePriority = pr->Pcb.BasePriority;
|
SpiCurrent->BasePriority = Process->Pcb.BasePriority;
|
||||||
SpiCur->UniqueProcessId = pr->UniqueProcessId;
|
SpiCurrent->UniqueProcessId = Process->UniqueProcessId;
|
||||||
SpiCur->InheritedFromUniqueProcessId = pr->InheritedFromUniqueProcessId;
|
SpiCurrent->InheritedFromUniqueProcessId = Process->InheritedFromUniqueProcessId;
|
||||||
SpiCur->HandleCount = (pr->ObjectTable ? ObpGetHandleCountByHandleTable(pr->ObjectTable) : 0);
|
SpiCurrent->HandleCount = (Process->ObjectTable ? ObpGetHandleCountByHandleTable(Process->ObjectTable) : 0);
|
||||||
SpiCur->PeakVirtualSize = pr->PeakVirtualSize;
|
SpiCurrent->PeakVirtualSize = Process->PeakVirtualSize;
|
||||||
SpiCur->VirtualSize = pr->VirtualSize;
|
SpiCurrent->VirtualSize = Process->VirtualSize;
|
||||||
SpiCur->PageFaultCount = pr->Vm.PageFaultCount;
|
SpiCurrent->PageFaultCount = Process->Vm.PageFaultCount;
|
||||||
SpiCur->PeakWorkingSetSize = pr->Vm.PeakWorkingSetSize;
|
SpiCurrent->PeakWorkingSetSize = Process->Vm.PeakWorkingSetSize;
|
||||||
SpiCur->WorkingSetSize = pr->Vm.WorkingSetSize;
|
SpiCurrent->WorkingSetSize = Process->Vm.WorkingSetSize;
|
||||||
SpiCur->QuotaPeakPagedPoolUsage = pr->QuotaPeak[0];
|
SpiCurrent->QuotaPeakPagedPoolUsage = Process->QuotaPeak[0];
|
||||||
SpiCur->QuotaPagedPoolUsage = pr->QuotaUsage[0];
|
SpiCurrent->QuotaPagedPoolUsage = Process->QuotaUsage[0];
|
||||||
SpiCur->QuotaPeakNonPagedPoolUsage = pr->QuotaPeak[1];
|
SpiCurrent->QuotaPeakNonPagedPoolUsage = Process->QuotaPeak[1];
|
||||||
SpiCur->QuotaNonPagedPoolUsage = pr->QuotaUsage[1];
|
SpiCurrent->QuotaNonPagedPoolUsage = Process->QuotaUsage[1];
|
||||||
SpiCur->PagefileUsage = pr->QuotaUsage[2];
|
SpiCurrent->PagefileUsage = Process->QuotaUsage[2];
|
||||||
SpiCur->PeakPagefileUsage = pr->QuotaPeak[2];
|
SpiCurrent->PeakPagefileUsage = Process->QuotaPeak[2];
|
||||||
SpiCur->PrivatePageCount = pr->CommitCharge;
|
SpiCurrent->PrivatePageCount = Process->CommitCharge;
|
||||||
ThreadInfo = (PSYSTEM_THREAD_INFORMATION)(SpiCur + 1);
|
ThreadInfo = (PSYSTEM_THREAD_INFORMATION)(SpiCurrent + 1);
|
||||||
|
|
||||||
current_entry = pr->ThreadListHead.Flink;
|
CurrentEntry = Process->ThreadListHead.Flink;
|
||||||
while (current_entry != &pr->ThreadListHead)
|
while (CurrentEntry != &Process->ThreadListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
CurrentThread = CONTAINING_RECORD(CurrentEntry, ETHREAD,
|
||||||
ThreadListEntry);
|
ThreadListEntry);
|
||||||
|
|
||||||
ThreadInfo->KernelTime.QuadPart = UInt32x32To64(current->Tcb.KernelTime, KeMaximumIncrement);
|
ThreadInfo->KernelTime.QuadPart = UInt32x32To64(CurrentThread->Tcb.KernelTime, KeMaximumIncrement);
|
||||||
ThreadInfo->UserTime.QuadPart = UInt32x32To64(current->Tcb.UserTime, KeMaximumIncrement);
|
ThreadInfo->UserTime.QuadPart = UInt32x32To64(CurrentThread->Tcb.UserTime, KeMaximumIncrement);
|
||||||
ThreadInfo->CreateTime.QuadPart = current->CreateTime.QuadPart;
|
ThreadInfo->CreateTime.QuadPart = CurrentThread->CreateTime.QuadPart;
|
||||||
ThreadInfo->WaitTime = current->Tcb.WaitTime;
|
ThreadInfo->WaitTime = CurrentThread->Tcb.WaitTime;
|
||||||
ThreadInfo->StartAddress = (PVOID) current->StartAddress;
|
ThreadInfo->StartAddress = (PVOID) CurrentThread->StartAddress;
|
||||||
ThreadInfo->ClientId = current->Cid;
|
ThreadInfo->ClientId = CurrentThread->Cid;
|
||||||
ThreadInfo->Priority = current->Tcb.Priority;
|
ThreadInfo->Priority = CurrentThread->Tcb.Priority;
|
||||||
ThreadInfo->BasePriority = current->Tcb.BasePriority;
|
ThreadInfo->BasePriority = CurrentThread->Tcb.BasePriority;
|
||||||
ThreadInfo->ContextSwitches = current->Tcb.ContextSwitches;
|
ThreadInfo->ContextSwitches = CurrentThread->Tcb.ContextSwitches;
|
||||||
ThreadInfo->ThreadState = current->Tcb.State;
|
ThreadInfo->ThreadState = CurrentThread->Tcb.State;
|
||||||
ThreadInfo->WaitReason = current->Tcb.WaitReason;
|
ThreadInfo->WaitReason = CurrentThread->Tcb.WaitReason;
|
||||||
|
|
||||||
ThreadInfo++;
|
ThreadInfo++;
|
||||||
current_entry = current_entry->Flink;
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Query total user/kernel times of a process */
|
/* Query total user/kernel times of a process */
|
||||||
TotalKernel = KeQueryRuntimeProcess(&pr->Pcb, &TotalUser);
|
TotalKernel = KeQueryRuntimeProcess(&Process->Pcb, &TotalUser);
|
||||||
SpiCur->UserTime.QuadPart = UInt32x32To64(TotalUser, KeMaximumIncrement);
|
SpiCurrent->UserTime.QuadPart = UInt32x32To64(TotalUser, KeMaximumIncrement);
|
||||||
SpiCur->KernelTime.QuadPart = UInt32x32To64(TotalKernel, KeMaximumIncrement);
|
SpiCurrent->KernelTime.QuadPart = UInt32x32To64(TotalKernel, KeMaximumIncrement);
|
||||||
|
|
||||||
/* Handle idle process entry */
|
/* Handle idle process entry */
|
||||||
if (pr == PsIdleProcess) pr = NULL;
|
if (Process == PsIdleProcess) Process = NULL;
|
||||||
|
|
||||||
pr = PsGetNextProcess(pr);
|
Process = PsGetNextProcess(Process);
|
||||||
nThreads = 0;
|
ThreadsCount = 0;
|
||||||
if ((pr == syspr) || (pr == NULL))
|
if ((Process == SystemProcess) || (Process == NULL))
|
||||||
{
|
{
|
||||||
SpiCur->NextEntryOffset = 0;
|
SpiCurrent->NextEntryOffset = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pCur = pCur + curSize + inLen;
|
Current += CurrentSize + ImageNameLength;
|
||||||
} while ((pr != syspr) && (pr != NULL));
|
} while ((Process != SystemProcess) && (Process != NULL));
|
||||||
|
|
||||||
if(pr != NULL)
|
if(Process != NULL)
|
||||||
ObDereferenceObject(pr);
|
ObDereferenceObject(Process);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
if(pr != NULL)
|
if(Process != NULL)
|
||||||
ObDereferenceObject(pr);
|
ObDereferenceObject(Process);
|
||||||
Status = _SEH2_GetExceptionCode();
|
Status = _SEH2_GetExceptionCode();
|
||||||
}
|
}
|
||||||
_SEH2_END
|
_SEH2_END
|
||||||
|
|
||||||
*ReqSize = ovlSize;
|
*ReqSize = TotalSize;
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue