1 /* $Id: ntstuff.h 3021 2017-01-07 16:52:16Z bird $ */ 2 /** @file 3 * Definitions, types, prototypes and globals for NT. 4 */ 5 6 /* 7 * Copyright (c) 2005-2013 knut st. osmundsen <bird-kBuild-spamx@anduin.net> 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 } MY_FILE_NETWORK_OPEN_INFORMATION; 182 183 typedef struct MY_FILE_INTERNAL_INFORMATION 184 { 185 LARGE_INTEGER IndexNumber; 186 } MY_FILE_INTERNAL_INFORMATION; 187 188 typedef struct MY_FILE_EA_INFORMATION 189 { 190 ULONG EaSize; 191 } MY_FILE_EA_INFORMATION; 192 193 typedef struct MY_FILE_ACCESS_INFORMATION 194 { 195 ACCESS_MASK AccessFlags; 196 } MY_FILE_ACCESS_INFORMATION; 197 198 typedef struct MY_FILE_POSITION_INFORMATION 199 { 200 LARGE_INTEGER CurrentByteOffset; 201 } MY_FILE_POSITION_INFORMATION; 202 203 typedef struct MY_FILE_MODE_INFORMATION 204 { 205 ULONG Mode; 206 } MY_FILE_MODE_INFORMATION; 207 208 typedef struct MY_FILE_ALIGNMENT_INFORMATION 209 { 210 ULONG AlignmentRequirement; 211 } MY_FILE_ALIGNMENT_INFORMATION; 212 213 typedef struct MY_FILE_NAME_INFORMATION 214 { 215 ULONG FileNameLength; 216 WCHAR FileName[1]; 217 } MY_FILE_NAME_INFORMATION; 218 219 typedef struct MY_FILE_ALL_INFORMATION 220 { 221 MY_FILE_BASIC_INFORMATION BasicInformation; 222 MY_FILE_STANDARD_INFORMATION StandardInformation; 223 MY_FILE_INTERNAL_INFORMATION InternalInformation; 224 MY_FILE_EA_INFORMATION EaInformation; 225 MY_FILE_ACCESS_INFORMATION AccessInformation; 226 MY_FILE_POSITION_INFORMATION PositionInformation; 227 MY_FILE_MODE_INFORMATION ModeInformation; 228 MY_FILE_ALIGNMENT_INFORMATION AlignmentInformation; 229 MY_FILE_NAME_INFORMATION NameInformation; 230 } MY_FILE_ALL_INFORMATION; 231 232 typedef struct MY_FILE_ATTRIBUTE_TAG_INFORMATION 233 { 234 ULONG FileAttributes; 235 ULONG ReparseTag; 236 } MY_FILE_ATTRIBUTE_TAG_INFORMATION; 237 238 239 typedef struct MY_FILE_NAMES_INFORMATION 240 { 241 ULONG NextEntryOffset; 242 ULONG FileIndex; 243 ULONG FileNameLength; 244 WCHAR FileName[1]; 245 } MY_FILE_NAMES_INFORMATION; 246 /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */ 247 #define MIN_SIZEOF_MY_FILE_NAMES_INFORMATION (4 + 4 + 4) 248 249 250 typedef struct MY_FILE_ID_FULL_DIR_INFORMATION 251 { 252 ULONG NextEntryOffset; 253 ULONG FileIndex; 254 LARGE_INTEGER CreationTime; 255 LARGE_INTEGER LastAccessTime; 256 LARGE_INTEGER LastWriteTime; 257 LARGE_INTEGER ChangeTime; 258 LARGE_INTEGER EndOfFile; 259 LARGE_INTEGER AllocationSize; 260 ULONG FileAttributes; 261 ULONG FileNameLength; 262 ULONG EaSize; 263 LARGE_INTEGER FileId; 264 WCHAR FileName[1]; 265 } MY_FILE_ID_FULL_DIR_INFORMATION; 266 /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */ 267 #define MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION ( (size_t)&((MY_FILE_ID_FULL_DIR_INFORMATION *)0)->FileName ) 268 269 typedef struct MY_FILE_BOTH_DIR_INFORMATION 270 { 271 ULONG NextEntryOffset; 272 ULONG FileIndex; 273 LARGE_INTEGER CreationTime; 274 LARGE_INTEGER LastAccessTime; 275 LARGE_INTEGER LastWriteTime; 276 LARGE_INTEGER ChangeTime; 277 LARGE_INTEGER EndOfFile; 278 LARGE_INTEGER AllocationSize; 279 ULONG FileAttributes; 280 ULONG FileNameLength; 281 ULONG EaSize; 282 CCHAR ShortNameLength; 283 WCHAR ShortName[12]; 284 WCHAR FileName[1]; 285 } MY_FILE_BOTH_DIR_INFORMATION; 286 /** The sizeof(MY_FILE_BOTH_DIR_INFORMATION) without the FileName. */ 287 #define MIN_SIZEOF_MY_FILE_BOTH_DIR_INFORMATION ( (size_t)&((MY_FILE_BOTH_DIR_INFORMATION *)0)->FileName ) 288 289 290 typedef struct MY_FILE_ID_BOTH_DIR_INFORMATION 291 { 292 ULONG NextEntryOffset; 293 ULONG FileIndex; 294 LARGE_INTEGER CreationTime; 295 LARGE_INTEGER LastAccessTime; 296 LARGE_INTEGER LastWriteTime; 297 LARGE_INTEGER ChangeTime; 298 LARGE_INTEGER EndOfFile; 299 LARGE_INTEGER AllocationSize; 300 ULONG FileAttributes; 301 ULONG FileNameLength; 302 ULONG EaSize; 303 CCHAR ShortNameLength; 304 WCHAR ShortName[12]; 305 LARGE_INTEGER FileId; 306 WCHAR FileName[1]; 307 } MY_FILE_ID_BOTH_DIR_INFORMATION; 308 /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */ 309 #define MIN_SIZEOF_MY_FILE_ID_BOTH_DIR_INFORMATION ( (size_t)&((MY_FILE_ID_BOTH_DIR_INFORMATION *)0)->FileName ) 310 311 312 typedef struct MY_FILE_DISPOSITION_INFORMATION 313 { 314 BOOLEAN DeleteFile; 315 } MY_FILE_DISPOSITION_INFORMATION; 316 317 318 typedef enum MY_FILE_INFORMATION_CLASS 319 { 320 MyFileDirectoryInformation = 1, 321 MyFileFullDirectoryInformation, /* = 2 */ 322 MyFileBothDirectoryInformation, /* = 3 */ 323 MyFileBasicInformation, /* = 4 */ 324 MyFileStandardInformation, /* = 5 */ 325 MyFileInternalInformation, /* = 6 */ 326 MyFileEaInformation, /* = 7 */ 327 MyFileAccessInformation, /* = 8 */ 328 MyFileNameInformation, /* = 9 */ 329 MyFileRenameInformation, /* = 10 */ 330 MyFileLinkInformation, /* = 11 */ 331 MyFileNamesInformation, /* = 12 */ 332 MyFileDispositionInformation, /* = 13 */ 333 MyFilePositionInformation, /* = 14 */ 334 MyFileFullEaInformation, /* = 15 */ 335 MyFileModeInformation, /* = 16 */ 336 MyFileAlignmentInformation, /* = 17 */ 337 MyFileAllInformation, /* = 18 */ 338 MyFileAllocationInformation, /* = 19 */ 339 MyFileEndOfFileInformation, /* = 20 */ 340 MyFileAlternateNameInformation, /* = 21 */ 341 MyFileStreamInformation, /* = 22 */ 342 MyFilePipeInformation, /* = 23 */ 343 MyFilePipeLocalInformation, /* = 24 */ 344 MyFilePipeRemoteInformation, /* = 25 */ 345 MyFileMailslotQueryInformation, /* = 26 */ 346 MyFileMailslotSetInformation, /* = 27 */ 347 MyFileCompressionInformation, /* = 28 */ 348 MyFileObjectIdInformation, /* = 29 */ 349 MyFileCompletionInformation, /* = 30 */ 350 MyFileMoveClusterInformation, /* = 31 */ 351 MyFileQuotaInformation, /* = 32 */ 352 MyFileReparsePointInformation, /* = 33 */ 353 MyFileNetworkOpenInformation, /* = 34 */ 354 MyFileAttributeTagInformation, /* = 35 */ 355 MyFileTrackingInformation, /* = 36 */ 356 MyFileIdBothDirectoryInformation, /* = 37 */ 357 MyFileIdFullDirectoryInformation, /* = 38 */ 358 MyFileValidDataLengthInformation, /* = 39 */ 359 MyFileShortNameInformation, /* = 40 */ 360 MyFileIoCompletionNotificationInformation, /* = 41 */ 361 MyFileIoStatusBlockRangeInformation, /* = 42 */ 362 MyFileIoPriorityHintInformation, /* = 43 */ 363 MyFileSfioReserveInformation, /* = 44 */ 364 MyFileSfioVolumeInformation, /* = 45 */ 365 MyFileHardLinkInformation, /* = 46 */ 366 MyFileProcessIdsUsingFileInformation, /* = 47 */ 367 MyFileNormalizedNameInformation, /* = 48 */ 368 MyFileNetworkPhysicalNameInformation, /* = 49 */ 369 MyFileIdGlobalTxDirectoryInformation, /* = 50 */ 370 MyFileIsRemoteDeviceInformation, /* = 51 */ 371 MyFileAttributeCacheInformation, /* = 52 */ 372 MyFileNumaNodeInformation, /* = 53 */ 373 MyFileStandardLinkInformation, /* = 54 */ 374 MyFileRemoteProtocolInformation, /* = 55 */ 375 MyFileMaximumInformation 376 } MY_FILE_INFORMATION_CLASS; 377 378 379 typedef struct MY_FILE_FS_VOLUME_INFORMATION 380 { 381 LARGE_INTEGER VolumeCreationTime; 382 ULONG VolumeSerialNumber; 383 ULONG VolumeLabelLength; 384 BOOLEAN SupportsObjects; 385 WCHAR VolumeLabel[1]; 386 } MY_FILE_FS_VOLUME_INFORMATION; 387 388 typedef struct _MY_FILE_FS_ATTRIBUTE_INFORMATION 389 { 390 ULONG FileSystemAttributes; 391 LONG MaximumComponentNameLength; 392 ULONG FileSystemNameLength; 393 WCHAR FileSystemName[1]; 394 } MY_FILE_FS_ATTRIBUTE_INFORMATION; 395 396 typedef enum MY_FSINFOCLASS 397 { 398 MyFileFsVolumeInformation = 1, 399 MyFileFsLabelInformation, /* = 2 */ 400 MyFileFsSizeInformation, /* = 3 */ 401 MyFileFsDeviceInformation, /* = 4 */ 402 MyFileFsAttributeInformation, /* = 5 */ 403 MyFileFsControlInformation, /* = 6 */ 404 MyFileFsFullSizeInformation, /* = 7 */ 405 MyFileFsObjectIdInformation, /* = 8 */ 406 MyFileFsDriverPathInformation, /* = 9 */ 407 MyFileFsVolumeFlagsInformation, /* = 10 */ 408 MyFileFsMaximumInformation 409 } MY_FS_INFORMATION_CLASS; 410 411 412 typedef struct MY_RTLP_CURDIR_REF 413 { 414 LONG RefCount; 415 HANDLE Handle; 416 } MY_RTLP_CURDIR_REF; 417 418 typedef struct MY_RTL_RELATIVE_NAME_U 419 { 420 MY_UNICODE_STRING RelativeName; 421 HANDLE ContainingDirectory; 422 MY_RTLP_CURDIR_REF CurDirRef; 423 } MY_RTL_RELATIVE_NAME_U; 424 425 426 #ifndef OBJ_INHERIT 427 # define OBJ_INHERIT 0x00000002U 428 # define OBJ_PERMANENT 0x00000010U 429 # define OBJ_EXCLUSIVE 0x00000020U 430 # define OBJ_CASE_INSENSITIVE 0x00000040U 431 # define OBJ_OPENIF 0x00000080U 432 # define OBJ_OPENLINK 0x00000100U 433 # define OBJ_KERNEL_HANDLE 0x00000200U 434 # define OBJ_FORCE_ACCESS_CHECK 0x00000400U 435 # define OBJ_VALID_ATTRIBUTES 0x000007f2U 436 #endif 437 438 #ifndef FILE_OPEN 439 # define FILE_SUPERSEDE 0x00000000U 440 # define FILE_OPEN 0x00000001U 441 # define FILE_CREATE 0x00000002U 442 # define FILE_OPEN_IF 0x00000003U 443 # define FILE_OVERWRITE 0x00000004U 444 # define FILE_OVERWRITE_IF 0x00000005U 445 # define FILE_MAXIMUM_DISPOSITION 0x00000005U 446 #endif 447 448 #ifndef FILE_DIRECTORY_FILE 449 # define FILE_DIRECTORY_FILE 0x00000001U 450 # define FILE_WRITE_THROUGH 0x00000002U 451 # define FILE_SEQUENTIAL_ONLY 0x00000004U 452 # define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008U 453 # define FILE_SYNCHRONOUS_IO_ALERT 0x00000010U 454 # define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020U 455 # define FILE_NON_DIRECTORY_FILE 0x00000040U 456 # define FILE_CREATE_TREE_CONNECTION 0x00000080U 457 # define FILE_COMPLETE_IF_OPLOCKED 0x00000100U 458 # define FILE_NO_EA_KNOWLEDGE 0x00000200U 459 # define FILE_OPEN_REMOTE_INSTANCE 0x00000400U 460 # define FILE_RANDOM_ACCESS 0x00000800U 461 # define FILE_DELETE_ON_CLOSE 0x00001000U 462 # define FILE_OPEN_BY_FILE_ID 0x00002000U 463 # define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000U 464 # define FILE_NO_COMPRESSION 0x00008000U 465 # define FILE_RESERVE_OPFILTER 0x00100000U 466 # define FILE_OPEN_REPARSE_POINT 0x00200000U 467 # define FILE_OPEN_NO_RECALL 0x00400000U 468 # define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000U 469 #endif 470 471 #ifndef DUPLICATE_CLOSE_SOURCE /* For the misnomer NtDuplicateObject. */ 472 # define DUPLICATE_CLOSE_SOURCE 0x00000001U 473 # define DUPLICATE_SAME_ACCESS 0x00000002U 474 #endif 475 #ifndef DUPLICATE_SAME_ATTRIBUTES 476 # define DUPLICATE_SAME_ATTRIBUTES 0x00000004U 477 #endif 478 479 480 /** @name NT status codes and associated macros. 481 * @{ */ 482 #define MY_NT_SUCCESS(a_ntRc) ((MY_NTSTATUS)(a_ntRc) >= 0) 483 #define MY_NT_FAILURE(a_ntRc) ((MY_NTSTATUS)(a_ntRc) < 0) 484 #define MY_STATUS_NO_MORE_FILES ((MY_NTSTATUS)0x80000006) 485 #define MY_STATUS_OBJECT_NAME_INVALID ((MY_NTSTATUS)0xc0000033) 486 #define MY_STATUS_OBJECT_NAME_NOT_FOUND ((MY_NTSTATUS)0xc0000034) 487 #define MY_STATUS_OBJECT_PATH_INVALID ((MY_NTSTATUS)0xc0000039) 488 #define MY_STATUS_OBJECT_PATH_NOT_FOUND ((MY_NTSTATUS)0xc000003a) 489 #define MY_STATUS_OBJECT_PATH_SYNTAX_BAD ((MY_NTSTATUS)0xc000003b) 490 /** @} */ 491 492 /** The pseudohandle for the current process. */ 493 #define MY_NT_CURRENT_PROCESS ((HANDLE)~(uintptr_t)0) 494 /** The pseudohandle for the current thread. */ 495 #define MY_NT_CURRENT_THREAD ((HANDLE)~(uintptr_t)1) 496 497 typedef struct MY_CLIENT_ID 498 { 499 HANDLE UniqueProcess; 500 HANDLE UniqueThread; 501 } MY_CLIENT_ID; 502 503 /** Partial TEB. */ 504 typedef struct MY_PARTIAL_TEB 505 { 506 NT_TIB NtTib; 507 PVOID EnvironmentPointer; 508 MY_CLIENT_ID ClientId; 509 PVOID ActiveRpcHandle; 510 PVOID ThreadLocalStoragePointer; 511 PPEB ProcessEnvironmentBlock; 512 KU32 LastErrorValue; 513 KU32 CountOfOwnedCriticalSections; 514 PVOID CsrClientThread; 515 PVOID Win32ThreadInfo; 516 } MY_PARTIAL_TEB; 517 518 /** Internal macro for reading uintptr_t sized TEB members. */ 519 #if K_ARCH == K_ARCH_AMD64 520 # define MY_NT_READ_TEB_WORKER(a_offTebMember) ( __readgsqword(a_offTebMember) ) 521 #elif K_ARCH == K_ARCH_X86_32 522 # define MY_NT_READ_TEB_WORKER(a_offTebMember) ( __readfsdword(a_offTebMember) ) 523 #else 524 # error "Port me!" 525 #endif 526 /** Get the PEB pointer. 527 * @remark Needs stddef.h. */ 528 #define MY_NT_CURRENT_PEB() ( (PPEB)MY_NT_READ_TEB_WORKER(offsetof(MY_PARTIAL_TEB, ProcessEnvironmentBlock)) ) 529 /** Get the TEB pointer. 530 * @remark Needs stddef.h. */ 531 #define MY_NT_CURRENT_TEB() ( (PTEB)MY_NT_READ_TEB_WORKER(offsetof(NT_TIB, Self)) ) 532 533 534 /******************************************************************************* 535 * Global Variables * 536 *******************************************************************************/ 537 extern MY_NTSTATUS (WINAPI * g_pfnNtClose)(HANDLE); 538 extern MY_NTSTATUS (WINAPI * g_pfnNtCreateFile)(PHANDLE, MY_ACCESS_MASK, MY_OBJECT_ATTRIBUTES *, MY_IO_STATUS_BLOCK *, 539 PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG); 540 extern MY_NTSTATUS (WINAPI * g_pfnNtDeleteFile)(MY_OBJECT_ATTRIBUTES *); 541 extern MY_NTSTATUS (WINAPI * g_pfnNtDuplicateObject)(HANDLE hSrcProc, HANDLE hSrc, HANDLE hDstProc, HANDLE *phRet, 542 MY_ACCESS_MASK fDesiredAccess, ULONG fAttribs, ULONG fOptions); 543 extern MY_NTSTATUS (WINAPI * g_pfnNtReadFile)(HANDLE hFile, HANDLE hEvent, MY_IO_APC_ROUTINE *pfnApc, PVOID pvApcCtx, 544 MY_IO_STATUS_BLOCK *, PVOID pvBuf, ULONG cbToRead, PLARGE_INTEGER poffFile, 545 PULONG puKey); 546 extern MY_NTSTATUS (WINAPI * g_pfnNtQueryInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, 547 PVOID, LONG, MY_FILE_INFORMATION_CLASS); 548 extern MY_NTSTATUS (WINAPI * g_pfnNtQueryVolumeInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, 549 PVOID, LONG, MY_FS_INFORMATION_CLASS); 550 extern MY_NTSTATUS (WINAPI * g_pfnNtQueryDirectoryFile)(HANDLE, HANDLE, MY_IO_APC_ROUTINE *, PVOID, MY_IO_STATUS_BLOCK *, 551 PVOID, ULONG, MY_FILE_INFORMATION_CLASS, BOOLEAN, 552 MY_UNICODE_STRING *, BOOLEAN); 553 extern MY_NTSTATUS (WINAPI * g_pfnNtQueryAttributesFile)(MY_OBJECT_ATTRIBUTES *, MY_FILE_BASIC_INFORMATION *); 554 extern MY_NTSTATUS (WINAPI * g_pfnNtQueryFullAttributesFile)(MY_OBJECT_ATTRIBUTES *, MY_FILE_NETWORK_OPEN_INFORMATION *); 555 extern MY_NTSTATUS (WINAPI * g_pfnNtSetInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, PVOID, LONG, MY_FILE_INFORMATION_CLASS); 556 extern BOOLEAN (WINAPI * g_pfnRtlDosPathNameToNtPathName_U)(PCWSTR, MY_UNICODE_STRING *, PCWSTR *, MY_RTL_RELATIVE_NAME_U *); 557 extern MY_NTSTATUS (WINAPI * g_pfnRtlAnsiStringToUnicodeString)(MY_UNICODE_STRING *, MY_ANSI_STRING const *, BOOLEAN); 558 extern MY_NTSTATUS (WINAPI * g_pfnRtlUnicodeStringToAnsiString)(MY_ANSI_STRING *, MY_UNICODE_STRING *, BOOLEAN); 559 extern BOOLEAN (WINAPI * g_pfnRtlEqualUnicodeString)(MY_UNICODE_STRING const *pUniStr1, MY_UNICODE_STRING const *pUniStr2, 560 BOOLEAN fCaseInsensitive); 561 extern BOOLEAN (WINAPI * g_pfnRtlEqualString)(MY_ANSI_STRING const *pAnsiStr1, MY_ANSI_STRING const *pAnsiStr2, 562 BOOLEAN fCaseInsensitive); 563 extern UCHAR (WINAPI * g_pfnRtlUpperChar)(UCHAR uch); 564 extern ULONG (WINAPI * g_pfnRtlNtStatusToDosError)(MY_NTSTATUS rcNt); 565 extern VOID (WINAPI * g_pfnRtlAcquirePebLock)(VOID); 566 extern VOID (WINAPI * g_pfnRtlReleasePebLock)(VOID); 567 568 569 /** @} */ 570 571 #endif 572 573