ReactOS 0.4.16-dev-109-gf4cb10f
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 /* 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 /* This one works different from the others */
54 {
55 if (ExpectedStatus == STATUS_INFO_LENGTH_MISMATCH)
56 {
57 SpecialStatus = STATUS_ACCESS_VIOLATION;
58 }
59 else
60 {
61 SpecialStatus = STATUS_INVALID_INFO_CLASS;
62 }
63 break;
64 }
65
66 /* These classes don't belong in the query group */
71 case ProcessLdtSize:
76 {
77 SpecialStatus = STATUS_INVALID_INFO_CLASS;
78 break;
79 }
80
81 /* These classes don't exist in Server 2003 */
93 {
94 SpecialStatus = STATUS_INVALID_INFO_CLASS;
95 break;
96 }
97 }
98
99 /* Query the information */
101 InfoClassIndex,
102 InfoPointer,
103 InfoLength,
104 NULL);
105
106 /* And probe the results we've got */
107 ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT,
108 "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);
109 break;
110 }
111
112 case SET:
113 {
114 switch (InfoClassIndex)
115 {
117 {
118 SpecialStatus = STATUS_INVALID_PARAMETER;
119 break;
120 }
121
122 /*
123 * This class returns STATUS_SUCCESS when testing
124 * for STATUS_ACCESS_VIOLATION (setting an invalid address).
125 */
127 {
128 SpecialStatus = STATUS_PORT_ALREADY_SET;
129 break;
130 }
131
132 /* This one works different from the others */
134 {
135 if (ExpectedStatus == STATUS_INFO_LENGTH_MISMATCH)
136 {
137 SpecialStatus = STATUS_ACCESS_VIOLATION;
138 }
139 else
140 {
141 SpecialStatus = STATUS_PRIVILEGE_NOT_HELD;
142 }
143 break;
144 }
145
146 /* These classes don't belong in the set group */
150 case ProcessTimes:
151 case ProcessDebugPort:
158 case ProcessCookie:
160 {
161 SpecialStatus = STATUS_INVALID_INFO_CLASS;
162 break;
163 }
164
165 /* These classes don't exist in Server 2003 */
168 case ProcessCycleTime:
177 {
178 SpecialStatus = STATUS_INVALID_INFO_CLASS;
179 break;
180 }
181
182 /* Alignment probing is not performed for these classes */
186 {
187 SpecialStatus = STATUS_ACCESS_VIOLATION;
188 break;
189 }
190 }
191
192 /* Set the information */
194 InfoClassIndex,
195 InfoPointer,
196 InfoLength);
197
198 /* And probe the results we've got */
199 ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT || Status == STATUS_SUCCESS,
200 "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);
201 break;
202 }
203
204 default:
205 break;
206 }
207}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define SET(field, seg, reg)
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
@ ProcessDebugPort
Definition: winternl.h:395
@ ProcessBasicInformation
Definition: winternl.h:394
@ ProcessWow64Information
Definition: winternl.h:396
@ ProcessImageFileName
Definition: winternl.h:397
@ ProcessPagePriority
Definition: winternl.h:894
@ ProcessLUIDDeviceMapsEnabled
Definition: winternl.h:884
@ ProcessMemoryAllocationMode
Definition: winternl.h:901
@ ProcessTlsInformation
Definition: winternl.h:890
@ ProcessWorkingSetWatchEx
Definition: winternl.h:897
@ ProcessAffinityMask
Definition: winternl.h:877
@ ProcessInstrumentationCallback
Definition: winternl.h:895
@ ProcessImageFileMapping
Definition: winternl.h:899
@ ProcessIoPortHandlers
Definition: winternl.h:869
@ ProcessRaisePriority
Definition: winternl.h:862
@ ProcessVmCounters
Definition: winternl.h:859
@ ProcessPriorityClass
Definition: winternl.h:874
@ ProcessImageInformation
Definition: winternl.h:892
@ ProcessCookie
Definition: winternl.h:891
@ ProcessPooledUsageAndLimits
Definition: winternl.h:870
@ ProcessLdtSize
Definition: winternl.h:867
@ ProcessIoCounters
Definition: winternl.h:858
@ ProcessImageFileNameWin32
Definition: winternl.h:898
@ ProcessAffinityUpdateMode
Definition: winternl.h:900
@ ProcessEnableAlignmentFaultFixup
Definition: winternl.h:873
@ ProcessBasePriority
Definition: winternl.h:861
@ ProcessCycleTime
Definition: winternl.h:893
@ ProcessAccessToken
Definition: winternl.h:865
@ ProcessHandleTracing
Definition: winternl.h:888
@ ProcessThreadStackAllocation
Definition: winternl.h:896
@ ProcessForegroundInformation
Definition: winternl.h:881
@ ProcessTimes
Definition: winternl.h:860
@ ProcessDebugObjectHandle
Definition: winternl.h:886
@ ProcessExceptionPort
Definition: winternl.h:864
@ ProcessWorkingSetWatch
Definition: winternl.h:871
@ ProcessHandleCount
Definition: winternl.h:876
@ ProcessUserModeIOPL
Definition: winternl.h:872
@ ProcessIoPriority
Definition: pstypes.h:266
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1105
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_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define STATUS_PORT_ALREADY_SET
Definition: ntstatus.h:308
#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

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

216{
217 NTSTATUS Status, SpecialStatus = STATUS_SUCCESS;
218
219 /* Before doing anything, check if we want query or set validation */
220 switch (ValidationMode)
221 {
222 case QUERY:
223 {
224 switch (InfoClassIndex)
225 {
226 /* These classes don't belong in the query group */
227 case ThreadPriority:
237 {
238 SpecialStatus = STATUS_INVALID_INFO_CLASS;
239 break;
240 }
241
242 /* These classes don't exist in Server 2003 SP2 */
245 case ThreadIoPriority:
246 case ThreadCycleTime:
250 case ThreadCSwitchMon:
251 {
252 SpecialStatus = STATUS_INVALID_INFO_CLASS;
253 break;
254 }
255 }
256
257 /* Query the information */
259 InfoClassIndex,
260 InfoPointer,
261 InfoLength,
262 NULL);
263
264 /* And probe the results we've got */
265 ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT,
266 "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);
267 break;
268 }
269
270 case SET:
271 {
272 switch (InfoClassIndex)
273 {
274 /* This class is not implemented in Windows Server 2003 SP2 */
276 {
277 SpecialStatus = STATUS_NOT_IMPLEMENTED;
278 break;
279 }
280
281 /*
282 * This class doesn't take a strict type for size length.
283 * The function happily succeds on an information length
284 * mismatch scenario with STATUS_SUCCESS.
285 */
287 {
288 SpecialStatus = STATUS_INFO_LENGTH_MISMATCH;
289 break;
290 }
291
292 /* These classes don't belong in the set group */
294 case ThreadTimes:
300 {
301 SpecialStatus = STATUS_INVALID_INFO_CLASS;
302 break;
303 }
304
305 /* These classes don't exist in Server 2003 SP2 */
308 case ThreadIoPriority:
309 case ThreadCycleTime:
313 case ThreadCSwitchMon:
314 {
315 SpecialStatus = STATUS_INVALID_INFO_CLASS;
316 break;
317 }
318
319 /* Alignment probing is not performed for this class */
321 {
322 SpecialStatus = STATUS_ACCESS_VIOLATION;
323 break;
324 }
325 }
326
327 /* Set the information */
329 InfoClassIndex,
330 InfoPointer,
331 InfoLength);
332
333 /* And probe the results we've got */
334 ok(Status == ExpectedStatus || Status == SpecialStatus || Status == STATUS_DATATYPE_MISALIGNMENT || Status == STATUS_SUCCESS,
335 "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);
336 }
337
338 default:
339 break;
340 }
341}
@ 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 PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2624
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define NtCurrentThread()

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)