- Add the real NT Object Callbacks and #ifdef out the ReactOS ones.
[reactos.git] / reactos / include / ndk / obtypes.h
1 /*++ NDK Version: 0095
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 obtypes.h
8
9 Abstract:
10
11 Type definitions for the Object Manager
12
13 Author:
14
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
16
17 --*/
18
19 #ifndef _OBTYPES_H
20 #define _OBTYPES_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26
27 #ifdef NTOS_MODE_USER
28
29 //
30 // Definitions for Object Creation
31 //
32 #define OBJ_INHERIT 0x00000002L
33 #define OBJ_PERMANENT 0x00000010L
34 #define OBJ_EXCLUSIVE 0x00000020L
35 #define OBJ_CASE_INSENSITIVE 0x00000040L
36 #define OBJ_OPENIF 0x00000080L
37 #define OBJ_OPENLINK 0x00000100L
38 #define OBJ_KERNEL_HANDLE 0x00000200L
39 #define OBJ_FORCE_ACCESS_CHECK 0x00000400L
40 #define OBJ_VALID_ATTRIBUTES 0x000007F2L
41
42 #define InitializeObjectAttributes(p,n,a,r,s) { \
43 (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
44 (p)->RootDirectory = (r); \
45 (p)->Attributes = (a); \
46 (p)->ObjectName = (n); \
47 (p)->SecurityDescriptor = (s); \
48 (p)->SecurityQualityOfService = NULL; \
49 }
50
51 //
52 // Directory Object Access Rights
53 //
54 #define DIRECTORY_QUERY 0x0001
55 #define DIRECTORY_TRAVERSE 0x0002
56 #define DIRECTORY_CREATE_OBJECT 0x0004
57 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
58 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
59
60 #else
61
62 //
63 // Object Flags
64 //
65 #define OB_FLAG_CREATE_INFO 0x01
66 #define OB_FLAG_KERNEL_MODE 0x02
67 #define OB_FLAG_CREATOR_INFO 0x04
68 #define OB_FLAG_EXCLUSIVE 0x08
69 #define OB_FLAG_PERMANENT 0x10
70 #define OB_FLAG_SECURITY 0x20
71 #define OB_FLAG_SINGLE_PROCESS 0x40
72
73 //
74 // Reasons for Open Callback
75 //
76 typedef enum _OB_OPEN_REASON
77 {
78 ObCreateHandle,
79 ObOpenHandle,
80 ObDuplicateHandle,
81 ObInheritHandle,
82 ObMaxOpenReason
83 } OB_OPEN_REASON;
84
85 #endif
86
87 //
88 // Object Duplication Flags
89 //
90 #define DUPLICATE_SAME_ATTRIBUTES 0x00000004
91
92 //
93 // Number of hash entries in an Object Directory
94 //
95 #define NUMBER_HASH_BUCKETS 37
96
97 //
98 // Types for DosDeviceDriveType
99 //
100 #define DOSDEVICE_DRIVE_UNKNOWN 0
101 #define DOSDEVICE_DRIVE_CALCULATE 1
102 #define DOSDEVICE_DRIVE_REMOVABLE 2
103 #define DOSDEVICE_DRIVE_FIXED 3
104 #define DOSDEVICE_DRIVE_REMOTE 4
105 #define DOSDEVICE_DRIVE_CDROM 5
106 #define DOSDEVICE_DRIVE_RAMDISK 6
107
108 //
109 // Object Information Classes for NtQueryInformationObject
110 //
111 typedef enum _OBJECT_INFORMATION_CLASS
112 {
113 ObjectBasicInformation,
114 ObjectNameInformation,
115 ObjectTypeInformation,
116 ObjectAllTypesInformation,
117 ObjectHandleInformation
118 } OBJECT_INFORMATION_CLASS;
119
120 //
121 // Dump Control Structure for Object Debugging
122 //
123 typedef struct _OBJECT_DUMP_CONTROL
124 {
125 PVOID Stream;
126 ULONG Detail;
127 } OBJECT_DUMP_CONTROL, *POBJECT_DUMP_CONTROL;
128
129 #ifndef NTOS_MODE_USER
130 #ifndef _REACTOS_
131
132 //
133 // Object Type Callbacks
134 //
135 typedef VOID
136 (NTAPI *OB_DUMP_METHOD)(
137 IN PVOID Object,
138 IN POB_DUMP_CONTROL Control OPTIONAL
139 );
140
141 typedef NTSTATUS
142 (NTAPI *OB_OPEN_METHOD)(
143 IN OB_OPEN_REASON Reason,
144 IN PEPROCESS Process OPTIONAL,
145 IN PVOID ObjectBody,
146 IN ACCESS_MASK GrantedAccess,
147 IN ULONG HandleCount
148 );
149
150 typedef VOID
151 (NTAPI *OB_CLOSE_METHOD)(
152 IN PEPROCESS Process OPTIONAL,
153 IN PVOID Object,
154 IN ACCESS_MASK GrantedAccess,
155 IN ULONG ProcessHandleCount,
156 IN ULONG SystemHandleCount
157 );
158
159 typedef VOID
160 (NTAPI *OB_DELETE_METHOD)(
161 IN PVOID Object
162 );
163
164 typedef NTSTATUS
165 (NTAPI *OB_PARSE_METHOD)(
166 IN PVOID ParseObject,
167 IN PVOID ObjectType,
168 IN OUT PACCESS_STATE AccessState,
169 IN KPROCESSOR_MODE AccessMode,
170 IN ULONG Attributes,
171 IN OUT PUNICODE_STRING CompleteName,
172 IN OUT PUNICODE_STRING RemainingName,
173 IN OUT PVOID Context OPTIONAL,
174 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
175 OUT PVOID *Object
176 );
177
178 typedef NTSTATUS
179 (NTAPI *OB_SECURITY_METHOD)(
180 IN PVOID Object,
181 IN SECURITY_OPERATION_CODE OperationType,
182 IN SECURITY_INFORMATION SecurityInformation,
183 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
184 IN OUT PULONG CapturedLength,
185 IN OUT PSECURITY_DESCRIPTOR *ObjectSecurityDescriptor,
186 IN POOL_TYPE PoolType,
187 IN PGENERIC_MAPPING GenericMapping
188 );
189
190 typedef NTSTATUS
191 (NTAPI *OB_QUERYNAME_METHOD)(
192 IN PVOID Object,
193 IN BOOLEAN HasObjectName,
194 OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
195 IN ULONG Length,
196 OUT PULONG ReturnLength
197 );
198
199 #else
200
201 //
202 // FIXME: ReactOS ONLY Object Callbacks
203 //
204 typedef NTSTATUS
205 (NTAPI *OB_OPEN_METHOD)(
206 OB_OPEN_REASON Reason,
207 PVOID ObjectBody,
208 PEPROCESS Process,
209 ULONG HandleCount,
210 ACCESS_MASK GrantedAccess
211 );
212
213 typedef NTSTATUS
214 (NTAPI *OB_PARSE_METHOD)(
215 PVOID Object,
216 PVOID *NextObject,
217 PUNICODE_STRING FullPath,
218 PWSTR *Path,
219 ULONG Attributes
220 );
221
222 typedef VOID
223 (NTAPI *OB_DELETE_METHOD)(
224 PVOID DeletedObject
225 );
226
227 typedef VOID
228 (NTAPI *OB_CLOSE_METHOD)(
229 PVOID ClosedObject,
230 ULONG HandleCount
231 );
232
233 typedef VOID
234 (NTAPI *OB_DUMP_METHOD)(
235 VOID
236 );
237
238 typedef NTSTATUS
239 (NTAPI *OB_OKAYTOCLOSE_METHOD)(
240 VOID
241 );
242
243 typedef NTSTATUS
244 (NTAPI *OB_QUERYNAME_METHOD)(
245 PVOID ObjectBody,
246 POBJECT_NAME_INFORMATION ObjectNameInfo,
247 ULONG Length,
248 PULONG ReturnLength
249 );
250
251 typedef PVOID
252 (NTAPI *OB_FIND_METHOD)(
253 PVOID WinStaObject,
254 PWSTR Name,
255 ULONG Attributes
256 );
257
258 typedef NTSTATUS
259 (NTAPI *OB_SECURITY_METHOD)(
260 PVOID Object,
261 SECURITY_OPERATION_CODE OperationType,
262 SECURITY_INFORMATION SecurityInformation,
263 PSECURITY_DESCRIPTOR NewSecurityDescriptor,
264 PULONG ReturnLength,
265 PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
266 POOL_TYPE PoolType,
267 PGENERIC_MAPPING GenericMapping
268 );
269
270 typedef NTSTATUS
271 (NTAPI *OB_CREATE_METHOD)(
272 PVOID ObjectBody,
273 PVOID Parent,
274 PWSTR RemainingPath,
275 struct _OBJECT_ATTRIBUTES* ObjectAttributes
276 );
277
278 #endif
279
280 #else
281
282 //
283 // Object Information Types for NtQueryInformationObject
284 //
285 typedef struct _OBJECT_NAME_INFORMATION
286 {
287 UNICODE_STRING Name;
288 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
289
290 #endif
291
292 typedef struct _OBJECT_HANDLE_ATTRIBUTE_INFORMATION
293 {
294 BOOLEAN Inherit;
295 BOOLEAN ProtectFromClose;
296 } OBJECT_HANDLE_ATTRIBUTE_INFORMATION, *POBJECT_HANDLE_ATTRIBUTE_INFORMATION;
297
298 typedef struct _OBJECT_DIRECTORY_INFORMATION
299 {
300 UNICODE_STRING ObjectName;
301 UNICODE_STRING ObjectTypeName;
302 } OBJECT_DIRECTORY_INFORMATION, *POBJECT_DIRECTORY_INFORMATION;
303
304 #ifndef NTOS_MODE_USER
305
306 typedef struct _OBJECT_BASIC_INFORMATION
307 {
308 ULONG Attributes;
309 ACCESS_MASK GrantedAccess;
310 ULONG HandleCount;
311 ULONG PointerCount;
312 ULONG PagedPoolUsage;
313 ULONG NonPagedPoolUsage;
314 ULONG Reserved[3];
315 ULONG NameInformationLength;
316 ULONG TypeInformationLength;
317 ULONG SecurityDescriptorLength;
318 LARGE_INTEGER CreateTime;
319 } OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
320
321 typedef struct _OBJECT_CREATE_INFORMATION
322 {
323 ULONG Attributes;
324 HANDLE RootDirectory;
325 PVOID ParseContext;
326 KPROCESSOR_MODE ProbeMode;
327 ULONG PagedPoolCharge;
328 ULONG NonPagedPoolCharge;
329 ULONG SecurityDescriptorCharge;
330 PSECURITY_DESCRIPTOR SecurityDescriptor;
331 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
332 SECURITY_QUALITY_OF_SERVICE SecurityQualityOfService;
333 } OBJECT_CREATE_INFORMATION, *POBJECT_CREATE_INFORMATION;
334
335 //
336 // Object Type Initialize for ObCreateObjectType
337 //
338 typedef struct _OBJECT_TYPE_INITIALIZER
339 {
340 USHORT Length;
341 UCHAR UseDefaultObject;
342 UCHAR CaseInsensitive;
343 ULONG InvalidAttributes;
344 GENERIC_MAPPING GenericMapping;
345 ULONG ValidAccessMask;
346 UCHAR SecurityRequired;
347 UCHAR MaintainHandleCount;
348 UCHAR MaintainTypeList;
349 POOL_TYPE PoolType;
350 ULONG DefaultPagedPoolCharge;
351 ULONG DefaultNonPagedPoolCharge;
352 OB_DUMP_METHOD DumpProcedure;
353 OB_OPEN_METHOD OpenProcedure;
354 OB_CLOSE_METHOD CloseProcedure;
355 OB_DELETE_METHOD DeleteProcedure;
356 OB_PARSE_METHOD ParseProcedure;
357 OB_SECURITY_METHOD SecurityProcedure;
358 OB_QUERYNAME_METHOD QueryNameProcedure;
359 OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure;
360 } OBJECT_TYPE_INITIALIZER, *POBJECT_TYPE_INITIALIZER;
361
362 //
363 // Object Type Object
364 //
365 typedef struct _OBJECT_TYPE
366 {
367 ERESOURCE Mutex;
368 LIST_ENTRY TypeList;
369 UNICODE_STRING Name;
370 PVOID DefaultObject;
371 ULONG Index;
372 ULONG TotalNumberOfObjects;
373 ULONG TotalNumberOfHandles;
374 ULONG HighWaterNumberOfObjects;
375 ULONG HighWaterNumberOfHandles;
376 OBJECT_TYPE_INITIALIZER TypeInfo;
377 ULONG Key;
378 ERESOURCE ObjectLocks[4];
379 } OBJECT_TYPE;
380
381 //
382 // Object Header Addon Information
383 //
384 typedef struct _OBJECT_HEADER_NAME_INFO
385 {
386 struct _DIRECTORY_OBJECT *Directory;
387 UNICODE_STRING Name;
388 ULONG QueryReferences;
389 ULONG Reserved2;
390 ULONG DbgReferenceCount;
391 } OBJECT_HEADER_NAME_INFO, *POBJECT_HEADER_NAME_INFO;
392
393 typedef struct _OBJECT_HANDLE_COUNT_ENTRY
394 {
395 struct _EPROCESS *Process;
396 ULONG HandleCount;
397 } OBJECT_HANDLE_COUNT_ENTRY, *POBJECT_HANDLE_COUNT_ENTRY;
398
399 typedef struct _OBJECT_HANDLE_COUNT_DATABASE
400 {
401 ULONG CountEntries;
402 POBJECT_HANDLE_COUNT_ENTRY HandleCountEntries[1];
403 } OBJECT_HANDLE_COUNT_DATABASE, *POBJECT_HANDLE_COUNT_DATABASE;
404
405 typedef struct _OBJECT_HEADER_HANDLE_INFO
406 {
407 union
408 {
409 POBJECT_HANDLE_COUNT_DATABASE HandleCountDatabase;
410 OBJECT_HANDLE_COUNT_ENTRY SingleEntry;
411 };
412 } OBJECT_HEADER_HANDLE_INFO, *POBJECT_HEADER_HANDLE_INFO;
413
414 typedef struct _OBJECT_HEADER_CREATOR_INFO
415 {
416 LIST_ENTRY TypeList;
417 PVOID CreatorUniqueProcess;
418 USHORT CreatorBackTraceIndex;
419 USHORT Reserved;
420 } OBJECT_HEADER_CREATOR_INFO, *POBJECT_HEADER_CREATOR_INFO;
421
422 //
423 // Object Header
424 //
425 typedef struct _OBJECT_HEADER
426 {
427 #ifdef _REACTOS_
428 LIST_ENTRY Entry; // FIXME: REACTOS ONLY
429 #endif
430 LONG PointerCount;
431 union
432 {
433 LONG HandleCount;
434 PVOID NextToFree;
435 };
436 POBJECT_TYPE Type;
437 UCHAR NameInfoOffset;
438 UCHAR HandleInfoOffset;
439 UCHAR QuotaInfoOffset;
440 UCHAR Flags;
441 union
442 {
443 POBJECT_CREATE_INFORMATION ObjectCreateInfo;
444 PVOID QuotaBlockCharged;
445 };
446 PSECURITY_DESCRIPTOR SecurityDescriptor;
447 QUAD Body;
448 } OBJECT_HEADER, *POBJECT_HEADER;
449
450 //
451 // Object Directory Structures
452 //
453 typedef struct _OBJECT_DIRECTORY_ENTRY
454 {
455 struct _OBJECT_DIRECTORY_ENTRY *ChainLink;
456 PVOID Object;
457 ULONG HashValue;
458 } OBJECT_DIRECTORY_ENTRY, *POBJECT_DIRECTORY_ENTRY;
459
460 typedef struct _OBJECT_DIRECTORY
461 {
462 struct _OBJECT_DIRECTORY_ENTRY *HashBuckets[NUMBER_HASH_BUCKETS];
463 struct _EX_PUSH_LOCK *Lock;
464 struct _DEVICE_MAP *DeviceMap;
465 ULONG SessionId;
466 } OBJECT_DIRECTORY, *POBJECT_DIRECTORY;
467
468 //
469 // Device Map
470 //
471 typedef struct _DEVICE_MAP
472 {
473 POBJECT_DIRECTORY DosDevicesDirectory;
474 POBJECT_DIRECTORY GlobalDosDevicesDirectory;
475 ULONG ReferenceCount;
476 ULONG DriveMap;
477 UCHAR DriveType[32];
478 } DEVICE_MAP, *PDEVICE_MAP;
479
480 //
481 // Kernel Exports
482 //
483 extern POBJECT_TYPE NTSYSAPI ObDirectoryType;
484 extern PDEVICE_MAP NTSYSAPI ObSystemDeviceMap;
485
486 #endif // !NTOS_MODE_USER
487
488 #endif // _OBTYPES_H