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