bd9fb1b4473afdbe75a213573b2c22c05e491cf7
[reactos.git] / reactos / ntoskrnl / include / internal / ex.h
1 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
2 #define __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
3
4 /* GLOBAL VARIABLES *********************************************************/
5
6 extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
7 extern LARGE_INTEGER ExpTimeZoneBias;
8 extern ULONG ExpTimeZoneId;
9 extern POBJECT_TYPE ExEventPairObjectType;
10
11 #define EX_OBJ_TO_HDR(eob) ((POBJECT_HEADER)((ULONG_PTR)(eob) & \
12 ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
13 EX_HANDLE_ENTRY_AUDITONCLOSE)))
14 #define EX_HTE_TO_HDR(hte) ((POBJECT_HEADER)((ULONG_PTR)((hte)->u1.Object) & \
15 ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
16 EX_HANDLE_ENTRY_AUDITONCLOSE)))
17
18 /* INITIALIZATION FUNCTIONS *************************************************/
19
20 VOID
21 STDCALL
22 ExpWin32kInit(VOID);
23
24 VOID
25 STDCALL
26 ExInit2(VOID);
27
28 VOID
29 STDCALL
30 ExpInitTimeZoneInfo(VOID);
31
32 VOID
33 STDCALL
34 ExpInitializeWorkerThreads(VOID);
35
36 VOID
37 STDCALL
38 ExpInitLookasideLists(VOID);
39
40 VOID
41 STDCALL
42 ExpInitializeCallbacks(VOID);
43
44 VOID
45 STDCALL
46 ExpInitUuids(VOID);
47
48 VOID
49 STDCALL
50 ExpInitializeExecutive(VOID);
51
52 VOID
53 STDCALL
54 ExpInitializeEventImplementation(VOID);
55
56 VOID
57 STDCALL
58 ExpInitializeEventImplementation(VOID);
59
60 VOID
61 STDCALL
62 ExpInitializeEventPairImplementation(VOID);
63
64 VOID
65 STDCALL
66 ExpInitializeSemaphoreImplementation(VOID);
67
68 VOID
69 STDCALL
70 ExpInitializeMutantImplementation(VOID);
71
72 VOID
73 STDCALL
74 ExpInitializeTimerImplementation(VOID);
75
76 VOID
77 STDCALL
78 ExpInitializeProfileImplementation(VOID);
79
80 /* HANDLE TABLE FUNCTIONS ***************************************************/
81
82 #define EX_HANDLE_ENTRY_LOCKED (1 << ((sizeof(PVOID) * 8) - 1))
83 #define EX_HANDLE_ENTRY_PROTECTFROMCLOSE (1 << 0)
84 #define EX_HANDLE_ENTRY_INHERITABLE (1 << 1)
85 #define EX_HANDLE_ENTRY_AUDITONCLOSE (1 << 2)
86
87 #define EX_HANDLE_TABLE_CLOSING 0x1
88
89 #define EX_HANDLE_ENTRY_FLAGSMASK (EX_HANDLE_ENTRY_LOCKED | \
90 EX_HANDLE_ENTRY_PROTECTFROMCLOSE | \
91 EX_HANDLE_ENTRY_INHERITABLE | \
92 EX_HANDLE_ENTRY_AUDITONCLOSE)
93
94 typedef VOID (STDCALL PEX_DESTROY_HANDLE_CALLBACK)(
95 PHANDLE_TABLE HandleTable,
96 PVOID Object,
97 ULONG GrantedAccess,
98 PVOID Context
99 );
100
101 typedef BOOLEAN (STDCALL PEX_DUPLICATE_HANDLE_CALLBACK)(
102 PHANDLE_TABLE HandleTable,
103 PHANDLE_TABLE_ENTRY HandleTableEntry,
104 PVOID Context
105 );
106
107 typedef BOOLEAN (STDCALL PEX_CHANGE_HANDLE_CALLBACK)(
108 PHANDLE_TABLE HandleTable,
109 PHANDLE_TABLE_ENTRY HandleTableEntry,
110 PVOID Context
111 );
112
113 VOID
114 ExpInitializeHandleTables(VOID);
115
116 PHANDLE_TABLE
117 ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL);
118
119 VOID
120 ExDestroyHandleTable(
121 IN PHANDLE_TABLE HandleTable,
122 IN PEX_DESTROY_HANDLE_CALLBACK DestroyHandleCallback OPTIONAL,
123 IN PVOID Context OPTIONAL
124 );
125
126 PHANDLE_TABLE
127 ExDupHandleTable(
128 IN PEPROCESS QuotaProcess OPTIONAL,
129 IN PEX_DUPLICATE_HANDLE_CALLBACK DuplicateHandleCallback OPTIONAL,
130 IN PVOID Context OPTIONAL,
131 IN PHANDLE_TABLE SourceHandleTable
132 );
133
134 BOOLEAN
135 ExLockHandleTableEntry(
136 IN PHANDLE_TABLE HandleTable,
137 IN PHANDLE_TABLE_ENTRY Entry
138 );
139
140 VOID
141 ExUnlockHandleTableEntry(
142 IN PHANDLE_TABLE HandleTable,
143 IN PHANDLE_TABLE_ENTRY Entry
144 );
145
146 HANDLE
147 ExCreateHandle(
148 IN PHANDLE_TABLE HandleTable,
149 IN PHANDLE_TABLE_ENTRY Entry
150 );
151
152 BOOLEAN
153 ExDestroyHandle(
154 IN PHANDLE_TABLE HandleTable,
155 IN HANDLE Handle
156 );
157
158 VOID
159 ExDestroyHandleByEntry(
160 IN PHANDLE_TABLE HandleTable,
161 IN PHANDLE_TABLE_ENTRY Entry,
162 IN HANDLE Handle
163 );
164
165 PHANDLE_TABLE_ENTRY
166 ExMapHandleToPointer(
167 IN PHANDLE_TABLE HandleTable,
168 IN HANDLE Handle
169 );
170
171 BOOLEAN
172 ExChangeHandle(
173 IN PHANDLE_TABLE HandleTable,
174 IN HANDLE Handle,
175 IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
176 IN PVOID Context
177 );
178
179 /* PSEH EXCEPTION HANDLING **************************************************/
180
181 LONG
182 STDCALL
183 ExSystemExceptionFilter(VOID);
184
185 static __inline _SEH_FILTER(_SEH_ExSystemExceptionFilter)
186 {
187 return ExSystemExceptionFilter();
188 }
189
190 /* OTHER FUNCTIONS **********************************************************/
191
192 LONGLONG
193 FASTCALL
194 ExfpInterlockedExchange64(
195 LONGLONG volatile * Destination,
196 PLONGLONG Exchange
197 );
198
199 NTSTATUS
200 ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation);
201
202 NTSTATUS
203 NTAPI
204 ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId);
205
206 VOID
207 STDCALL
208 ExTimerRundown(VOID);
209
210 #define InterlockedDecrementUL(Addend) \
211 (ULONG)InterlockedDecrement((PLONG)(Addend))
212
213 #define InterlockedIncrementUL(Addend) \
214 (ULONG)InterlockedIncrement((PLONG)(Addend))
215
216 #define InterlockedExchangeUL(Target, Value) \
217 (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
218
219 #define InterlockedExchangeAddUL(Addend, Value) \
220 (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
221
222 #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
223 (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
224
225 #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
226 (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
227
228 #define ExfpInterlockedExchange64UL(Target, Value) \
229 (ULONGLONG)ExfpInterlockedExchange64((PLONGLONG)(Target), (PLONGLONG)(Value))
230
231 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */