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