github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/dokan/dokan_header/fileinfo.h (about) 1 /* 2 Dokan : user-mode file system library for Windows 3 4 Copyright (C) 2015 - 2018 Adrien J. <liryna.stark@gmail.com> and Maxime C. <maxime@islog.com> 5 Copyright (C) 2007 - 2011 Hiroki Asakawa <info@dokan-dev.net> 6 7 http://dokan-dev.github.io 8 9 This program is free software; you can redistribute it and/or modify it under 10 the terms of the GNU Lesser General Public License as published by the Free 11 Software Foundation; either version 3 of the License, or (at your option) any 12 later version. 13 14 This program is distributed in the hope that it will be useful, but WITHOUT ANY 15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public License along 19 with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef FILEINFO_H_ 23 #define FILEINFO_H_ 24 25 #define IRP_MJ_CREATE 0x00 26 #define IRP_MJ_CREATE_NAMED_PIPE 0x01 27 #define IRP_MJ_CLOSE 0x02 28 #define IRP_MJ_READ 0x03 29 #define IRP_MJ_WRITE 0x04 30 #define IRP_MJ_QUERY_INFORMATION 0x05 31 #define IRP_MJ_SET_INFORMATION 0x06 32 #define IRP_MJ_QUERY_EA 0x07 33 #define IRP_MJ_SET_EA 0x08 34 #define IRP_MJ_FLUSH_BUFFERS 0x09 35 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a 36 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b 37 #define IRP_MJ_DIRECTORY_CONTROL 0x0c 38 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d 39 #define IRP_MJ_DEVICE_CONTROL 0x0e 40 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f 41 #define IRP_MJ_SHUTDOWN 0x10 42 #define IRP_MJ_LOCK_CONTROL 0x11 43 #define IRP_MJ_CLEANUP 0x12 44 #define IRP_MJ_CREATE_MAILSLOT 0x13 45 #define IRP_MJ_QUERY_SECURITY 0x14 46 #define IRP_MJ_SET_SECURITY 0x15 47 #define IRP_MJ_POWER 0x16 48 #define IRP_MJ_SYSTEM_CONTROL 0x17 49 #define IRP_MJ_DEVICE_CHANGE 0x18 50 #define IRP_MJ_QUERY_QUOTA 0x19 51 #define IRP_MJ_SET_QUOTA 0x1a 52 #define IRP_MJ_PNP 0x1b 53 #define IRP_MJ_PNP_POWER IRP_MJ_PNP 54 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b 55 56 #define IRP_MN_LOCK 0x01 57 #define IRP_MN_UNLOCK_SINGLE 0x02 58 #define IRP_MN_UNLOCK_ALL 0x03 59 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04 60 61 typedef enum _FILE_INFORMATION_CLASS { 62 FileDirectoryInformation = 1, 63 FileFullDirectoryInformation, // 2 64 FileBothDirectoryInformation, // 3 65 FileBasicInformation, // 4 66 FileStandardInformation, // 5 67 FileInternalInformation, // 6 68 FileEaInformation, // 7 69 FileAccessInformation, // 8 70 FileNameInformation, // 9 71 FileRenameInformation, // 10 72 FileLinkInformation, // 11 73 FileNamesInformation, // 12 74 FileDispositionInformation, // 13 75 FilePositionInformation, // 14 76 FileFullEaInformation, // 15 77 FileModeInformation, // 16 78 FileAlignmentInformation, // 17 79 FileAllInformation, // 18 80 FileAllocationInformation, // 19 81 FileEndOfFileInformation, // 20 82 FileAlternateNameInformation, // 21 83 FileStreamInformation, // 22 84 FilePipeInformation, // 23 85 FilePipeLocalInformation, // 24 86 FilePipeRemoteInformation, // 25 87 FileMailslotQueryInformation, // 26 88 FileMailslotSetInformation, // 27 89 FileCompressionInformation, // 28 90 FileObjectIdInformation, // 29 91 FileCompletionInformation, // 30 92 FileMoveClusterInformation, // 31 93 FileQuotaInformation, // 32 94 FileReparsePointInformation, // 33 95 FileNetworkOpenInformation, // 34 96 FileAttributeTagInformation, // 35 97 FileTrackingInformation, // 36 98 FileIdBothDirectoryInformation, // 37 99 FileIdFullDirectoryInformation, // 38 100 FileValidDataLengthInformation, // 39 101 FileShortNameInformation, // 40 102 FileIoCompletionNotificationInformation, // 41 103 FileIoStatusBlockRangeInformation, // 42 104 FileIoPriorityHintInformation, // 43 105 FileSfioReserveInformation, // 44 106 FileSfioVolumeInformation, // 45 107 FileHardLinkInformation, // 46 108 FileProcessIdsUsingFileInformation, // 47 109 FileNormalizedNameInformation, // 48 110 FileNetworkPhysicalNameInformation, // 49 111 FileIdGlobalTxDirectoryInformation, // 50 112 FileIsRemoteDeviceInformation, // 51 113 FileUnusedInformation, // 52 114 FileNumaNodeInformation, // 53 115 FileStandardLinkInformation, // 54 116 FileRemoteProtocolInformation, // 55 117 118 // 119 // These are special versions of these operations (defined earlier) 120 // which can be used by kernel mode drivers only to bypass security 121 // access checks for Rename and HardLink operations. These operations 122 // are only recognized by the IOManager, a file system should never 123 // receive these. 124 // 125 126 FileRenameInformationBypassAccessCheck, // 56 127 FileLinkInformationBypassAccessCheck, // 57 128 129 // 130 // End of special information classes reserved for IOManager. 131 // 132 133 FileVolumeNameInformation, // 58 134 FileIdInformation, // 59 135 FileIdExtdDirectoryInformation, // 60 136 FileReplaceCompletionInformation, // 61 137 FileHardLinkFullIdInformation, // 62 138 FileIdExtdBothDirectoryInformation, // 63 139 FileDispositionInformationEx, // 64 140 FileRenameInformationEx, // 65 141 FileRenameInformationExBypassAccessCheck, // 66 142 FileDesiredStorageClassInformation, // 67 143 FileStatInformation, // 68 144 FileMemoryPartitionInformation, // 69 145 146 FileMaximumInformation 147 } FILE_INFORMATION_CLASS, 148 *PFILE_INFORMATION_CLASS; 149 150 typedef enum _FSINFOCLASS { 151 FileFsVolumeInformation = 1, 152 FileFsLabelInformation, // 2 153 FileFsSizeInformation, // 3 154 FileFsDeviceInformation, // 4 155 FileFsAttributeInformation, // 5 156 FileFsControlInformation, // 6 157 FileFsFullSizeInformation, // 7 158 FileFsObjectIdInformation, // 8 159 FileFsDriverPathInformation, // 9 160 FileFsVolumeFlagsInformation, // 10 161 FileFsMaximumInformation 162 } FS_INFORMATION_CLASS, 163 *PFS_INFORMATION_CLASS; 164 165 /** 166 * \struct FILE_ALIGNMENT_INFORMATION 167 * \brief Used as an argument to the ZwQueryInformationFile routine. 168 * 169 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileAllInformation 170 */ 171 typedef struct _FILE_ALIGNMENT_INFORMATION { 172 /** 173 * The buffer alignment required by the underlying device. For a list of system-defined values, see DEVICE_OBJECT. 174 * The value must be one of the FILE_XXX_ALIGNMENT values defined in Wdm.h. 175 * For more information, see DEVICE_OBJECT and Initializing a Device Object. 176 */ 177 ULONG AlignmentRequirement; 178 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; 179 180 /** 181 * \struct FILE_NAME_INFORMATION 182 * \brief Used as argument to the ZwQueryInformationFile and ZwSetInformationFile routines. 183 * 184 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileNameInformation 185 */ 186 typedef struct _FILE_NAME_INFORMATION { 187 /** 188 * Specifies the length, in bytes, of the file name string. 189 */ 190 ULONG FileNameLength; 191 /** 192 * Specifies the first character of the file name string. This is followed in memory by the remainder of the string. 193 */ 194 WCHAR FileName[1]; 195 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; 196 197 /** 198 * \struct FILE_ATTRIBUTE_TAG_INFORMATION 199 * \brief Used as an argument to ZwQueryInformationFile. 200 * 201 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileAttributeTagInformation 202 */ 203 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { 204 /** 205 * Specifies one or more FILE_ATTRIBUTE_XXX flags. 206 * For descriptions of these flags, see the documentation of the GetFileAttributes function in the Microsoft Windows SDK. 207 */ 208 ULONG FileAttributes; 209 /** 210 * Specifies the reparse point tag. If the FileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute flag, 211 * this member specifies the reparse tag. Otherwise, this member is unused. 212 */ 213 ULONG ReparseTag; 214 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; 215 216 /** 217 * \struct FILE_DISPOSITION_INFORMATION 218 * \brief Used as an argument to the ZwSetInformationFile routine. 219 * 220 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileDispositionInformation 221 */ 222 typedef struct _FILE_DISPOSITION_INFORMATION { 223 /** 224 * Indicates whether the operating system file should delete the file when the file is closed. 225 * Set this member to TRUE to delete the file when it is closed. 226 * Otherwise, set to FALSE. Setting this member to FALSE has no effect if the handle was opened with FILE_FLAG_DELETE_ON_CLOSE. 227 */ 228 BOOLEAN DeleteFile; 229 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; 230 231 /** 232 * \struct FILE_END_OF_FILE_INFORMATION 233 * \brief Used as an argument to the ZwSetInformationFile routine. 234 * 235 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileEndOfFileInformation 236 */ 237 typedef struct _FILE_END_OF_FILE_INFORMATION { 238 /** 239 * The absolute new end of file position as a byte offset from the start of the file. 240 */ 241 LARGE_INTEGER EndOfFile; 242 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; 243 244 /** 245 * \struct FILE_VALID_DATA_LENGTH_INFORMATION 246 * \brief Used as an argument to ZwSetInformationFile. 247 * 248 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileValidDataLengthInformation 249 */ 250 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { 251 /** 252 * Specifies the new valid data length for the file. 253 * This parameter must be a positive value that is greater than the current valid data length, but less than or equal to the current file size. 254 */ 255 LARGE_INTEGER ValidDataLength; 256 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; 257 258 /** 259 * \struct FILE_BASIC_INFORMATION 260 * \brief Used as an argument to routines that query or set file information. 261 * 262 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileBasicInformation and FileAllInformation 263 */ 264 typedef struct _FILE_BASIC_INFORMATION { 265 /** 266 * Specifies the time that the file was created. 267 */ 268 LARGE_INTEGER CreationTime; 269 /** 270 * Specifies the time that the file was last accessed. 271 */ 272 LARGE_INTEGER LastAccessTime; 273 /** 274 * Specifies the time that the file was last written to. 275 */ 276 LARGE_INTEGER LastWriteTime; 277 /** 278 * Specifies the last time the file was changed. 279 */ 280 LARGE_INTEGER ChangeTime; 281 /** 282 * Specifies one or more FILE_ATTRIBUTE_XXX flags. For descriptions of these flags, 283 * see the documentation for the GetFileAttributes function in the Microsoft Windows SDK. 284 */ 285 ULONG FileAttributes; 286 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; 287 288 /** 289 * \struct FILE_STANDARD_INFORMATION 290 * \brief Used as an argument to routines that query or set file information. 291 * 292 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileStandardInformation and FileAllInformation 293 */ 294 typedef struct _FILE_STANDARD_INFORMATION { 295 /** 296 * The file allocation size in bytes. Usually, this value is a multiple of the sector or cluster size of the underlying physical device. 297 */ 298 LARGE_INTEGER AllocationSize; 299 /** 300 * The end of file location as a byte offset. 301 */ 302 LARGE_INTEGER EndOfFile; 303 /** 304 * The number of hard links to the file. 305 */ 306 ULONG NumberOfLinks; 307 /** 308 * The delete pending status. TRUE indicates that a file deletion has been requested. 309 */ 310 BOOLEAN DeletePending; 311 /** 312 * The file directory status. TRUE indicates the file object represents a directory. 313 */ 314 BOOLEAN Directory; 315 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; 316 317 /** 318 * \struct FILE_POSITION_INFORMATION 319 * \brief Used as an argument to routines that query or set file information. 320 * 321 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FilePositionInformation and FileAllInformation 322 */ 323 typedef struct _FILE_POSITION_INFORMATION { 324 /** 325 * The byte offset of the current file pointer. 326 */ 327 LARGE_INTEGER CurrentByteOffset; 328 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; 329 330 /** 331 * \struct FILE_DIRECTORY_INFORMATION 332 * \brief Used to query detailed information for the files in a directory. 333 */ 334 typedef struct _FILE_DIRECTORY_INFORMATION { 335 /** 336 * Byte offset of the next FILE_DIRECTORY_INFORMATION entry, if multiple entries are present in a buffer. 337 * This member is zero if no other entries follow this one. 338 */ 339 ULONG NextEntryOffset; 340 /** 341 * Byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, 342 * in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. 343 */ 344 ULONG FileIndex; 345 /** 346 * Time when the file was created. 347 */ 348 LARGE_INTEGER CreationTime; 349 /** 350 * Last time the file was accessed. 351 */ 352 LARGE_INTEGER LastAccessTime; 353 /** 354 * Last time information was written to the file. 355 */ 356 LARGE_INTEGER LastWriteTime; 357 /** 358 * Last time the file was changed. 359 */ 360 LARGE_INTEGER ChangeTime; 361 /** 362 * Absolute new end-of-file position as a byte offset from the start of the file. 363 * EndOfFile specifies the byte offset to the end of the file. 364 * Because this value is zero-based, it actually refers to the first free byte in the file. In other words, 365 * EndOfFile is the offset to the byte immediately following the last valid byte in the file. 366 */ 367 LARGE_INTEGER EndOfFile; 368 /** 369 * File allocation size, in bytes. Usually, this value is a multiple of the sector or cluster size of the underlying physical device. 370 */ 371 LARGE_INTEGER AllocationSize; 372 /** 373 * File attributes, which can be any valid combination of the following: 374 * 375 * \li \c FILE_ATTRIBUTE_READONLY 376 * \li \c FILE_ATTRIBUTE_HIDDEN 377 * \li \c FILE_ATTRIBUTE_SYSTEM 378 * \li \c FILE_ATTRIBUTE_DIRECTORY 379 * \li \c FILE_ATTRIBUTE_ARCHIVE 380 * \li \c FILE_ATTRIBUTE_NORMAL 381 * \li \c FILE_ATTRIBUTE_TEMPORARY 382 * \li \c FILE_ATTRIBUTE_COMPRESSED 383 */ 384 ULONG FileAttributes; 385 /** 386 * Specifies the length of the file name string. 387 */ 388 ULONG FileNameLength; 389 /** 390 * Specifies the first character of the file name string. 391 * This is followed in memory by the remainder of the string. 392 */ 393 WCHAR FileName[1]; 394 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION; 395 396 /** 397 * \struct FILE_FULL_DIR_INFORMATION 398 * \brief Used to query detailed information for the files in a directory. 399 */ 400 typedef struct _FILE_FULL_DIR_INFORMATION { 401 /** 402 * Byte offset of the next FILE_DIRECTORY_INFORMATION entry, if multiple entries are present in a buffer. 403 * This member is zero if no other entries follow this one. 404 */ 405 ULONG NextEntryOffset; 406 /** 407 * Byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, 408 * in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. 409 */ 410 ULONG FileIndex; 411 /** 412 * Time when the file was created. 413 */ 414 LARGE_INTEGER CreationTime; 415 /** 416 * Last time the file was accessed. 417 */ 418 LARGE_INTEGER LastAccessTime; 419 /** 420 * Last time information was written to the file. 421 */ 422 LARGE_INTEGER LastWriteTime; 423 /** 424 * Last time the file was changed. 425 */ 426 LARGE_INTEGER ChangeTime; 427 /** 428 * Absolute new end-of-file position as a byte offset from the start of the file. 429 * EndOfFile specifies the byte offset to the end of the file. 430 * Because this value is zero-based, it actually refers to the first free byte in the file. In other words, 431 * EndOfFile is the offset to the byte immediately following the last valid byte in the file. 432 */ 433 LARGE_INTEGER EndOfFile; 434 /** 435 * File allocation size, in bytes. Usually, this value is a multiple of the sector or cluster size of the underlying physical device. 436 */ 437 LARGE_INTEGER AllocationSize; 438 /** 439 * File attributes, which can be any valid combination of the following: 440 * 441 * \li \c FILE_ATTRIBUTE_READONLY 442 * \li \c FILE_ATTRIBUTE_HIDDEN 443 * \li \c FILE_ATTRIBUTE_SYSTEM 444 * \li \c FILE_ATTRIBUTE_DIRECTORY 445 * \li \c FILE_ATTRIBUTE_ARCHIVE 446 * \li \c FILE_ATTRIBUTE_NORMAL 447 * \li \c FILE_ATTRIBUTE_TEMPORARY 448 * \li \c FILE_ATTRIBUTE_COMPRESSED 449 */ 450 ULONG FileAttributes; 451 /** 452 * Specifies the length of the file name string. 453 */ 454 ULONG FileNameLength; 455 /** 456 * Combined length, in bytes, of the extended attributes (EA) for the file. 457 */ 458 ULONG EaSize; 459 /** 460 * Specifies the first character of the file name string. 461 * This is followed in memory by the remainder of the string. 462 */ 463 WCHAR FileName[1]; 464 } FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION; 465 466 /** 467 * \struct FILE_ID_FULL_DIR_INFORMATION 468 * \brief Used to query detailed information for the files in a directory. 469 */ 470 typedef struct _FILE_ID_FULL_DIR_INFORMATION { 471 /** 472 * Byte offset of the next FILE_DIRECTORY_INFORMATION entry, if multiple entries are present in a buffer. 473 * This member is zero if no other entries follow this one. 474 */ 475 ULONG NextEntryOffset; 476 /** 477 * Byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, 478 * in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. 479 */ 480 ULONG FileIndex; 481 /** 482 * Time when the file was created. 483 */ 484 LARGE_INTEGER CreationTime; 485 /** 486 * Last time the file was accessed. 487 */ 488 LARGE_INTEGER LastAccessTime; 489 /** 490 * Last time information was written to the file. 491 */ 492 LARGE_INTEGER LastWriteTime; 493 /** 494 * Last time the file was changed. 495 */ 496 LARGE_INTEGER ChangeTime; 497 /** 498 * Absolute new end-of-file position as a byte offset from the start of the file. 499 * EndOfFile specifies the byte offset to the end of the file. 500 * Because this value is zero-based, it actually refers to the first free byte in the file. In other words, 501 * EndOfFile is the offset to the byte immediately following the last valid byte in the file. 502 */ 503 LARGE_INTEGER EndOfFile; 504 /** 505 * File allocation size, in bytes. Usually, this value is a multiple of the sector or cluster size of the underlying physical device. 506 */ 507 LARGE_INTEGER AllocationSize; 508 /** 509 * File attributes, which can be any valid combination of the following: 510 * 511 * \li \c FILE_ATTRIBUTE_READONLY 512 * \li \c FILE_ATTRIBUTE_HIDDEN 513 * \li \c FILE_ATTRIBUTE_SYSTEM 514 * \li \c FILE_ATTRIBUTE_DIRECTORY 515 * \li \c FILE_ATTRIBUTE_ARCHIVE 516 * \li \c FILE_ATTRIBUTE_NORMAL 517 * \li \c FILE_ATTRIBUTE_TEMPORARY 518 * \li \c FILE_ATTRIBUTE_COMPRESSED 519 */ 520 ULONG FileAttributes; 521 /** 522 * Specifies the length of the file name string. 523 */ 524 ULONG FileNameLength; 525 /** 526 * Combined length, in bytes, of the extended attributes (EA) for the file. 527 */ 528 ULONG EaSize; 529 /** 530 * The 8-byte file reference number for the file. (Note that this is not the same as the 16-byte 531 * "file object ID" that was added to NTFS for Microsoft Windows 2000.) 532 */ 533 LARGE_INTEGER FileId; 534 /** 535 * Specifies the first character of the file name string. 536 * This is followed in memory by the remainder of the string. 537 */ 538 WCHAR FileName[1]; 539 } FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION; 540 541 /** 542 * \struct FILE_BOTH_DIR_INFORMATION 543 * \brief Used to query detailed information for the files in a directory. 544 */ 545 typedef struct _FILE_BOTH_DIR_INFORMATION { 546 /** 547 * Byte offset of the next FILE_DIRECTORY_INFORMATION entry, if multiple entries are present in a buffer. 548 * This member is zero if no other entries follow this one. 549 */ 550 ULONG NextEntryOffset; 551 /** 552 * Byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, 553 * in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. 554 */ 555 ULONG FileIndex; 556 /** 557 * Time when the file was created. 558 */ 559 LARGE_INTEGER CreationTime; 560 /** 561 * Last time the file was accessed. 562 */ 563 LARGE_INTEGER LastAccessTime; 564 /** 565 * Last time information was written to the file. 566 */ 567 LARGE_INTEGER LastWriteTime; 568 /** 569 * Last time the file was changed. 570 */ 571 LARGE_INTEGER ChangeTime; 572 /** 573 * Absolute new end-of-file position as a byte offset from the start of the file. 574 * EndOfFile specifies the byte offset to the end of the file. 575 * Because this value is zero-based, it actually refers to the first free byte in the file. In other words, 576 * EndOfFile is the offset to the byte immediately following the last valid byte in the file. 577 */ 578 LARGE_INTEGER EndOfFile; 579 /** 580 * File allocation size, in bytes. Usually, this value is a multiple of the sector or cluster size of the underlying physical device. 581 */ 582 LARGE_INTEGER AllocationSize; 583 /** 584 * File attributes, which can be any valid combination of the following: 585 * 586 * \li \c FILE_ATTRIBUTE_READONLY 587 * \li \c FILE_ATTRIBUTE_HIDDEN 588 * \li \c FILE_ATTRIBUTE_SYSTEM 589 * \li \c FILE_ATTRIBUTE_DIRECTORY 590 * \li \c FILE_ATTRIBUTE_ARCHIVE 591 * \li \c FILE_ATTRIBUTE_NORMAL 592 * \li \c FILE_ATTRIBUTE_TEMPORARY 593 * \li \c FILE_ATTRIBUTE_COMPRESSED 594 */ 595 ULONG FileAttributes; 596 /** 597 * Specifies the length of the file name string. 598 */ 599 ULONG FileNameLength; 600 /** 601 * Combined length, in bytes, of the extended attributes (EA) for the file. 602 */ 603 ULONG EaSize; 604 /** 605 * Specifies the length, in bytes, of the short file name string. 606 */ 607 CCHAR ShortNameLength; 608 /** 609 * Unicode string containing the short (8.3) name for the file. 610 */ 611 WCHAR ShortName[12]; 612 /** 613 * Specifies the first character of the file name string. This is followed in memory by the remainder of the string. 614 */ 615 WCHAR FileName[1]; 616 } FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION; 617 618 /** 619 * \struct FILE_ID_BOTH_DIR_INFORMATION 620 * \brief Used to query detailed information for the files in a directory. 621 */ 622 typedef struct _FILE_ID_BOTH_DIR_INFORMATION { 623 /** 624 * Byte offset of the next FILE_DIRECTORY_INFORMATION entry, if multiple entries are present in a buffer. 625 * This member is zero if no other entries follow this one. 626 */ 627 ULONG NextEntryOffset; 628 /** 629 * Byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, 630 * in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. 631 */ 632 ULONG FileIndex; 633 /** 634 * Time when the file was created. 635 */ 636 LARGE_INTEGER CreationTime; 637 /** 638 * Last time the file was accessed. 639 */ 640 LARGE_INTEGER LastAccessTime; 641 /** 642 * Last time information was written to the file. 643 */ 644 LARGE_INTEGER LastWriteTime; 645 /** 646 * Last time the file was changed. 647 */ 648 LARGE_INTEGER ChangeTime; 649 /** 650 * Absolute new end-of-file position as a byte offset from the start of the file. 651 * EndOfFile specifies the byte offset to the end of the file. 652 * Because this value is zero-based, it actually refers to the first free byte in the file. In other words, 653 * EndOfFile is the offset to the byte immediately following the last valid byte in the file. 654 */ 655 LARGE_INTEGER EndOfFile; 656 /** 657 * File allocation size, in bytes. Usually, this value is a multiple of the sector or cluster size of the underlying physical device. 658 */ 659 LARGE_INTEGER AllocationSize; 660 /** 661 * File attributes, which can be any valid combination of the following: 662 * 663 * \li \c FILE_ATTRIBUTE_READONLY 664 * \li \c FILE_ATTRIBUTE_HIDDEN 665 * \li \c FILE_ATTRIBUTE_SYSTEM 666 * \li \c FILE_ATTRIBUTE_DIRECTORY 667 * \li \c FILE_ATTRIBUTE_ARCHIVE 668 * \li \c FILE_ATTRIBUTE_NORMAL 669 * \li \c FILE_ATTRIBUTE_TEMPORARY 670 * \li \c FILE_ATTRIBUTE_COMPRESSED 671 */ 672 ULONG FileAttributes; 673 /** 674 * Specifies the length of the file name string. 675 */ 676 ULONG FileNameLength; 677 /** 678 * Combined length, in bytes, of the extended attributes (EA) for the file. 679 */ 680 ULONG EaSize; 681 /** 682 * Specifies the length, in bytes, of the short file name string. 683 */ 684 CCHAR ShortNameLength; 685 /** 686 * Unicode string containing the short (8.3) name for the file. 687 */ 688 WCHAR ShortName[12]; 689 /** 690 * The 8-byte file reference number for the file. This number is generated and assigned to the file by the file system. 691 * (Note that the FileId is not the same as the 16-byte "file object ID" that was added to NTFS for Microsoft Windows 2000.) 692 */ 693 LARGE_INTEGER FileId; 694 /** 695 * Specifies the first character of the file name string. This is followed in memory by the remainder of the string. 696 */ 697 WCHAR FileName[1]; 698 } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION; 699 700 /** 701 * \struct FILE_NAMES_INFORMATION 702 * \brief Used to query detailed information about the names of files in a directory. 703 */ 704 typedef struct _FILE_NAMES_INFORMATION { 705 /** 706 * Byte offset for the next FILE_NAMES_INFORMATION entry, if multiple entries are present in a buffer. 707 * This member is zero if no other entries follow this one. 708 */ 709 ULONG NextEntryOffset; 710 /** 711 * Byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, 712 * in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. 713 */ 714 ULONG FileIndex; 715 /** 716 * Specifies the length of the file name string. 717 */ 718 ULONG FileNameLength; 719 /** 720 * Specifies the first character of the file name string. This is followed in memory by the remainder of the string. 721 */ 722 WCHAR FileName[1]; 723 } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION; 724 725 #define ANSI_DOS_STAR ('<') 726 #define ANSI_DOS_QM ('>') 727 #define ANSI_DOS_DOT ('"') 728 729 #define DOS_STAR (L'<') 730 #define DOS_QM (L'>') 731 #define DOS_DOT (L'"') 732 733 /** 734 * \struct FILE_INTERNAL_INFORMATION 735 * \brief Used to query for the file system's 8-byte file reference number for a file. 736 * 737 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileInternalInformation 738 */ 739 typedef struct _FILE_INTERNAL_INFORMATION { 740 /** 741 * The 8-byte file reference number for the file. This number is assigned by the file system and is file-system-specific. 742 * (Note that this is not the same as the 16-byte "file object ID" that was added to NTFS for Microsoft Windows 2000.) 743 */ 744 LARGE_INTEGER IndexNumber; 745 } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; 746 747 /** 748 * \struct FILE_ID_INFORMATION 749 * \brief Contains identification information for a file. 750 * 751 * This structure is returned from the GetFileInformationByHandleEx function when FileIdInfo is passed in the FileInformationClass parameter. 752 * 753 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileIdInformation 754 */ 755 typedef struct _FILE_ID_INFORMATION { 756 /** 757 * The serial number of the volume that contains a file. 758 */ 759 ULONGLONG VolumeSerialNumber; 760 /** 761 * The 128-bit file identifier for the file. The file identifier and the volume serial number uniquely identify a file on a single computer. 762 * To determine whether two open handles represent the same file, combine the identifier and the volume serial number for each file and compare them. 763 */ 764 FILE_ID_128 FileId; 765 } FILE_ID_INFORMATION, *PFILE_ID_INFORMATION; 766 767 /** 768 * \struct FILE_EA_INFORMATION 769 * \brief Used to query for the size of the extended attributes (EA) for a file. 770 * 771 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileEaInformation and FileAllInformation 772 */ 773 typedef struct _FILE_EA_INFORMATION { 774 /** 775 * Specifies the combined length, in bytes, of the extended attributes for the file. 776 */ 777 ULONG EaSize; 778 } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; 779 780 /** 781 * \struct FILE_ACCESS_INFORMATION 782 * \brief Used to query for or set the access rights of a file. 783 * 784 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileAllInformation 785 */ 786 typedef struct _FILE_ACCESS_INFORMATION { 787 /** 788 * Flags that specify a set of access rights in the access mask of an access control entry. 789 * This member is a value of type ACCESS_MASK. 790 */ 791 ACCESS_MASK AccessFlags; 792 } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; 793 794 /** 795 * \struct FILE_MODE_INFORMATION 796 * \brief Used to query or set the access mode of a file. 797 * 798 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileAllInformation 799 */ 800 typedef struct _FILE_MODE_INFORMATION { 801 /** 802 * Specifies the mode in which the file will be accessed following a create-file or open-file operation. 803 * This parameter is either zero or the bitwise OR of one or more of the following file option flags: 804 * 805 * \li \c FILE_WRITE_THROUGH 806 * \li \c FILE_SEQUENTIAL_ONLY 807 * \li \c FILE_NO_INTERMEDIATE_BUFFERING 808 * \li \c FILE_SYNCHRONOUS_IO_ALERT 809 * \li \c FILE_SYNCHRONOUS_IO_NONALERT 810 * \li \c FILE_DELETE_ON_CLOSE 811 */ 812 ULONG Mode; 813 } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; 814 815 /** 816 * \struct FILE_ALL_INFORMATION 817 * \brief Structure is a container for several FILE_XXX_INFORMATION structures. 818 * 819 * The struct is requested during IRP_MJ_QUERY_INFORMATION with query FileAllInformation 820 */ 821 typedef struct _FILE_ALL_INFORMATION { 822 /** \see FILE_BASIC_INFORMATION */ 823 FILE_BASIC_INFORMATION BasicInformation; 824 /** \see FILE_STANDARD_INFORMATION */ 825 FILE_STANDARD_INFORMATION StandardInformation; 826 /** \see FILE_INTERNAL_INFORMATION */ 827 FILE_INTERNAL_INFORMATION InternalInformation; 828 /** \see FILE_EA_INFORMATION */ 829 FILE_EA_INFORMATION EaInformation; 830 /** \see FILE_ACCESS_INFORMATION */ 831 FILE_ACCESS_INFORMATION AccessInformation; 832 /** \see FILE_POSITION_INFORMATION */ 833 FILE_POSITION_INFORMATION PositionInformation; 834 /** \see FILE_MODE_INFORMATION */ 835 FILE_MODE_INFORMATION ModeInformation; 836 /** \see FILE_ALIGNMENT_INFORMATION */ 837 FILE_ALIGNMENT_INFORMATION AlignmentInformation; 838 /** \see FILE_NAME_INFORMATION */ 839 FILE_NAME_INFORMATION NameInformation; 840 } FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; 841 842 /** 843 * \struct FILE_ALLOCATION_INFORMATION 844 * \brief Used to set the allocation size for a file. 845 * 846 * The struct is requested during IRP_MJ_SET_INFORMATION with query FileAllocationInformation 847 */ 848 typedef struct _FILE_ALLOCATION_INFORMATION { 849 /** 850 * File allocation size, in bytes. Usually this value is a multiple 851 * of the sector or cluster size of the underlying physical device. 852 */ 853 LARGE_INTEGER AllocationSize; 854 } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION; 855 856 /** 857 * \struct FILE_LINK_INFORMATION 858 * \brief Used to create an NTFS hard link to an existing file. 859 * 860 * The struct is requested during IRP_MJ_SET_INFORMATION with query FileLinkInformation 861 */ 862 typedef struct _FILE_LINK_INFORMATION { 863 /** 864 * Set to TRUE to specify that if the link already exists, it should be replaced with the new link. 865 * Set to FALSE if the link creation operation should fail if the link already exists. 866 */ 867 BOOLEAN ReplaceIfExists; 868 /** 869 * If the link is to be created in the same directory as the file that is being linked to, 870 * or if the FileName member contains the full pathname for the link to be created, this is NULL. 871 * Otherwise it is a handle for the directory where the link is to be created. 872 */ 873 HANDLE RootDirectory; 874 /** 875 * Length, in bytes, of the file name string. 876 */ 877 ULONG FileNameLength; 878 /** 879 * The first character of the name to be assigned to the newly created link. 880 * This is followed in memory by the remainder of the string. 881 * If the RootDirectory member is NULL and the link is to be created in a different directory from the file that is being linked to, 882 * this member specifies the full pathname for the link to be created. Otherwise, it specifies only the file name. 883 * (See the Remarks section for ZwQueryInformationFile for details on the syntax of this file name string.) 884 */ 885 WCHAR FileName[1]; 886 } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION; 887 888 /** 889 * \struct FILE_RENAME_INFORMATION 890 * \brief Used to rename a file. 891 * 892 * The struct is requested during IRP_MJ_SET_INFORMATION with query FileRenameInformation 893 */ 894 typedef struct _FILE_RENAME_INFORMATION { 895 /** 896 * Set to TRUE to specify that if a file with the given name already exists, it should be replaced with the given file. 897 * Set to FALSE if the rename operation should fail if a file with the given name already exists. 898 */ 899 BOOLEAN ReplaceIfExists; 900 /** 901 * If the file is not being moved to a different directory, 902 * or if the FileName member contains the full pathname, this member is NULL. Otherwise, 903 * it is a handle for the root directory under which the file will reside after it is renamed. 904 */ 905 HANDLE RootDirectory; 906 /** 907 * Length, in bytes, of the new name for the file. 908 */ 909 ULONG FileNameLength; 910 /** 911 * The first character of a wide-character string containing the new name for the file. 912 * This is followed in memory by the remainder of the string. If the RootDirectory member is NULL, 913 * and the file is being moved to a different directory, this member specifies the full pathname to be assigned to the file. 914 * Otherwise, it specifies only the file name or a relative pathname. 915 */ 916 WCHAR FileName[1]; 917 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION; 918 919 /** 920 * \struct FILE_STREAM_INFORMATION 921 * \brief Used to enumerate the streams for a file. 922 * 923 * The struct is requested during IRP_MJ_SET_INFORMATION query FileStreamInformation 924 */ 925 typedef struct _FILE_STREAM_INFORMATION { 926 /** 927 * The offset of the next FILE_STREAM_INFORMATION entry. 928 * This member is zero if no other entries follow this one. 929 */ 930 ULONG NextEntryOffset; 931 /** 932 * Length, in bytes, of the StreamName string. 933 */ 934 ULONG StreamNameLength; 935 /** 936 * Size, in bytes, of the stream. 937 */ 938 LARGE_INTEGER StreamSize; 939 /** 940 * File stream allocation size, in bytes. Usually this value is a multiple of the sector 941 * or cluster size of the underlying physical device. 942 */ 943 LARGE_INTEGER StreamAllocationSize; 944 /** 945 * Unicode string that contains the name of the stream. 946 */ 947 WCHAR StreamName[1]; 948 } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION; 949 950 /** 951 * \struct FILE_FS_LABEL_INFORMATION 952 * \brief Used to set the label for a file system volume. 953 * 954 * The struct is requested during IRP_MJ_SET_VOLUME_INFORMATION query FileFsLabelInformation 955 */ 956 typedef struct _FILE_FS_LABEL_INFORMATION { 957 /** 958 * Length, in bytes, of the name for the volume. 959 */ 960 ULONG VolumeLabelLength; 961 /** 962 * Name for the volume. 963 */ 964 WCHAR VolumeLabel[1]; 965 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; 966 967 /** 968 * \struct FILE_FS_VOLUME_INFORMATION 969 * \brief Used to query information about a volume on which a file system is mounted. 970 * 971 * The struct is requested during IRP_MJ_QUERY_VOLUME_INFORMATION query FileFsVolumeInformation 972 */ 973 typedef struct _FILE_FS_VOLUME_INFORMATION { 974 /** 975 * Time when the volume was created. 976 */ 977 LARGE_INTEGER VolumeCreationTime; 978 /** 979 * Serial number of the volume. 980 */ 981 ULONG VolumeSerialNumber; 982 /** 983 * Length, in bytes, of the name of the volume. 984 */ 985 ULONG VolumeLabelLength; 986 /** 987 * TRUE if the file system supports object-oriented file system objects, FALSE otherwise. 988 */ 989 BOOLEAN SupportsObjects; 990 /** 991 * Name of the volume. 992 */ 993 WCHAR VolumeLabel[1]; 994 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; 995 996 /** 997 * \struct FILE_FS_SIZE_INFORMATION 998 * \brief Used to query sector size information for a file system volume. 999 * 1000 * The struct is requested during IRP_MJ_QUERY_VOLUME_INFORMATION query FileFsSizeInformation 1001 */ 1002 typedef struct _FILE_FS_SIZE_INFORMATION { 1003 /** 1004 * Total number of allocation units on the volume that are available to the user associated with the calling thread. 1005 * If per-user quotas are in use, this value may be less than the total number of allocation units on the disk. 1006 */ 1007 LARGE_INTEGER TotalAllocationUnits; 1008 /** 1009 * Total number of free allocation units on the volume that are available to the user associated with the calling thread. 1010 * If per-user quotas are in use, this value may be less than the total number of free allocation units on the disk. 1011 */ 1012 LARGE_INTEGER AvailableAllocationUnits; 1013 /** 1014 * Number of sectors in each allocation unit. 1015 */ 1016 ULONG SectorsPerAllocationUnit; 1017 /** 1018 * Number of bytes in each sector. 1019 */ 1020 ULONG BytesPerSector; 1021 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; 1022 1023 /** 1024 * \struct FILE_FS_FULL_SIZE_INFORMATION 1025 * \brief Used to query sector size information for a file system volume. 1026 * 1027 * The struct is requested during IRP_MJ_QUERY_VOLUME_INFORMATION query FileFsFullSizeInformation 1028 */ 1029 typedef struct _FILE_FS_FULL_SIZE_INFORMATION { 1030 /** 1031 * Total number of allocation units on the volume that are available to the user associated with the calling thread. 1032 * If per-user quotas are in use, this value may be less than the total number of allocation units on the disk. 1033 */ 1034 LARGE_INTEGER TotalAllocationUnits; 1035 /** 1036 * Total number of free allocation units on the volume that are available to the user associated with the calling thread. 1037 * If per-user quotas are in use, this value may be less than the total number of free allocation units on the disk. 1038 */ 1039 LARGE_INTEGER CallerAvailableAllocationUnits; 1040 /** 1041 * Total number of free allocation units on the volume. 1042 */ 1043 LARGE_INTEGER ActualAvailableAllocationUnits; 1044 /** 1045 * Number of sectors in each allocation unit. 1046 */ 1047 ULONG SectorsPerAllocationUnit; 1048 /** 1049 * Number of bytes in each sector. 1050 */ 1051 ULONG BytesPerSector; 1052 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; 1053 1054 /** 1055 * \struct FILE_FS_ATTRIBUTE_INFORMATION 1056 * \brief Used to query attribute information for a file system. 1057 * 1058 * The struct is requested during IRP_MJ_QUERY_VOLUME_INFORMATION query FileFsAttributeInformation 1059 */ 1060 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { 1061 /** 1062 * Bitmask of flags specifying attributes of the specified file system. 1063 * \see https://msdn.microsoft.com/en-us/library/windows/hardware/ff540251(v=vs.85).aspx 1064 */ 1065 ULONG FileSystemAttributes; 1066 /** 1067 * Maximum file name component length, in bytes, supported by the specified file system. 1068 * A file name component is that portion of a file name between backslashes. 1069 */ 1070 LONG MaximumComponentNameLength; 1071 /** 1072 * Length, in bytes, of the file system name. 1073 */ 1074 ULONG FileSystemNameLength; 1075 /** 1076 * File system name. 1077 */ 1078 WCHAR FileSystemName[1]; 1079 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; 1080 1081 /** 1082 * \struct FILE_NETWORK_OPEN_INFORMATION 1083 * \brief Used as an argument to ZwQueryInformationFile. 1084 * 1085 * The struct is requested during IRP_MJ_QUERY_VOLUME_INFORMATION query FileNetworkOpenInformation 1086 */ 1087 typedef struct _FILE_NETWORK_OPEN_INFORMATION { 1088 /** 1089 * Specifies the time that the file was created. 1090 */ 1091 LARGE_INTEGER CreationTime; 1092 /** 1093 * Specifies the time that the file was last accessed. 1094 */ 1095 LARGE_INTEGER LastAccessTime; 1096 /** 1097 * Specifies he time that the file was last written to. 1098 */ 1099 LARGE_INTEGER LastWriteTime; 1100 /** 1101 * Specifies the time that the file was last changed. 1102 */ 1103 LARGE_INTEGER ChangeTime; 1104 /** 1105 * Specifies the file allocation size, in bytes. Usually, 1106 * this value is a multiple of the sector or cluster size of the underlying physical device. 1107 */ 1108 LARGE_INTEGER AllocationSize; 1109 /** 1110 * Specifies the absolute end-of-file position as a byte offset from the start of the file. 1111 * EndOfFile specifies the byte offset to the end of the file. Because this value is zero-based, 1112 * it actually refers to the first free byte in the file. In other words, 1113 * EndOfFile is the offset to the byte immediately following the last valid byte in the file. 1114 */ 1115 LARGE_INTEGER EndOfFile; 1116 /** 1117 * Specifies one or more FILE_ATTRIBUTE_XXX flags. For descriptions of these flags, 1118 * see the documentation of the GetFileAttributes function in the Microsoft Windows SDK. 1119 */ 1120 ULONG FileAttributes; 1121 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; 1122 1123 /** 1124 * \struct FILE_NETWORK_PHYSICAL_NAME_INFORMATION 1125 * \brief Contains the full UNC physical pathname for a file or directory on a remote file share. 1126 * 1127 * The struct is requested during IRP_MJ_QUERY_VOLUME_INFORMATION query FileNetworkPhysicalNameInformation 1128 */ 1129 typedef struct _FILE_NETWORK_PHYSICAL_NAME_INFORMATION { 1130 /** 1131 * The length, in bytes, of the physical name in FileName. 1132 */ 1133 ULONG FileNameLength; 1134 /** 1135 * The full UNC path of the network file share of the target. 1136 */ 1137 WCHAR FileName[1]; 1138 } FILE_NETWORK_PHYSICAL_NAME_INFORMATION, 1139 *PFILE_NETWORK_PHYSICAL_NAME_INFORMATION; 1140 1141 #define SL_RESTART_SCAN 0x01 1142 #define SL_RETURN_SINGLE_ENTRY 0x02 1143 #define SL_INDEX_SPECIFIED 0x04 1144 #define SL_FORCE_ACCESS_CHECK 0x01 1145 1146 #define SL_OPEN_PAGING_FILE 0x02 1147 #define SL_OPEN_TARGET_DIRECTORY 0x04 1148 #define SL_CASE_SENSITIVE 0x80 1149 1150 #define ALIGN_DOWN(length, type) ((ULONG)(length) & ~(sizeof(type) - 1)) 1151 1152 #define ALIGN_UP(length, type) \ 1153 (ALIGN_DOWN(((ULONG)(length) + sizeof(type) - 1), type)) 1154 1155 #define ALIGN_DOWN_POINTER(address, type) \ 1156 ((PVOID)((ULONG_PTR)(address) & ~((ULONG_PTR)sizeof(type) - 1))) 1157 1158 #define ALIGN_UP_POINTER(address, type) \ 1159 (ALIGN_DOWN_POINTER(((ULONG_PTR)(address) + sizeof(type) - 1), type)) 1160 1161 #define WordAlign(Val) (ALIGN_UP(Val, WORD)) 1162 1163 #define WordAlignPtr(Ptr) (ALIGN_UP_POINTER(Ptr, WORD)) 1164 1165 #define LongAlign(Val) (ALIGN_UP(Val, LONG)) 1166 1167 #define LongAlignPtr(Ptr) (ALIGN_UP_POINTER(Ptr, LONG)) 1168 1169 #define QuadAlign(Val) (ALIGN_UP(Val, ULONGLONG)) 1170 1171 #define QuadAlignPtr(Ptr) (ALIGN_UP_POINTER(Ptr, ULONGLONG)) 1172 1173 #define IsPtrQuadAligned(Ptr) (QuadAlignPtr(Ptr) == (PVOID)(Ptr)) 1174 1175 // from wdm.h 1176 #define FILE_SUPERSEDE 0x00000000 1177 #define FILE_OPEN 0x00000001 1178 #define FILE_CREATE 0x00000002 1179 #define FILE_OPEN_IF 0x00000003 1180 #define FILE_OVERWRITE 0x00000004 1181 #define FILE_OVERWRITE_IF 0x00000005 1182 #define FILE_MAXIMUM_DISPOSITION 0x00000005 1183 1184 #define FILE_DIRECTORY_FILE 0x00000001 1185 #define FILE_WRITE_THROUGH 0x00000002 1186 #define FILE_SEQUENTIAL_ONLY 0x00000004 1187 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 1188 1189 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 1190 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 1191 #define FILE_NON_DIRECTORY_FILE 0x00000040 1192 #define FILE_CREATE_TREE_CONNECTION 0x00000080 1193 1194 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100 1195 #define FILE_NO_EA_KNOWLEDGE 0x00000200 1196 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400 1197 #define FILE_RANDOM_ACCESS 0x00000800 1198 1199 #define FILE_DELETE_ON_CLOSE 0x00001000 1200 #define FILE_OPEN_BY_FILE_ID 0x00002000 1201 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 1202 #define FILE_NO_COMPRESSION 0x00008000 1203 1204 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) 1205 #define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 1206 #define FILE_DISALLOW_EXCLUSIVE 0x00020000 1207 #endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */ 1208 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) 1209 #define FILE_SESSION_AWARE 0x00040000 1210 #endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */ 1211 1212 #define FILE_RESERVE_OPFILTER 0x00100000 1213 #define FILE_OPEN_REPARSE_POINT 0x00200000 1214 #define FILE_OPEN_NO_RECALL 0x00400000 1215 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 1216 1217 #define FILE_VALID_OPTION_FLAGS 0x00ffffff 1218 1219 #define FILE_SUPERSEDED 0x00000000 1220 #define FILE_OPENED 0x00000001 1221 #define FILE_CREATED 0x00000002 1222 #define FILE_OVERWRITTEN 0x00000003 1223 #define FILE_EXISTS 0x00000004 1224 #define FILE_DOES_NOT_EXIST 0x00000005 1225 1226 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff 1227 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe 1228 1229 /** 1230 * \struct UNICODE_STRING 1231 * \brief Structure is used to define Unicode strings. 1232 */ 1233 // Already defined in mingw ntdef.h 1234 //typedef struct _UNICODE_STRING { 1235 // /** 1236 // * The length, in bytes, of the string stored in Buffer. 1237 // */ 1238 // USHORT Length; 1239 // /** 1240 // * The length, in bytes, of Buffer. 1241 // */ 1242 // USHORT MaximumLength; 1243 // /** 1244 // * Pointer to a buffer used to contain a string of wide characters. 1245 // */ 1246 // PWSTR Buffer; 1247 //} UNICODE_STRING, *PUNICODE_STRING; 1248 1249 1250 #endif // FILEINFO_H_