mirror of
https://github.com/reactos/reactos.git
synced 2025-07-09 05:28:04 +00:00
[NTOS:PS]
- Use ProbeForRead instead ProbeForWrite (ProbeForWrite is a behavior which was in win2000) - Set returned length after checking buffer size (ntdll_apitest NtQueryInformationProcess has tests only for ProcessTimes, but I checked other cases and always Length is set after check of the size) * Fixes 4 tests in ntdll_apitest NtQueryInformationProcess (all NtQueryInformationProcess tests passed now) svn path=/trunk/; revision=72532
This commit is contained in:
parent
e72b567d4e
commit
24834c0492
1 changed files with 76 additions and 67 deletions
|
@ -88,9 +88,9 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
/* Probe the buffer */
|
/* Probe the buffer */
|
||||||
ProbeForWrite(ProcessInformation,
|
ProbeForRead(ProcessInformation,
|
||||||
ProcessInformationLength,
|
ProcessInformationLength,
|
||||||
sizeof(ULONG));
|
sizeof(ULONG));
|
||||||
|
|
||||||
/* Probe the return length if required */
|
/* Probe the return length if required */
|
||||||
if (ReturnLength) ProbeForWriteUlong(ReturnLength);
|
if (ReturnLength) ProbeForWriteUlong(ReturnLength);
|
||||||
|
@ -121,15 +121,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Basic process information */
|
/* Basic process information */
|
||||||
case ProcessBasicInformation:
|
case ProcessBasicInformation:
|
||||||
|
|
||||||
/* Set return length */
|
if (ProcessInformationLength != sizeof(PROCESS_BASIC_INFORMATION))
|
||||||
Length = sizeof(PROCESS_BASIC_INFORMATION);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set return length */
|
||||||
|
Length = sizeof(PROCESS_BASIC_INFORMATION);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -167,13 +167,14 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Process quota limits */
|
/* Process quota limits */
|
||||||
case ProcessQuotaLimits:
|
case ProcessQuotaLimits:
|
||||||
|
|
||||||
Length = sizeof(QUOTA_LIMITS);
|
if (ProcessInformationLength != sizeof(QUOTA_LIMITS))
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Length = sizeof(QUOTA_LIMITS);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -230,13 +231,14 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessIoCounters:
|
case ProcessIoCounters:
|
||||||
|
|
||||||
Length = sizeof(IO_COUNTERS);
|
if (ProcessInformationLength != sizeof(IO_COUNTERS))
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Length = sizeof(IO_COUNTERS);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -273,14 +275,14 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
case ProcessTimes:
|
case ProcessTimes:
|
||||||
|
|
||||||
/* Set the return length */
|
/* Set the return length */
|
||||||
Length = sizeof(KERNEL_USER_TIMES);
|
if (ProcessInformationLength != sizeof(KERNEL_USER_TIMES))
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Length = sizeof(KERNEL_USER_TIMES);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -314,15 +316,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Process Debug Port */
|
/* Process Debug Port */
|
||||||
case ProcessDebugPort:
|
case ProcessDebugPort:
|
||||||
|
|
||||||
/* Set return length */
|
if (ProcessInformationLength != sizeof(HANDLE))
|
||||||
Length = sizeof(HANDLE);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set return length */
|
||||||
|
Length = sizeof(HANDLE);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -352,15 +354,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessHandleCount:
|
case ProcessHandleCount:
|
||||||
|
|
||||||
/* Set the return length*/
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length*/
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -393,15 +395,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Session ID for the process */
|
/* Session ID for the process */
|
||||||
case ProcessSessionInformation:
|
case ProcessSessionInformation:
|
||||||
|
|
||||||
/* Set the return length*/
|
if (ProcessInformationLength != sizeof(PROCESS_SESSION_INFORMATION))
|
||||||
Length = sizeof(PROCESS_SESSION_INFORMATION);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length*/
|
||||||
|
Length = sizeof(PROCESS_SESSION_INFORMATION);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -483,15 +485,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Hard Error Processing Mode */
|
/* Hard Error Processing Mode */
|
||||||
case ProcessDefaultHardErrorMode:
|
case ProcessDefaultHardErrorMode:
|
||||||
|
|
||||||
/* Set the return length*/
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length*/
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -522,15 +524,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Priority Boosting status */
|
/* Priority Boosting status */
|
||||||
case ProcessPriorityBoost:
|
case ProcessPriorityBoost:
|
||||||
|
|
||||||
/* Set the return length */
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length */
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -561,10 +563,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* DOS Device Map */
|
/* DOS Device Map */
|
||||||
case ProcessDeviceMap:
|
case ProcessDeviceMap:
|
||||||
|
|
||||||
/* Set the return length */
|
if (ProcessInformationLength != sizeof(PROCESS_DEVICEMAP_INFORMATION))
|
||||||
Length = sizeof(PROCESS_DEVICEMAP_INFORMATION);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
if (ProcessInformationLength == sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
|
if (ProcessInformationLength == sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
|
||||||
{
|
{
|
||||||
|
@ -578,6 +577,9 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length */
|
||||||
|
Length = sizeof(PROCESS_DEVICEMAP_INFORMATION);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -609,15 +611,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Priority class */
|
/* Priority class */
|
||||||
case ProcessPriorityClass:
|
case ProcessPriorityClass:
|
||||||
|
|
||||||
/* Set the return length*/
|
if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
|
||||||
Length = sizeof(PROCESS_PRIORITY_CLASS);
|
|
||||||
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length*/
|
||||||
|
Length = sizeof(PROCESS_PRIORITY_CLASS);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -701,14 +703,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessDebugFlags:
|
case ProcessDebugFlags:
|
||||||
|
|
||||||
/* Set the return length*/
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length*/
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -737,14 +740,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessBreakOnTermination:
|
case ProcessBreakOnTermination:
|
||||||
|
|
||||||
/* Set the return length*/
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length */
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -818,15 +822,16 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessImageInformation:
|
case ProcessImageInformation:
|
||||||
|
|
||||||
/* Set the length required and validate it */
|
if (ProcessInformationLength != sizeof(SECTION_IMAGE_INFORMATION))
|
||||||
Length = sizeof(SECTION_IMAGE_INFORMATION);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
/* Break out */
|
/* Break out */
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the length required and validate it */
|
||||||
|
Length = sizeof(SECTION_IMAGE_INFORMATION);
|
||||||
|
|
||||||
/* Enter SEH to protect write */
|
/* Enter SEH to protect write */
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
|
@ -845,14 +850,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessDebugObjectHandle:
|
case ProcessDebugObjectHandle:
|
||||||
|
|
||||||
/* Set the return length */
|
if (ProcessInformationLength != sizeof(HANDLE))
|
||||||
Length = sizeof(HANDLE);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length */
|
||||||
|
Length = sizeof(HANDLE);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -889,14 +895,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessLUIDDeviceMapsEnabled:
|
case ProcessLUIDDeviceMapsEnabled:
|
||||||
|
|
||||||
/* Set the return length */
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length */
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Indicate success */
|
/* Indicate success */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -916,14 +923,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessWx86Information:
|
case ProcessWx86Information:
|
||||||
|
|
||||||
/* Set the return length */
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the return length */
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -952,15 +960,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessWow64Information:
|
case ProcessWow64Information:
|
||||||
|
|
||||||
/* Set return length */
|
if (ProcessInformationLength != sizeof(ULONG_PTR))
|
||||||
Length = sizeof(ULONG_PTR);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Length = 0;
|
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set return length */
|
||||||
|
Length = sizeof(ULONG_PTR);
|
||||||
|
|
||||||
/* Reference the process */
|
/* Reference the process */
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
@ -1002,14 +1010,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
case ProcessExecuteFlags:
|
case ProcessExecuteFlags:
|
||||||
|
|
||||||
/* Set return length */
|
if (ProcessInformationLength != sizeof(ULONG))
|
||||||
Length = sizeof(ULONG);
|
|
||||||
if (ProcessInformationLength != Length)
|
|
||||||
{
|
{
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set return length */
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
|
||||||
if (ProcessHandle != NtCurrentProcess())
|
if (ProcessHandle != NtCurrentProcess())
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue