[CONSRV] Fix for console windows shrinking on Minimize and Restore (#2014)
[reactos.git] / sdk / 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 #ifdef _X86_
88
89 #ifdef _WIN2K_COMPAT_SLIST_USAGE
90
91 NTKERNELAPI
92 PSLIST_ENTRY
93 FASTCALL
94 ExInterlockedPushEntrySList(
95 _Inout_ PSLIST_HEADER SListHead,
96 _Inout_ __drv_aliasesMem PSLIST_ENTRY SListEntry,
97 _Inout_opt_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
98
99 NTKERNELAPI
100 PSLIST_ENTRY
101 FASTCALL
102 ExInterlockedPopEntrySList(
103 _Inout_ PSLIST_HEADER SListHead,
104 _Inout_opt_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
105
106 #else /* !_WIN2K_COMPAT_SLIST_USAGE */
107
108 #define ExInterlockedPushEntrySList(SListHead, SListEntry, Lock) \
109 InterlockedPushEntrySList(SListHead, SListEntry)
110
111 #define ExInterlockedPopEntrySList(SListHead, Lock) \
112 InterlockedPopEntrySList(SListHead)
113
114 #endif /* _WIN2K_COMPAT_SLIST_USAGE */
115
116 NTKERNELAPI
117 PSLIST_ENTRY
118 FASTCALL
119 ExInterlockedFlushSList(
120 _Inout_ PSLIST_HEADER SListHead);
121
122 #ifdef NONAMELESSUNION
123 #define ExQueryDepthSList(SListHead) (SListHead)->s.Depth
124 #else
125 #define ExQueryDepthSList(SListHead) (SListHead)->Depth
126 #endif
127
128 #else /* !_X86_ */
129
130 NTKERNELAPI
131 PSLIST_ENTRY
132 ExpInterlockedPushEntrySList(
133 _Inout_ PSLIST_HEADER SListHead,
134 _Inout_ __drv_aliasesMem PSLIST_ENTRY SListEntry);
135
136 NTKERNELAPI
137 PSLIST_ENTRY
138 ExpInterlockedPopEntrySList(
139 _Inout_ PSLIST_HEADER SListHead);
140
141 NTKERNELAPI
142 PSLIST_ENTRY
143 ExpInterlockedFlushSList(
144 _Inout_ PSLIST_HEADER SListHead);
145
146 #if !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
147 NTKERNELAPI
148 USHORT
149 ExQueryDepthSList(_In_ PSLIST_HEADER SListHead);
150 #else
151 FORCEINLINE
152 USHORT
153 ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
154 {
155 #ifdef _WIN64
156 return (USHORT)(SListHead->Alignment & 0xffff);
157 #else /* !_WIN64 */
158 return (USHORT)SListHead->Depth;
159 #endif /* _WIN64 */
160 }
161 #endif
162
163 #define ExInterlockedPushEntrySList(SListHead, SListEntry, Lock) \
164 ExpInterlockedPushEntrySList(SListHead, SListEntry)
165
166 #define ExInterlockedPopEntrySList(SListHead, Lock) \
167 ExpInterlockedPopEntrySList(SListHead)
168
169 #define ExInterlockedFlushSList(SListHead) \
170 ExpInterlockedFlushSList(SListHead)
171
172 #endif /* _X86_ */
173
174
175 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
176
177 _IRQL_requires_max_(APC_LEVEL)
178 NTKERNELAPI
179 PVOID
180 NTAPI
181 ExAllocateFromPagedLookasideList(
182 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside);
183
184 _IRQL_requires_max_(APC_LEVEL)
185 NTKERNELAPI
186 VOID
187 NTAPI
188 ExFreeToPagedLookasideList(
189 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside,
190 _In_ PVOID Entry);
191
192 #else /* !_WIN2K_COMPAT_SLIST_USAGE */
193
194 _IRQL_requires_max_(APC_LEVEL)
195 static __inline
196 PVOID
197 ExAllocateFromPagedLookasideList(
198 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside)
199 {
200 PVOID Entry;
201
202 Lookaside->L.TotalAllocates++;
203 #ifdef NONAMELESSUNION
204 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
205 if (Entry == NULL) {
206 Lookaside->L.u2.AllocateMisses++;
207 Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
208 Lookaside->L.Size,
209 Lookaside->L.Tag);
210 }
211 #else /* NONAMELESSUNION */
212 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
213 if (Entry == NULL) {
214 Lookaside->L.AllocateMisses++;
215 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
216 Lookaside->L.Size,
217 Lookaside->L.Tag);
218 }
219 #endif /* NONAMELESSUNION */
220 return Entry;
221 }
222
223 _IRQL_requires_max_(APC_LEVEL)
224 static __inline
225 VOID
226 ExFreeToPagedLookasideList(
227 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside,
228 _In_ PVOID Entry)
229 {
230 Lookaside->L.TotalFrees++;
231 #ifdef NONAMELESSUNION
232 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
233 Lookaside->L.u3.FreeMisses++;
234 (Lookaside->L.u5.Free)(Entry);
235 } else {
236 InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry);
237 }
238 #else /* NONAMELESSUNION */
239 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
240 Lookaside->L.FreeMisses++;
241 (Lookaside->L.Free)(Entry);
242 } else {
243 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
244 }
245 #endif /* NONAMELESSUNION */
246 }
247
248 #endif /* _WIN2K_COMPAT_SLIST_USAGE */
249
250
251 /* ERESOURCE_THREAD
252 * ExGetCurrentResourceThread(
253 * VOID);
254 */
255 #define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread())
256
257 #define ExReleaseResource(R) (ExReleaseResourceLite(R))
258
259 /* VOID
260 * ExInitializeWorkItem(
261 * IN PWORK_QUEUE_ITEM Item,
262 * IN PWORKER_THREAD_ROUTINE Routine,
263 * IN PVOID Context)
264 */
265 #define ExInitializeWorkItem(Item, Routine, Context) \
266 { \
267 (Item)->WorkerRoutine = Routine; \
268 (Item)->Parameter = Context; \
269 (Item)->List.Flink = NULL; \
270 }
271
272 FORCEINLINE
273 VOID
274 ExInitializeFastMutex(
275 _Out_ PFAST_MUTEX FastMutex)
276 {
277 FastMutex->Count = FM_LOCK_BIT;
278 FastMutex->Owner = NULL;
279 FastMutex->Contention = 0;
280 KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE);
281 return;
282 }
283
284 $endif (_WDMDDK_)
285 $if (_NTDDK_)
286 static __inline PVOID
287 ExAllocateFromZone(
288 IN PZONE_HEADER Zone)
289 {
290 PVOID Result = (PVOID)Zone->FreeList.Next;
291 if (Zone->FreeList.Next)
292 Zone->FreeList.Next = Zone->FreeList.Next->Next;
293 return Result;
294 }
295
296 static __inline PVOID
297 ExFreeToZone(
298 IN PZONE_HEADER Zone,
299 IN PVOID Block)
300 {
301 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
302 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
303 return ((PSINGLE_LIST_ENTRY) Block)->Next;
304 }
305
306 /*
307 * PVOID
308 * ExInterlockedAllocateFromZone(
309 * IN PZONE_HEADER Zone,
310 * IN PKSPIN_LOCK Lock)
311 */
312 #define ExInterlockedAllocateFromZone(Zone, Lock) \
313 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
314
315 /* PVOID
316 * ExInterlockedFreeToZone(
317 * IN PZONE_HEADER Zone,
318 * IN PVOID Block,
319 * IN PKSPIN_LOCK Lock);
320 */
321 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
322 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
323
324 /*
325 * BOOLEAN
326 * ExIsFullZone(
327 * IN PZONE_HEADER Zone)
328 */
329 #define ExIsFullZone(Zone) \
330 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
331
332 /* BOOLEAN
333 * ExIsObjectInFirstZoneSegment(
334 * IN PZONE_HEADER Zone,
335 * IN PVOID Object);
336 */
337 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
338 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
339 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
340 (Zone)->TotalSegmentSize)) )
341
342 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
343 #define ExAcquireResourceShared ExAcquireResourceSharedLite
344 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
345 #define ExDeleteResource ExDeleteResourceLite
346 #define ExInitializeResource ExInitializeResourceLite
347 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
348 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
349 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
350 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
351
352 #ifndef _M_IX86
353 #define RESULT_ZERO 0
354 #define RESULT_NEGATIVE 1
355 #define RESULT_POSITIVE 2
356 #endif
357
358 typedef enum _INTERLOCKED_RESULT {
359 ResultNegative = RESULT_NEGATIVE,
360 ResultZero = RESULT_ZERO,
361 ResultPositive = RESULT_POSITIVE
362 } INTERLOCKED_RESULT;
363
364 #ifdef _X86_
365
366 NTKERNELAPI
367 INTERLOCKED_RESULT
368 FASTCALL
369 Exfi386InterlockedIncrementLong(
370 _Inout_ _Interlocked_operand_ LONG volatile *Addend);
371
372 NTKERNELAPI
373 INTERLOCKED_RESULT
374 FASTCALL
375 Exfi386InterlockedDecrementLong(
376 _Inout_ _Interlocked_operand_ PLONG Addend);
377
378 NTKERNELAPI
379 ULONG
380 FASTCALL
381 Exfi386InterlockedExchangeUlong(
382 _Inout_ _Interlocked_operand_ PULONG Target,
383 _In_ ULONG Value);
384
385 #endif
386
387 $endif (_NTDDK_)
388 $if (_NTIFS_)
389
390 #define ExDisableResourceBoost ExDisableResourceBoostLite
391
392 VOID
393 NTAPI
394 ExInitializePushLock(
395 _Out_ PEX_PUSH_LOCK PushLock);
396 $endif (_NTIFS_)
397
398 #if (NTDDI_VERSION >= NTDDI_WIN2K)
399 $if (_WDMDDK_)
400 _IRQL_requires_max_(APC_LEVEL)
401 _Requires_lock_held_(_Global_critical_region_)
402 NTKERNELAPI
403 VOID
404 FASTCALL
405 ExAcquireFastMutexUnsafe(
406 _Inout_ _Requires_lock_not_held_(*_Curr_) _Acquires_lock_(*_Curr_)
407 PFAST_MUTEX FastMutex);
408
409 _IRQL_requires_max_(APC_LEVEL)
410 _Requires_lock_held_(_Global_critical_region_)
411 NTKERNELAPI
412 VOID
413 FASTCALL
414 ExReleaseFastMutexUnsafe(
415 _Inout_ _Requires_lock_held_(*_Curr_) _Releases_lock_(*_Curr_)
416 PFAST_MUTEX FastMutex);
417
418 _Requires_lock_held_(_Global_critical_region_)
419 _Requires_lock_not_held_(*Resource)
420 _When_(Wait!=0, _Acquires_exclusive_lock_(*Resource))
421 _IRQL_requires_max_(APC_LEVEL)
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 ExAcquireResourceExclusiveLite(
428 _Inout_ PERESOURCE Resource,
429 _In_ _Literal_ BOOLEAN Wait);
430
431 _IRQL_requires_max_(APC_LEVEL)
432 _Requires_lock_held_(_Global_critical_region_)
433 _When_(Wait!=0, _Post_satisfies_(return == 1))
434 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
435 NTKERNELAPI
436 BOOLEAN
437 NTAPI
438 ExAcquireResourceSharedLite(
439 _Inout_ _Requires_lock_not_held_(*_Curr_)
440 _When_(return!=0, _Acquires_shared_lock_(*_Curr_))
441 PERESOURCE Resource,
442 _In_ BOOLEAN Wait);
443
444 _IRQL_requires_max_(APC_LEVEL)
445 _Requires_lock_held_(_Global_critical_region_)
446 _When_(Wait!=0, _Post_satisfies_(return == 1))
447 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
448 NTKERNELAPI
449 BOOLEAN
450 NTAPI
451 ExAcquireSharedStarveExclusive(
452 _Inout_ _Requires_lock_not_held_(*_Curr_)
453 _When_(return!=0, _Acquires_shared_lock_(*_Curr_))
454 PERESOURCE Resource,
455 _In_ BOOLEAN Wait);
456
457 _IRQL_requires_max_(APC_LEVEL)
458 _Requires_lock_held_(_Global_critical_region_)
459 _When_(Wait!=0, _Post_satisfies_(return == 1))
460 _When_(Wait==0, _Post_satisfies_(return == 0 || return == 1) _Must_inspect_result_)
461 NTKERNELAPI
462 BOOLEAN
463 NTAPI
464 ExAcquireSharedWaitForExclusive(
465 _Inout_ _Requires_lock_not_held_(*_Curr_)
466 _When_(return!=0, _Acquires_lock_(*_Curr_))
467 PERESOURCE Resource,
468 _In_ BOOLEAN Wait);
469
470 __drv_preferredFunction("ExAllocatePoolWithTag",
471 "No tag interferes with debugging.")
472 __drv_allocatesMem(Mem)
473 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
474 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
475 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
476 __drv_reportError("Must succeed pool allocations are forbidden. "
477 "Allocation failures cause a system crash"))
478 _When_((PoolType & (NonPagedPoolMustSucceed |
479 POOL_RAISE_IF_ALLOCATION_FAILURE)) == 0,
480 _Post_maybenull_ _Must_inspect_result_)
481 _When_((PoolType & (NonPagedPoolMustSucceed |
482 POOL_RAISE_IF_ALLOCATION_FAILURE)) != 0,
483 _Post_notnull_)
484 _Post_writable_byte_size_(NumberOfBytes)
485 NTKERNELAPI
486 PVOID
487 NTAPI
488 ExAllocatePool(
489 __drv_strictTypeMatch(__drv_typeExpr) _In_ POOL_TYPE PoolType,
490 _In_ SIZE_T NumberOfBytes);
491
492 __drv_preferredFunction("ExAllocatePoolWithQuotaTag",
493 "No tag interferes with debugging.")
494 __drv_allocatesMem(Mem)
495 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
496 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
497 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
498 __drv_reportError("Must succeed pool allocations are forbidden. "
499 "Allocation failures cause a system crash"))
500 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) != 0,
501 _Post_maybenull_ _Must_inspect_result_)
502 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) == 0, _Post_notnull_)
503 _Post_writable_byte_size_(NumberOfBytes)
504 NTKERNELAPI
505 PVOID
506 NTAPI
507 ExAllocatePoolWithQuota(
508 __drv_strictTypeMatch(__drv_typeExpr) _In_ POOL_TYPE PoolType,
509 _In_ SIZE_T NumberOfBytes);
510
511 __drv_allocatesMem(Mem)
512 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
513 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
514 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
515 __drv_reportError("Must succeed pool allocations are forbidden. "
516 "Allocation failures cause a system crash"))
517 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) != 0,
518 _Post_maybenull_ _Must_inspect_result_)
519 _When_((PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE) == 0, _Post_notnull_)
520 _Post_writable_byte_size_(NumberOfBytes)
521 NTKERNELAPI
522 PVOID
523 NTAPI
524 ExAllocatePoolWithQuotaTag(
525 _In_ __drv_strictTypeMatch(__drv_typeExpr) POOL_TYPE PoolType,
526 _In_ SIZE_T NumberOfBytes,
527 _In_ ULONG Tag);
528
529 #ifndef POOL_TAGGING
530 #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
531 #endif
532
533 __drv_allocatesMem(Mem)
534 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
535 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
536 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
537 __drv_reportError("Must succeed pool allocations are forbidden. "
538 "Allocation failures cause a system crash"))
539 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) == 0,
540 _Post_maybenull_ _Must_inspect_result_)
541 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) != 0,
542 _Post_notnull_)
543 _Post_writable_byte_size_(NumberOfBytes)
544 _Function_class_(ALLOCATE_FUNCTION)
545 NTKERNELAPI
546 PVOID
547 NTAPI
548 ExAllocatePoolWithTag(
549 _In_ __drv_strictTypeMatch(__drv_typeExpr) POOL_TYPE PoolType,
550 _In_ SIZE_T NumberOfBytes,
551 _In_ ULONG Tag);
552
553 #ifndef POOL_TAGGING
554 #define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
555 #endif
556
557 __drv_allocatesMem(Mem)
558 _When_((PoolType & PagedPool) != 0, _IRQL_requires_max_(APC_LEVEL))
559 _When_((PoolType & PagedPool) == 0, _IRQL_requires_max_(DISPATCH_LEVEL))
560 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
561 __drv_reportError("Must succeed pool allocations are forbidden. "
562 "Allocation failures cause a system crash"))
563 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) == 0,
564 _Post_maybenull_ _Must_inspect_result_)
565 _When_((PoolType & (NonPagedPoolMustSucceed | POOL_RAISE_IF_ALLOCATION_FAILURE)) != 0,
566 _Post_notnull_)
567 _Post_writable_byte_size_(NumberOfBytes)
568 NTKERNELAPI
569 PVOID
570 NTAPI
571 ExAllocatePoolWithTagPriority(
572 _In_ __drv_strictTypeMatch(__drv_typeCond) POOL_TYPE PoolType,
573 _In_ SIZE_T NumberOfBytes,
574 _In_ ULONG Tag,
575 _In_ __drv_strictTypeMatch(__drv_typeExpr) EX_POOL_PRIORITY Priority);
576
577 _IRQL_requires_max_(DISPATCH_LEVEL)
578 NTKERNELAPI
579 VOID
580 NTAPI
581 ExConvertExclusiveToSharedLite(
582 _Inout_ _Requires_lock_held_(*_Curr_) PERESOURCE Resource);
583
584 _IRQL_requires_max_(APC_LEVEL)
585 NTKERNELAPI
586 NTSTATUS
587 NTAPI
588 ExCreateCallback(
589 _Outptr_ PCALLBACK_OBJECT *CallbackObject,
590 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
591 _In_ BOOLEAN Create,
592 _In_ BOOLEAN AllowMultipleCallbacks);
593
594 NTKERNELAPI
595 VOID
596 NTAPI
597 ExDeleteNPagedLookasideList(
598 _Inout_ PNPAGED_LOOKASIDE_LIST Lookaside);
599
600 _IRQL_requires_max_(APC_LEVEL)
601 NTKERNELAPI
602 VOID
603 NTAPI
604 ExDeletePagedLookasideList(
605 _Inout_ PPAGED_LOOKASIDE_LIST Lookaside);
606
607 _IRQL_requires_max_(DISPATCH_LEVEL)
608 NTKERNELAPI
609 NTSTATUS
610 NTAPI
611 ExDeleteResourceLite(
612 _Inout_ PERESOURCE Resource);
613
614 _IRQL_requires_max_(DISPATCH_LEVEL)
615 _Function_class_(FREE_FUNCTION)
616 NTKERNELAPI
617 VOID
618 NTAPI
619 ExFreePool(
620 _Pre_notnull_ __drv_freesMem(Mem) PVOID P);
621
622 _IRQL_requires_max_(DISPATCH_LEVEL)
623 NTKERNELAPI
624 VOID
625 NTAPI
626 ExFreePoolWithTag(
627 _Pre_notnull_ __drv_freesMem(Mem) PVOID P,
628 _In_ ULONG Tag);
629
630 _IRQL_requires_max_(DISPATCH_LEVEL)
631 NTKERNELAPI
632 ULONG
633 NTAPI
634 ExGetExclusiveWaiterCount(
635 _In_ PERESOURCE Resource);
636
637 _IRQL_requires_max_(DISPATCH_LEVEL)
638 NTKERNELAPI
639 KPROCESSOR_MODE
640 NTAPI
641 ExGetPreviousMode(VOID);
642
643 _IRQL_requires_max_(DISPATCH_LEVEL)
644 NTKERNELAPI
645 ULONG
646 NTAPI
647 ExGetSharedWaiterCount(
648 _In_ PERESOURCE Resource);
649
650 _IRQL_requires_max_(DISPATCH_LEVEL)
651 NTKERNELAPI
652 VOID
653 NTAPI
654 ExInitializeNPagedLookasideList(
655 _Out_ PNPAGED_LOOKASIDE_LIST Lookaside,
656 _In_opt_ PALLOCATE_FUNCTION Allocate,
657 _In_opt_ PFREE_FUNCTION Free,
658 _In_ ULONG Flags,
659 _In_ SIZE_T Size,
660 _In_ ULONG Tag,
661 _In_ USHORT Depth);
662
663 _IRQL_requires_max_(APC_LEVEL)
664 NTKERNELAPI
665 VOID
666 NTAPI
667 ExInitializePagedLookasideList(
668 _Out_ PPAGED_LOOKASIDE_LIST Lookaside,
669 _In_opt_ PALLOCATE_FUNCTION Allocate,
670 _In_opt_ PFREE_FUNCTION Free,
671 _In_ ULONG Flags,
672 _In_ SIZE_T Size,
673 _In_ ULONG Tag,
674 _In_ USHORT Depth);
675
676 _IRQL_requires_max_(DISPATCH_LEVEL)
677 NTKERNELAPI
678 NTSTATUS
679 NTAPI
680 ExInitializeResourceLite(
681 _Out_ PERESOURCE Resource);
682
683 NTKERNELAPI
684 LARGE_INTEGER
685 NTAPI
686 ExInterlockedAddLargeInteger(
687 _Inout_ PLARGE_INTEGER Addend,
688 _In_ LARGE_INTEGER Increment,
689 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
690
691 #if !defined(_M_IX86)
692 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
693 (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment)
694 #else
695 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
696 (VOID)_InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment)
697 #endif
698
699 NTKERNELAPI
700 ULONG
701 FASTCALL
702 ExInterlockedAddUlong(
703 _Inout_ PULONG Addend,
704 _In_ ULONG Increment,
705 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
706
707 #if defined(_M_IX86)
708
709 NTKERNELAPI
710 LONGLONG
711 FASTCALL
712 ExfInterlockedCompareExchange64(
713 _Inout_ _Interlocked_operand_ LONGLONG volatile *Destination,
714 _In_ PLONGLONG Exchange,
715 _In_ PLONGLONG Comperand);
716
717 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
718 ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
719
720 #else
721
722 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
723 InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
724
725 #endif /* defined(_M_IX86) */
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 #ifdef _MSC_VER
1193 #pragma warning(push)
1194 #pragma warning(disable:__WARNING_MEMORY_NOT_ACQUIRED)
1195 #endif
1196
1197 __drv_allocatesMem(Mem)
1198 _Must_inspect_result_
1199 _IRQL_requires_max_(DISPATCH_LEVEL)
1200 FORCEINLINE
1201 PVOID
1202 ExAllocateFromLookasideListEx(
1203 _Inout_ PLOOKASIDE_LIST_EX Lookaside)
1204 {
1205 PVOID Entry;
1206
1207 Lookaside->L.TotalAllocates += 1;
1208 #ifdef NONAMELESSUNION
1209 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
1210 if (Entry == NULL) {
1211 Lookaside->L.u2.AllocateMisses += 1;
1212 Entry = (Lookaside->L.u4.AllocateEx)(Lookaside->L.Type,
1213 Lookaside->L.Size,
1214 Lookaside->L.Tag,
1215 Lookaside);
1216 }
1217 #else /* NONAMELESSUNION */
1218 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
1219 if (Entry == NULL) {
1220 Lookaside->L.AllocateMisses += 1;
1221 Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type,
1222 Lookaside->L.Size,
1223 Lookaside->L.Tag,
1224 Lookaside);
1225 }
1226 #endif /* NONAMELESSUNION */
1227 return Entry;
1228 }
1229
1230 #ifdef _MSC_VER
1231 #pragma warning(pop)
1232 #endif
1233
1234 _IRQL_requires_max_(DISPATCH_LEVEL)
1235 FORCEINLINE
1236 VOID
1237 ExFreeToLookasideListEx(
1238 _Inout_ PLOOKASIDE_LIST_EX Lookaside,
1239 _In_ __drv_freesMem(Entry) PVOID Entry)
1240 {
1241 Lookaside->L.TotalFrees += 1;
1242 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
1243 Lookaside->L.FreeMisses += 1;
1244 (Lookaside->L.FreeEx)(Entry, Lookaside);
1245 } else {
1246 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
1247 }
1248 return;
1249 }
1250
1251 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1252
1253 #if (NTDDI_VERSION >= NTDDI_WIN7)
1254
1255 _IRQL_requires_max_(DISPATCH_LEVEL)
1256 NTKERNELAPI
1257 VOID
1258 NTAPI
1259 ExSetResourceOwnerPointerEx(
1260 _Inout_ PERESOURCE Resource,
1261 _In_ PVOID OwnerPointer,
1262 _In_ ULONG Flags);
1263
1264 #define FLAG_OWNER_POINTER_IS_THREAD 0x1
1265
1266 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1267
1268 __drv_allocatesMem(Mem)
1269 _IRQL_requires_max_(DISPATCH_LEVEL)
1270 _Ret_maybenull_
1271 _Post_writable_byte_size_(Lookaside->L.Size)
1272 static __inline
1273 PVOID
1274 ExAllocateFromNPagedLookasideList(
1275 _Inout_ PNPAGED_LOOKASIDE_LIST Lookaside)
1276 {
1277 PVOID Entry;
1278
1279 Lookaside->L.TotalAllocates++;
1280 #ifdef NONAMELESSUNION
1281 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1282 Entry = ExInterlockedPopEntrySList(&Lookaside->L.u.ListHead,
1283 &Lookaside->Lock__ObsoleteButDoNotDelete);
1284 #else
1285 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
1286 #endif
1287 if (Entry == NULL) {
1288 Lookaside->L.u2.AllocateMisses++;
1289 Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
1290 Lookaside->L.Size,
1291 Lookaside->L.Tag);
1292 }
1293 #else /* NONAMELESSUNION */
1294 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1295 Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead,
1296 &Lookaside->Lock__ObsoleteButDoNotDelete);
1297 #else
1298 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
1299 #endif
1300 if (Entry == NULL) {
1301 Lookaside->L.AllocateMisses++;
1302 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
1303 Lookaside->L.Size,
1304 Lookaside->L.Tag);
1305 }
1306 #endif /* NONAMELESSUNION */
1307 return Entry;
1308 }
1309
1310 _IRQL_requires_max_(DISPATCH_LEVEL)
1311 static __inline
1312 VOID
1313 ExFreeToNPagedLookasideList(
1314 _Inout_ PNPAGED_LOOKASIDE_LIST Lookaside,
1315 _In_ __drv_freesMem(Mem) PVOID Entry)
1316 {
1317 Lookaside->L.TotalFrees++;
1318 #ifdef NONAMELESSUNION
1319 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
1320 Lookaside->L.u3.FreeMisses++;
1321 (Lookaside->L.u5.Free)(Entry);
1322 } else {
1323 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1324 ExInterlockedPushEntrySList(&Lookaside->L.u.ListHead,
1325 (PSLIST_ENTRY)Entry,
1326 &Lookaside->Lock__ObsoleteButDoNotDelete);
1327 #else
1328 InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry);
1329 #endif
1330 }
1331 #else /* NONAMELESSUNION */
1332 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
1333 Lookaside->L.FreeMisses++;
1334 (Lookaside->L.Free)(Entry);
1335 } else {
1336 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1337 ExInterlockedPushEntrySList(&Lookaside->L.ListHead,
1338 (PSLIST_ENTRY)Entry,
1339 &Lookaside->Lock__ObsoleteButDoNotDelete);
1340 #else
1341 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
1342 #endif
1343 }
1344 #endif /* NONAMELESSUNION */
1345 }
1346
1347 $endif (_WDMDDK_)