72816cae77916895e75e1485c48044088e5cdbcb
[reactos.git] / reactos / include / xdk / exfuncs.h
1 /******************************************************************************
2 * Executive Functions *
3 ******************************************************************************/
4
5 $if (_WDMDDK_)
6 #define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend)
7 #define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend)
8 #define ExInterlockedExchangeUlong(Target, Value, Lock) Exfi386InterlockedExchangeUlong(Target, Value)
9
10 #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
11 #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
12 #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
13 #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
14
15 #define ExInitializeSListHead InitializeSListHead
16
17 #if defined(_NTHAL_) && defined(_X86_)
18
19 NTKERNELAPI
20 VOID
21 FASTCALL
22 ExiAcquireFastMutex(
23 IN OUT PFAST_MUTEX FastMutex);
24
25 NTKERNELAPI
26 VOID
27 FASTCALL
28 ExiReleaseFastMutex(
29 IN OUT PFAST_MUTEX FastMutex);
30
31 NTKERNELAPI
32 BOOLEAN
33 FASTCALL
34 ExiTryToAcquireFastMutex(
35 IN OUT PFAST_MUTEX FastMutex);
36
37 #define ExAcquireFastMutex ExiAcquireFastMutex
38 #define ExReleaseFastMutex ExiReleaseFastMutex
39 #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex
40
41 #else
42
43 #if (NTDDI_VERSION >= NTDDI_WIN2K)
44
45 _IRQL_raises_(APC_LEVEL)
46 _IRQL_saves_global_(OldIrql, FastMutex)
47 NTKERNELAPI
48 VOID
49 FASTCALL
50 ExAcquireFastMutex(
51 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_lock_(*_Curr_)
52 PFAST_MUTEX FastMutex);
53
54 _IRQL_requires_(APC_LEVEL)
55 _IRQL_restores_global_(OldIrql, FastMutex)
56 NTKERNELAPI
57 VOID
58 FASTCALL
59 ExReleaseFastMutex(
60 _Inout_ _Requires_lock_held_(*_Curr_) _Releases_lock_(*_Curr_)
61 PFAST_MUTEX FastMutex);
62
63 _Must_inspect_result_
64 _Success_(return!=FALSE)
65 _IRQL_raises_(APC_LEVEL)
66 _IRQL_saves_global_(OldIrql, FastMutex)
67 NTKERNELAPI
68 BOOLEAN
69 FASTCALL
70 ExTryToAcquireFastMutex(
71 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_lock_(*_Curr_)
72 PFAST_MUTEX FastMutex);
73
74 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
75
76 #endif /* defined(_NTHAL_) && defined(_X86_) */
77
78 #if defined(_X86_)
79 #define ExInterlockedAddUlong ExfInterlockedAddUlong
80 #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList
81 #define ExInterlockedInsertTailList ExfInterlockedInsertTailList
82 #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList
83 #define ExInterlockedPopEntryList ExfInterlockedPopEntryList
84 #define ExInterlockedPushEntryList ExfInterlockedPushEntryList
85 #endif /* defined(_X86_) */
86
87 #if defined(_WIN64)
88
89 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || \
90 defined(_NTHAL_) || defined(_NTOSP_)
91 NTKERNELAPI
92 USHORT
93 ExQueryDepthSList(_In_ PSLIST_HEADER ListHead);
94 #else
95 FORCEINLINE
96 USHORT
97 ExQueryDepthSList(_In_ PSLIST_HEADER ListHead)
98 {
99 return (USHORT)(ListHead->Alignment & 0xffff);
100 }
101 #endif
102
103 NTKERNELAPI
104 PSLIST_ENTRY
105 ExpInterlockedFlushSList(
106 PSLIST_HEADER ListHead);
107
108 NTKERNELAPI
109 PSLIST_ENTRY
110 ExpInterlockedPopEntrySList(
111 _Inout_ PSLIST_HEADER ListHead);
112
113 NTKERNELAPI
114 PSLIST_ENTRY
115 ExpInterlockedPushEntrySList(
116 _Inout_ PSLIST_HEADER ListHead,
117 _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry);
118
119 #define ExInterlockedFlushSList(Head) \
120 ExpInterlockedFlushSList(Head)
121 #define ExInterlockedPopEntrySList(Head, Lock) \
122 ExpInterlockedPopEntrySList(Head)
123 #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
124 ExpInterlockedPushEntrySList(Head, Entry)
125
126 #else /* !defined(_WIN64) */
127
128 #ifdef NONAMELESSUNION
129 #define ExQueryDepthSList(listhead) (listhead)->s.Depth
130 #else
131 #define ExQueryDepthSList(listhead) (listhead)->Depth
132 #endif
133
134 NTKERNELAPI
135 PSINGLE_LIST_ENTRY
136 FASTCALL
137 ExInterlockedFlushSList(
138 _Inout_ PSLIST_HEADER ListHead);
139
140 #endif /* !defined(_WIN64) */
141
142 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
143
144 NTKERNELAPI
145 PSINGLE_LIST_ENTRY
146 FASTCALL
147 ExInterlockedPopEntrySList(
148 _Inout_ PSLIST_HEADER ListHead,
149 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
150
151 NTKERNELAPI
152 PSINGLE_LIST_ENTRY
153 FASTCALL
154 ExInterlockedPushEntrySList(
155 _Inout_ PSLIST_HEADER ListHead,
156 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY ListEntry,
157 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
158
159 _IRQL_requires_max_(APC_LEVEL)
160 NTKERNELAPI
161 PVOID
162 NTAPI
163 ExAllocateFromPagedLookasideList(
164 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside);
165
166 _IRQL_requires_max_(APC_LEVEL)
167 NTKERNELAPI
168 VOID
169 NTAPI
170 ExFreeToPagedLookasideList(
171 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside,
172 _In_ PVOID Entry);
173
174 #else /* !_WIN2K_COMPAT_SLIST_USAGE */
175
176 #if !defined(_WIN64)
177 #define ExInterlockedPopEntrySList(_ListHead, _Lock) \
178 InterlockedPopEntrySList(_ListHead)
179 #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \
180 InterlockedPushEntrySList(_ListHead, _ListEntry)
181 #endif
182
183 _IRQL_requires_max_(APC_LEVEL)
184 static __inline
185 PVOID
186 ExAllocateFromPagedLookasideList(
187 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside)
188 {
189 PVOID Entry;
190
191 Lookaside->L.TotalAllocates++;
192 #ifdef NONAMELESSUNION
193 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
194 if (Entry == NULL) {
195 Lookaside->L.u2.AllocateMisses++;
196 Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
197 Lookaside->L.Size,
198 Lookaside->L.Tag);
199 }
200 #else /* NONAMELESSUNION */
201 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
202 if (Entry == NULL) {
203 Lookaside->L.AllocateMisses++;
204 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
205 Lookaside->L.Size,
206 Lookaside->L.Tag);
207 }
208 #endif /* NONAMELESSUNION */
209 return Entry;
210 }
211
212 _IRQL_requires_max_(APC_LEVEL)
213 static __inline
214 VOID
215 ExFreeToPagedLookasideList(
216 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside,
217 _In_ PVOID Entry)
218 {
219 Lookaside->L.TotalFrees++;
220 #ifdef NONAMELESSUNION
221 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
222 Lookaside->L.u3.FreeMisses++;
223 (Lookaside->L.u5.Free)(Entry);
224 } else {
225 InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry);
226 }
227 #else /* NONAMELESSUNION */
228 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
229 Lookaside->L.FreeMisses++;
230 (Lookaside->L.Free)(Entry);
231 } else {
232 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
233 }
234 #endif /* NONAMELESSUNION */
235 }
236
237 #endif /* _WIN2K_COMPAT_SLIST_USAGE */
238
239
240 /* ERESOURCE_THREAD
241 * ExGetCurrentResourceThread(
242 * VOID);
243 */
244 #define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread())
245
246 #define ExReleaseResource(R) (ExReleaseResourceLite(R))
247
248 /* VOID
249 * ExInitializeWorkItem(
250 * IN PWORK_QUEUE_ITEM Item,
251 * IN PWORKER_THREAD_ROUTINE Routine,
252 * IN PVOID Context)
253 */
254 #define ExInitializeWorkItem(Item, Routine, Context) \
255 { \
256 (Item)->WorkerRoutine = Routine; \
257 (Item)->Parameter = Context; \
258 (Item)->List.Flink = NULL; \
259 }
260
261 FORCEINLINE
262 VOID
263 ExInitializeFastMutex(
264 _Out_ PFAST_MUTEX FastMutex)
265 {
266 FastMutex->Count = FM_LOCK_BIT;
267 FastMutex->Owner = NULL;
268 FastMutex->Contention = 0;
269 KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE);
270 return;
271 }
272
273 $endif (_WDMDDK_)
274 $if (_NTDDK_)
275 static __inline PVOID
276 ExAllocateFromZone(
277 IN PZONE_HEADER Zone)
278 {
279 PVOID Result = (PVOID)Zone->FreeList.Next;
280 if (Zone->FreeList.Next)
281 Zone->FreeList.Next = Zone->FreeList.Next->Next;
282 return Result;
283 }
284
285 static __inline PVOID
286 ExFreeToZone(
287 IN PZONE_HEADER Zone,
288 IN PVOID Block)
289 {
290 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
291 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
292 return ((PSINGLE_LIST_ENTRY) Block)->Next;
293 }
294
295 /*
296 * PVOID
297 * ExInterlockedAllocateFromZone(
298 * IN PZONE_HEADER Zone,
299 * IN PKSPIN_LOCK Lock)
300 */
301 #define ExInterlockedAllocateFromZone(Zone, Lock) \
302 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
303
304 /* PVOID
305 * ExInterlockedFreeToZone(
306 * IN PZONE_HEADER Zone,
307 * IN PVOID Block,
308 * IN PKSPIN_LOCK Lock);
309 */
310 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
311 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
312
313 /*
314 * BOOLEAN
315 * ExIsFullZone(
316 * IN PZONE_HEADER Zone)
317 */
318 #define ExIsFullZone(Zone) \
319 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
320
321 /* BOOLEAN
322 * ExIsObjectInFirstZoneSegment(
323 * IN PZONE_HEADER Zone,
324 * IN PVOID Object);
325 */
326 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
327 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
328 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
329 (Zone)->TotalSegmentSize)) )
330
331 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
332 #define ExAcquireResourceShared ExAcquireResourceSharedLite
333 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
334 #define ExDeleteResource ExDeleteResourceLite
335 #define ExInitializeResource ExInitializeResourceLite
336 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
337 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
338 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
339 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
340
341 #ifndef _M_IX86
342 #define RESULT_ZERO 0
343 #define RESULT_NEGATIVE 1
344 #define RESULT_POSITIVE 2
345 #endif
346
347 typedef enum _INTERLOCKED_RESULT {
348 ResultNegative = RESULT_NEGATIVE,
349 ResultZero = RESULT_ZERO,
350 ResultPositive = RESULT_POSITIVE
351 } INTERLOCKED_RESULT;
352
353 #ifdef _X86_
354
355 NTKERNELAPI
356 INTERLOCKED_RESULT
357 FASTCALL
358 Exfi386InterlockedIncrementLong(
359 _Inout_ _Interlocked_operand_ LONG volatile *Addend);
360
361 NTKERNELAPI
362 INTERLOCKED_RESULT
363 FASTCALL
364 Exfi386InterlockedDecrementLong(
365 _Inout_ _Interlocked_operand_ PLONG Addend);
366
367 NTKERNELAPI
368 ULONG
369 FASTCALL
370 Exfi386InterlockedExchangeUlong(
371 _Inout_ _Interlocked_operand_ PULONG Target,
372 _In_ ULONG Value);
373
374 #endif
375
376 $endif (_NTDDK_)
377 $if (_NTIFS_)
378
379 #define ExDisableResourceBoost ExDisableResourceBoostLite
380
381 VOID
382 NTAPI
383 ExInitializePushLock(
384 _Out_ PEX_PUSH_LOCK PushLock);
385 $endif (_NTIFS_)
386
387 #if (NTDDI_VERSION >= NTDDI_WIN2K)
388 $if (_WDMDDK_)
389 _IRQL_requires_max_(APC_LEVEL)
390 _Requires_lock_held_(_Global_critical_region_)
391 NTKERNELAPI
392 VOID
393 FASTCALL
394 ExAcquireFastMutexUnsafe(
395 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_lock_(*_Curr_)
396 PFAST_MUTEX FastMutex);
397
398 _IRQL_requires_max_(APC_LEVEL)
399 _Requires_lock_held_(_Global_critical_region_)
400 NTKERNELAPI
401 VOID
402 FASTCALL
403 ExReleaseFastMutexUnsafe(
404 _Inout_ _Requires_lock_held_(*_Curr_) _Releases_lock_(*_Curr_)
405 PFAST_MUTEX FastMutex);
406
407 _Requires_lock_held_(_Global_critical_region_)
408 _Requires_lock_not_held_(*Resource)
409 _When_(Wait!=0, _Acquires_exclusive_lock_(*Resource))
410 _IRQL_requires_max_(APC_LEVEL)
411 _When_(Wait!=0, _Post_satisfies_(return == 1))
412 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
413 NTKERNELAPI
414 BOOLEAN
415 NTAPI
416 ExAcquireResourceExclusiveLite(
417 _Inout_ PERESOURCE Resource,
418 _In_ _Literal_ BOOLEAN Wait);
419
420 _IRQL_requires_max_(APC_LEVEL)
421 _Requires_lock_held_(_Global_critical_region_)
422 _When_(Wait!=0, _Post_satisfies_(return == 1))
423 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
424 NTKERNELAPI
425 BOOLEAN
426 NTAPI
427 ExAcquireResourceSharedLite(
428 _Inout_ _Requires_lock_not_held_(*_Curr_)
429 _When_(return!=0, _Acquires_shared_lock_(*_Curr_))
430 PERESOURCE Resource,
431 _In_ BOOLEAN Wait);
432
433 _IRQL_requires_max_(APC_LEVEL)
434 _Requires_lock_held_(_Global_critical_region_)
435 _When_(Wait!=0, _Post_satisfies_(return == 1))
436 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
437 NTKERNELAPI
438 BOOLEAN
439 NTAPI
440 ExAcquireSharedStarveExclusive(
441 _Inout_ _Requires_lock_not_held_(*_Curr_)
442 _When_(return!=0, _Acquires_shared_lock_(*_Curr_))
443 PERESOURCE Resource,
444 _In_ BOOLEAN Wait);
445
446 _IRQL_requires_max_(APC_LEVEL)
447 _Requires_lock_held_(_Global_critical_region_)
448 _When_(Wait!=0, _Post_satisfies_(return == 1))
449 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
450 NTKERNELAPI
451 BOOLEAN
452 NTAPI
453 ExAcquireSharedWaitForExclusive(
454 _Inout_ _Requires_lock_not_held_(*_Curr_)
455 _When_(return!=0, _Acquires_lock_(*_Curr_))
456 PERESOURCE Resource,
457 _In_ BOOLEAN Wait);
458
459 __drv_preferredFunction("ExAllocatePoolWithTag",
460 "No tag interferes with debugging.")
461 __drv_allocatesMem(Mem)
462 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
463 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
464 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
465 __drv_reportError("Must succeed pool allocations are forbidden. "
466 "Allocation failures cause a system crash"))
467 _When_((PoolType & (NonPagedPoolMustSucceed |
468 POOL_RAISE_IF_ALLOCATION_FAILURE)) == 0,
469 _Post_maybenull_ _Must_inspect_result_)
470 _When_((PoolType & (NonPagedPoolMustSucceed |
471 POOL_RAISE_IF_ALLOCATION_FAILURE)) != 0,
472 _Post_notnull_)
473 _Post_writable_byte_size_(NumberOfBytes)
474 NTKERNELAPI
475 PVOID
476 NTAPI
477 ExAllocatePool(
478 __drv_strictTypeMatch(__drv_typeExpr) _In_ POOL_TYPE PoolType,
479 _In_ SIZE_T NumberOfBytes);
480
481 __drv_preferredFunction("ExAllocatePoolWithQuotaTag",
482 "No tag interferes with debugging.")
483 __drv_allocatesMem(Mem)
484 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
485 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
486 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
487 __drv_reportError("Must succeed pool allocations are forbidden. "
488 "Allocation failures cause a system crash"))
489 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) != 0,
490 _Post_maybenull_ _Must_inspect_result_)
491 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) == 0, _Post_notnull_)
492 _Post_writable_byte_size_(NumberOfBytes)
493 NTKERNELAPI
494 PVOID
495 NTAPI
496 ExAllocatePoolWithQuota(
497 __drv_strictTypeMatch(__drv_typeExpr) _In_ POOL_TYPE PoolType,
498 _In_ SIZE_T NumberOfBytes);
499
500 __drv_allocatesMem(Mem)
501 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
502 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
503 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
504 __drv_reportError("Must succeed pool allocations are forbidden. "
505 "Allocation failures cause a system crash"))
506 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) != 0,
507 _Post_maybenull_ _Must_inspect_result_)
508 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) == 0, _Post_notnull_)
509 _Post_writable_byte_size_(NumberOfBytes)
510 NTKERNELAPI
511 PVOID
512 NTAPI
513 ExAllocatePoolWithQuotaTag(
514 _In_ __drv_strictTypeMatch(__drv_typeExpr) POOL_TYPE PoolType,
515 _In_ SIZE_T NumberOfBytes,
516 _In_ ULONG Tag);
517
518 #ifndef POOL_TAGGING
519 #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
520 #endif
521
522 __drv_allocatesMem(Mem)
523 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
524 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
525 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
526 __drv_reportError("Must succeed pool allocations are forbidden. "
527 "Allocation failures cause a system crash"))
528 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) == 0,
529 _Post_maybenull_ _Must_inspect_result_)
530 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) != 0,
531 _Post_notnull_)
532 _Post_writable_byte_size_(NumberOfBytes)
533 _Function_class_(ALLOCATE_FUNCTION)
534 NTKERNELAPI
535 PVOID
536 NTAPI
537 ExAllocatePoolWithTag(
538 _In_ __drv_strictTypeMatch(__drv_typeExpr) POOL_TYPE PoolType,
539 _In_ SIZE_T NumberOfBytes,
540 _In_ ULONG Tag);
541
542 #ifndef POOL_TAGGING
543 #define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
544 #endif
545
546 __drv_allocatesMem(Mem)
547 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
548 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
549 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
550 __drv_reportError("Must succeed pool allocations are forbidden. "
551 "Allocation failures cause a system crash"))
552 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) == 0,
553 _Post_maybenull_ _Must_inspect_result_)
554 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) != 0,
555 _Post_notnull_)
556 _Post_writable_byte_size_(NumberOfBytes)
557 NTKERNELAPI
558 PVOID
559 NTAPI
560 ExAllocatePoolWithTagPriority(
561 _In_ __drv_strictTypeMatch(__drv_typeCond) POOL_TYPE PoolType,
562 _In_ SIZE_T NumberOfBytes,
563 _In_ ULONG Tag,
564 _In_ __drv_strictTypeMatch(__drv_typeExpr) EX_POOL_PRIORITY Priority);
565
566 _IRQL_requires_max_(DISPATCH_LEVEL)
567 NTKERNELAPI
568 VOID
569 NTAPI
570 ExConvertExclusiveToSharedLite(
571 _Inout_ _Requires_lock_held_(*_Curr_) PERESOURCE Resource);
572
573 _IRQL_requires_max_(APC_LEVEL)
574 NTKERNELAPI
575 NTSTATUS
576 NTAPI
577 ExCreateCallback(
578 _Outptr_ PCALLBACK_OBJECT *CallbackObject,
579 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
580 _In_ BOOLEAN Create,
581 _In_ BOOLEAN AllowMultipleCallbacks);
582
583 NTKERNELAPI
584 VOID
585 NTAPI
586 ExDeleteNPagedLookasideList(
587 _Inout_ PNPAGED_LOOKASIDE_LIST Lookaside);
588
589 _IRQL_requires_max_(APC_LEVEL)
590 NTKERNELAPI
591 VOID
592 NTAPI
593 ExDeletePagedLookasideList(
594 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside);
595
596 _IRQL_requires_max_(DISPATCH_LEVEL)
597 NTKERNELAPI
598 NTSTATUS
599 NTAPI
600 ExDeleteResourceLite(
601 _Inout_ PERESOURCE Resource);
602
603 _IRQL_requires_max_(DISPATCH_LEVEL)
604 _Function_class_(FREE_FUNCTION)
605 NTKERNELAPI
606 VOID
607 NTAPI
608 ExFreePool(
609 _Pre_notnull_ __drv_freesMem(Mem) PVOID P);
610
611 _IRQL_requires_max_(DISPATCH_LEVEL)
612 NTKERNELAPI
613 VOID
614 NTAPI
615 ExFreePoolWithTag(
616 _Pre_notnull_ __drv_freesMem(Mem) PVOID P,
617 _In_ ULONG Tag);
618
619 _IRQL_requires_max_(DISPATCH_LEVEL)
620 NTKERNELAPI
621 ULONG
622 NTAPI
623 ExGetExclusiveWaiterCount(
624 _In_ PERESOURCE Resource);
625
626 _IRQL_requires_max_(DISPATCH_LEVEL)
627 NTKERNELAPI
628 KPROCESSOR_MODE
629 NTAPI
630 ExGetPreviousMode(VOID);
631
632 _IRQL_requires_max_(DISPATCH_LEVEL)
633 NTKERNELAPI
634 ULONG
635 NTAPI
636 ExGetSharedWaiterCount(
637 _In_ PERESOURCE Resource);
638
639 _IRQL_requires_max_(DISPATCH_LEVEL)
640 NTKERNELAPI
641 VOID
642 NTAPI
643 ExInitializeNPagedLookasideList(
644 _Out_ PNPAGED_LOOKASIDE_LIST Lookaside,
645 _In_opt_ PALLOCATE_FUNCTION Allocate,
646 _In_opt_ PFREE_FUNCTION Free,
647 _In_ ULONG Flags,
648 _In_ SIZE_T Size,
649 _In_ ULONG Tag,
650 _In_ USHORT Depth);
651
652 _IRQL_requires_max_(APC_LEVEL)
653 NTKERNELAPI
654 VOID
655 NTAPI
656 ExInitializePagedLookasideList(
657 _Out_ PPAGED_LOOKASIDE_LIST Lookaside,
658 _In_opt_ PALLOCATE_FUNCTION Allocate,
659 _In_opt_ PFREE_FUNCTION Free,
660 _In_ ULONG Flags,
661 _In_ SIZE_T Size,
662 _In_ ULONG Tag,
663 _In_ USHORT Depth);
664
665 _IRQL_requires_max_(DISPATCH_LEVEL)
666 NTKERNELAPI
667 NTSTATUS
668 NTAPI
669 ExInitializeResourceLite(
670 _Out_ PERESOURCE Resource);
671
672 NTKERNELAPI
673 LARGE_INTEGER
674 NTAPI
675 ExInterlockedAddLargeInteger(
676 _Inout_ PLARGE_INTEGER Addend,
677 _In_ LARGE_INTEGER Increment,
678 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
679
680 #if !defined(_M_IX86)
681 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
682 (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment)
683 #else
684 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
685 (VOID)_InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment)
686 #endif
687
688 NTKERNELAPI
689 ULONG
690 FASTCALL
691 ExInterlockedAddUlong(
692 _Inout_ PULONG Addend,
693 _In_ ULONG Increment,
694 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
695
696 #if defined(_AMD64_) || defined(_IA64_)
697
698 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
699 InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
700
701 #elif defined(_X86_)
702
703 NTKERNELAPI
704 LONGLONG
705 FASTCALL
706 ExfInterlockedCompareExchange64(
707 _Inout_ _Interlocked_operand_ LONGLONG volatile *Destination,
708 _In_ PLONGLONG Exchange,
709 _In_ PLONGLONG Comperand);
710
711 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
712 ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
713
714 #else
715
716 NTKERNELAPI
717 LONGLONG
718 FASTCALL
719 ExInterlockedCompareExchange64(
720 IN OUT LONGLONG volatile *Destination,
721 IN PLONGLONG Exchange,
722 IN PLONGLONG Comparand,
723 IN PKSPIN_LOCK Lock);
724
725 #endif /* defined(_AMD64_) || defined(_IA64_) */
726
727 NTKERNELAPI
728 PLIST_ENTRY
729 FASTCALL
730 ExInterlockedInsertHeadList(
731 _Inout_ PLIST_ENTRY ListHead,
732 _Inout_ __drv_aliasesMem PLIST_ENTRY ListEntry,
733 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
734
735 NTKERNELAPI
736 PLIST_ENTRY
737 FASTCALL
738 ExInterlockedInsertTailList(
739 _Inout_ PLIST_ENTRY ListHead,
740 _Inout_ __drv_aliasesMem PLIST_ENTRY ListEntry,
741 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
742
743 NTKERNELAPI
744 PSINGLE_LIST_ENTRY
745 FASTCALL
746 ExInterlockedPopEntryList(
747 _Inout_ PSINGLE_LIST_ENTRY ListHead,
748 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
749
750 NTKERNELAPI
751 PSINGLE_LIST_ENTRY
752 FASTCALL
753 ExInterlockedPushEntryList(
754 _Inout_ PSINGLE_LIST_ENTRY ListHead,
755 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY ListEntry,
756 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
757
758 NTKERNELAPI
759 PLIST_ENTRY
760 FASTCALL
761 ExInterlockedRemoveHeadList(
762 _Inout_ PLIST_ENTRY ListHead,
763 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
764
765 _IRQL_requires_max_(PASSIVE_LEVEL)
766 NTKERNELAPI
767 BOOLEAN
768 NTAPI
769 ExIsProcessorFeaturePresent(
770 _In_ ULONG ProcessorFeature);
771
772 _IRQL_requires_max_(DISPATCH_LEVEL)
773 NTKERNELAPI
774 BOOLEAN
775 NTAPI
776 ExIsResourceAcquiredExclusiveLite(
777 _In_ PERESOURCE Resource);
778
779 _IRQL_requires_max_(DISPATCH_LEVEL)
780 NTKERNELAPI
781 ULONG
782 NTAPI
783 ExIsResourceAcquiredSharedLite(
784 _In_ PERESOURCE Resource);
785
786 #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite
787
788 NTKERNELAPI
789 VOID
790 NTAPI
791 ExLocalTimeToSystemTime(
792 _In_ PLARGE_INTEGER LocalTime,
793 _Out_ PLARGE_INTEGER SystemTime);
794
795 _IRQL_requires_max_(DISPATCH_LEVEL)
796 NTKERNELAPI
797 VOID
798 NTAPI
799 ExNotifyCallback(
800 _In_ PCALLBACK_OBJECT CallbackObject,
801 _In_opt_ PVOID Argument1,
802 _In_opt_ PVOID Argument2);
803
804 _IRQL_requires_max_(DISPATCH_LEVEL)
805 NTKERNELAPI
806 VOID
807 NTAPI
808 ExQueueWorkItem(
809 _Inout_ __drv_aliasesMem PWORK_QUEUE_ITEM WorkItem,
810 __drv_strictTypeMatch(__drv_typeExpr) _In_ WORK_QUEUE_TYPE QueueType);
811
812 _IRQL_requires_max_(APC_LEVEL)
813 NTKERNELAPI
814 DECLSPEC_NORETURN
815 VOID
816 NTAPI
817 ExRaiseStatus(
818 _In_ NTSTATUS Status);
819
820 _IRQL_requires_max_(APC_LEVEL)
821 NTKERNELAPI
822 PVOID
823 NTAPI
824 ExRegisterCallback(
825 _Inout_ PCALLBACK_OBJECT CallbackObject,
826 _In_ PCALLBACK_FUNCTION CallbackFunction,
827 _In_opt_ PVOID CallbackContext);
828
829 _IRQL_requires_max_(DISPATCH_LEVEL)
830 NTKERNELAPI
831 NTSTATUS
832 NTAPI
833 ExReinitializeResourceLite(
834 _Inout_ PERESOURCE Resource);
835
836 _IRQL_requires_max_(DISPATCH_LEVEL)
837 _Requires_lock_held_(_Global_critical_region_)
838 NTKERNELAPI
839 VOID
840 NTAPI
841 ExReleaseResourceForThreadLite(
842 _Inout_ _Requires_lock_held_(*_Curr_) _Releases_lock_(*_Curr_)
843 PERESOURCE Resource,
844 _In_ ERESOURCE_THREAD ResourceThreadId);
845
846 _Requires_lock_held_(_Global_critical_region_)
847 _Requires_lock_held_(*Resource)
848 _Releases_lock_(*Resource)
849 _IRQL_requires_max_(DISPATCH_LEVEL)
850 NTKERNELAPI
851 VOID
852 FASTCALL
853 ExReleaseResourceLite(
854 _Inout_ PERESOURCE Resource);
855
856 _IRQL_requires_max_(DISPATCH_LEVEL)
857 NTKERNELAPI
858 VOID
859 NTAPI
860 ExSetResourceOwnerPointer(
861 _Inout_ PERESOURCE Resource,
862 _In_ PVOID OwnerPointer);
863
864 _IRQL_requires_max_(APC_LEVEL)
865 NTKERNELAPI
866 ULONG
867 NTAPI
868 ExSetTimerResolution(
869 _In_ ULONG DesiredTime,
870 _In_ BOOLEAN SetResolution);
871
872 NTKERNELAPI
873 VOID
874 NTAPI
875 ExSystemTimeToLocalTime(
876 _In_ PLARGE_INTEGER SystemTime,
877 _Out_ PLARGE_INTEGER LocalTime);
878
879 _IRQL_requires_max_(APC_LEVEL)
880 NTKERNELAPI
881 VOID
882 NTAPI
883 ExUnregisterCallback(
884 _Inout_ PVOID CbRegistration);
885
886 $endif (_WDMDDK_)
887 $if (_NTDDK_)
888 NTKERNELAPI
889 NTSTATUS
890 NTAPI
891 ExExtendZone(
892 _Inout_ PZONE_HEADER Zone,
893 _Inout_ PVOID Segment,
894 _In_ ULONG SegmentSize);
895
896 NTKERNELAPI
897 NTSTATUS
898 NTAPI
899 ExInitializeZone(
900 _Out_ PZONE_HEADER Zone,
901 _In_ ULONG BlockSize,
902 _Inout_ PVOID InitialSegment,
903 _In_ ULONG InitialSegmentSize);
904
905 _IRQL_requires_max_(DISPATCH_LEVEL)
906 NTKERNELAPI
907 NTSTATUS
908 NTAPI
909 ExInterlockedExtendZone(
910 _Inout_ PZONE_HEADER Zone,
911 _Inout_ PVOID Segment,
912 _In_ ULONG SegmentSize,
913 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
914
915 _IRQL_requires_max_(PASSIVE_LEVEL)
916 NTKERNELAPI
917 NTSTATUS
918 NTAPI
919 ExUuidCreate(
920 _Out_ UUID *Uuid);
921
922 _IRQL_requires_max_(PASSIVE_LEVEL)
923 NTKERNELAPI
924 DECLSPEC_NORETURN
925 VOID
926 NTAPI
927 ExRaiseAccessViolation(VOID);
928
929 _IRQL_requires_max_(PASSIVE_LEVEL)
930 NTKERNELAPI
931 DECLSPEC_NORETURN
932 VOID
933 NTAPI
934 ExRaiseDatatypeMisalignment(VOID);
935
936 $endif (_NTDDK_)
937 $if (_NTIFS_)
938
939 _IRQL_requires_max_(DISPATCH_LEVEL)
940 NTKERNELAPI
941 SIZE_T
942 NTAPI
943 ExQueryPoolBlockSize(
944 _In_ PVOID PoolBlock,
945 _Out_ PBOOLEAN QuotaCharged);
946
947 _IRQL_requires_max_(DISPATCH_LEVEL)
948 VOID
949 ExAdjustLookasideDepth(VOID);
950
951 _IRQL_requires_max_(DISPATCH_LEVEL)
952 NTKERNELAPI
953 VOID
954 NTAPI
955 ExDisableResourceBoostLite(
956 _In_ PERESOURCE Resource);
957 $endif (_NTIFS_)
958 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
959
960 $if (_WDMDDK_ || _NTIFS_)
961 #if (NTDDI_VERSION >= NTDDI_WINXP)
962 $endif (_WDMDDK_ || _NTIFS_)
963 $if (_WDMDDK_)
964
965 _Must_inspect_result_
966 _Post_satisfies_(return == 0 || return == 1)
967 NTKERNELAPI
968 BOOLEAN
969 FASTCALL
970 ExAcquireRundownProtection(
971 _Inout_ PEX_RUNDOWN_REF RunRef);
972
973 NTKERNELAPI
974 VOID
975 FASTCALL
976 ExInitializeRundownProtection(
977 _Out_ PEX_RUNDOWN_REF RunRef);
978
979 NTKERNELAPI
980 VOID
981 FASTCALL
982 ExReInitializeRundownProtection(
983 _Inout_ PEX_RUNDOWN_REF RunRef);
984
985 NTKERNELAPI
986 VOID
987 FASTCALL
988 ExReleaseRundownProtection(
989 _Inout_ PEX_RUNDOWN_REF RunRef);
990
991 NTKERNELAPI
992 VOID
993 FASTCALL
994 ExRundownCompleted(
995 _Out_ PEX_RUNDOWN_REF RunRef);
996
997 NTKERNELAPI
998 BOOLEAN
999 NTAPI
1000 ExVerifySuite(
1001 __drv_strictTypeMatch(__drv_typeExpr) _In_ SUITE_TYPE SuiteType);
1002
1003 NTKERNELAPI
1004 VOID
1005 FASTCALL
1006 ExWaitForRundownProtectionRelease(
1007 _Inout_ PEX_RUNDOWN_REF RunRef);
1008 $endif (_WDMDDK_)
1009 $if (_NTIFS_)
1010
1011 PSLIST_ENTRY
1012 FASTCALL
1013 InterlockedPushListSList(
1014 _Inout_ PSLIST_HEADER ListHead,
1015 _Inout_ __drv_aliasesMem PSLIST_ENTRY List,
1016 _Inout_ PSLIST_ENTRY ListEnd,
1017 _In_ ULONG Count);
1018 $endif (_NTIFS_)
1019 $if (_WDMDDK_ || _NTIFS_)
1020 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
1021 $endif (_WDMDDK_ || _NTIFS_)
1022
1023 $if (_WDMDDK_)
1024 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1025
1026 _Must_inspect_result_
1027 _Post_satisfies_(return == 0 || return == 1)
1028 NTKERNELAPI
1029 BOOLEAN
1030 FASTCALL
1031 ExAcquireRundownProtectionEx(
1032 _Inout_ PEX_RUNDOWN_REF RunRef,
1033 _In_ ULONG Count);
1034
1035 NTKERNELAPI
1036 VOID
1037 FASTCALL
1038 ExReleaseRundownProtectionEx(
1039 _Inout_ PEX_RUNDOWN_REF RunRef,
1040 _In_ ULONG Count);
1041
1042 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
1043
1044 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
1045
1046 _Must_inspect_result_
1047 _IRQL_requires_max_(APC_LEVEL)
1048 NTKERNELAPI
1049 PEX_RUNDOWN_REF_CACHE_AWARE
1050 NTAPI
1051 ExAllocateCacheAwareRundownProtection(
1052 __drv_strictTypeMatch(__drv_typeExpr) _In_ POOL_TYPE PoolType,
1053 _In_ ULONG PoolTag);
1054
1055 _IRQL_requires_max_(APC_LEVEL)
1056 NTKERNELAPI
1057 SIZE_T
1058 NTAPI
1059 ExSizeOfRundownProtectionCacheAware(VOID);
1060
1061 _IRQL_requires_max_(APC_LEVEL)
1062 _Acquires_lock_(_Global_critical_region_)
1063 NTKERNELAPI
1064 PVOID
1065 NTAPI
1066 ExEnterCriticalRegionAndAcquireResourceShared(
1067 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_shared_lock_(*_Curr_)
1068 PERESOURCE Resource);
1069
1070 _IRQL_requires_max_(APC_LEVEL)
1071 _Acquires_lock_(_Global_critical_region_)
1072 NTKERNELAPI
1073 PVOID
1074 NTAPI
1075 ExEnterCriticalRegionAndAcquireResourceExclusive(
1076 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_exclusive_lock_(*_Curr_)
1077 PERESOURCE Resource);
1078
1079 _IRQL_requires_max_(APC_LEVEL)
1080 _Acquires_lock_(_Global_critical_region_)
1081 NTKERNELAPI
1082 PVOID
1083 NTAPI
1084 ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(
1085 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_lock_(*_Curr_)
1086 PERESOURCE Resource);
1087
1088 _IRQL_requires_max_(DISPATCH_LEVEL)
1089 _Releases_lock_(_Global_critical_region_)
1090 NTKERNELAPI
1091 VOID
1092 FASTCALL
1093 ExReleaseResourceAndLeaveCriticalRegion(
1094 _Inout_ _Requires_lock_held_(*_Curr_) _Releases_lock_(*_Curr_)
1095 PERESOURCE Resource);
1096
1097 _IRQL_requires_max_(APC_LEVEL)
1098 NTKERNELAPI
1099 VOID
1100 NTAPI
1101 ExInitializeRundownProtectionCacheAware(
1102 _Out_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
1103 _In_ SIZE_T RunRefSize);
1104
1105 _IRQL_requires_max_(APC_LEVEL)
1106 NTKERNELAPI
1107 VOID
1108 NTAPI
1109 ExFreeCacheAwareRundownProtection(
1110 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
1111
1112 _Must_inspect_result_
1113 _Post_satisfies_(return == 0 || return == 1)
1114 NTKERNELAPI
1115 BOOLEAN
1116 FASTCALL
1117 ExAcquireRundownProtectionCacheAware(
1118 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
1119
1120 NTKERNELAPI
1121 VOID
1122 FASTCALL
1123 ExReleaseRundownProtectionCacheAware(
1124 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
1125
1126 _Must_inspect_result_
1127 _Post_satisfies_(return == 0 || return == 1)
1128 NTKERNELAPI
1129 BOOLEAN
1130 FASTCALL
1131 ExAcquireRundownProtectionCacheAwareEx(
1132 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
1133 _In_ ULONG Count);
1134
1135 NTKERNELAPI
1136 VOID
1137 FASTCALL
1138 ExReleaseRundownProtectionCacheAwareEx(
1139 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRef,
1140 _In_ ULONG Count);
1141
1142 NTKERNELAPI
1143 VOID
1144 FASTCALL
1145 ExWaitForRundownProtectionReleaseCacheAware(
1146 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef);
1147
1148 NTKERNELAPI
1149 VOID
1150 FASTCALL
1151 ExReInitializeRundownProtectionCacheAware(
1152 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
1153
1154 NTKERNELAPI
1155 VOID
1156 FASTCALL
1157 ExRundownCompletedCacheAware(
1158 _Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
1159
1160 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
1161
1162 #if (NTDDI_VERSION >= NTDDI_VISTA)
1163
1164 _IRQL_requires_max_(DISPATCH_LEVEL)
1165 NTKERNELAPI
1166 NTSTATUS
1167 NTAPI
1168 ExInitializeLookasideListEx(
1169 _Out_ PLOOKASIDE_LIST_EX Lookaside,
1170 _In_opt_ PALLOCATE_FUNCTION_EX Allocate,
1171 _In_opt_ PFREE_FUNCTION_EX Free,
1172 _In_ POOL_TYPE PoolType,
1173 _In_ ULONG Flags,
1174 _In_ SIZE_T Size,
1175 _In_ ULONG Tag,
1176 _In_ USHORT Depth);
1177
1178 _IRQL_requires_max_(DISPATCH_LEVEL)
1179 NTKERNELAPI
1180 VOID
1181 NTAPI
1182 ExDeleteLookasideListEx(
1183 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
1184
1185 _IRQL_requires_max_(DISPATCH_LEVEL)
1186 NTKERNELAPI
1187 VOID
1188 NTAPI
1189 ExFlushLookasideListEx(
1190 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
1191
1192 _Must_inspect_result_
1193 _IRQL_requires_max_(DISPATCH_LEVEL)
1194 FORCEINLINE
1195 PVOID
1196 ExAllocateFromLookasideListEx(
1197 _Inout_ PLOOKASIDE_LIST_EX Lookaside)
1198 {
1199 PVOID Entry;
1200
1201 Lookaside->L.TotalAllocates += 1;
1202 #ifdef NONAMELESSUNION
1203 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
1204 if (Entry == NULL) {
1205 Lookaside->L.u2.AllocateMisses += 1;
1206 Entry = (Lookaside->L.u4.AllocateEx)(Lookaside->L.Type,
1207 Lookaside->L.Size,
1208 Lookaside->L.Tag,
1209 Lookaside);
1210 }
1211 #else /* NONAMELESSUNION */
1212 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
1213 if (Entry == NULL) {
1214 Lookaside->L.AllocateMisses += 1;
1215 Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type,
1216 Lookaside->L.Size,
1217 Lookaside->L.Tag,
1218 Lookaside);
1219 }
1220 #endif /* NONAMELESSUNION */
1221 return Entry;
1222 }
1223
1224 _IRQL_requires_max_(DISPATCH_LEVEL)
1225 FORCEINLINE
1226 VOID
1227 ExFreeToLookasideListEx(
1228 _Inout_ PLOOKASIDE_LIST_EX Lookaside,
1229 _In_ PVOID Entry)
1230 {
1231 Lookaside->L.TotalFrees += 1;
1232 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
1233 Lookaside->L.FreeMisses += 1;
1234 (Lookaside->L.FreeEx)(Entry, Lookaside);
1235 } else {
1236 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
1237 }
1238 return;
1239 }
1240
1241 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1242
1243 #if (NTDDI_VERSION >= NTDDI_WIN7)
1244
1245 _IRQL_requires_max_(DISPATCH_LEVEL)
1246 NTKERNELAPI
1247 VOID
1248 NTAPI
1249 ExSetResourceOwnerPointerEx(
1250 _Inout_ PERESOURCE Resource,
1251 _In_ PVOID OwnerPointer,
1252 _In_ ULONG Flags);
1253
1254 #define FLAG_OWNER_POINTER_IS_THREAD 0x1
1255
1256 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1257
1258 _IRQL_requires_max_(DISPATCH_LEVEL)
1259 static __inline PVOID
1260 ExAllocateFromNPagedLookasideList(
1261 _Inout_ PNPAGED_LOOKASIDE_LIST Lookaside)
1262 {
1263 PVOID Entry;
1264
1265 Lookaside->L.TotalAllocates++;
1266 #ifdef NONAMELESSUNION
1267 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1268 Entry = ExInterlockedPopEntrySList(&Lookaside->L.u.ListHead,
1269 &Lookaside->Lock__ObsoleteButDoNotDelete);
1270 #else
1271 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
1272 #endif
1273 if (Entry == NULL) {
1274 Lookaside->L.u2.AllocateMisses++;
1275 Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
1276 Lookaside->L.Size,
1277 Lookaside->L.Tag);
1278 }
1279 #else /* NONAMELESSUNION */
1280 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1281 Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead,
1282 &Lookaside->Lock__ObsoleteButDoNotDelete);
1283 #else
1284 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
1285 #endif
1286 if (Entry == NULL) {
1287 Lookaside->L.AllocateMisses++;
1288 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
1289 Lookaside->L.Size,
1290 Lookaside->L.Tag);
1291 }
1292 #endif /* NONAMELESSUNION */
1293 return Entry;
1294 }
1295
1296 _IRQL_requires_max_(DISPATCH_LEVEL)
1297 static __inline VOID
1298 ExFreeToNPagedLookasideList(
1299 _Inout_ PNPAGED_LOOKASIDE_LIST Lookaside,
1300 _In_ PVOID Entry)
1301 {
1302 Lookaside->L.TotalFrees++;
1303 #ifdef NONAMELESSUNION
1304 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
1305 Lookaside->L.u3.FreeMisses++;
1306 (Lookaside->L.u5.Free)(Entry);
1307 } else {
1308 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1309 ExInterlockedPushEntrySList(&Lookaside->L.u.ListHead,
1310 (PSLIST_ENTRY)Entry,
1311 &Lookaside->Lock__ObsoleteButDoNotDelete);
1312 #else
1313 InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry);
1314 #endif
1315 }
1316 #else /* NONAMELESSUNION */
1317 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
1318 Lookaside->L.FreeMisses++;
1319 (Lookaside->L.Free)(Entry);
1320 } else {
1321 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1322 ExInterlockedPushEntrySList(&Lookaside->L.ListHead,
1323 (PSLIST_ENTRY)Entry,
1324 &Lookaside->Lock__ObsoleteButDoNotDelete);
1325 #else
1326 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
1327 #endif
1328 }
1329 #endif /* NONAMELESSUNION */
1330 }
1331
1332 $endif (_WDMDDK_)