-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathobject_generated.go
277 lines (253 loc) · 8.83 KB
/
object_generated.go
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
// This file was autogenerated using go run mkcode.go -- object.go
// DO NOT EDIT.
package ntdll
import "unsafe"
import "reflect"
// The ObjectInformationClass constants have been derived from the OBJECT_INFORMATION_CLASS enum definition.
type ObjectInformationClass uint32
const (
ObjectBasicInformation ObjectInformationClass = 0
ObjectNameInformation = 1
ObjectTypeInformation = 2
ObjectAllInformation = 3
ObjectDataInformation = 4
)
var (
procNtOpenDirectoryObject = modntdll.NewProc("NtOpenDirectoryObject")
procNtQueryDirectoryObject = modntdll.NewProc("NtQueryDirectoryObject")
procNtOpenSymbolicLinkObject = modntdll.NewProc("NtOpenSymbolicLinkObject")
procNtQuerySymbolicLinkObject = modntdll.NewProc("NtQuerySymbolicLinkObject")
procNtCreateSymbolicLinkObject = modntdll.NewProc("NtCreateSymbolicLinkObject")
procNtCreateDirectoryObject = modntdll.NewProc("NtCreateDirectoryObject")
procNtCreateDirectoryObjectEx = modntdll.NewProc("NtCreateDirectoryObjectEx")
procNtQueryObject = modntdll.NewProc("NtQueryObject")
procNtDuplicateObject = modntdll.NewProc("NtDuplicateObject")
)
// ObjectAttributes has been derived from the OBJECT_ATTRIBUTES struct definition.
type ObjectAttributes struct {
Length uint32
RootDirectory Handle
ObjectName *UnicodeString
Attributes uint32
SecurityDescriptor *byte
SecurityQualityOfService *byte
}
// ObjectDirectoryInformationT has been derived from the OBJECT_DIRECTORY_INFORMATION struct definition.
type ObjectDirectoryInformationT struct {
Name UnicodeString
TypeName UnicodeString
}
// ObjectBasicInformationT has been derived from the OBJECT_BASIC_INFORMATION struct definition.
type ObjectBasicInformationT struct {
Attributes uint32
GrantedAccess AccessMask
HandleCount uint32
PointerCount uint32
PagedPoolUsage uint32
NonPagedPoolUsage uint32
Reserved [3]uint32
NameInformationLength uint32
TypeInformationLength uint32
SecurityDescriptorLength uint32
CreateTime int64
}
// ObjectNameInformationT has been derived from the OBJECT_NAME_INFORMATION struct definition.
type ObjectNameInformationT struct {
Name UnicodeString
}
// GenericMapping has been derived from the GENERIC_MAPPING struct definition.
type GenericMapping struct {
GenericRead AccessMask
GenericWrite AccessMask
GenericExecute AccessMask
GenericAll AccessMask
}
// ObjectTypeInformationT has been derived from the OBJECT_TYPE_INFORMATION struct definition.
type ObjectTypeInformationT struct {
TypeName UnicodeString
TotalNumberOfObjects uint32
TotalNumberOfHandles uint32
TotalPagedPoolUsage uint32
TotalNonPagedPoolUsage uint32
TotalNamePoolUsage uint32
TotalHandleTableUsage uint32
HighWaterNumberOfObjects uint32
HighWaterNumberOfHandles uint32
HighWaterPagedPoolUsage uint32
HighWaterNonPagedPoolUsage uint32
HighWaterNamePoolUsage uint32
HighWaterHandleTableUsage uint32
InvalidAttributes uint32
GenericMapping GenericMapping
ValidAccessMask uint32
SecurityRequired bool
MaintainHandleCount bool
TypeIndex byte
ReservedByte byte
PoolType uint32
DefaultPagedPoolCharge uint32
DefaultNonPagedPoolCharge uint32
}
// ObjectAllInformationT has been derived from the OBJECT_ALL_INFORMATION struct definition.
type ObjectAllInformationT struct {
NumberOfObjects uint32
ObjectTypeInformation [1]ObjectTypeInformationT
}
// ObjectTypeInformationSlice returns a slice over the elements of ObjectAllInformationT.ObjectTypeInformation.
//
// Beware: The data is not copied out of ObjectAllInformationT. The size can usually be taken from an other member of the struct (ObjectAllInformationT).
func (t *ObjectAllInformationT) ObjectTypeInformationSlice(size int) []ObjectTypeInformationT {
s := []ObjectTypeInformationT{}
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&s))
hdr.Data = uintptr(unsafe.Pointer(&t.ObjectTypeInformation[0]))
hdr.Len = size
hdr.Cap = size
return s
}
// SetObjectTypeInformationSlice copies s into the memory at ObjectAllInformationT.ObjectTypeInformation.
//
// Beware: No bounds check is performed. Another member of the struct (ObjectAllInformationT) usually has to be set to the array size.
func (t *ObjectAllInformationT) SetObjectTypeInformationSlice(s []ObjectTypeInformationT) {
s1 := []ObjectTypeInformationT{}
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&s1))
hdr.Data = uintptr(unsafe.Pointer(&t.ObjectTypeInformation[0]))
hdr.Len = len(s)
hdr.Cap = len(s)
copy(s1, s)
}
// ObjectDataInformationT has been derived from the OBJECT_DATA_INFORMATION struct definition.
type ObjectDataInformationT struct {
InheritHandle bool
ProtectFromClose bool
}
// OUT-parameter: DirectoryHandle.
func NtOpenDirectoryObject(
DirectoryHandle *Handle,
DesiredAccess AccessMask,
ObjectAttributes *ObjectAttributes,
) NtStatus {
r0, _, _ := procNtOpenDirectoryObject.Call(uintptr(unsafe.Pointer(DirectoryHandle)),
uintptr(DesiredAccess),
uintptr(unsafe.Pointer(ObjectAttributes)))
return NtStatus(r0)
}
// OUT-parameter: Buffer, ReturnLength.
// INOUT-parameter: Context.
// *OPT-parameter: Buffer, ReturnLength.
func NtQueryDirectoryObject(
DirectoryHandle Handle,
Buffer *byte,
Length uint32,
ReturnSingleEntry bool,
RestartScan bool,
Context *uint32,
ReturnLength *uint32,
) NtStatus {
r0, _, _ := procNtQueryDirectoryObject.Call(uintptr(DirectoryHandle),
uintptr(unsafe.Pointer(Buffer)),
uintptr(Length),
fromBool(ReturnSingleEntry),
fromBool(RestartScan),
uintptr(unsafe.Pointer(Context)),
uintptr(unsafe.Pointer(ReturnLength)))
return NtStatus(r0)
}
// OUT-parameter: LinkHandle.
func NtOpenSymbolicLinkObject(
LinkHandle *Handle,
DesiredAccess AccessMask,
ObjectAttributes *ObjectAttributes,
) NtStatus {
r0, _, _ := procNtOpenSymbolicLinkObject.Call(uintptr(unsafe.Pointer(LinkHandle)),
uintptr(DesiredAccess),
uintptr(unsafe.Pointer(ObjectAttributes)))
return NtStatus(r0)
}
// OUT-parameter: ReturnedLength.
// INOUT-parameter: LinkTarget.
// *OPT-parameter: ReturnedLength.
func NtQuerySymbolicLinkObject(
LinkHandle Handle,
LinkTarget *UnicodeString,
ReturnedLength *uint32,
) NtStatus {
r0, _, _ := procNtQuerySymbolicLinkObject.Call(uintptr(LinkHandle),
uintptr(unsafe.Pointer(LinkTarget)),
uintptr(unsafe.Pointer(ReturnedLength)))
return NtStatus(r0)
}
// OUT-parameter: SymbolicLinkHandle.
func NtCreateSymbolicLinkObject(
SymbolicLinkHandle *Handle,
DesiredAccess AccessMask,
ObjectAttributes *ObjectAttributes,
TargetName *UnicodeString,
) NtStatus {
r0, _, _ := procNtCreateSymbolicLinkObject.Call(uintptr(unsafe.Pointer(SymbolicLinkHandle)),
uintptr(DesiredAccess),
uintptr(unsafe.Pointer(ObjectAttributes)),
uintptr(unsafe.Pointer(TargetName)))
return NtStatus(r0)
}
// OUT-parameter: DirectoryHandle.
func NtCreateDirectoryObject(
DirectoryHandle *Handle,
DesiredAccess AccessMask,
ObjectAttributes *ObjectAttributes,
) NtStatus {
r0, _, _ := procNtCreateDirectoryObject.Call(uintptr(unsafe.Pointer(DirectoryHandle)),
uintptr(DesiredAccess),
uintptr(unsafe.Pointer(ObjectAttributes)))
return NtStatus(r0)
}
// OUT-parameter: DirectoryHandle.
func NtCreateDirectoryObjectEx(
DirectoryHandle *Handle,
DesiredAccess AccessMask,
ObjectAttributes *ObjectAttributes,
ShadowDirectoryHandle Handle,
Flags uint32,
) NtStatus {
r0, _, _ := procNtCreateDirectoryObjectEx.Call(uintptr(unsafe.Pointer(DirectoryHandle)),
uintptr(DesiredAccess),
uintptr(unsafe.Pointer(ObjectAttributes)),
uintptr(ShadowDirectoryHandle),
uintptr(Flags))
return NtStatus(r0)
}
// OUT-parameter: ObjectInformation, ReturnLength.
// *OPT-parameter: Handle, ReturnLength.
func NtQueryObject(
Handle Handle,
ObjectInformationClass ObjectInformationClass,
ObjectInformation *byte,
ObjectInformationLength uint32,
ReturnLength *uint32,
) NtStatus {
r0, _, _ := procNtQueryObject.Call(uintptr(Handle),
uintptr(ObjectInformationClass),
uintptr(unsafe.Pointer(ObjectInformation)),
uintptr(ObjectInformationLength),
uintptr(unsafe.Pointer(ReturnLength)))
return NtStatus(r0)
}
// OUT-parameter: TargetHandle.
// *OPT-parameter: TargetProcessHandle, TargetHandle.
func NtDuplicateObject(
SourceProcessHandle Handle,
SourceHandle Handle,
TargetProcessHandle Handle,
TargetHandle *Handle,
DesiredAccess AccessMask,
HandleAttributes uint32,
Options uint32,
) NtStatus {
r0, _, _ := procNtDuplicateObject.Call(uintptr(SourceProcessHandle),
uintptr(SourceHandle),
uintptr(TargetProcessHandle),
uintptr(unsafe.Pointer(TargetHandle)),
uintptr(DesiredAccess),
uintptr(HandleAttributes),
uintptr(Options))
return NtStatus(r0)
}