0e38d139ff4a1588efff90c3b2c447ed9bc21ce4
[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_SWEEP_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 );
123
124 VOID
125 ExSweepHandleTable(
126 IN PHANDLE_TABLE HandleTable,
127 IN PEX_SWEEP_HANDLE_CALLBACK SweepHandleCallback OPTIONAL,
128 IN PVOID Context OPTIONAL
129 );
130
131 PHANDLE_TABLE
132 ExDupHandleTable(
133 IN PEPROCESS QuotaProcess OPTIONAL,
134 IN PEX_DUPLICATE_HANDLE_CALLBACK DuplicateHandleCallback OPTIONAL,
135 IN PVOID Context OPTIONAL,
136 IN PHANDLE_TABLE SourceHandleTable
137 );
138
139 BOOLEAN
140 ExLockHandleTableEntry(
141 IN PHANDLE_TABLE HandleTable,
142 IN PHANDLE_TABLE_ENTRY Entry
143 );
144
145 VOID
146 ExUnlockHandleTableEntry(
147 IN PHANDLE_TABLE HandleTable,
148 IN PHANDLE_TABLE_ENTRY Entry
149 );
150
151 HANDLE
152 ExCreateHandle(
153 IN PHANDLE_TABLE HandleTable,
154 IN PHANDLE_TABLE_ENTRY Entry
155 );
156
157 BOOLEAN
158 ExDestroyHandle(
159 IN PHANDLE_TABLE HandleTable,
160 IN HANDLE Handle
161 );
162
163 VOID
164 ExDestroyHandleByEntry(
165 IN PHANDLE_TABLE HandleTable,
166 IN PHANDLE_TABLE_ENTRY Entry,
167 IN HANDLE Handle
168 );
169
170 PHANDLE_TABLE_ENTRY
171 ExMapHandleToPointer(
172 IN PHANDLE_TABLE HandleTable,
173 IN HANDLE Handle
174 );
175
176 BOOLEAN
177 ExChangeHandle(
178 IN PHANDLE_TABLE HandleTable,
179 IN HANDLE Handle,
180 IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
181 IN PVOID Context
182 );
183
184 /* PSEH EXCEPTION HANDLING **************************************************/
185
186 LONG
187 STDCALL
188 ExSystemExceptionFilter(VOID);
189
190 static __inline _SEH_FILTER(_SEH_ExSystemExceptionFilter)
191 {
192 return ExSystemExceptionFilter();
193 }
194
195 /* OTHER FUNCTIONS **********************************************************/
196
197 LONGLONG
198 FASTCALL
199 ExfpInterlockedExchange64(
200 LONGLONG volatile * Destination,
201 PLONGLONG Exchange
202 );
203
204 NTSTATUS
205 ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation);
206
207 NTSTATUS
208 NTAPI
209 ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId);
210
211 VOID
212 STDCALL
213 ExTimerRundown(VOID);
214
215 #define InterlockedDecrementUL(Addend) \
216 (ULONG)InterlockedDecrement((PLONG)(Addend))
217
218 #define InterlockedIncrementUL(Addend) \
219 (ULONG)InterlockedIncrement((PLONG)(Addend))
220
221 #define InterlockedExchangeUL(Target, Value) \
222 (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
223
224 #define InterlockedExchangeAddUL(Addend, Value) \
225 (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
226
227 #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
228 (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
229
230 #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
231 (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
232
233 #define ExfpInterlockedExchange64UL(Target, Value) \
234 (ULONGLONG)ExfpInterlockedExchange64((PLONGLONG)(Target), (PLONGLONG)(Value))
235
236 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */