e6184dcbafbccd29ac13a3d3b0b656387a4eb5ba
[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 #define NTOS_MODE_KERNEL
13 #include <ntos.h>
14
15 struct _EPROCESS;
16
17 typedef struct
18 {
19 CSHORT Type;
20 CSHORT Size;
21 } COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
22
23 typedef PVOID POBJECT;
24
25 typedef struct _DIRECTORY_OBJECT
26 {
27 CSHORT Type;
28 CSHORT Size;
29
30 /*
31 * PURPOSE: Head of the list of our subdirectories
32 */
33 LIST_ENTRY head;
34 KSPIN_LOCK Lock;
35 } DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
36
37
38 typedef struct _SYMLINK_OBJECT
39 {
40 CSHORT Type;
41 CSHORT Size;
42 UNICODE_STRING TargetName;
43 LARGE_INTEGER CreateTime;
44 } SYMLINK_OBJECT, *PSYMLINK_OBJECT;
45
46
47 typedef struct _TYPE_OBJECT
48 {
49 CSHORT Type;
50 CSHORT Size;
51
52 /* pointer to object type data */
53 POBJECT_TYPE ObjectType;
54 } TYPE_OBJECT, *PTYPE_OBJECT;
55
56
57 /*
58 * Enumeration of object types
59 */
60 enum
61 {
62 OBJTYP_INVALID,
63 OBJTYP_TYPE,
64 OBJTYP_DIRECTORY,
65 OBJTYP_SYMLNK,
66 OBJTYP_DEVICE,
67 OBJTYP_THREAD,
68 OBJTYP_FILE,
69 OBJTYP_PROCESS,
70 OBJTYP_SECTION,
71 OBJTYP_MAX,
72 };
73
74
75 #define OBJECT_ALLOC_SIZE(ObjectSize) ((ObjectSize)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
76
77
78 extern PDIRECTORY_OBJECT NameSpaceRoot;
79 extern POBJECT_TYPE ObSymbolicLinkType;
80
81
82 POBJECT_HEADER BODY_TO_HEADER(PVOID body);
83 PVOID HEADER_TO_BODY(POBJECT_HEADER obj);
84
85 VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent,
86 POBJECT_HEADER Header,
87 PWSTR Name);
88 VOID ObpRemoveEntryDirectory(POBJECT_HEADER Header);
89
90 VOID
91 ObInitSymbolicLinkImplementation(VOID);
92
93
94 NTSTATUS ObCreateHandle(struct _EPROCESS* Process,
95 PVOID ObjectBody,
96 ACCESS_MASK GrantedAccess,
97 BOOLEAN Inherit,
98 PHANDLE Handle);
99 VOID ObCreateHandleTable(struct _EPROCESS* Parent,
100 BOOLEAN Inherit,
101 struct _EPROCESS* Process);
102 NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
103 PVOID* ReturnedObject,
104 PUNICODE_STRING RemainingPath,
105 POBJECT_TYPE ObjectType);
106 VOID ObCloseAllHandles(struct _EPROCESS* Process);
107 VOID ObDeleteHandleTable(struct _EPROCESS* Process);
108
109 NTSTATUS
110 ObDeleteHandle(PEPROCESS Process,
111 HANDLE Handle,
112 PVOID *ObjectBody);
113
114 NTSTATUS
115 ObpQueryHandleAttributes(HANDLE Handle,
116 POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo);
117
118 NTSTATUS
119 ObpSetHandleAttributes(HANDLE Handle,
120 POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo);
121
122 NTSTATUS
123 ObpCreateTypeObject(POBJECT_TYPE ObjectType);
124
125 ULONG
126 ObGetObjectHandleCount(PVOID Object);
127 NTSTATUS
128 ObDuplicateObject(PEPROCESS SourceProcess,
129 PEPROCESS TargetProcess,
130 HANDLE SourceHandle,
131 PHANDLE TargetHandle,
132 ACCESS_MASK DesiredAccess,
133 BOOLEAN InheritHandle,
134 ULONG Options);
135
136 ULONG
137 ObpGetHandleCountByHandleTable(PHANDLE_TABLE HandleTable);
138
139
140 /* Security descriptor cache functions */
141
142 NTSTATUS
143 ObpInitSdCache(VOID);
144
145 NTSTATUS
146 ObpAddSecurityDescriptor(IN PSECURITY_DESCRIPTOR SourceSD,
147 OUT PSECURITY_DESCRIPTOR *DestinationSD);
148
149 NTSTATUS
150 ObpRemoveSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
151
152
153 #endif /* __INCLUDE_INTERNAL_OBJMGR_H */