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