1 | /* $Id: ntstuff.h 3223 2018-03-31 02:29:56Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * Definitions, types, prototypes and globals for NT.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2005-2013 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
---|
25 | * IN THE SOFTWARE.
|
---|
26 | *
|
---|
27 | * Alternatively, the content of this file may be used under the terms of the
|
---|
28 | * GPL version 2 or later, or LGPL version 2.1 or later.
|
---|
29 | */
|
---|
30 |
|
---|
31 |
|
---|
32 | #ifndef ___nt_ntstuff_h
|
---|
33 | #define ___nt_ntstuff_h
|
---|
34 |
|
---|
35 | #define timeval timeval_Windows
|
---|
36 | #define WIN32_NO_STATUS
|
---|
37 | #include <Windows.h>
|
---|
38 | #include <winternl.h>
|
---|
39 | #undef WIN32_NO_STATUS
|
---|
40 | #include <ntstatus.h>
|
---|
41 | #undef timeval
|
---|
42 |
|
---|
43 | #include <k/kTypes.h>
|
---|
44 |
|
---|
45 |
|
---|
46 | /** @defgroup grp_nt_ntstuff NT Stuff
|
---|
47 | * @{ */
|
---|
48 |
|
---|
49 | typedef LONG MY_NTSTATUS;
|
---|
50 | typedef ULONG MY_ACCESS_MASK;
|
---|
51 |
|
---|
52 | typedef struct MY_IO_STATUS_BLOCK
|
---|
53 | {
|
---|
54 | union
|
---|
55 | {
|
---|
56 | MY_NTSTATUS Status;
|
---|
57 | PVOID Pointer;
|
---|
58 | } u;
|
---|
59 | ULONG_PTR Information;
|
---|
60 | } MY_IO_STATUS_BLOCK;
|
---|
61 |
|
---|
62 | typedef VOID WINAPI MY_IO_APC_ROUTINE(PVOID, MY_IO_STATUS_BLOCK *, ULONG);
|
---|
63 |
|
---|
64 | typedef struct MY_UNICODE_STRING
|
---|
65 | {
|
---|
66 | USHORT Length;
|
---|
67 | USHORT MaximumLength;
|
---|
68 | PWSTR Buffer;
|
---|
69 | } MY_UNICODE_STRING;
|
---|
70 |
|
---|
71 | typedef struct MY_STRING
|
---|
72 | {
|
---|
73 | USHORT Length;
|
---|
74 | USHORT MaximumLength;
|
---|
75 | PCHAR Buffer;
|
---|
76 | } MY_STRING;
|
---|
77 | typedef MY_STRING MY_ANSI_STRING;
|
---|
78 |
|
---|
79 | typedef struct MY_CURDIR
|
---|
80 | {
|
---|
81 | UNICODE_STRING DosPath;
|
---|
82 | HANDLE Handle;
|
---|
83 | } MY_CURDIR;
|
---|
84 | typedef MY_CURDIR *PMY_CURDIR;
|
---|
85 |
|
---|
86 | typedef struct MY_RTL_DRIVE_LETTER_CURDIR
|
---|
87 | {
|
---|
88 | USHORT Flags;
|
---|
89 | USHORT Length;
|
---|
90 | ULONG TimeStamp;
|
---|
91 | MY_ANSI_STRING DosPath;
|
---|
92 | } MY_RTL_DRIVE_LETTER_CURDIR;
|
---|
93 | typedef MY_RTL_DRIVE_LETTER_CURDIR *PRTL_DRIVE_LETTER_CURDIR;
|
---|
94 |
|
---|
95 | typedef struct MY_RTL_USER_PROCESS_PARAMETERS
|
---|
96 | {
|
---|
97 | ULONG MaximumLength;
|
---|
98 | ULONG Length;
|
---|
99 | ULONG Flags;
|
---|
100 | ULONG DebugFlags;
|
---|
101 | HANDLE ConsoleHandle;
|
---|
102 | ULONG ConsoleFlags;
|
---|
103 | HANDLE StandardInput;
|
---|
104 | HANDLE StandardOutput;
|
---|
105 | HANDLE StandardError;
|
---|
106 | MY_CURDIR CurrentDirectory;
|
---|
107 | MY_UNICODE_STRING DllPath;
|
---|
108 | MY_UNICODE_STRING ImagePathName;
|
---|
109 | MY_UNICODE_STRING CommandLine;
|
---|
110 | PWSTR Environment;
|
---|
111 | ULONG StartingX;
|
---|
112 | ULONG StartingY;
|
---|
113 | ULONG CountX;
|
---|
114 | ULONG CountY;
|
---|
115 | ULONG CountCharsX;
|
---|
116 | ULONG CountCharsY;
|
---|
117 | ULONG FillAttribute;
|
---|
118 | ULONG WindowFlags;
|
---|
119 | ULONG ShowWindowFlags;
|
---|
120 | MY_UNICODE_STRING WindowTitle;
|
---|
121 | MY_UNICODE_STRING DesktopInfo;
|
---|
122 | MY_UNICODE_STRING ShellInfo;
|
---|
123 | MY_UNICODE_STRING RuntimeInfo;
|
---|
124 | MY_RTL_DRIVE_LETTER_CURDIR CurrentDirectories[0x20];
|
---|
125 | SIZE_T EnvironmentSize; /* >= Vista+ */
|
---|
126 | SIZE_T EnvironmentVersion; /* >= Windows 7. */
|
---|
127 | PVOID PackageDependencyData; /* >= Windows 8 or Windows 8.1. */
|
---|
128 | ULONG ProcessGroupId; /* >= Windows 8 or Windows 8.1. */
|
---|
129 | } MY_RTL_USER_PROCESS_PARAMETERS;
|
---|
130 | typedef MY_RTL_USER_PROCESS_PARAMETERS *PMY_RTL_USER_PROCESS_PARAMETERS;
|
---|
131 |
|
---|
132 | typedef struct MY_OBJECT_ATTRIBUTES
|
---|
133 | {
|
---|
134 | ULONG Length;
|
---|
135 | HANDLE RootDirectory;
|
---|
136 | MY_UNICODE_STRING *ObjectName;
|
---|
137 | ULONG Attributes;
|
---|
138 | PVOID SecurityDescriptor;
|
---|
139 | PVOID SecurityQualityOfService;
|
---|
140 | } MY_OBJECT_ATTRIBUTES;
|
---|
141 |
|
---|
142 | #define MyInitializeObjectAttributes(a_pAttr, a_pName, a_fAttribs, a_hRoot, a_pSecDesc) \
|
---|
143 | do { \
|
---|
144 | (a_pAttr)->Length = sizeof(MY_OBJECT_ATTRIBUTES); \
|
---|
145 | (a_pAttr)->RootDirectory = (a_hRoot); \
|
---|
146 | (a_pAttr)->Attributes = (a_fAttribs); \
|
---|
147 | (a_pAttr)->ObjectName = (a_pName); \
|
---|
148 | (a_pAttr)->SecurityDescriptor = (a_pSecDesc); \
|
---|
149 | (a_pAttr)->SecurityQualityOfService = NULL; \
|
---|
150 | } while (0)
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 | typedef struct MY_FILE_BASIC_INFORMATION
|
---|
155 | {
|
---|
156 | LARGE_INTEGER CreationTime;
|
---|
157 | LARGE_INTEGER LastAccessTime;
|
---|
158 | LARGE_INTEGER LastWriteTime;
|
---|
159 | LARGE_INTEGER ChangeTime;
|
---|
160 | ULONG FileAttributes;
|
---|
161 | } MY_FILE_BASIC_INFORMATION;
|
---|
162 |
|
---|
163 | typedef struct MY_FILE_STANDARD_INFORMATION
|
---|
164 | {
|
---|
165 | LARGE_INTEGER AllocationSize;
|
---|
166 | LARGE_INTEGER EndOfFile;
|
---|
167 | ULONG NumberOfLinks;
|
---|
168 | BOOLEAN DeletePending;
|
---|
169 | BOOLEAN Directory;
|
---|
170 | } MY_FILE_STANDARD_INFORMATION;
|
---|
171 |
|
---|
172 | typedef struct MY_FILE_NETWORK_OPEN_INFORMATION
|
---|
173 | {
|
---|
174 | LARGE_INTEGER CreationTime;
|
---|
175 | LARGE_INTEGER LastAccessTime;
|
---|
176 | LARGE_INTEGER LastWriteTime;
|
---|
177 | LARGE_INTEGER ChangeTime;
|
---|
178 | LARGE_INTEGER AllocationSize;
|
---|
179 | LARGE_INTEGER EndOfFile;
|
---|
180 | ULONG FileAttributes;
|
---|
181 | ULONG AlignmentPadding;
|
---|
182 | } MY_FILE_NETWORK_OPEN_INFORMATION;
|
---|
183 |
|
---|
184 | typedef struct MY_FILE_INTERNAL_INFORMATION
|
---|
185 | {
|
---|
186 | LARGE_INTEGER IndexNumber;
|
---|
187 | } MY_FILE_INTERNAL_INFORMATION;
|
---|
188 |
|
---|
189 | typedef struct MY_FILE_EA_INFORMATION
|
---|
190 | {
|
---|
191 | ULONG EaSize;
|
---|
192 | } MY_FILE_EA_INFORMATION;
|
---|
193 |
|
---|
194 | typedef struct MY_FILE_ACCESS_INFORMATION
|
---|
195 | {
|
---|
196 | ACCESS_MASK AccessFlags;
|
---|
197 | } MY_FILE_ACCESS_INFORMATION;
|
---|
198 |
|
---|
199 | typedef struct MY_FILE_POSITION_INFORMATION
|
---|
200 | {
|
---|
201 | LARGE_INTEGER CurrentByteOffset;
|
---|
202 | } MY_FILE_POSITION_INFORMATION;
|
---|
203 |
|
---|
204 | typedef struct MY_FILE_MODE_INFORMATION
|
---|
205 | {
|
---|
206 | ULONG Mode;
|
---|
207 | } MY_FILE_MODE_INFORMATION;
|
---|
208 |
|
---|
209 | typedef struct MY_FILE_ALIGNMENT_INFORMATION
|
---|
210 | {
|
---|
211 | ULONG AlignmentRequirement;
|
---|
212 | } MY_FILE_ALIGNMENT_INFORMATION;
|
---|
213 |
|
---|
214 | typedef struct MY_FILE_NAME_INFORMATION
|
---|
215 | {
|
---|
216 | ULONG FileNameLength;
|
---|
217 | WCHAR FileName[1];
|
---|
218 | } MY_FILE_NAME_INFORMATION;
|
---|
219 |
|
---|
220 | typedef struct MY_FILE_ALL_INFORMATION
|
---|
221 | {
|
---|
222 | MY_FILE_BASIC_INFORMATION BasicInformation;
|
---|
223 | MY_FILE_STANDARD_INFORMATION StandardInformation;
|
---|
224 | MY_FILE_INTERNAL_INFORMATION InternalInformation;
|
---|
225 | MY_FILE_EA_INFORMATION EaInformation;
|
---|
226 | MY_FILE_ACCESS_INFORMATION AccessInformation;
|
---|
227 | MY_FILE_POSITION_INFORMATION PositionInformation;
|
---|
228 | MY_FILE_MODE_INFORMATION ModeInformation;
|
---|
229 | MY_FILE_ALIGNMENT_INFORMATION AlignmentInformation;
|
---|
230 | MY_FILE_NAME_INFORMATION NameInformation;
|
---|
231 | } MY_FILE_ALL_INFORMATION;
|
---|
232 |
|
---|
233 | typedef struct MY_FILE_ATTRIBUTE_TAG_INFORMATION
|
---|
234 | {
|
---|
235 | ULONG FileAttributes;
|
---|
236 | ULONG ReparseTag;
|
---|
237 | } MY_FILE_ATTRIBUTE_TAG_INFORMATION;
|
---|
238 |
|
---|
239 |
|
---|
240 | typedef struct MY_FILE_NAMES_INFORMATION
|
---|
241 | {
|
---|
242 | ULONG NextEntryOffset;
|
---|
243 | ULONG FileIndex;
|
---|
244 | ULONG FileNameLength;
|
---|
245 | WCHAR FileName[1];
|
---|
246 | } MY_FILE_NAMES_INFORMATION;
|
---|
247 | /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */
|
---|
248 | #define MIN_SIZEOF_MY_FILE_NAMES_INFORMATION (4 + 4 + 4)
|
---|
249 |
|
---|
250 |
|
---|
251 | typedef struct MY_FILE_ID_FULL_DIR_INFORMATION
|
---|
252 | {
|
---|
253 | ULONG NextEntryOffset;
|
---|
254 | ULONG FileIndex;
|
---|
255 | LARGE_INTEGER CreationTime;
|
---|
256 | LARGE_INTEGER LastAccessTime;
|
---|
257 | LARGE_INTEGER LastWriteTime;
|
---|
258 | LARGE_INTEGER ChangeTime;
|
---|
259 | LARGE_INTEGER EndOfFile;
|
---|
260 | LARGE_INTEGER AllocationSize;
|
---|
261 | ULONG FileAttributes;
|
---|
262 | ULONG FileNameLength;
|
---|
263 | ULONG EaSize;
|
---|
264 | LARGE_INTEGER FileId;
|
---|
265 | WCHAR FileName[1];
|
---|
266 | } MY_FILE_ID_FULL_DIR_INFORMATION;
|
---|
267 | /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */
|
---|
268 | #define MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION ( (size_t)&((MY_FILE_ID_FULL_DIR_INFORMATION *)0)->FileName )
|
---|
269 |
|
---|
270 | typedef struct MY_FILE_BOTH_DIR_INFORMATION
|
---|
271 | {
|
---|
272 | ULONG NextEntryOffset;
|
---|
273 | ULONG FileIndex;
|
---|
274 | LARGE_INTEGER CreationTime;
|
---|
275 | LARGE_INTEGER LastAccessTime;
|
---|
276 | LARGE_INTEGER LastWriteTime;
|
---|
277 | LARGE_INTEGER ChangeTime;
|
---|
278 | LARGE_INTEGER EndOfFile;
|
---|
279 | LARGE_INTEGER AllocationSize;
|
---|
280 | ULONG FileAttributes;
|
---|
281 | ULONG FileNameLength;
|
---|
282 | ULONG EaSize;
|
---|
283 | CCHAR ShortNameLength;
|
---|
284 | WCHAR ShortName[12];
|
---|
285 | WCHAR FileName[1];
|
---|
286 | } MY_FILE_BOTH_DIR_INFORMATION;
|
---|
287 | /** The sizeof(MY_FILE_BOTH_DIR_INFORMATION) without the FileName. */
|
---|
288 | #define MIN_SIZEOF_MY_FILE_BOTH_DIR_INFORMATION ( (size_t)&((MY_FILE_BOTH_DIR_INFORMATION *)0)->FileName )
|
---|
289 |
|
---|
290 |
|
---|
291 | typedef struct MY_FILE_ID_BOTH_DIR_INFORMATION
|
---|
292 | {
|
---|
293 | ULONG NextEntryOffset;
|
---|
294 | ULONG FileIndex;
|
---|
295 | LARGE_INTEGER CreationTime;
|
---|
296 | LARGE_INTEGER LastAccessTime;
|
---|
297 | LARGE_INTEGER LastWriteTime;
|
---|
298 | LARGE_INTEGER ChangeTime;
|
---|
299 | LARGE_INTEGER EndOfFile;
|
---|
300 | LARGE_INTEGER AllocationSize;
|
---|
301 | ULONG FileAttributes;
|
---|
302 | ULONG FileNameLength;
|
---|
303 | ULONG EaSize;
|
---|
304 | CCHAR ShortNameLength;
|
---|
305 | WCHAR ShortName[12];
|
---|
306 | LARGE_INTEGER FileId;
|
---|
307 | WCHAR FileName[1];
|
---|
308 | } MY_FILE_ID_BOTH_DIR_INFORMATION;
|
---|
309 | /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */
|
---|
310 | #define MIN_SIZEOF_MY_FILE_ID_BOTH_DIR_INFORMATION ( (size_t)&((MY_FILE_ID_BOTH_DIR_INFORMATION *)0)->FileName )
|
---|
311 |
|
---|
312 |
|
---|
313 | typedef struct MY_FILE_DISPOSITION_INFORMATION
|
---|
314 | {
|
---|
315 | BOOLEAN DeleteFile;
|
---|
316 | } MY_FILE_DISPOSITION_INFORMATION;
|
---|
317 |
|
---|
318 |
|
---|
319 | typedef enum MY_FILE_INFORMATION_CLASS
|
---|
320 | {
|
---|
321 | MyFileDirectoryInformation = 1,
|
---|
322 | MyFileFullDirectoryInformation, /* = 2 */
|
---|
323 | MyFileBothDirectoryInformation, /* = 3 */
|
---|
324 | MyFileBasicInformation, /* = 4 */
|
---|
325 | MyFileStandardInformation, /* = 5 */
|
---|
326 | MyFileInternalInformation, /* = 6 */
|
---|
327 | MyFileEaInformation, /* = 7 */
|
---|
328 | MyFileAccessInformation, /* = 8 */
|
---|
329 | MyFileNameInformation, /* = 9 */
|
---|
330 | MyFileRenameInformation, /* = 10 */
|
---|
331 | MyFileLinkInformation, /* = 11 */
|
---|
332 | MyFileNamesInformation, /* = 12 */
|
---|
333 | MyFileDispositionInformation, /* = 13 */
|
---|
334 | MyFilePositionInformation, /* = 14 */
|
---|
335 | MyFileFullEaInformation, /* = 15 */
|
---|
336 | MyFileModeInformation, /* = 16 */
|
---|
337 | MyFileAlignmentInformation, /* = 17 */
|
---|
338 | MyFileAllInformation, /* = 18 */
|
---|
339 | MyFileAllocationInformation, /* = 19 */
|
---|
340 | MyFileEndOfFileInformation, /* = 20 */
|
---|
341 | MyFileAlternateNameInformation, /* = 21 */
|
---|
342 | MyFileStreamInformation, /* = 22 */
|
---|
343 | MyFilePipeInformation, /* = 23 */
|
---|
344 | MyFilePipeLocalInformation, /* = 24 */
|
---|
345 | MyFilePipeRemoteInformation, /* = 25 */
|
---|
346 | MyFileMailslotQueryInformation, /* = 26 */
|
---|
347 | MyFileMailslotSetInformation, /* = 27 */
|
---|
348 | MyFileCompressionInformation, /* = 28 */
|
---|
349 | MyFileObjectIdInformation, /* = 29 */
|
---|
350 | MyFileCompletionInformation, /* = 30 */
|
---|
351 | MyFileMoveClusterInformation, /* = 31 */
|
---|
352 | MyFileQuotaInformation, /* = 32 */
|
---|
353 | MyFileReparsePointInformation, /* = 33 */
|
---|
354 | MyFileNetworkOpenInformation, /* = 34 */
|
---|
355 | MyFileAttributeTagInformation, /* = 35 */
|
---|
356 | MyFileTrackingInformation, /* = 36 */
|
---|
357 | MyFileIdBothDirectoryInformation, /* = 37 */
|
---|
358 | MyFileIdFullDirectoryInformation, /* = 38 */
|
---|
359 | MyFileValidDataLengthInformation, /* = 39 */
|
---|
360 | MyFileShortNameInformation, /* = 40 */
|
---|
361 | MyFileIoCompletionNotificationInformation, /* = 41 */
|
---|
362 | MyFileIoStatusBlockRangeInformation, /* = 42 */
|
---|
363 | MyFileIoPriorityHintInformation, /* = 43 */
|
---|
364 | MyFileSfioReserveInformation, /* = 44 */
|
---|
365 | MyFileSfioVolumeInformation, /* = 45 */
|
---|
366 | MyFileHardLinkInformation, /* = 46 */
|
---|
367 | MyFileProcessIdsUsingFileInformation, /* = 47 */
|
---|
368 | MyFileNormalizedNameInformation, /* = 48 */
|
---|
369 | MyFileNetworkPhysicalNameInformation, /* = 49 */
|
---|
370 | MyFileIdGlobalTxDirectoryInformation, /* = 50 */
|
---|
371 | MyFileIsRemoteDeviceInformation, /* = 51 */
|
---|
372 | MyFileAttributeCacheInformation, /* = 52 */
|
---|
373 | MyFileNumaNodeInformation, /* = 53 */
|
---|
374 | MyFileStandardLinkInformation, /* = 54 */
|
---|
375 | MyFileRemoteProtocolInformation, /* = 55 */
|
---|
376 | MyFileMaximumInformation
|
---|
377 | } MY_FILE_INFORMATION_CLASS;
|
---|
378 |
|
---|
379 |
|
---|
380 | typedef struct MY_FILE_FS_VOLUME_INFORMATION
|
---|
381 | {
|
---|
382 | LARGE_INTEGER VolumeCreationTime;
|
---|
383 | ULONG VolumeSerialNumber;
|
---|
384 | ULONG VolumeLabelLength;
|
---|
385 | BOOLEAN SupportsObjects;
|
---|
386 | WCHAR VolumeLabel[1];
|
---|
387 | } MY_FILE_FS_VOLUME_INFORMATION;
|
---|
388 |
|
---|
389 | typedef struct _MY_FILE_FS_ATTRIBUTE_INFORMATION
|
---|
390 | {
|
---|
391 | ULONG FileSystemAttributes;
|
---|
392 | LONG MaximumComponentNameLength;
|
---|
393 | ULONG FileSystemNameLength;
|
---|
394 | WCHAR FileSystemName[1];
|
---|
395 | } MY_FILE_FS_ATTRIBUTE_INFORMATION;
|
---|
396 |
|
---|
397 | typedef enum MY_FSINFOCLASS
|
---|
398 | {
|
---|
399 | MyFileFsVolumeInformation = 1,
|
---|
400 | MyFileFsLabelInformation, /* = 2 */
|
---|
401 | MyFileFsSizeInformation, /* = 3 */
|
---|
402 | MyFileFsDeviceInformation, /* = 4 */
|
---|
403 | MyFileFsAttributeInformation, /* = 5 */
|
---|
404 | MyFileFsControlInformation, /* = 6 */
|
---|
405 | MyFileFsFullSizeInformation, /* = 7 */
|
---|
406 | MyFileFsObjectIdInformation, /* = 8 */
|
---|
407 | MyFileFsDriverPathInformation, /* = 9 */
|
---|
408 | MyFileFsVolumeFlagsInformation, /* = 10 */
|
---|
409 | MyFileFsMaximumInformation
|
---|
410 | } MY_FS_INFORMATION_CLASS;
|
---|
411 |
|
---|
412 |
|
---|
413 | typedef struct MY_RTLP_CURDIR_REF
|
---|
414 | {
|
---|
415 | LONG RefCount;
|
---|
416 | HANDLE Handle;
|
---|
417 | } MY_RTLP_CURDIR_REF;
|
---|
418 |
|
---|
419 | typedef struct MY_RTL_RELATIVE_NAME_U
|
---|
420 | {
|
---|
421 | MY_UNICODE_STRING RelativeName;
|
---|
422 | HANDLE ContainingDirectory;
|
---|
423 | MY_RTLP_CURDIR_REF CurDirRef;
|
---|
424 | } MY_RTL_RELATIVE_NAME_U;
|
---|
425 |
|
---|
426 |
|
---|
427 | #ifndef OBJ_INHERIT
|
---|
428 | # define OBJ_INHERIT 0x00000002U
|
---|
429 | # define OBJ_PERMANENT 0x00000010U
|
---|
430 | # define OBJ_EXCLUSIVE 0x00000020U
|
---|
431 | # define OBJ_CASE_INSENSITIVE 0x00000040U
|
---|
432 | # define OBJ_OPENIF 0x00000080U
|
---|
433 | # define OBJ_OPENLINK 0x00000100U
|
---|
434 | # define OBJ_KERNEL_HANDLE 0x00000200U
|
---|
435 | # define OBJ_FORCE_ACCESS_CHECK 0x00000400U
|
---|
436 | # define OBJ_VALID_ATTRIBUTES 0x000007f2U
|
---|
437 | #endif
|
---|
438 |
|
---|
439 | #ifndef FILE_OPEN
|
---|
440 | # define FILE_SUPERSEDE 0x00000000U
|
---|
441 | # define FILE_OPEN 0x00000001U
|
---|
442 | # define FILE_CREATE 0x00000002U
|
---|
443 | # define FILE_OPEN_IF 0x00000003U
|
---|
444 | # define FILE_OVERWRITE 0x00000004U
|
---|
445 | # define FILE_OVERWRITE_IF 0x00000005U
|
---|
446 | # define FILE_MAXIMUM_DISPOSITION 0x00000005U
|
---|
447 | #endif
|
---|
448 |
|
---|
449 | #ifndef FILE_DIRECTORY_FILE
|
---|
450 | # define FILE_DIRECTORY_FILE 0x00000001U
|
---|
451 | # define FILE_WRITE_THROUGH 0x00000002U
|
---|
452 | # define FILE_SEQUENTIAL_ONLY 0x00000004U
|
---|
453 | # define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008U
|
---|
454 | # define FILE_SYNCHRONOUS_IO_ALERT 0x00000010U
|
---|
455 | # define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020U
|
---|
456 | # define FILE_NON_DIRECTORY_FILE 0x00000040U
|
---|
457 | # define FILE_CREATE_TREE_CONNECTION 0x00000080U
|
---|
458 | # define FILE_COMPLETE_IF_OPLOCKED 0x00000100U
|
---|
459 | # define FILE_NO_EA_KNOWLEDGE 0x00000200U
|
---|
460 | # define FILE_OPEN_REMOTE_INSTANCE 0x00000400U
|
---|
461 | # define FILE_RANDOM_ACCESS 0x00000800U
|
---|
462 | # define FILE_DELETE_ON_CLOSE 0x00001000U
|
---|
463 | # define FILE_OPEN_BY_FILE_ID 0x00002000U
|
---|
464 | # define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000U
|
---|
465 | # define FILE_NO_COMPRESSION 0x00008000U
|
---|
466 | # define FILE_RESERVE_OPFILTER 0x00100000U
|
---|
467 | # define FILE_OPEN_REPARSE_POINT 0x00200000U
|
---|
468 | # define FILE_OPEN_NO_RECALL 0x00400000U
|
---|
469 | # define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000U
|
---|
470 | #endif
|
---|
471 |
|
---|
472 | #ifndef DUPLICATE_CLOSE_SOURCE /* For the misnomer NtDuplicateObject. */
|
---|
473 | # define DUPLICATE_CLOSE_SOURCE 0x00000001U
|
---|
474 | # define DUPLICATE_SAME_ACCESS 0x00000002U
|
---|
475 | #endif
|
---|
476 | #ifndef DUPLICATE_SAME_ATTRIBUTES
|
---|
477 | # define DUPLICATE_SAME_ATTRIBUTES 0x00000004U
|
---|
478 | #endif
|
---|
479 |
|
---|
480 |
|
---|
481 | /** @name NT status codes and associated macros.
|
---|
482 | * @{ */
|
---|
483 | #define MY_NT_SUCCESS(a_ntRc) ((MY_NTSTATUS)(a_ntRc) >= 0)
|
---|
484 | #define MY_NT_FAILURE(a_ntRc) ((MY_NTSTATUS)(a_ntRc) < 0)
|
---|
485 | #define MY_STATUS_NO_MORE_FILES ((MY_NTSTATUS)0x80000006)
|
---|
486 | #define MY_STATUS_OBJECT_NAME_INVALID ((MY_NTSTATUS)0xc0000033)
|
---|
487 | #define MY_STATUS_OBJECT_NAME_NOT_FOUND ((MY_NTSTATUS)0xc0000034)
|
---|
488 | #define MY_STATUS_OBJECT_PATH_INVALID ((MY_NTSTATUS)0xc0000039)
|
---|
489 | #define MY_STATUS_OBJECT_PATH_NOT_FOUND ((MY_NTSTATUS)0xc000003a)
|
---|
490 | #define MY_STATUS_OBJECT_PATH_SYNTAX_BAD ((MY_NTSTATUS)0xc000003b)
|
---|
491 | /** @} */
|
---|
492 |
|
---|
493 | /** The pseudohandle for the current process. */
|
---|
494 | #define MY_NT_CURRENT_PROCESS ((HANDLE)~(uintptr_t)0)
|
---|
495 | /** The pseudohandle for the current thread. */
|
---|
496 | #define MY_NT_CURRENT_THREAD ((HANDLE)~(uintptr_t)1)
|
---|
497 |
|
---|
498 | typedef struct MY_CLIENT_ID
|
---|
499 | {
|
---|
500 | HANDLE UniqueProcess;
|
---|
501 | HANDLE UniqueThread;
|
---|
502 | } MY_CLIENT_ID;
|
---|
503 |
|
---|
504 | /** Partial TEB. */
|
---|
505 | typedef struct MY_PARTIAL_TEB
|
---|
506 | {
|
---|
507 | NT_TIB NtTib;
|
---|
508 | PVOID EnvironmentPointer;
|
---|
509 | MY_CLIENT_ID ClientId;
|
---|
510 | PVOID ActiveRpcHandle;
|
---|
511 | PVOID ThreadLocalStoragePointer;
|
---|
512 | PPEB ProcessEnvironmentBlock;
|
---|
513 | KU32 LastErrorValue;
|
---|
514 | KU32 CountOfOwnedCriticalSections;
|
---|
515 | PVOID CsrClientThread;
|
---|
516 | PVOID Win32ThreadInfo;
|
---|
517 | } MY_PARTIAL_TEB;
|
---|
518 |
|
---|
519 | /** Internal macro for reading uintptr_t sized TEB members. */
|
---|
520 | #if K_ARCH == K_ARCH_AMD64
|
---|
521 | # define MY_NT_READ_TEB_WORKER(a_offTebMember) ( __readgsqword(a_offTebMember) )
|
---|
522 | #elif K_ARCH == K_ARCH_X86_32
|
---|
523 | # define MY_NT_READ_TEB_WORKER(a_offTebMember) ( __readfsdword(a_offTebMember) )
|
---|
524 | #else
|
---|
525 | # error "Port me!"
|
---|
526 | #endif
|
---|
527 | /** Get the PEB pointer.
|
---|
528 | * @remark Needs stddef.h. */
|
---|
529 | #define MY_NT_CURRENT_PEB() ( (PPEB)MY_NT_READ_TEB_WORKER(offsetof(MY_PARTIAL_TEB, ProcessEnvironmentBlock)) )
|
---|
530 | /** Get the TEB pointer.
|
---|
531 | * @remark Needs stddef.h. */
|
---|
532 | #define MY_NT_CURRENT_TEB() ( (PTEB)MY_NT_READ_TEB_WORKER(offsetof(NT_TIB, Self)) )
|
---|
533 |
|
---|
534 |
|
---|
535 | /*******************************************************************************
|
---|
536 | * Global Variables *
|
---|
537 | *******************************************************************************/
|
---|
538 | extern MY_NTSTATUS (WINAPI * g_pfnNtClose)(HANDLE);
|
---|
539 | extern MY_NTSTATUS (WINAPI * g_pfnNtCreateFile)(PHANDLE, MY_ACCESS_MASK, MY_OBJECT_ATTRIBUTES *, MY_IO_STATUS_BLOCK *,
|
---|
540 | PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG);
|
---|
541 | extern MY_NTSTATUS (WINAPI * g_pfnNtDeleteFile)(MY_OBJECT_ATTRIBUTES *);
|
---|
542 | extern MY_NTSTATUS (WINAPI * g_pfnNtDuplicateObject)(HANDLE hSrcProc, HANDLE hSrc, HANDLE hDstProc, HANDLE *phRet,
|
---|
543 | MY_ACCESS_MASK fDesiredAccess, ULONG fAttribs, ULONG fOptions);
|
---|
544 | extern MY_NTSTATUS (WINAPI * g_pfnNtReadFile)(HANDLE hFile, HANDLE hEvent, MY_IO_APC_ROUTINE *pfnApc, PVOID pvApcCtx,
|
---|
545 | MY_IO_STATUS_BLOCK *, PVOID pvBuf, ULONG cbToRead, PLARGE_INTEGER poffFile,
|
---|
546 | PULONG puKey);
|
---|
547 | extern MY_NTSTATUS (WINAPI * g_pfnNtQueryInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *,
|
---|
548 | PVOID, LONG, MY_FILE_INFORMATION_CLASS);
|
---|
549 | extern MY_NTSTATUS (WINAPI * g_pfnNtQueryVolumeInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *,
|
---|
550 | PVOID, LONG, MY_FS_INFORMATION_CLASS);
|
---|
551 | extern MY_NTSTATUS (WINAPI * g_pfnNtQueryDirectoryFile)(HANDLE, HANDLE, MY_IO_APC_ROUTINE *, PVOID, MY_IO_STATUS_BLOCK *,
|
---|
552 | PVOID, ULONG, MY_FILE_INFORMATION_CLASS, BOOLEAN,
|
---|
553 | MY_UNICODE_STRING *, BOOLEAN);
|
---|
554 | extern MY_NTSTATUS (WINAPI * g_pfnNtQueryAttributesFile)(MY_OBJECT_ATTRIBUTES *, MY_FILE_BASIC_INFORMATION *);
|
---|
555 | extern MY_NTSTATUS (WINAPI * g_pfnNtQueryFullAttributesFile)(MY_OBJECT_ATTRIBUTES *, MY_FILE_NETWORK_OPEN_INFORMATION *);
|
---|
556 | extern MY_NTSTATUS (WINAPI * g_pfnNtSetInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, PVOID, LONG, MY_FILE_INFORMATION_CLASS);
|
---|
557 | extern BOOLEAN (WINAPI * g_pfnRtlDosPathNameToNtPathName_U)(PCWSTR, MY_UNICODE_STRING *, PCWSTR *, MY_RTL_RELATIVE_NAME_U *);
|
---|
558 | extern MY_NTSTATUS (WINAPI * g_pfnRtlAnsiStringToUnicodeString)(MY_UNICODE_STRING *, MY_ANSI_STRING const *, BOOLEAN);
|
---|
559 | extern MY_NTSTATUS (WINAPI * g_pfnRtlUnicodeStringToAnsiString)(MY_ANSI_STRING *, MY_UNICODE_STRING *, BOOLEAN);
|
---|
560 | extern BOOLEAN (WINAPI * g_pfnRtlEqualUnicodeString)(MY_UNICODE_STRING const *pUniStr1, MY_UNICODE_STRING const *pUniStr2,
|
---|
561 | BOOLEAN fCaseInsensitive);
|
---|
562 | extern BOOLEAN (WINAPI * g_pfnRtlEqualString)(MY_ANSI_STRING const *pAnsiStr1, MY_ANSI_STRING const *pAnsiStr2,
|
---|
563 | BOOLEAN fCaseInsensitive);
|
---|
564 | extern UCHAR (WINAPI * g_pfnRtlUpperChar)(UCHAR uch);
|
---|
565 | extern ULONG (WINAPI * g_pfnRtlNtStatusToDosError)(MY_NTSTATUS rcNt);
|
---|
566 | extern VOID (WINAPI * g_pfnRtlAcquirePebLock)(VOID);
|
---|
567 | extern VOID (WINAPI * g_pfnRtlReleasePebLock)(VOID);
|
---|
568 |
|
---|
569 |
|
---|
570 | /** @} */
|
---|
571 |
|
---|
572 | #endif
|
---|
573 |
|
---|