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