mirror of
https://github.com/reactos/reactos.git
synced 2025-05-11 13:27:47 +00:00
revert hackfix (revision 39704)
svn path=/trunk/; revision=39705
This commit is contained in:
parent
0ef3ed3fb1
commit
c5dfe0ed6f
1 changed files with 141 additions and 179 deletions
|
@ -701,7 +701,7 @@ QSI_DEF(SystemPathInformation)
|
||||||
/* Class 5 - Process Information */
|
/* Class 5 - Process Information */
|
||||||
QSI_DEF(SystemProcessInformation)
|
QSI_DEF(SystemProcessInformation)
|
||||||
{
|
{
|
||||||
PSYSTEM_PROCESS_INFORMATION SpiCurrent = NULL;
|
PSYSTEM_PROCESS_INFORMATION SpiCurrent;
|
||||||
PSYSTEM_THREAD_INFORMATION ThreadInfo;
|
PSYSTEM_THREAD_INFORMATION ThreadInfo;
|
||||||
PEPROCESS Process = NULL, SystemProcess;
|
PEPROCESS Process = NULL, SystemProcess;
|
||||||
PETHREAD CurrentThread;
|
PETHREAD CurrentThread;
|
||||||
|
@ -712,18 +712,11 @@ QSI_DEF(SystemProcessInformation)
|
||||||
PLIST_ENTRY CurrentEntry;
|
PLIST_ENTRY CurrentEntry;
|
||||||
ULONG TotalSize = 0, ThreadsCount;
|
ULONG TotalSize = 0, ThreadsCount;
|
||||||
ULONG TotalUser, TotalKernel;
|
ULONG TotalUser, TotalKernel;
|
||||||
PUCHAR Current = NULL;
|
PUCHAR Current;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PUNICODE_STRING ProcessImageName;
|
PUNICODE_STRING ProcessImageName;
|
||||||
PWCHAR szSrc;
|
PWCHAR szSrc;
|
||||||
|
|
||||||
//1 Write in to bufer
|
|
||||||
//2 Calc size buffer
|
|
||||||
//4 Vista compatible
|
|
||||||
//Flags always start write and calculate size
|
|
||||||
//For Vista compatible add "| 4"
|
|
||||||
USHORT OSMode = 1 | 2;
|
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
/* scan the process list */
|
/* scan the process list */
|
||||||
|
@ -731,34 +724,22 @@ QSI_DEF(SystemProcessInformation)
|
||||||
PSYSTEM_PROCESS_INFORMATION Spi
|
PSYSTEM_PROCESS_INFORMATION Spi
|
||||||
= (PSYSTEM_PROCESS_INFORMATION) Buffer;
|
= (PSYSTEM_PROCESS_INFORMATION) Buffer;
|
||||||
|
|
||||||
while ((OSMode & 1) || (OSMode & 2))
|
*ReqSize = sizeof(SYSTEM_PROCESS_INFORMATION);
|
||||||
{
|
|
||||||
//Vista first cycle only calc size and readonly
|
|
||||||
if (OSMode & 4 && OSMode & 1)
|
|
||||||
OSMode ^= 1;
|
|
||||||
//not exists byffer or size protect write, only calc size
|
|
||||||
if (OSMode & 1 && ((Size == 0) || (!Buffer)))
|
|
||||||
OSMode ^= 1;
|
|
||||||
|
|
||||||
if (OSMode & 1)
|
if (Size < sizeof(SYSTEM_PROCESS_INFORMATION))
|
||||||
{
|
{
|
||||||
//Only in second cycle and vista compatible
|
|
||||||
if (TotalSize > 0 && TotalSize > Size)
|
|
||||||
{
|
|
||||||
*ReqSize = TotalSize;
|
|
||||||
_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
|
||||||
}
|
}
|
||||||
if (Size > 0)
|
|
||||||
RtlZeroMemory(Spi, Size);
|
RtlZeroMemory(Spi, Size);
|
||||||
Current = (PUCHAR) Spi;
|
|
||||||
SpiCurrent = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemProcess = PsIdleProcess;
|
SystemProcess = PsIdleProcess;
|
||||||
Process = SystemProcess;
|
Process = SystemProcess;
|
||||||
|
Current = (PUCHAR) Spi;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
SpiCurrent = (PSYSTEM_PROCESS_INFORMATION) Current;
|
||||||
|
|
||||||
ThreadsCount = 0;
|
ThreadsCount = 0;
|
||||||
CurrentEntry = Process->ThreadListHead.Flink;
|
CurrentEntry = Process->ThreadListHead.Flink;
|
||||||
while (CurrentEntry != &Process->ThreadListHead)
|
while (CurrentEntry != &Process->ThreadListHead)
|
||||||
|
@ -772,7 +753,7 @@ QSI_DEF(SystemProcessInformation)
|
||||||
ImageNameLength = 0;
|
ImageNameLength = 0;
|
||||||
Status = SeLocateProcessImageName(Process, &ProcessImageName);
|
Status = SeLocateProcessImageName(Process, &ProcessImageName);
|
||||||
szSrc = NULL;
|
szSrc = NULL;
|
||||||
if (NT_SUCCESS(Status) && ProcessImageName->Length > 0)
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
szSrc = (PWCHAR)((PCHAR)ProcessImageName->Buffer + ProcessImageName->Length);
|
szSrc = (PWCHAR)((PCHAR)ProcessImageName->Buffer + ProcessImageName->Length);
|
||||||
/* Loop the file name*/
|
/* Loop the file name*/
|
||||||
|
@ -796,20 +777,23 @@ QSI_DEF(SystemProcessInformation)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Round up the image name length as NT does */
|
/* Round up the image name length as NT does */
|
||||||
ImageNameMaximumLength =
|
ImageNameMaximumLength = ROUND_UP(ImageNameLength, 8);
|
||||||
(ImageNameLength > 0 ? ROUND_UP(ImageNameLength+1, 8) : 0);
|
|
||||||
|
|
||||||
if (OSMode & 2)
|
|
||||||
TotalSize += CurrentSize + ImageNameMaximumLength;
|
TotalSize += CurrentSize + ImageNameMaximumLength;
|
||||||
|
|
||||||
if ((OSMode & 1) && Buffer && TotalSize <= Size)
|
if (TotalSize > Size)
|
||||||
{
|
{
|
||||||
//Set prev structure NextEntryOffset next structure only exists write buffer
|
*ReqSize = TotalSize;
|
||||||
if (SpiCurrent && TotalSize <= Size)
|
ObDereferenceObject(Process);
|
||||||
SpiCurrent->NextEntryOffset = Current - (PUCHAR)SpiCurrent;// relative offset to the beginnnig of the next structure
|
|
||||||
SpiCurrent = (PSYSTEM_PROCESS_INFORMATION) Current;
|
/* Release the memory allocated by SeLocateProcessImageName */
|
||||||
|
if (NT_SUCCESS(Status)) ExFreePool(ProcessImageName);
|
||||||
|
|
||||||
|
_SEH2_YIELD(return STATUS_INFO_LENGTH_MISMATCH); // in case buffer size is too small
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill system information */
|
/* Fill system information */
|
||||||
|
SpiCurrent->NextEntryOffset = CurrentSize + ImageNameMaximumLength; // relative offset to the beginnnig of the next structure
|
||||||
SpiCurrent->NumberOfThreads = ThreadsCount;
|
SpiCurrent->NumberOfThreads = ThreadsCount;
|
||||||
SpiCurrent->CreateTime = Process->CreateTime;
|
SpiCurrent->CreateTime = Process->CreateTime;
|
||||||
SpiCurrent->ImageName.Length = ImageNameLength;
|
SpiCurrent->ImageName.Length = ImageNameLength;
|
||||||
|
@ -822,6 +806,9 @@ QSI_DEF(SystemProcessInformation)
|
||||||
if (szSrc)
|
if (szSrc)
|
||||||
{
|
{
|
||||||
RtlCopyMemory(SpiCurrent->ImageName.Buffer, szSrc, SpiCurrent->ImageName.Length);
|
RtlCopyMemory(SpiCurrent->ImageName.Buffer, szSrc, SpiCurrent->ImageName.Length);
|
||||||
|
|
||||||
|
/* Release the memory allocated by SeLocateProcessImageName */
|
||||||
|
ExFreePool(ProcessImageName);
|
||||||
}
|
}
|
||||||
else if (Process->ImageFileName)
|
else if (Process->ImageFileName)
|
||||||
{
|
{
|
||||||
|
@ -878,9 +865,6 @@ QSI_DEF(SystemProcessInformation)
|
||||||
TotalKernel = KeQueryRuntimeProcess(&Process->Pcb, &TotalUser);
|
TotalKernel = KeQueryRuntimeProcess(&Process->Pcb, &TotalUser);
|
||||||
SpiCurrent->UserTime.QuadPart = UInt32x32To64(TotalUser, KeMaximumIncrement);
|
SpiCurrent->UserTime.QuadPart = UInt32x32To64(TotalUser, KeMaximumIncrement);
|
||||||
SpiCurrent->KernelTime.QuadPart = UInt32x32To64(TotalKernel, KeMaximumIncrement);
|
SpiCurrent->KernelTime.QuadPart = UInt32x32To64(TotalKernel, KeMaximumIncrement);
|
||||||
}
|
|
||||||
/* Release the memory allocated by SeLocateProcessImageName */
|
|
||||||
if (NT_SUCCESS(Status)) ExFreePool(ProcessImageName);
|
|
||||||
|
|
||||||
/* Handle idle process entry */
|
/* Handle idle process entry */
|
||||||
if (Process == PsIdleProcess) Process = NULL;
|
if (Process == PsIdleProcess) Process = NULL;
|
||||||
|
@ -889,36 +873,15 @@ QSI_DEF(SystemProcessInformation)
|
||||||
ThreadsCount = 0;
|
ThreadsCount = 0;
|
||||||
if ((Process == SystemProcess) || (Process == NULL))
|
if ((Process == SystemProcess) || (Process == NULL))
|
||||||
{
|
{
|
||||||
|
SpiCurrent->NextEntryOffset = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (Current)
|
|
||||||
Current += CurrentSize + ImageNameMaximumLength;
|
Current += CurrentSize + ImageNameMaximumLength;
|
||||||
}
|
|
||||||
} while ((Process != SystemProcess) && (Process != NULL));
|
} while ((Process != SystemProcess) && (Process != NULL));
|
||||||
//Break parameters information for only calc size
|
|
||||||
if ((Size == 0) || (!Buffer))
|
|
||||||
break;
|
|
||||||
//Stop write in to buffer
|
|
||||||
if (OSMode & 1)
|
|
||||||
OSMode ^= 1;
|
|
||||||
//Only first cycle calc size
|
|
||||||
if (OSMode & 2)
|
|
||||||
OSMode ^= 2;
|
|
||||||
//Vista next cycle write in to Buffer
|
|
||||||
if (OSMode & 4)
|
|
||||||
{
|
|
||||||
OSMode |= 1;
|
|
||||||
OSMode ^= 4;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if(Process != NULL)
|
if(Process != NULL)
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
if ((Size == 0) || (!Buffer) || (TotalSize > Size))
|
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
|
||||||
else
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
@ -1925,9 +1888,8 @@ NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
||||||
if (PreviousMode != KernelMode)
|
if (PreviousMode != KernelMode)
|
||||||
{
|
{
|
||||||
/* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
|
/* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
|
||||||
if (SystemInformation)
|
|
||||||
ProbeForWrite(SystemInformation, Length, 1);
|
ProbeForWrite(SystemInformation, Length, 1);
|
||||||
if (UnsafeResultLength)
|
if (UnsafeResultLength != NULL)
|
||||||
ProbeForWriteUlong(UnsafeResultLength);
|
ProbeForWriteUlong(UnsafeResultLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue