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)
9 #ifndef __INCLUDE_INTERNAL_OBJMGR_H
10 #define __INCLUDE_INTERNAL_OBJMGR_H
12 #define NTOS_MODE_KERNEL
15 #define TAG_OBJECT_TYPE TAG('O', 'b', 'j', 'T')
23 } COMMON_BODY_HEADER
, *PCOMMON_BODY_HEADER
;
25 typedef PVOID POBJECT
;
28 typedef struct _OBJECT_TYPE
31 * PURPOSE: Tag to be used when allocating objects of this type
36 * PURPOSE: Name of the type
38 UNICODE_STRING TypeName
;
41 * PURPOSE: Total number of objects of this type
46 * PURPOSE: Total number of handles of this type
51 * PURPOSE: Peak objects of this type
56 * PURPOSE: Peak handles of this type
61 * PURPOSE: Paged pool charge
63 ULONG PagedPoolCharge
;
66 * PURPOSE: Nonpaged pool charge
68 ULONG NonpagedPoolCharge
;
71 * PURPOSE: Mapping of generic access rights
73 PGENERIC_MAPPING Mapping
;
76 * PURPOSE: Dumps the object
79 VOID
STDCALL_FUNC (*Dump
)(VOID
);
82 * PURPOSE: Opens the object
85 VOID
STDCALL_FUNC (*Open
)(VOID
);
88 * PURPOSE: Called to close an object if OkayToClose returns true
90 VOID
STDCALL_FUNC (*Close
)(PVOID ObjectBody
,
94 * PURPOSE: Called to delete an object when the last reference is removed
96 VOID
STDCALL_FUNC (*Delete
)(PVOID ObjectBody
);
99 * PURPOSE: Called when an open attempts to open a file apparently
100 * residing within the object
102 * STATUS_SUCCESS NextObject was found
103 * STATUS_UNSUCCESSFUL NextObject not found
104 * STATUS_REPARSE Path changed, restart parsing the path
106 NTSTATUS
STDCALL_FUNC (*Parse
)(PVOID ParsedObject
,
108 PUNICODE_STRING FullPath
,
113 * PURPOSE: Called to set, query, delete or assign a security-descriptor
116 * STATUS_SUCCESS NextObject was found
118 NTSTATUS
STDCALL_FUNC (*Security
)(PVOID ObjectBody
,
119 SECURITY_OPERATION_CODE OperationCode
,
120 SECURITY_INFORMATION SecurityInformation
,
121 PSECURITY_DESCRIPTOR SecurityDescriptor
,
122 PULONG BufferLength
);
125 * PURPOSE: Called to query the name of the object
127 * STATUS_SUCCESS NextObject was found
129 NTSTATUS
STDCALL_FUNC (*QueryName
)(PVOID ObjectBody
,
130 POBJECT_NAME_INFORMATION ObjectNameInfo
,
132 PULONG ReturnLength
);
135 * PURPOSE: Called when a process asks to close the object
137 VOID
STDCALL_FUNC (*OkayToClose
)(VOID
);
139 NTSTATUS
STDCALL_FUNC (*Create
)(PVOID ObjectBody
,
142 struct _OBJECT_ATTRIBUTES
* ObjectAttributes
);
144 VOID
STDCALL_FUNC (*DuplicationNotify
)(PEPROCESS DuplicateTo
,
145 PEPROCESS DuplicateFrom
,
151 typedef struct _OBJECT_HEADER
153 * PURPOSE: Header for every object managed by the object manager
160 BOOLEAN CloseInProcess
;
163 struct _DIRECTORY_OBJECT
* Parent
;
164 POBJECT_TYPE ObjectType
;
165 PSECURITY_DESCRIPTOR SecurityDescriptor
;
168 * PURPOSE: Object type
169 * NOTE: This overlaps the first member of the object body
174 * PURPOSE: Object size
175 * NOTE: This overlaps the second member of the object body
180 } OBJECT_HEADER
, *POBJECT_HEADER
;
183 typedef struct _DIRECTORY_OBJECT
189 * PURPOSE: Head of the list of our subdirectories
193 } DIRECTORY_OBJECT
, *PDIRECTORY_OBJECT
;
195 typedef struct _SYMLINK_OBJECT
199 UNICODE_STRING TargetName
;
200 LARGE_INTEGER CreateTime
;
201 } SYMLINK_OBJECT
, *PSYMLINK_OBJECT
;
204 typedef struct _TYPE_OBJECT
209 /* pointer to object type data */
210 POBJECT_TYPE ObjectType
;
211 } TYPE_OBJECT
, *PTYPE_OBJECT
;
215 * Enumeration of object types
232 #define OBJECT_ALLOC_SIZE(ObjectSize) ((ObjectSize)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
235 extern PDIRECTORY_OBJECT NameSpaceRoot
;
236 extern POBJECT_TYPE ObSymbolicLinkType
;
239 POBJECT_HEADER
BODY_TO_HEADER(PVOID body
);
240 PVOID
HEADER_TO_BODY(POBJECT_HEADER obj
);
242 VOID
ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent
,
243 POBJECT_HEADER Header
,
245 VOID
ObpRemoveEntryDirectory(POBJECT_HEADER Header
);
248 ObInitSymbolicLinkImplementation(VOID
);
251 NTSTATUS
ObCreateHandle(struct _EPROCESS
* Process
,
253 ACCESS_MASK GrantedAccess
,
256 VOID
ObCreateHandleTable(struct _EPROCESS
* Parent
,
258 struct _EPROCESS
* Process
);
259 NTSTATUS
ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes
,
260 PVOID
* ReturnedObject
,
261 PUNICODE_STRING RemainingPath
,
262 POBJECT_TYPE ObjectType
);
263 VOID
ObCloseAllHandles(struct _EPROCESS
* Process
);
264 VOID
ObDeleteHandleTable(struct _EPROCESS
* Process
);
267 ObDeleteHandle(PEPROCESS Process
,
272 ObpQueryHandleAttributes(HANDLE Handle
,
273 POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo
);
276 ObpSetHandleAttributes(HANDLE Handle
,
277 POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo
);
280 ObpCreateTypeObject(POBJECT_TYPE ObjectType
);
283 ObGetObjectHandleCount(PVOID Object
);
285 ObDuplicateObject(PEPROCESS SourceProcess
,
286 PEPROCESS TargetProcess
,
288 PHANDLE TargetHandle
,
289 ACCESS_MASK DesiredAccess
,
290 BOOLEAN InheritHandle
,
294 ObpGetHandleCountByHandleTable(PHANDLE_TABLE HandleTable
);
298 ObQueryDeviceMapInformation(PEPROCESS Process
, PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo
);
300 /* Security descriptor cache functions */
303 ObpInitSdCache(VOID
);
306 ObpAddSecurityDescriptor(IN PSECURITY_DESCRIPTOR SourceSD
,
307 OUT PSECURITY_DESCRIPTOR
*DestinationSD
);
310 ObpRemoveSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
313 ObpReferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
316 ObpDereferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
319 #endif /* __INCLUDE_INTERNAL_OBJMGR_H */