Prevent: warning: dereferencing type-punned pointer will break strict-aliasing rules
[reactos.git] / include / ntos / obtypes.h
1 #ifndef _INCLUDE_DDK_OBTYPES_H
2 #define _INCLUDE_DDK_OBTYPES_H
3 /* $Id$ */
4 struct _DIRECTORY_OBJECT;
5 struct _OBJECT_ATTRIBUTES;
6
7 #ifndef __USE_W32API
8
9 typedef struct _ACCESS_STATE
10 {
11     LUID OperationID;
12     BOOLEAN SecurityEvaluated;
13     BOOLEAN GenerateAudit;
14     BOOLEAN GenerateOnClose;
15     BOOLEAN PrivilegesAllocated;
16     ULONG Flags;
17     ACCESS_MASK RemainingDesiredAccess;
18     ACCESS_MASK PreviouslyGrantedAccess;
19     ACCESS_MASK OriginalDesiredAccess;
20     SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
21     PSECURITY_DESCRIPTOR SecurityDescriptor;
22     PVOID AuxData;
23     union
24     {
25         INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
26         PRIVILEGE_SET PrivilegeSet;
27     } Privileges;
28  
29     BOOLEAN AuditPrivileges;
30     UNICODE_STRING ObjectName;
31     UNICODE_STRING ObjectTypeName;
32 } ACCESS_STATE, *PACCESS_STATE;
33
34 typedef struct _OBJECT_NAME_INFORMATION
35 {
36   UNICODE_STRING Name;
37 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
38
39 typedef struct _OBJECT_HANDLE_INFORMATION
40 {
41   ULONG HandleAttributes;
42   ACCESS_MASK GrantedAccess;
43 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
44
45 #endif /* __USE_W32API */
46
47 typedef struct _OBJECT_TYPE
48 {
49   /*
50    * PURPOSE: Tag to be used when allocating objects of this type
51    */
52   ULONG Tag;
53
54   /*
55    * PURPOSE: Name of the type
56    */
57   UNICODE_STRING TypeName;
58   
59   /*
60    * PURPOSE: Total number of objects of this type
61    */
62   ULONG TotalObjects;
63   
64   /*
65    * PURPOSE: Total number of handles of this type
66    */
67   ULONG TotalHandles;
68   
69   /*
70    * PURPOSE: Maximum objects of this type
71    */
72   ULONG MaxObjects;
73   
74    /*
75     * PURPOSE: Maximum handles of this type
76     */
77   ULONG MaxHandles;
78   
79   /*
80    * PURPOSE: Paged pool charge
81    */
82    ULONG PagedPoolCharge;
83   
84   /*
85    * PURPOSE: Nonpaged pool charge
86    */
87   ULONG NonpagedPoolCharge;
88   
89   /*
90    * PURPOSE: Mapping of generic access rights
91    */
92   PGENERIC_MAPPING Mapping;
93   
94   /*
95    * PURPOSE: Dumps the object
96    * NOTE: To be defined
97    */
98   VOID STDCALL_FUNC (*Dump)(VOID);
99   
100   /*
101    * PURPOSE: Opens the object
102    * NOTE: To be defined
103    */
104   VOID STDCALL_FUNC (*Open)(VOID);
105   
106    /*
107     * PURPOSE: Called to close an object if OkayToClose returns true
108     */
109   VOID STDCALL_FUNC (*Close)(PVOID ObjectBody,
110                         ULONG HandleCount);
111   
112   /*
113    * PURPOSE: Called to delete an object when the last reference is removed
114    */
115   VOID STDCALL_FUNC (*Delete)(PVOID ObjectBody);
116   
117   /*
118    * PURPOSE: Called when an open attempts to open a file apparently
119    * residing within the object
120    * RETURNS
121    *     STATUS_SUCCESS       NextObject was found
122    *     STATUS_UNSUCCESSFUL  NextObject not found
123    *     STATUS_REPARSE       Path changed, restart parsing the path
124    */
125    NTSTATUS STDCALL_FUNC (*Parse)(PVOID ParsedObject,
126                              PVOID *NextObject,
127                              PUNICODE_STRING FullPath,
128                              PWSTR *Path,
129                              ULONG Attributes);
130
131   /*
132    * PURPOSE: Called to set, query, delete or assign a security-descriptor
133    * to the object
134    * RETURNS
135    *     STATUS_SUCCESS       NextObject was found
136    */
137   NTSTATUS STDCALL_FUNC (*Security)(PVOID ObjectBody,
138                                     SECURITY_OPERATION_CODE OperationCode,
139                                     SECURITY_INFORMATION SecurityInformation,
140                                     PSECURITY_DESCRIPTOR SecurityDescriptor,
141                                     PULONG BufferLength);
142
143   /*
144    * PURPOSE: Called to query the name of the object
145    * RETURNS
146    *     STATUS_SUCCESS       NextObject was found
147    */
148   NTSTATUS STDCALL_FUNC (*QueryName)(PVOID ObjectBody,
149                                      POBJECT_NAME_INFORMATION ObjectNameInfo,
150                                      ULONG Length,
151                                      PULONG ReturnLength);
152
153   /*
154    * PURPOSE: Called when a process asks to close the object
155    */
156   VOID STDCALL_FUNC (*OkayToClose)(VOID);
157
158   NTSTATUS STDCALL_FUNC (*Create)(PVOID ObjectBody,
159                              PVOID Parent,
160                              PWSTR RemainingPath,
161                              struct _OBJECT_ATTRIBUTES* ObjectAttributes);
162
163   VOID STDCALL_FUNC (*DuplicationNotify)(PEPROCESS DuplicateTo,
164                                     PEPROCESS DuplicateFrom,
165                                     PVOID Object);
166 } OBJECT_TYPE;
167
168 #ifndef __USE_W32API
169
170 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
171
172 #endif /* __USE_W32API */
173
174
175 typedef struct _OBJECT_HEADER
176 /*
177  * PURPOSE: Header for every object managed by the object manager
178  */
179 {
180    UNICODE_STRING Name;
181    LIST_ENTRY Entry;
182    LONG RefCount;
183    LONG HandleCount;
184    BOOLEAN CloseInProcess;
185    BOOLEAN Permanent;
186    struct _DIRECTORY_OBJECT* Parent;
187    POBJECT_TYPE ObjectType;
188    
189    /*
190     * PURPOSE: Object type
191     * NOTE: This overlaps the first member of the object body
192     */
193    CSHORT Type;
194    
195    /*
196     * PURPOSE: Object size
197     * NOTE: This overlaps the second member of the object body
198     */
199    CSHORT Size;
200    
201    
202 } OBJECT_HEADER, *POBJECT_HEADER;
203
204 #ifndef __USE_W32API
205
206 typedef struct _OBJECT_ATTRIBUTES
207 {
208    ULONG Length;
209    HANDLE RootDirectory;
210    PUNICODE_STRING ObjectName;
211    ULONG Attributes;
212    SECURITY_DESCRIPTOR *SecurityDescriptor;
213    SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;
214 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
215
216 #endif /* __USE_W32API */
217
218 typedef struct _HANDLE_TABLE
219 {
220    LIST_ENTRY ListHead;
221    KSPIN_LOCK ListLock;
222 } HANDLE_TABLE;
223
224 #ifndef __USE_W32API
225
226 typedef struct _HANDLE_TABLE *PHANDLE_TABLE;
227
228 #endif /* __USE_W32API */
229
230 extern POBJECT_TYPE ObDirectoryType;
231
232 #endif /* ndef _INCLUDE_DDK_OBTYPES_H */