ReactOS 0.4.16-dev-2354-g16de117
precomp.h File Reference
#include <stdio.h>
#include <apitest.h>
#include <apitest_guard.h>
#include <ndk/ntndk.h>
#include <strsafe.h>
Include dependency graph for precomp.h:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 

Typedefs

typedef enum _ALIGNMENT_PROBE_MODE ALIGNMENT_PROBE_MODE
 

Enumerations

enum  _ALIGNMENT_PROBE_MODE { QUERY , SET }
 

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)
 
void SetupLocale (_In_ ULONG AnsiCode, _In_ ULONG OemCode, _In_ ULONG Unicode)
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 7 of file precomp.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 8 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 6 of file precomp.h.

Typedef Documentation

◆ ALIGNMENT_PROBE_MODE

Enumeration Type Documentation

◆ _ALIGNMENT_PROBE_MODE

Enumerator
QUERY 
SET 

Definition at line 16 of file precomp.h.

17{
18 QUERY,
19 SET
@ QUERY
Definition: precomp.h:18
@ SET
Definition: precomp.h:19
enum _ALIGNMENT_PROBE_MODE ALIGNMENT_PROBE_MODE

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 if ((PsProcessInfoClass[InfoClassIndex].RequiredSizeQUERY == 0) &&
22 (PsProcessInfoClass[InfoClassIndex].RequiredSizeSET == 0))
23 {
24 skip("FIXME: Skipping test for InfoClass %lu, because PsProcessInfoClass[] doesn't have it.\n", InfoClassIndex);
25 return;
26 }
27
28 /* Before doing anything, check if we want query or set validation */
29 switch (ValidationMode)
30 {
31 case QUERY:
32 {
33 switch (InfoClassIndex)
34 {
36 {
37 SpecialStatus = STATUS_UNSUCCESSFUL;
38 break;
39 }
40
42 {
43 SpecialStatus = STATUS_INVALID_PARAMETER;
44 break;
45 }
46
47 /*
48 * This class returns an arbitrary size pointed by InformationLength
49 * which equates to the image filename of the process. Such status
50 * is returned in an invalid address query (STATUS_ACCESS_VIOLATION)
51 * where the function expects STATUS_INFO_LENGTH_MISMATCH instead.
52 */
54 {
55 SpecialStatus = STATUS_INFO_LENGTH_MISMATCH;
56 break;
57 }
58
59 /* This one works different from the others */
61 {
62 if (ExpectedStatus == STATUS_INFO_LENGTH_MISMATCH)
63 {
64 SpecialStatus = STATUS_ACCESS_VIOLATION;
65 }
66 else
67 {
68 SpecialStatus = STATUS_INVALID_INFO_CLASS;
69 }
70 break;
71 }
72
73 /* These classes don't belong in the query group */
78 case ProcessLdtSize:
82 {
83 SpecialStatus = STATUS_INVALID_INFO_CLASS;
84 break;
85 }
86
88 {
89 if (ExpectedStatus != STATUS_DATATYPE_MISALIGNMENT)
90 {
91 SpecialStatus = STATUS_INVALID_INFO_CLASS;
92 }
93 break;
94 }
95
96 /* These classes don't exist in Server 2003 */
98 {
99 /* Need to fix up the length */
100 if (InfoLength == sizeof(UNICODE_STRING))
101 {
102 InfoLength += MAX_PATH * sizeof(WCHAR);
103 }
104 /* Fall through */
105 }
108 case ProcessCycleTime:
116 {
118 {
119 SpecialStatus = STATUS_INVALID_INFO_CLASS;
120 }
121 break;
122 }
123
124#ifndef _M_IX86
126 {
127 SpecialStatus = STATUS_NOT_IMPLEMENTED;
128 break;
129 }
130#endif
131 }
132
133 /* Query the information */
135 InfoClassIndex,
136 InfoPointer,
137 InfoLength,
138 NULL);
139
140 /* And probe the results we've got */
141 ok(Status == ExpectedStatus || Status == SpecialStatus,
142 "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);
143 break;
144 }
145
146 case SET:
147 {
148 switch (InfoClassIndex)
149 {
151 {
152#ifndef _M_IX86
153 SpecialStatus = STATUS_NOT_IMPLEMENTED;
154#else
155 SpecialStatus = STATUS_INVALID_PARAMETER;
156#endif
157 break;
158 }
159
160 /*
161 * This class returns STATUS_SUCCESS when testing
162 * for STATUS_ACCESS_VIOLATION (setting an invalid address).
163 */
165 {
166 if (ExpectedStatus == STATUS_ACCESS_VIOLATION)
167 ExpectedStatus = STATUS_SUCCESS;
168 SpecialStatus = STATUS_PORT_ALREADY_SET;
169 break;
170 }
171
172 /* This one works different from the others */
174 {
175 if (ExpectedStatus == STATUS_INFO_LENGTH_MISMATCH)
176 {
177 SpecialStatus = STATUS_ACCESS_VIOLATION;
178 }
179 else
180 {
181 SpecialStatus = STATUS_PRIVILEGE_NOT_HELD;
182 }
183 break;
184 }
185
186 /* These classes don't belong in the set group */
190 case ProcessTimes:
191 case ProcessDebugPort:
198 case ProcessCookie:
200 {
201 SpecialStatus = STATUS_INVALID_INFO_CLASS;
202 break;
203 }
204
205 /* These classes don't exist in Server 2003 */
208 case ProcessCycleTime:
217 {
218 SpecialStatus = STATUS_INVALID_INFO_CLASS;
219 break;
220 }
221
222 /* Alignment probing is not performed for these classes */
226 {
227 SpecialStatus = STATUS_ACCESS_VIOLATION;
228 break;
229 }
230
231#ifndef _M_IX86
233 case ProcessLdtSize:
234 {
235 SpecialStatus = STATUS_NOT_IMPLEMENTED;
236 break;
237 }
238#endif
239 }
240
241 /* Set the information */
243 InfoClassIndex,
244 InfoPointer,
245 InfoLength);
246
247 /* And probe the results we've got */
248 ok(Status == ExpectedStatus || Status == SpecialStatus,
249 "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);
250 break;
251 }
252
253 default:
254 break;
255 }
256}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define GetNTVersion()
Definition: apitest.h:17
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
@ ProcessDebugPort
Definition: cicbase.cpp:64
@ ProcessBasicInformation
Definition: cicbase.cpp:63
@ ProcessWow64Information
Definition: cicbase.cpp:65
@ ProcessImageFileName
Definition: cicbase.cpp:66
#define SET(field, seg, reg)
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define STATUS_ACCESS_VIOLATION
Status
Definition: gdiplustypes.h:25
#define NtCurrentProcess()
Definition: nt_native.h:1660
NTSTATUS NTAPI NtSetInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength)
Definition: query.c:1389
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:263
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:333
#define STATUS_PORT_ALREADY_SET
Definition: ntstatus.h:402
static const INFORMATION_CLASS_INFO PsProcessInfoClass[]
Definition: ps_i.h:15
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
@ ProcessPagePriority
Definition: winternl.h:1921
@ ProcessLUIDDeviceMapsEnabled
Definition: winternl.h:1910
@ ProcessMemoryAllocationMode
Definition: winternl.h:1928
@ ProcessTlsInformation
Definition: winternl.h:1917
@ ProcessWorkingSetWatchEx
Definition: winternl.h:1924
@ ProcessAffinityMask
Definition: winternl.h:1903
@ ProcessInstrumentationCallback
Definition: winternl.h:1922
@ ProcessImageFileMapping
Definition: winternl.h:1926
@ ProcessIoPortHandlers
Definition: winternl.h:1895
@ ProcessRaisePriority
Definition: winternl.h:1888
@ ProcessVmCounters
Definition: winternl.h:1885
@ ProcessPriorityClass
Definition: winternl.h:1900
@ ProcessImageInformation
Definition: winternl.h:1919
@ ProcessCookie
Definition: winternl.h:1918
@ ProcessPooledUsageAndLimits
Definition: winternl.h:1896
@ ProcessLdtSize
Definition: winternl.h:1893
@ ProcessIoCounters
Definition: winternl.h:1884
@ ProcessImageFileNameWin32
Definition: winternl.h:1925
@ ProcessAffinityUpdateMode
Definition: winternl.h:1927
@ ProcessEnableAlignmentFaultFixup
Definition: winternl.h:1899
@ ProcessBasePriority
Definition: winternl.h:1887
@ ProcessCycleTime
Definition: winternl.h:1920
@ ProcessAccessToken
Definition: winternl.h:1891
@ ProcessIoPriority
Definition: winternl.h:1915
@ ProcessHandleTracing
Definition: winternl.h:1914
@ ProcessThreadStackAllocation
Definition: winternl.h:1923
@ ProcessForegroundInformation
Definition: winternl.h:1907
@ ProcessTimes
Definition: winternl.h:1886
@ ProcessDebugObjectHandle
Definition: winternl.h:1912
@ ProcessExceptionPort
Definition: winternl.h:1890
@ ProcessWorkingSetWatch
Definition: winternl.h:1897
@ ProcessLdtInformation
Definition: winternl.h:1892
@ ProcessHandleCount
Definition: winternl.h:1902
@ ProcessUserModeIOPL
Definition: winternl.h:1898
__wchar_t WCHAR
Definition: xmlstorage.h:180

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 259 of file probelib.c.

265{
266 NTSTATUS Status, SpecialStatus = STATUS_SUCCESS;
267
268 /* Before doing anything, check if we want query or set validation */
269 switch (ValidationMode)
270 {
271 case QUERY:
272 {
273 switch (InfoClassIndex)
274 {
275 /* These classes don't belong in the query group */
276 case ThreadPriority:
285 {
286 SpecialStatus = STATUS_INVALID_INFO_CLASS;
287 break;
288 }
289
290 /* This class supports queries only on Vista and above */
292 {
294 SpecialStatus = STATUS_INVALID_INFO_CLASS;
295 break;
296 }
297
298 /* These classes don't exist in Server 2003 SP2 */
301 case ThreadIoPriority:
302 case ThreadCycleTime:
306 case ThreadCSwitchMon:
307 {
308 SpecialStatus = STATUS_INVALID_INFO_CLASS;
309 break;
310 }
311 }
312
313 /* Query the information */
315 InfoClassIndex,
316 InfoPointer,
317 InfoLength,
318 NULL);
319
320 /* And probe the results we've got */
321 ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT,
322 "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);
323 break;
324 }
325
326 case SET:
327 {
328 switch (InfoClassIndex)
329 {
330 /* This class is not implemented in Windows Server 2003 SP2 */
332 {
333 SpecialStatus = STATUS_NOT_IMPLEMENTED;
334 break;
335 }
336
337 /*
338 * This class doesn't take a strict type for size length.
339 * The function happily succeeds on an information length
340 * mismatch scenario with STATUS_SUCCESS.
341 */
343 {
344 SpecialStatus = STATUS_INFO_LENGTH_MISMATCH;
345 break;
346 }
347
348 /* These classes don't belong in the set group */
350 case ThreadTimes:
356 {
357 SpecialStatus = STATUS_INVALID_INFO_CLASS;
358 break;
359 }
360
361 /* These classes don't exist in Server 2003 SP2 */
364 case ThreadIoPriority:
365 case ThreadCycleTime:
369 case ThreadCSwitchMon:
370 {
371 SpecialStatus = STATUS_INVALID_INFO_CLASS;
372 break;
373 }
374
375 /* Alignment probing is not performed for this class */
377 {
378 SpecialStatus = STATUS_ACCESS_VIOLATION;
379 break;
380 }
381 }
382
383 /* Set the information */
385 InfoClassIndex,
386 InfoPointer,
387 InfoLength);
388
389 /* And probe the results we've got */
390 ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT || Status == STATUS_SUCCESS,
391 "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);
392 }
393
394 default:
395 break;
396 }
397}
@ ThreadEnableAlignmentFaultFixup
Definition: compat.h:942
@ ThreadDescriptorTableEntry
Definition: compat.h:941
@ ThreadEventPair_Reusable
Definition: compat.h:943
@ ThreadAmILastThread
Definition: compat.h:947
@ ThreadTimes
Definition: compat.h:936
@ ThreadPagePriority
Definition: compat.h:959
@ ThreadCSwitchMon
Definition: compat.h:962
@ ThreadPriority
Definition: compat.h:937
@ ThreadIdealProcessor
Definition: compat.h:948
@ ThreadActualBasePriority
Definition: compat.h:960
@ ThreadSwitchLegacyState
Definition: compat.h:954
@ ThreadIsTerminated
Definition: compat.h:955
@ ThreadLastSystemCall
Definition: compat.h:956
@ ThreadImpersonationToken
Definition: compat.h:940
@ ThreadSetTlsArrayAddress
Definition: compat.h:950
@ ThreadAffinityMask
Definition: compat.h:939
@ ThreadBasePriority
Definition: compat.h:938
@ ThreadTebInformation
Definition: compat.h:961
@ ThreadIoPriority
Definition: compat.h:957
@ ThreadCycleTime
Definition: compat.h:958
@ ThreadBasicInformation
Definition: compat.h:935
@ ThreadPerformanceCount
Definition: compat.h:946
@ ThreadIsIoPending
Definition: compat.h:951
@ ThreadZeroTlsCell
Definition: compat.h:945
@ ThreadHideFromDebugger
Definition: compat.h:952
NTSTATUS NTAPI NtQueryInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _Out_writes_bytes_to_opt_(ThreadInformationLength, *ReturnLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:2881
NTSTATUS NTAPI NtSetInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength)
Definition: query.c:2268
#define NtCurrentThread()
Definition: winternl.h:5368

Referenced by Test_ThreadQueryAlignmentProbe(), and Test_ThreadSetAlignmentProbe().

◆ SetupLocale()

void SetupLocale ( _In_ ULONG  AnsiCode,
_In_ ULONG  OemCode,
_In_ ULONG  Unicode 
)

Definition at line 58 of file locale.c.

62{
63 NLSTABLEINFO NlsTable;
64 PVOID AnsiCodePageData;
65 PVOID OemCodePageData;
66 PVOID UnicodeCaseTableData;
67
68 AnsiCodePageData = LoadCodePageData(AnsiCode);
69 OemCodePageData = LoadCodePageData(OemCode);
70 UnicodeCaseTableData = LoadCodePageData(Unicode);
71
72 RtlInitNlsTables(AnsiCodePageData, OemCodePageData, UnicodeCaseTableData, &NlsTable);
73 RtlResetRtlTranslations(&NlsTable);
74 /*
75 * Do NOT free the buffers here, they are directly used!
76 * Yes, we leak the old buffers, but this is a test anyway...
77 */
78}
static PVOID LoadCodePageData(_In_ ULONG Code)
Definition: locale.c:15
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)