This commit was generated by cvs2svn to compensate for changes in r10,
[reactos.git] / reactos / include / internal / objmgr.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 typedef struct
15 {
16 CSHORT Type;
17 CSHORT Size;
18 } COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
19
20 typedef struct _DIRECTORY_OBJECT
21 {
22 CSHORT Type;
23 CSHORT Size;
24
25 /*
26 * PURPOSE: Head of the list of our subdirectories
27 */
28 LIST_ENTRY head;
29 } DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
30
31
32 /*
33 * Enumeration of object types
34 */
35 enum
36 {
37 OBJTYP_INVALID,
38 OBJTYP_TYPE,
39 OBJTYP_DIRECTORY,
40 OBJTYP_SYMLNK,
41 OBJTYP_DEVICE,
42 OBJTYP_THREAD,
43 OBJTYP_MAX,
44 };
45
46 BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object);
47
48 VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
49
50 VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
51 POBJECT_HEADER obj);
52
53 /*
54 * FUNCTION: Get the size of an object
55 * ARGUMENTS:
56 * Type = Object type
57 * RETURNS: The size in bytes
58 */
59 ULONG ObSizeOf(CSHORT Type);
60 HANDLE ObAddHandle(PVOID obj);
61
62 PVOID ObGetObjectByHandle(HANDLE h);
63 PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string);
64 PVOID ObGenericCreateObject(PHANDLE Handle,
65 ACCESS_MASK DesiredAccess,
66 POBJECT_ATTRIBUTES ObjectAttributes,
67 CSHORT Type);
68
69 /*
70 * FUNCTION: Creates an entry within a directory
71 * ARGUMENTS:
72 * parent = Parent directory
73 * object = Header of the object to add
74 */
75 VOID ObCreateEntry(PDIRECTORY_OBJECT parent, POBJECT_HEADER object);
76
77 extern inline POBJECT_HEADER BODY_TO_HEADER(PVOID body)
78 {
79 PCOMMON_BODY_HEADER chdr = (PCOMMON_BODY_HEADER)body;
80 return(CONTAINING_RECORD((&(chdr->Type)),OBJECT_HEADER,Type));
81 }
82
83 extern inline PVOID HEADER_TO_BODY(POBJECT_HEADER obj)
84 {
85 return(((void *)obj)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER));
86 }
87
88 #define OBJECT_ALLOC_SIZE(type) (ObSizeOf(type)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
89
90 #endif /* __INCLUDE_INTERNAL_OBJMGR_H */