Added ObGetObjectHandleCount().
[reactos.git] / reactos / ntoskrnl / include / internal / ob.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: include/internal/objmgr.h
5 * PURPOSE: Object manager definitions
6 * PROGRAMMER: David Welch (welch@mcmail.com)
7 */
8
9 #ifndef __INCLUDE_INTERNAL_OBJMGR_H
10 #define __INCLUDE_INTERNAL_OBJMGR_H
11
12 #include <ddk/types.h>
13
14 struct _EPROCESS;
15
16 typedef struct
17 {
18 CSHORT Type;
19 CSHORT Size;
20 } COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
21
22 typedef PVOID POBJECT;
23
24 typedef struct _DIRECTORY_OBJECT
25 {
26 CSHORT Type;
27 CSHORT Size;
28
29 /*
30 * PURPOSE: Head of the list of our subdirectories
31 */
32 LIST_ENTRY head;
33 KSPIN_LOCK Lock;
34 } DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
35
36
37 typedef struct _TYPE_OBJECT
38 {
39 CSHORT Type;
40 CSHORT Size;
41
42 /* pointer to object type data */
43 POBJECT_TYPE ObjectType;
44 } TYPE_OBJECT, *PTYPE_OBJECT;
45
46
47 /*
48 * Enumeration of object types
49 */
50 enum
51 {
52 OBJTYP_INVALID,
53 OBJTYP_TYPE,
54 OBJTYP_DIRECTORY,
55 OBJTYP_SYMLNK,
56 OBJTYP_DEVICE,
57 OBJTYP_THREAD,
58 OBJTYP_FILE,
59 OBJTYP_PROCESS,
60 OBJTYP_SECTION,
61 OBJTYP_MAX,
62 };
63
64
65 #define OBJECT_ALLOC_SIZE(type) (type->NonpagedPoolCharge+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
66
67
68 extern PDIRECTORY_OBJECT NameSpaceRoot;
69
70
71 POBJECT_HEADER BODY_TO_HEADER(PVOID body);
72 PVOID HEADER_TO_BODY(POBJECT_HEADER obj);
73
74 VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent,
75 POBJECT_HEADER Header,
76 PWSTR Name);
77 VOID ObpRemoveEntryDirectory(POBJECT_HEADER Header);
78
79
80
81 NTSTATUS ObCreateHandle(struct _EPROCESS* Process,
82 PVOID ObjectBody,
83 ACCESS_MASK GrantedAccess,
84 BOOLEAN Inherit,
85 PHANDLE Handle);
86 VOID ObCreateHandleTable(struct _EPROCESS* Parent,
87 BOOLEAN Inherit,
88 struct _EPROCESS* Process);
89 NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
90 PVOID* ReturnedObject,
91 PUNICODE_STRING RemainingPath,
92 POBJECT_TYPE ObjectType);
93 VOID ObCloseAllHandles(struct _EPROCESS* Process);
94 VOID ObDeleteHandleTable(struct _EPROCESS* Process);
95 PVOID ObDeleteHandle(struct _EPROCESS* Process,
96 HANDLE Handle);
97
98 NTSTATUS
99 ObpCreateTypeObject(POBJECT_TYPE ObjectType);
100
101 ULONG
102 ObGetObjectHandleCount(PVOID Object);
103
104 #endif /* __INCLUDE_INTERNAL_OBJMGR_H */