Author: dchapyshev
Date: Thu Sep 1 22:38:25 2016
New Revision: 72532
URL:
http://svn.reactos.org/svn/reactos?rev=72532&view=rev
Log:
[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)
Modified:
trunk/reactos/ntoskrnl/ps/query.c
Modified: trunk/reactos/ntoskrnl/ps/query.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/query.c?rev=72…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/query.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/query.c [iso-8859-1] Thu Sep 1 22:38:25 2016
@@ -88,9 +88,9 @@
_SEH2_TRY
{
/* Probe the buffer */
- ProbeForWrite(ProcessInformation,
- ProcessInformationLength,
- sizeof(ULONG));
+ ProbeForRead(ProcessInformation,
+ ProcessInformationLength,
+ sizeof(ULONG));
/* Probe the return length if required */
if (ReturnLength) ProbeForWriteUlong(ReturnLength);
@@ -121,14 +121,14 @@
/* Basic process information */
case ProcessBasicInformation:
+ if (ProcessInformationLength != sizeof(PROCESS_BASIC_INFORMATION))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set return length */
Length = sizeof(PROCESS_BASIC_INFORMATION);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -167,12 +167,13 @@
/* Process quota limits */
case ProcessQuotaLimits:
+ if (ProcessInformationLength != sizeof(QUOTA_LIMITS))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
Length = sizeof(QUOTA_LIMITS);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -230,12 +231,13 @@
case ProcessIoCounters:
+ if (ProcessInformationLength != sizeof(IO_COUNTERS))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
Length = sizeof(IO_COUNTERS);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -273,13 +275,13 @@
case ProcessTimes:
/* Set the return length */
+ if (ProcessInformationLength != sizeof(KERNEL_USER_TIMES))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
Length = sizeof(KERNEL_USER_TIMES);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -314,14 +316,14 @@
/* Process Debug Port */
case ProcessDebugPort:
+ if (ProcessInformationLength != sizeof(HANDLE))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set return length */
Length = sizeof(HANDLE);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -352,14 +354,14 @@
case ProcessHandleCount:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length*/
Length = sizeof(ULONG);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -393,14 +395,14 @@
/* Session ID for the process */
case ProcessSessionInformation:
+ if (ProcessInformationLength != sizeof(PROCESS_SESSION_INFORMATION))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length*/
Length = sizeof(PROCESS_SESSION_INFORMATION);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -483,14 +485,14 @@
/* Hard Error Processing Mode */
case ProcessDefaultHardErrorMode:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length*/
Length = sizeof(ULONG);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -522,14 +524,14 @@
/* Priority Boosting status */
case ProcessPriorityBoost:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length */
Length = sizeof(ULONG);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -561,10 +563,7 @@
/* DOS Device Map */
case ProcessDeviceMap:
- /* Set the return length */
- Length = sizeof(PROCESS_DEVICEMAP_INFORMATION);
-
- if (ProcessInformationLength != Length)
+ if (ProcessInformationLength != sizeof(PROCESS_DEVICEMAP_INFORMATION))
{
if (ProcessInformationLength ==
sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
{
@@ -578,6 +577,9 @@
break;
}
+ /* Set the return length */
+ Length = sizeof(PROCESS_DEVICEMAP_INFORMATION);
+
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_QUERY_INFORMATION,
@@ -609,14 +611,14 @@
/* Priority class */
case ProcessPriorityClass:
+ if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length*/
Length = sizeof(PROCESS_PRIORITY_CLASS);
-
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -701,13 +703,14 @@
case ProcessDebugFlags:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length*/
Length = sizeof(ULONG);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -737,13 +740,14 @@
case ProcessBreakOnTermination:
- /* Set the return length*/
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
+ /* Set the return length */
Length = sizeof(ULONG);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -818,14 +822,15 @@
case ProcessImageInformation:
+ if (ProcessInformationLength != sizeof(SECTION_IMAGE_INFORMATION))
+ {
+ /* Break out */
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the length required and validate it */
Length = sizeof(SECTION_IMAGE_INFORMATION);
- if (ProcessInformationLength != Length)
- {
- /* Break out */
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Enter SEH to protect write */
_SEH2_TRY
@@ -845,13 +850,14 @@
case ProcessDebugObjectHandle:
+ if (ProcessInformationLength != sizeof(HANDLE))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length */
Length = sizeof(HANDLE);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -889,13 +895,14 @@
case ProcessLUIDDeviceMapsEnabled:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length */
Length = sizeof(ULONG);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Indicate success */
Status = STATUS_SUCCESS;
@@ -916,13 +923,14 @@
case ProcessWx86Information:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set the return length */
Length = sizeof(ULONG);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -952,14 +960,14 @@
case ProcessWow64Information:
+ if (ProcessInformationLength != sizeof(ULONG_PTR))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set return length */
Length = sizeof(ULONG_PTR);
- if (ProcessInformationLength != Length)
- {
- Length = 0;
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
/* Reference the process */
Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -1002,13 +1010,14 @@
case ProcessExecuteFlags:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Set return length */
Length = sizeof(ULONG);
- if (ProcessInformationLength != Length)
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- break;
- }
if (ProcessHandle != NtCurrentProcess())
{