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