- Forgot to add the define which enables _REACTOS_
[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 /* FUNCTION TYPES ************************************************************/
121
122 #ifndef NTOS_MODE_USER
123
124 //
125 // FIXME: Object Callbacks
126 //
127 typedef NTSTATUS
128 (NTAPI *OB_OPEN_METHOD)(
129 OB_OPEN_REASON Reason,
130 PVOID ObjectBody,
131 PEPROCESS Process,
132 ULONG HandleCount,
133 ACCESS_MASK GrantedAccess
134 );
135
136 typedef NTSTATUS
137 (NTAPI *OB_PARSE_METHOD)(
138 PVOID Object,
139 PVOID *NextObject,
140 PUNICODE_STRING FullPath,
141 PWSTR *Path,
142 ULONG Attributes
143 );
144
145 typedef VOID
146 (NTAPI *OB_DELETE_METHOD)(
147 PVOID DeletedObject
148 );
149
150 typedef VOID
151 (NTAPI *OB_CLOSE_METHOD)(
152 PVOID ClosedObject,
153 ULONG HandleCount
154 );
155
156 typedef VOID
157 (NTAPI *OB_DUMP_METHOD)(
158 VOID
159 );
160
161 typedef NTSTATUS
162 (NTAPI *OB_OKAYTOCLOSE_METHOD)(
163 VOID
164 );
165
166 typedef NTSTATUS
167 (NTAPI *OB_QUERYNAME_METHOD)(
168 PVOID ObjectBody,
169 POBJECT_NAME_INFORMATION ObjectNameInfo,
170 ULONG Length,
171 PULONG ReturnLength
172 );
173
174 typedef PVOID
175 (NTAPI *OB_FIND_METHOD)(
176 PVOID WinStaObject,
177 PWSTR Name,
178 ULONG Attributes
179 );
180
181 typedef NTSTATUS
182 (NTAPI *OB_SECURITY_METHOD)(
183 PVOID Object,
184 SECURITY_OPERATION_CODE OperationType,
185 SECURITY_INFORMATION SecurityInformation,
186 PSECURITY_DESCRIPTOR NewSecurityDescriptor,
187 PULONG ReturnLength,
188 PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
189 POOL_TYPE PoolType,
190 PGENERIC_MAPPING GenericMapping
191 );
192
193 typedef NTSTATUS
194 (NTAPI *OB_CREATE_METHOD)(
195 PVOID ObjectBody,
196 PVOID Parent,
197 PWSTR RemainingPath,
198 struct _OBJECT_ATTRIBUTES* ObjectAttributes
199 );
200
201 #else
202
203 //
204 // Object Information Types for NtQueryInformationObject
205 //
206 typedef struct _OBJECT_NAME_INFORMATION
207 {
208 UNICODE_STRING Name;
209 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
210
211 #endif
212
213 typedef struct _OBJECT_HANDLE_ATTRIBUTE_INFORMATION
214 {
215 BOOLEAN Inherit;
216 BOOLEAN ProtectFromClose;
217 } OBJECT_HANDLE_ATTRIBUTE_INFORMATION, *POBJECT_HANDLE_ATTRIBUTE_INFORMATION;
218
219 typedef struct _OBJECT_DIRECTORY_INFORMATION
220 {
221 UNICODE_STRING ObjectName;
222 UNICODE_STRING ObjectTypeName;
223 } OBJECT_DIRECTORY_INFORMATION, *POBJECT_DIRECTORY_INFORMATION;
224
225 #ifndef NTOS_MODE_USER
226
227 typedef struct _OBJECT_BASIC_INFORMATION
228 {
229 ULONG Attributes;
230 ACCESS_MASK GrantedAccess;
231 ULONG HandleCount;
232 ULONG PointerCount;
233 ULONG PagedPoolUsage;
234 ULONG NonPagedPoolUsage;
235 ULONG Reserved[3];
236 ULONG NameInformationLength;
237 ULONG TypeInformationLength;
238 ULONG SecurityDescriptorLength;
239 LARGE_INTEGER CreateTime;
240 } OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
241
242 typedef struct _OBJECT_CREATE_INFORMATION
243 {
244 ULONG Attributes;
245 HANDLE RootDirectory;
246 PVOID ParseContext;
247 KPROCESSOR_MODE ProbeMode;
248 ULONG PagedPoolCharge;
249 ULONG NonPagedPoolCharge;
250 ULONG SecurityDescriptorCharge;
251 PSECURITY_DESCRIPTOR SecurityDescriptor;
252 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
253 SECURITY_QUALITY_OF_SERVICE SecurityQualityOfService;
254 } OBJECT_CREATE_INFORMATION, *POBJECT_CREATE_INFORMATION;
255
256 //
257 // Object Type Initialize for ObCreateObjectType
258 //
259 typedef struct _OBJECT_TYPE_INITIALIZER
260 {
261 USHORT Length;
262 UCHAR UseDefaultObject;
263 UCHAR CaseInsensitive;
264 ULONG InvalidAttributes;
265 GENERIC_MAPPING GenericMapping;
266 ULONG ValidAccessMask;
267 UCHAR SecurityRequired;
268 UCHAR MaintainHandleCount;
269 UCHAR MaintainTypeList;
270 POOL_TYPE PoolType;
271 ULONG DefaultPagedPoolCharge;
272 ULONG DefaultNonPagedPoolCharge;
273 OB_DUMP_METHOD DumpProcedure;
274 OB_OPEN_METHOD OpenProcedure;
275 OB_CLOSE_METHOD CloseProcedure;
276 OB_DELETE_METHOD DeleteProcedure;
277 OB_PARSE_METHOD ParseProcedure;
278 OB_SECURITY_METHOD SecurityProcedure;
279 OB_QUERYNAME_METHOD QueryNameProcedure;
280 OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure;
281 } OBJECT_TYPE_INITIALIZER, *POBJECT_TYPE_INITIALIZER;
282
283 //
284 // Object Type Object
285 //
286 typedef struct _OBJECT_TYPE
287 {
288 ERESOURCE Mutex;
289 LIST_ENTRY TypeList;
290 UNICODE_STRING Name;
291 PVOID DefaultObject;
292 ULONG Index;
293 ULONG TotalNumberOfObjects;
294 ULONG TotalNumberOfHandles;
295 ULONG HighWaterNumberOfObjects;
296 ULONG HighWaterNumberOfHandles;
297 OBJECT_TYPE_INITIALIZER TypeInfo;
298 ULONG Key;
299 ERESOURCE ObjectLocks[4];
300 } OBJECT_TYPE;
301
302 //
303 // Object Header Addon Information
304 //
305 typedef struct _OBJECT_HEADER_NAME_INFO
306 {
307 struct _DIRECTORY_OBJECT *Directory;
308 UNICODE_STRING Name;
309 ULONG QueryReferences;
310 ULONG Reserved2;
311 ULONG DbgReferenceCount;
312 } OBJECT_HEADER_NAME_INFO, *POBJECT_HEADER_NAME_INFO;
313
314 typedef struct _OBJECT_HANDLE_COUNT_ENTRY
315 {
316 struct _EPROCESS *Process;
317 ULONG HandleCount;
318 } OBJECT_HANDLE_COUNT_ENTRY, *POBJECT_HANDLE_COUNT_ENTRY;
319
320 typedef struct _OBJECT_HANDLE_COUNT_DATABASE
321 {
322 ULONG CountEntries;
323 POBJECT_HANDLE_COUNT_ENTRY HandleCountEntries[1];
324 } OBJECT_HANDLE_COUNT_DATABASE, *POBJECT_HANDLE_COUNT_DATABASE;
325
326 typedef struct _OBJECT_HEADER_HANDLE_INFO
327 {
328 union
329 {
330 POBJECT_HANDLE_COUNT_DATABASE HandleCountDatabase;
331 OBJECT_HANDLE_COUNT_ENTRY SingleEntry;
332 };
333 } OBJECT_HEADER_HANDLE_INFO, *POBJECT_HEADER_HANDLE_INFO;
334
335 typedef struct _OBJECT_HEADER_CREATOR_INFO
336 {
337 LIST_ENTRY TypeList;
338 PVOID CreatorUniqueProcess;
339 USHORT CreatorBackTraceIndex;
340 USHORT Reserved;
341 } OBJECT_HEADER_CREATOR_INFO, *POBJECT_HEADER_CREATOR_INFO;
342
343 //
344 // Object Header
345 //
346 typedef struct _OBJECT_HEADER
347 {
348 #ifdef _REACTOS_
349 LIST_ENTRY Entry; // FIXME: REACTOS ONLY
350 #endif
351 LONG PointerCount;
352 union
353 {
354 LONG HandleCount;
355 PVOID NextToFree;
356 };
357 POBJECT_TYPE Type;
358 UCHAR NameInfoOffset;
359 UCHAR HandleInfoOffset;
360 UCHAR QuotaInfoOffset;
361 UCHAR Flags;
362 union
363 {
364 POBJECT_CREATE_INFORMATION ObjectCreateInfo;
365 PVOID QuotaBlockCharged;
366 };
367 PSECURITY_DESCRIPTOR SecurityDescriptor;
368 QUAD Body;
369 } OBJECT_HEADER, *POBJECT_HEADER;
370
371 //
372 // Object Directory Structures
373 //
374 typedef struct _OBJECT_DIRECTORY_ENTRY
375 {
376 struct _OBJECT_DIRECTORY_ENTRY *ChainLink;
377 PVOID Object;
378 ULONG HashValue;
379 } OBJECT_DIRECTORY_ENTRY, *POBJECT_DIRECTORY_ENTRY;
380
381 typedef struct _OBJECT_DIRECTORY
382 {
383 struct _OBJECT_DIRECTORY_ENTRY *HashBuckets[NUMBER_HASH_BUCKETS];
384 struct _EX_PUSH_LOCK *Lock;
385 struct _DEVICE_MAP *DeviceMap;
386 ULONG SessionId;
387 } OBJECT_DIRECTORY, *POBJECT_DIRECTORY;
388
389 //
390 // Device Map
391 //
392 typedef struct _DEVICE_MAP
393 {
394 POBJECT_DIRECTORY DosDevicesDirectory;
395 POBJECT_DIRECTORY GlobalDosDevicesDirectory;
396 ULONG ReferenceCount;
397 ULONG DriveMap;
398 UCHAR DriveType[32];
399 } DEVICE_MAP, *PDEVICE_MAP;
400
401 //
402 // Kernel Exports
403 //
404 extern POBJECT_TYPE NTSYSAPI ObDirectoryType;
405 extern PDEVICE_MAP NTSYSAPI ObSystemDeviceMap;
406
407 #endif // !NTOS_MODE_USER
408
409 #endif // _OBTYPES_H