ReactOS  0.4.15-dev-3316-g067ca88
probelib.c File Reference
#include "precomp.h"
#include <internal/ps_i.h>
Include dependency graph for probelib.c:

Go to the source code of this file.

Functions

VOID QuerySetProcessValidator (_In_ ALIGNMENT_PROBE_MODE ValidationMode, _In_ ULONG InfoClassIndex, _In_ PVOID InfoPointer, _In_ ULONG InfoLength, _In_ NTSTATUS ExpectedStatus)
 
VOID QuerySetThreadValidator (_In_ ALIGNMENT_PROBE_MODE ValidationMode, _In_ ULONG InfoClassIndex, _In_ PVOID InfoPointer, _In_ ULONG InfoLength, _In_ NTSTATUS ExpectedStatus)
 

Function Documentation

◆ QuerySetProcessValidator()

VOID QuerySetProcessValidator ( _In_ ALIGNMENT_PROBE_MODE  ValidationMode,
_In_ ULONG  InfoClassIndex,
_In_ PVOID  InfoPointer,
_In_ ULONG  InfoLength,
_In_ NTSTATUS  ExpectedStatus 
)

Definition at line 12 of file probelib.c.

18 {
19  NTSTATUS Status, SpecialStatus = STATUS_SUCCESS;
20 
21  /* Before doing anything, check if we want query or set validation */
22  switch (ValidationMode)
23  {
24  case QUERY:
25  {
26  switch (InfoClassIndex)
27  {
29  {
30  SpecialStatus = STATUS_UNSUCCESSFUL;
31  break;
32  }
33 
35  {
36  SpecialStatus = STATUS_INVALID_PARAMETER;
37  break;
38  }
39 
40  /*
41  * This class returns an arbitrary size pointed by InformationLength
42  * which equates to the image filename of the process. Such status
43  * is returned in an invalid address query (STATUS_ACCESS_VIOLATION)
44  * where the function expects STATUS_INFO_LENGTH_MISMATCH instead.
45  */
47  {
48  SpecialStatus = STATUS_INFO_LENGTH_MISMATCH;
49  break;
50  }
51 
52  /* These classes don't belong in the query group */
56  case ProcessAccessToken:
57  case ProcessLdtSize:
63  {
64  SpecialStatus = STATUS_INVALID_INFO_CLASS;
65  break;
66  }
67 
68  /* These classes don't exist in Server 2003 */
69  case ProcessIoPriority:
71  case ProcessCycleTime:
80  {
81  SpecialStatus = STATUS_INVALID_INFO_CLASS;
82  break;
83  }
84  }
85 
86  /* Query the information */
88  InfoClassIndex,
89  InfoPointer,
90  InfoLength,
91  NULL);
92 
93  /* And probe the results we've got */
94  ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT,
95  "0x%lx or special status (0x%lx) expected but got 0x%lx for class information %lu in query information process operation!\n", ExpectedStatus, SpecialStatus, Status, InfoClassIndex);
96  break;
97  }
98 
99  case SET:
100  {
101  switch (InfoClassIndex)
102  {
104  {
105  SpecialStatus = STATUS_INVALID_PARAMETER;
106  break;
107  }
108 
109  /*
110  * This class returns STATUS_SUCCESS when testing
111  * for STATUS_ACCESS_VIOLATION (setting an invalid address).
112  */
114  {
115  SpecialStatus = STATUS_PORT_ALREADY_SET;
116  break;
117  }
118 
119  case ProcessUserModeIOPL:
120  {
121  SpecialStatus = STATUS_PRIVILEGE_NOT_HELD;
122  break;
123  }
124 
125  /* These classes don't belong in the set group */
127  case ProcessIoCounters:
128  case ProcessVmCounters:
129  case ProcessTimes:
130  case ProcessDebugPort:
132  case ProcessHandleCount:
137  case ProcessCookie:
139  {
140  SpecialStatus = STATUS_INVALID_INFO_CLASS;
141  break;
142  }
143 
144  /* These classes don't exist in Server 2003 */
145  case ProcessIoPriority:
147  case ProcessCycleTime:
148  case ProcessPagePriority:
156  {
157  SpecialStatus = STATUS_INVALID_INFO_CLASS;
158  break;
159  }
160 
161  /* Alignment probing is not performed for these classes */
165  {
166  SpecialStatus = STATUS_ACCESS_VIOLATION;
167  break;
168  }
169  }
170 
171  /* Set the information */
173  InfoClassIndex,
174  InfoPointer,
175  InfoLength);
176 
177  /* And probe the results we've got */
178  ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT || Status == STATUS_SUCCESS,
179  "0x%lx or special status (0x%lx) expected but got 0x%lx for class information %lu in set information process operation!\n", ExpectedStatus, SpecialStatus, Status, InfoClassIndex);
180  break;
181  }
182 
183  default:
184  break;
185  }
186 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define SET(field, seg, reg)
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1105
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: precomp.h:18
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define STATUS_PORT_ALREADY_SET
Definition: ntstatus.h:308

Referenced by Test_ProcQueryAlignmentProbe(), and Test_ProcSetAlignmentProbe().

◆ QuerySetThreadValidator()

VOID QuerySetThreadValidator ( _In_ ALIGNMENT_PROBE_MODE  ValidationMode,
_In_ ULONG  InfoClassIndex,
_In_ PVOID  InfoPointer,
_In_ ULONG  InfoLength,
_In_ NTSTATUS  ExpectedStatus 
)

Definition at line 189 of file probelib.c.

195 {
196  NTSTATUS Status, SpecialStatus = STATUS_SUCCESS;
197 
198  /* Before doing anything, check if we want query or set validation */
199  switch (ValidationMode)
200  {
201  case QUERY:
202  {
203  switch (InfoClassIndex)
204  {
205  /* These classes don't belong in the query group */
206  case ThreadPriority:
207  case ThreadBasePriority:
208  case ThreadAffinityMask:
211  case ThreadZeroTlsCell:
216  {
217  SpecialStatus = STATUS_INVALID_INFO_CLASS;
218  break;
219  }
220 
221  /* These classes don't exist in Server 2003 SP2 */
224  case ThreadIoPriority:
225  case ThreadCycleTime:
226  case ThreadPagePriority:
229  case ThreadCSwitchMon:
230  {
231  SpecialStatus = STATUS_INVALID_INFO_CLASS;
232  break;
233  }
234  }
235 
236  /* Query the information */
238  InfoClassIndex,
239  InfoPointer,
240  InfoLength,
241  NULL);
242 
243  /* And probe the results we've got */
244  ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT,
245  "0x%lx or special status (0x%lx) expected but got 0x%lx for class information %lu in query information thread operation!\n", ExpectedStatus, SpecialStatus, Status, InfoClassIndex);
246  break;
247  }
248 
249  case SET:
250  {
251  switch (InfoClassIndex)
252  {
253  /* This class is not implemented in Windows Server 2003 SP2 */
255  {
256  SpecialStatus = STATUS_NOT_IMPLEMENTED;
257  break;
258  }
259 
260  /*
261  * This class doesn't take a strict type for size length.
262  * The function happily succeds on an information length
263  * mismatch scenario with STATUS_SUCCESS.
264  */
266  {
267  SpecialStatus = STATUS_INFO_LENGTH_MISMATCH;
268  break;
269  }
270 
271  /* These classes don't belong in the set group */
273  case ThreadTimes:
276  case ThreadAmILastThread:
277  case ThreadIsIoPending:
278  case ThreadIsTerminated:
279  {
280  SpecialStatus = STATUS_INVALID_INFO_CLASS;
281  break;
282  }
283 
284  /* These classes don't exist in Server 2003 SP2 */
287  case ThreadIoPriority:
288  case ThreadCycleTime:
289  case ThreadPagePriority:
292  case ThreadCSwitchMon:
293  {
294  SpecialStatus = STATUS_INVALID_INFO_CLASS;
295  break;
296  }
297 
298  /* Alignment probing is not performed for this class */
300  {
301  SpecialStatus = STATUS_ACCESS_VIOLATION;
302  break;
303  }
304  }
305 
306  /* Set the information */
308  InfoClassIndex,
309  InfoPointer,
310  InfoLength);
311 
312  /* And probe the results we've got */
313  ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT || Status == STATUS_SUCCESS,
314  "0x%lx or special status (0x%lx) expected but got 0x%lx for class information %lu in set information thread operation!\n", ExpectedStatus, SpecialStatus, Status, InfoClassIndex);
315  }
316 
317  default:
318  break;
319  }
320 }
#define SET(field, seg, reg)
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONG NTSTATUS
Definition: precomp.h:26
#define NtCurrentThread()
return STATUS_NOT_IMPLEMENTED
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2624
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: precomp.h:18

Referenced by Test_ThreadQueryAlignmentProbe(), and Test_ThreadSetAlignmentProbe().