filesystem.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package winapi
  2. //sys NtCreateFile(handle *uintptr, accessMask uint32, oa *ObjectAttributes, iosb *IOStatusBlock, allocationSize *uint64, fileAttributes uint32, shareAccess uint32, createDisposition uint32, createOptions uint32, eaBuffer *byte, eaLength uint32) (status uint32) = ntdll.NtCreateFile
  3. //sys NtSetInformationFile(handle uintptr, iosb *IOStatusBlock, information uintptr, length uint32, class uint32) (status uint32) = ntdll.NtSetInformationFile
  4. //sys NtOpenDirectoryObject(handle *uintptr, accessMask uint32, oa *ObjectAttributes) (status uint32) = ntdll.NtOpenDirectoryObject
  5. //sys NtQueryDirectoryObject(handle uintptr, buffer *byte, length uint32, singleEntry bool, restartScan bool, context *uint32, returnLength *uint32)(status uint32) = ntdll.NtQueryDirectoryObject
  6. const (
  7. FileLinkInformationClass = 11
  8. FileDispositionInformationExClass = 64
  9. FILE_READ_ATTRIBUTES = 0x0080
  10. FILE_WRITE_ATTRIBUTES = 0x0100
  11. DELETE = 0x10000
  12. FILE_OPEN = 1
  13. FILE_CREATE = 2
  14. FILE_LIST_DIRECTORY = 0x00000001
  15. FILE_DIRECTORY_FILE = 0x00000001
  16. FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
  17. FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
  18. FILE_OPEN_REPARSE_POINT = 0x00200000
  19. FILE_DISPOSITION_DELETE = 0x00000001
  20. OBJ_DONT_REPARSE = 0x1000
  21. STATUS_MORE_ENTRIES = 0x105
  22. STATUS_NO_MORE_ENTRIES = 0x8000001a
  23. )
  24. // Select entries from FILE_INFO_BY_HANDLE_CLASS.
  25. //
  26. // C declaration:
  27. // typedef enum _FILE_INFO_BY_HANDLE_CLASS {
  28. // FileBasicInfo,
  29. // FileStandardInfo,
  30. // FileNameInfo,
  31. // FileRenameInfo,
  32. // FileDispositionInfo,
  33. // FileAllocationInfo,
  34. // FileEndOfFileInfo,
  35. // FileStreamInfo,
  36. // FileCompressionInfo,
  37. // FileAttributeTagInfo,
  38. // FileIdBothDirectoryInfo,
  39. // FileIdBothDirectoryRestartInfo,
  40. // FileIoPriorityHintInfo,
  41. // FileRemoteProtocolInfo,
  42. // FileFullDirectoryInfo,
  43. // FileFullDirectoryRestartInfo,
  44. // FileStorageInfo,
  45. // FileAlignmentInfo,
  46. // FileIdInfo,
  47. // FileIdExtdDirectoryInfo,
  48. // FileIdExtdDirectoryRestartInfo,
  49. // FileDispositionInfoEx,
  50. // FileRenameInfoEx,
  51. // FileCaseSensitiveInfo,
  52. // FileNormalizedNameInfo,
  53. // MaximumFileInfoByHandleClass
  54. // } FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
  55. //
  56. // Documentation: https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ne-minwinbase-file_info_by_handle_class
  57. const (
  58. FileIdInfo = 18
  59. )
  60. type FileDispositionInformationEx struct {
  61. Flags uintptr
  62. }
  63. type IOStatusBlock struct {
  64. Status, Information uintptr
  65. }
  66. type ObjectAttributes struct {
  67. Length uintptr
  68. RootDirectory uintptr
  69. ObjectName *UnicodeString
  70. Attributes uintptr
  71. SecurityDescriptor uintptr
  72. SecurityQoS uintptr
  73. }
  74. type ObjectDirectoryInformation struct {
  75. Name UnicodeString
  76. TypeName UnicodeString
  77. }
  78. type FileLinkInformation struct {
  79. ReplaceIfExists bool
  80. RootDirectory uintptr
  81. FileNameLength uint32
  82. FileName [1]uint16
  83. }
  84. // C declaration:
  85. // typedef struct _FILE_ID_INFO {
  86. // ULONGLONG VolumeSerialNumber;
  87. // FILE_ID_128 FileId;
  88. // } FILE_ID_INFO, *PFILE_ID_INFO;
  89. //
  90. // Documentation: https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_id_info
  91. type FILE_ID_INFO struct {
  92. VolumeSerialNumber uint64
  93. FileID [16]byte
  94. }