More formatting fixe
[reactos.git] / include / xdk / exfuncs.h
index 242b002..3b215d9 100644 (file)
@@ -2,6 +2,100 @@
  *                          Executive Functions                               *
  ******************************************************************************/
 
+$if (_NTDDK_)
+static __inline PVOID
+ExAllocateFromZone(
+  IN PZONE_HEADER Zone)
+{
+  if (Zone->FreeList.Next)
+    Zone->FreeList.Next = Zone->FreeList.Next->Next;
+  return (PVOID) Zone->FreeList.Next;
+}
+
+static __inline PVOID
+ExFreeToZone(
+  IN PZONE_HEADER Zone,
+  IN PVOID Block)
+{
+  ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
+  Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
+  return ((PSINGLE_LIST_ENTRY) Block)->Next;
+}
+
+/*
+ * PVOID
+ * ExInterlockedAllocateFromZone(
+ *   IN PZONE_HEADER  Zone,
+ *   IN PKSPIN_LOCK  Lock)
+ */
+#define ExInterlockedAllocateFromZone(Zone, Lock) \
+    ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
+
+/* PVOID
+ * ExInterlockedFreeToZone(
+ *  IN PZONE_HEADER  Zone,
+ *  IN PVOID  Block,
+ *  IN PKSPIN_LOCK  Lock);
+ */
+#define ExInterlockedFreeToZone(Zone, Block, Lock) \
+    ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
+
+/*
+ * BOOLEAN
+ * ExIsFullZone(
+ *  IN PZONE_HEADER  Zone)
+ */
+#define ExIsFullZone(Zone) \
+  ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
+
+/* BOOLEAN
+ * ExIsObjectInFirstZoneSegment(
+ *     IN PZONE_HEADER Zone,
+ *     IN PVOID Object);
+ */
+#define ExIsObjectInFirstZoneSegment(Zone,Object) \
+    ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
+                ((PUCHAR)(Object) <  (PUCHAR)(Zone)->SegmentList.Next + \
+                         (Zone)->TotalSegmentSize)) )
+
+#define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
+#define ExAcquireResourceShared ExAcquireResourceSharedLite
+#define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
+#define ExDeleteResource ExDeleteResourceLite
+#define ExInitializeResource ExInitializeResourceLite
+#define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
+#define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
+#define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
+#define ExReleaseResourceForThread ExReleaseResourceForThreadLite
+
+typedef enum _INTERLOCKED_RESULT {
+  ResultNegative = RESULT_NEGATIVE,
+  ResultZero = RESULT_ZERO,
+  ResultPositive = RESULT_POSITIVE
+} INTERLOCKED_RESULT;
+
+#ifdef _X86_
+NTKERNELAPI
+INTERLOCKED_RESULT
+FASTCALL
+Exfi386InterlockedIncrementLong(
+  IN OUT LONG volatile *Addend);
+
+NTKERNELAPI
+INTERLOCKED_RESULT
+FASTCALL
+Exfi386InterlockedDecrementLong(
+  IN PLONG  Addend);
+
+NTKERNELAPI
+ULONG
+FASTCALL
+Exfi386InterlockedExchangeUlong(
+  IN PULONG  Target,
+  IN ULONG  Value);
+#endif
+
+$endif  (_NTDDK_)
 $if (_WDMDDK_)
 #define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend)
 #define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend)
@@ -14,19 +108,64 @@ $if (_WDMDDK_)
 
 #define ExInitializeSListHead InitializeSListHead
 
-#if defined(_X86_)
-#if defined(_NTHAL_)
+#if defined(_NTHAL_) && defined(_X86_)
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExiAcquireFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExiReleaseFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExiTryToAcquireFastMutex(
+    IN OUT PFAST_MUTEX FastMutex);
+
 #define ExAcquireFastMutex ExiAcquireFastMutex
 #define ExReleaseFastMutex ExiReleaseFastMutex
 #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex
-#endif
+
+#else
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExAcquireFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReleaseFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExTryToAcquireFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+#endif /* defined(_NTHAL_) && defined(_X86_) */
+
+#if defined(_X86_)
 #define ExInterlockedAddUlong ExfInterlockedAddUlong
 #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList
 #define ExInterlockedInsertTailList ExfInterlockedInsertTailList
 #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList
 #define ExInterlockedPopEntryList ExfInterlockedPopEntryList
 #define ExInterlockedPushEntryList ExfInterlockedPushEntryList
-#endif
+#endif /* defined(_X86_) */
 
 #if defined(_WIN64)
 
@@ -40,25 +179,25 @@ FORCEINLINE
 USHORT
 ExQueryDepthSList(IN PSLIST_HEADER ListHead)
 {
-    return (USHORT)(ListHead->Alignment & 0xffff);
+  return (USHORT)(ListHead->Alignment & 0xffff);
 }
 #endif
 
 NTKERNELAPI
 PSLIST_ENTRY
 ExpInterlockedFlushSList(
-    PSLIST_HEADER ListHead);
+  PSLIST_HEADER ListHead);
 
 NTKERNELAPI
 PSLIST_ENTRY
 ExpInterlockedPopEntrySList(
-    PSLIST_HEADER ListHead);
+  PSLIST_HEADER ListHead);
 
 NTKERNELAPI
 PSLIST_ENTRY
 ExpInterlockedPushEntrySList(
-    PSLIST_HEADER ListHead,
-    PSLIST_ENTRY ListEntry);
+  PSLIST_HEADER ListHead,
+  PSLIST_ENTRY ListEntry);
 
 #define ExInterlockedFlushSList(Head) \
     ExpInterlockedFlushSList(Head)
@@ -67,7 +206,7 @@ ExpInterlockedPushEntrySList(
 #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
     ExpInterlockedPushEntrySList(Head, Entry)
 
-#else // !defined(_WIN64)
+#else /* !defined(_WIN64) */
 
 #define ExQueryDepthSList(listhead) (listhead)->Depth
 
@@ -75,37 +214,90 @@ NTKERNELAPI
 PSINGLE_LIST_ENTRY
 FASTCALL
 ExInterlockedFlushSList(
-    IN PSLIST_HEADER ListHead);
+  IN OUT PSLIST_HEADER ListHead);
+
+#endif /* !defined(_WIN64) */
 
 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
+
 NTKERNELAPI
 PSINGLE_LIST_ENTRY 
 FASTCALL
 ExInterlockedPopEntrySList(
-    IN PSLIST_HEADER ListHead,
-    IN PKSPIN_LOCK Lock);
+  IN PSLIST_HEADER ListHead,
+  IN PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 PSINGLE_LIST_ENTRY 
 FASTCALL
 ExInterlockedPushEntrySList(
-    IN PSLIST_HEADER ListHead,
-    IN PSINGLE_LIST_ENTRY ListEntry,
-    IN PKSPIN_LOCK Lock);
-#else
+  IN PSLIST_HEADER ListHead,
+  IN PSINGLE_LIST_ENTRY ListEntry,
+  IN PKSPIN_LOCK Lock);
+
+NTKERNELAPI
+PVOID
+NTAPI
+ExAllocateFromPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside);
+
+NTKERNELAPI
+VOID
+NTAPI
+ExFreeToPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside,
+  IN PVOID Entry);
+
+#else /* !_WIN2K_COMPAT_SLIST_USAGE */
+
+#if !defined(_WIN64)
 #define ExInterlockedPopEntrySList(_ListHead, _Lock) \
     InterlockedPopEntrySList(_ListHead)
 #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \
     InterlockedPushEntrySList(_ListHead, _ListEntry)
-#endif // _WIN2K_COMPAT_SLIST_USAGE
+#endif
+
+static __inline
+PVOID
+ExAllocateFromPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside)
+{
+  PVOID Entry;
+
+  Lookaside->L.TotalAllocates++;
+  Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
+  if (Entry == NULL) {
+    Lookaside->L.AllocateMisses++;
+    Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
+                                    Lookaside->L.Size,
+                                    Lookaside->L.Tag);
+  }
+  return Entry;
+}
+
+static __inline
+VOID
+ExFreeToPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside,
+  IN PVOID Entry)
+{
+  Lookaside->L.TotalFrees++;
+  if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
+    Lookaside->L.FreeMisses++;
+    (Lookaside->L.Free)(Entry);
+  } else {
+    InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
+  }
+}
+
+#endif /* _WIN2K_COMPAT_SLIST_USAGE */
 
-#endif // !defined(_WIN64)
 
 /* ERESOURCE_THREAD
  * ExGetCurrentResourceThread(
  *     VOID);
  */
-#define ExGetCurrentResourceThread() ((ERESOURCE_THREAD)PsGetCurrentThread())
+#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread())
 
 #define ExReleaseResource(R) (ExReleaseResourceLite(R))
 
@@ -134,222 +326,242 @@ ExInitializeFastMutex(
   return;
 }
 
+$endif (_WDMDDK_)
 #if (NTDDI_VERSION >= NTDDI_WIN2K)
+$if (_NTDDK_)
+NTKERNELAPI
+NTSTATUS
+NTAPI
+ExExtendZone(
+  IN OUT PZONE_HEADER Zone,
+  IN OUT PVOID Segment,
+  IN ULONG SegmentSize);
 
 NTKERNELAPI
-VOID
-FASTCALL
-ExAcquireFastMutex(
-    IN OUT PFAST_MUTEX FastMutex);
+NTSTATUS
+NTAPI
+ExInitializeZone(
+  OUT PZONE_HEADER Zone,
+  IN ULONG BlockSize,
+  IN OUT PVOID InitialSegment,
+  IN ULONG InitialSegmentSize);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+ExInterlockedExtendZone(
+  IN OUT PZONE_HEADER Zone,
+  IN OUT PVOID Segment,
+  IN ULONG SegmentSize,
+  IN OUT PKSPIN_LOCK Lock);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+ExUuidCreate(
+  OUT UUID *Uuid);
 
 NTKERNELAPI
+DECLSPEC_NORETURN
 VOID
-FASTCALL
-ExReleaseFastMutex(
-    IN OUT PFAST_MUTEX FastMutex);
+NTAPI
+ExRaiseAccessViolation(VOID);
 
 NTKERNELAPI
-BOOLEAN
-FASTCALL
-ExTryToAcquireFastMutex(
-    IN OUT PFAST_MUTEX FastMutex);
+DECLSPEC_NORETURN
+VOID
+NTAPI
+ExRaiseDatatypeMisalignment(VOID);
 
+$endif  (_NTDDK_)
+$if (_WDMDDK_)
 NTKERNELAPI
 VOID
 FASTCALL
 ExAcquireFastMutexUnsafe(
-    IN OUT PFAST_MUTEX FastMutex);
+  IN OUT PFAST_MUTEX FastMutex);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExReleaseFastMutexUnsafe(
-    IN OUT PFAST_MUTEX FastMutex);
+  IN OUT PFAST_MUTEX FastMutex);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireResourceExclusiveLite(
-    IN PERESOURCE Resource,
-    IN BOOLEAN Wait);
+  IN OUT PERESOURCE Resource,
+  IN BOOLEAN Wait);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireResourceSharedLite(
-    IN PERESOURCE Resource,
-    IN BOOLEAN Wait);
+  IN OUT PERESOURCE Resource,
+  IN BOOLEAN Wait);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireSharedStarveExclusive(
-    IN PERESOURCE Resource,
-    IN BOOLEAN Wait);
+  IN OUT PERESOURCE Resource,
+  IN BOOLEAN Wait);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireSharedWaitForExclusive(
-    IN PERESOURCE Resource,
-    IN BOOLEAN Wait);
+  IN OUT PERESOURCE Resource,
+  IN BOOLEAN Wait);
 
 NTKERNELAPI
 PVOID
 NTAPI
 ExAllocatePool(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes);
-
-#ifdef POOL_TAGGING
-#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD')
-#endif /* POOL_TAGGING */
+  IN POOL_TYPE PoolType,
+  IN SIZE_T NumberOfBytes);
 
 NTKERNELAPI
 PVOID
 NTAPI
 ExAllocatePoolWithQuota(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes);
-
-#ifdef POOL_TAGGING
-#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD')
-#endif /* POOL_TAGGING */
+  IN POOL_TYPE PoolType,
+  IN SIZE_T NumberOfBytes);
 
 NTKERNELAPI
 PVOID
 NTAPI
 ExAllocatePoolWithQuotaTag(
-  IN POOL_TYPE  PoolType,
-  IN SIZE_T  NumberOfBytes,
-  IN ULONG  Tag);
+  IN POOL_TYPE PoolType,
+  IN SIZE_T NumberOfBytes,
+  IN ULONG Tag);
 
 #ifndef POOL_TAGGING
 #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
-#endif /* POOL_TAGGING */
+#endif
 
 NTKERNELAPI
 PVOID
 NTAPI
 ExAllocatePoolWithTag(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes,
-    IN ULONG Tag);
+  IN POOL_TYPE PoolType,
+  IN SIZE_T NumberOfBytes,
+  IN ULONG Tag);
+
+#ifndef POOL_TAGGING
+#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
+#endif
 
 NTKERNELAPI
 PVOID
 NTAPI
 ExAllocatePoolWithTagPriority(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes,
-    IN ULONG Tag,
-    IN EX_POOL_PRIORITY Priority);
+  IN POOL_TYPE PoolType,
+  IN SIZE_T NumberOfBytes,
+  IN ULONG Tag,
+  IN EX_POOL_PRIORITY Priority);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExConvertExclusiveToSharedLite(
-    IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
 ExCreateCallback(
-    OUT PCALLBACK_OBJECT *CallbackObject,
-    IN POBJECT_ATTRIBUTES ObjectAttributes,
-    IN BOOLEAN Create,
-    IN BOOLEAN AllowMultipleCallbacks);
+  OUT PCALLBACK_OBJECT *CallbackObject,
+  IN POBJECT_ATTRIBUTES ObjectAttributes,
+  IN BOOLEAN Create,
+  IN BOOLEAN AllowMultipleCallbacks);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExDeleteNPagedLookasideList(
-    IN PNPAGED_LOOKASIDE_LIST Lookaside);
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExDeletePagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside);
+  IN PPAGED_LOOKASIDE_LIST Lookaside);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
 ExDeleteResourceLite(
-    IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExFreePool(
-    IN PVOID P);
-
-#ifdef POOL_TAGGING
-#define ExFreePool(P) ExFreePoolWithTag(P, 0)
-#endif
+  IN PVOID P);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExFreePoolWithTag(
-    IN PVOID P,
-    IN ULONG Tag);
+  IN PVOID P,
+  IN ULONG Tag);
 
 NTKERNELAPI
 ULONG
 NTAPI
 ExGetExclusiveWaiterCount(
-    IN PERESOURCE Resource);
+  IN PERESOURCE Resource);
 
 NTKERNELAPI
 KPROCESSOR_MODE
 NTAPI
-ExGetPreviousMode(
-    VOID);
+ExGetPreviousMode(VOID);
 
 NTKERNELAPI
 ULONG
 NTAPI
 ExGetSharedWaiterCount(
-    IN PERESOURCE Resource);
+  IN PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExInitializeNPagedLookasideList(
-    IN PNPAGED_LOOKASIDE_LIST Lookaside,
-    IN PALLOCATE_FUNCTION Allocate OPTIONAL,
-    IN PFREE_FUNCTION Free OPTIONAL,
-    IN ULONG Flags,
-    IN SIZE_T Size,
-    IN ULONG Tag,
-    IN USHORT Depth);
+  IN PNPAGED_LOOKASIDE_LIST Lookaside,
+  IN PALLOCATE_FUNCTION Allocate OPTIONAL,
+  IN PFREE_FUNCTION Free OPTIONAL,
+  IN ULONG Flags,
+  IN SIZE_T Size,
+  IN ULONG Tag,
+  IN USHORT Depth);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExInitializePagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside,
-    IN PALLOCATE_FUNCTION Allocate OPTIONAL,
-    IN PFREE_FUNCTION Free OPTIONAL,
-    IN ULONG Flags,
-    IN SIZE_T Size,
-    IN ULONG Tag,
-    IN USHORT Depth);
+  IN PPAGED_LOOKASIDE_LIST Lookaside,
+  IN PALLOCATE_FUNCTION Allocate OPTIONAL,
+  IN PFREE_FUNCTION Free OPTIONAL,
+  IN ULONG Flags,
+  IN SIZE_T Size,
+  IN ULONG Tag,
+  IN USHORT Depth);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
 ExInitializeResourceLite(
-    IN PERESOURCE Resource);
+  OUT PERESOURCE Resource);
 
 NTKERNELAPI
 LARGE_INTEGER
 NTAPI
 ExInterlockedAddLargeInteger(
-    IN PLARGE_INTEGER Addend,
-    IN LARGE_INTEGER Increment,
-    IN PKSPIN_LOCK Lock);
+  IN PLARGE_INTEGER Addend,
+  IN LARGE_INTEGER Increment,
+  IN PKSPIN_LOCK Lock);
 
 #if defined(_WIN64)
 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
@@ -363,89 +575,96 @@ NTKERNELAPI
 ULONG
 FASTCALL
 ExInterlockedAddUlong(
-    IN PULONG Addend,
-    IN ULONG Increment,
-    PKSPIN_LOCK Lock);
+  IN PULONG Addend,
+  IN ULONG Increment,
+  IN OUT PKSPIN_LOCK Lock);
 
 #if defined(_AMD64_) || defined(_IA64_)
+
 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
     InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
+
 #elif defined(_X86_)
+
 NTKERNELAPI
 LONGLONG
 FASTCALL
 ExfInterlockedCompareExchange64(
-    IN OUT LONGLONG volatile *Destination,
-    IN PLONGLONG Exchange,
-    IN PLONGLONG Comperand);
+  IN OUT LONGLONG volatile *Destination,
+  IN PLONGLONG Exchange,
+  IN PLONGLONG Comperand);
+
 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
     ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
+
 #else
+
 NTKERNELAPI
 LONGLONG
 FASTCALL
 ExInterlockedCompareExchange64(
-    IN OUT LONGLONG volatile *Destination,
-    IN PLONGLONG Exchange,
-    IN PLONGLONG Comparand,
-    IN PKSPIN_LOCK Lock);
-#endif
+  IN OUT LONGLONG volatile *Destination,
+  IN PLONGLONG Exchange,
+  IN PLONGLONG Comparand,
+  IN PKSPIN_LOCK Lock);
+
+#endif /* defined(_AMD64_) || defined(_IA64_) */
 
 NTKERNELAPI
 PLIST_ENTRY
 FASTCALL
 ExInterlockedInsertHeadList(
-    IN PLIST_ENTRY ListHead,
-    IN PLIST_ENTRY ListEntry,
-    IN PKSPIN_LOCK Lock);
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY ListEntry,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 PLIST_ENTRY
 FASTCALL
 ExInterlockedInsertTailList(
-    IN PLIST_ENTRY ListHead,
-    IN PLIST_ENTRY ListEntry,
-    IN PKSPIN_LOCK Lock);
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY ListEntry,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 PSINGLE_LIST_ENTRY
 FASTCALL
 ExInterlockedPopEntryList(
-    IN PSINGLE_LIST_ENTRY ListHead,
-    IN PKSPIN_LOCK Lock);
+  IN OUT PSINGLE_LIST_ENTRY ListHead,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 PSINGLE_LIST_ENTRY
 FASTCALL
 ExInterlockedPushEntryList(
-    IN PSINGLE_LIST_ENTRY ListHead,
-    IN PSINGLE_LIST_ENTRY ListEntry,
-    IN PKSPIN_LOCK Lock);
+  IN OUT PSINGLE_LIST_ENTRY ListHead,
+  IN OUT PSINGLE_LIST_ENTRY ListEntry,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 PLIST_ENTRY
 FASTCALL
 ExInterlockedRemoveHeadList(
-    IN PLIST_ENTRY ListHead,
-    IN PKSPIN_LOCK Lock);
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExIsProcessorFeaturePresent(
-    IN ULONG ProcessorFeature);
+  IN ULONG ProcessorFeature);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExIsResourceAcquiredExclusiveLite(
-    IN PERESOURCE Resource);
+  IN PERESOURCE Resource);
 
 NTKERNELAPI
 ULONG
 NTAPI
 ExIsResourceAcquiredSharedLite(
-    IN PERESOURCE Resource);
+  IN PERESOURCE Resource);
 
 #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite
 
@@ -453,243 +672,368 @@ NTKERNELAPI
 VOID
 NTAPI
 ExLocalTimeToSystemTime(
-    IN PLARGE_INTEGER LocalTime,
-    OUT PLARGE_INTEGER SystemTime);
+  IN PLARGE_INTEGER LocalTime,
+  OUT PLARGE_INTEGER SystemTime);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExNotifyCallback(
-    IN PCALLBACK_OBJECT CallbackObject,
-    IN PVOID Argument1,
-    IN PVOID Argument2);
+  IN PCALLBACK_OBJECT CallbackObject,
+  IN PVOID Argument1 OPTIONAL,
+  IN PVOID Argument2 OPTIONAL);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExQueueWorkItem(
-    IN PWORK_QUEUE_ITEM WorkItem,
-    IN WORK_QUEUE_TYPE QueueType);
+  IN OUT PWORK_QUEUE_ITEM WorkItem,
+  IN WORK_QUEUE_TYPE QueueType);
 
 NTKERNELAPI
 DECLSPEC_NORETURN
 VOID
 NTAPI
 ExRaiseStatus(
-    IN NTSTATUS Status);
+  IN NTSTATUS Status);
 
 NTKERNELAPI
 PVOID
 NTAPI
 ExRegisterCallback(
-    IN PCALLBACK_OBJECT CallbackObject,
-    IN PCALLBACK_FUNCTION CallbackFunction,
-    IN PVOID CallbackContext);
+  IN PCALLBACK_OBJECT CallbackObject,
+  IN PCALLBACK_FUNCTION CallbackFunction,
+  IN PVOID CallbackContext OPTIONAL);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
 ExReinitializeResourceLite(
-    IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExReleaseResourceForThreadLite(
-    IN PERESOURCE Resource,
-    IN ERESOURCE_THREAD ResourceThreadId);
+  IN OUT PERESOURCE Resource,
+  IN ERESOURCE_THREAD ResourceThreadId);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExReleaseResourceLite(
-    IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExSetResourceOwnerPointer(
-    IN PERESOURCE Resource,
-    IN PVOID OwnerPointer);
+  IN OUT PERESOURCE Resource,
+  IN PVOID OwnerPointer);
 
 NTKERNELAPI
 ULONG
 NTAPI
 ExSetTimerResolution(
-    IN ULONG DesiredTime,
-    IN BOOLEAN SetResolution);
+  IN ULONG DesiredTime,
+  IN BOOLEAN SetResolution);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExSystemTimeToLocalTime(
-    IN PLARGE_INTEGER SystemTime,
-    OUT PLARGE_INTEGER LocalTime);
+  IN PLARGE_INTEGER SystemTime,
+  OUT PLARGE_INTEGER LocalTime);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExUnregisterCallback(
-    IN PVOID CbRegistration);
+  IN OUT PVOID CbRegistration);
 
+$endif  (_WDMDDK_)
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
-#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
-
+$if (_WDMDDK_)
 #if (NTDDI_VERSION >= NTDDI_WINXP)
+
 NTKERNELAPI
 BOOLEAN
 FASTCALL
 ExAcquireRundownProtection(
-    IN OUT PEX_RUNDOWN_REF RunRef);
+  IN OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExInitializeRundownProtection(
-    OUT PEX_RUNDOWN_REF RunRef);
+  OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExReInitializeRundownProtection(
-    OUT PEX_RUNDOWN_REF RunRef);
+  IN OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExReleaseRundownProtection(
-    IN OUT PEX_RUNDOWN_REF RunRef);
+  IN OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExRundownCompleted(
-    OUT PEX_RUNDOWN_REF RunRef);
+  OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExVerifySuite(
-    IN SUITE_TYPE SuiteType);
+  IN SUITE_TYPE SuiteType);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExWaitForRundownProtectionRelease(
-    IN OUT PEX_RUNDOWN_REF RunRef);
+  IN OUT PEX_RUNDOWN_REF RunRef);
 
-#endif // (NTDDI_VERSION >= NTDDI_WINXP)
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
 
 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
+
 NTKERNELAPI
 BOOLEAN
 FASTCALL
 ExAcquireRundownProtectionEx(
-    IN OUT PEX_RUNDOWN_REF RunRef,
-    IN ULONG Count);
+  IN OUT PEX_RUNDOWN_REF RunRef,
+  IN ULONG Count);
 
 NTKERNELAPI
 VOID
 FASTCALL
 ExReleaseRundownProtectionEx(
-    IN OUT PEX_RUNDOWN_REF RunRef,
-    IN ULONG Count);
-#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2)
+  IN OUT PEX_RUNDOWN_REF RunRef,
+  IN ULONG Count);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
 
 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
+
 NTKERNELAPI
 PEX_RUNDOWN_REF_CACHE_AWARE
 NTAPI
 ExAllocateCacheAwareRundownProtection(
-    IN POOL_TYPE PoolType,
-    IN ULONG PoolTag);
+  IN POOL_TYPE PoolType,
+  IN ULONG PoolTag);
 
 NTKERNELAPI
 SIZE_T
 NTAPI
 ExSizeOfRundownProtectionCacheAware(VOID);
-#endif // (NTDDI_VERSION >= NTDDI_WS03SP1)
+
+NTKERNELAPI
+PVOID
+NTAPI
+ExEnterCriticalRegionAndAcquireResourceShared(
+  IN OUT PERESOURCE Resource);
+
+NTKERNELAPI
+PVOID
+NTAPI
+ExEnterCriticalRegionAndAcquireResourceExclusive(
+  IN OUT PERESOURCE Resource);
+
+NTKERNELAPI
+PVOID
+NTAPI
+ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(
+  IN OUT PERESOURCE Resource);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReleaseResourceAndLeaveCriticalRegion(
+  IN OUT PERESOURCE Resource);
+
+NTKERNELAPI
+VOID
+NTAPI
+ExInitializeRundownProtectionCacheAware(
+  OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
+  IN SIZE_T RunRefSize);
+
+NTKERNELAPI
+VOID
+NTAPI
+ExFreeCacheAwareRundownProtection(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExAcquireRundownProtectionCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReleaseRundownProtectionCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExAcquireRundownProtectionCacheAwareEx(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
+  IN ULONG Count);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReleaseRundownProtectionCacheAwareEx(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef,
+  IN ULONG Count);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExWaitForRundownProtectionReleaseCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReInitializeRundownProtectionCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExRundownCompletedCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
 
 #if (NTDDI_VERSION >= NTDDI_VISTA)
+
 NTKERNELAPI
 NTSTATUS
 NTAPI
 ExInitializeLookasideListEx(
-    OUT PLOOKASIDE_LIST_EX Lookaside,
-    IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL,
-    IN PFREE_FUNCTION_EX Free OPTIONAL,
-    IN POOL_TYPE PoolType,
-    IN ULONG Flags,
-    IN SIZE_T Size,
-    IN ULONG Tag,
-    IN USHORT Depth);
-#endif
+  OUT PLOOKASIDE_LIST_EX Lookaside,
+  IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL,
+  IN PFREE_FUNCTION_EX Free OPTIONAL,
+  IN POOL_TYPE PoolType,
+  IN ULONG Flags,
+  IN SIZE_T Size,
+  IN ULONG Tag,
+  IN USHORT Depth);
 
-#if !defined(MIDL_PASS)
+NTKERNELAPI
+VOID
+NTAPI
+ExDeleteLookasideListEx(
+  IN OUT PLOOKASIDE_LIST_EX Lookaside);
 
-static __inline PVOID
-ExAllocateFromNPagedLookasideList(
-    IN PNPAGED_LOOKASIDE_LIST Lookaside)
+NTKERNELAPI
+VOID
+NTAPI
+ExFlushLookasideListEx(
+  IN OUT PLOOKASIDE_LIST_EX Lookaside);
+
+FORCEINLINE
+PVOID
+ExAllocateFromLookasideListEx(
+  IN OUT PLOOKASIDE_LIST_EX Lookaside)
 {
-    PVOID Entry;
-
-    Lookaside->L.TotalAllocates++;
-    Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
-    if (Entry == NULL) {
-        Lookaside->L.AllocateMisses++;
-        Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
-                                        Lookaside->L.Size,
-                                        Lookaside->L.Tag);
-    }
-    return Entry;
+  PVOID Entry;
+
+  Lookaside->L.TotalAllocates += 1;
+  Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
+  if (Entry == NULL) {
+    Lookaside->L.AllocateMisses += 1;
+    Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type,
+                                      Lookaside->L.Size,
+                                      Lookaside->L.Tag,
+                                      Lookaside);
+  }
+  return Entry;
 }
 
-static __inline PVOID
-ExAllocateFromPagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside)
+FORCEINLINE
+VOID
+ExFreeToLookasideListEx(
+  IN OUT PLOOKASIDE_LIST_EX Lookaside,
+  IN PVOID Entry)
 {
-    PVOID Entry;
-
-    Lookaside->L.TotalAllocates++;
-    Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
-    if (Entry == NULL) {
-        Lookaside->L.AllocateMisses++;
-        Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
-                                        Lookaside->L.Size,
-                                        Lookaside->L.Tag);
-    }
-    return Entry;
+  Lookaside->L.TotalFrees += 1;
+  if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
+    Lookaside->L.FreeMisses += 1;
+    (Lookaside->L.FreeEx)(Entry, Lookaside);
+  } else {
+    InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
+  }
+  return;
 }
 
-static __inline VOID
-ExFreeToNPagedLookasideList(
-    IN PNPAGED_LOOKASIDE_LIST Lookaside,
-    IN PVOID  Entry)
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+
+NTKERNELAPI
+VOID
+NTAPI
+ExSetResourceOwnerPointerEx(
+  IN OUT PERESOURCE Resource,
+  IN PVOID OwnerPointer,
+  IN ULONG Flags);
+
+#define FLAG_OWNER_POINTER_IS_THREAD 0x1
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
+
+static __inline PVOID
+ExAllocateFromNPagedLookasideList(
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside)
 {
-    Lookaside->L.TotalFrees++;
-    if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
-        Lookaside->L.FreeMisses++;
-        (Lookaside->L.Free)(Entry);
-    } else {
-        InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
-    }
+  PVOID Entry;
+
+  Lookaside->L.TotalAllocates++;
+#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
+  Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead,
+                                     &Lookaside->Lock__ObsoleteButDoNotDelete);
+#else
+  Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
+#endif
+  if (Entry == NULL) {
+    Lookaside->L.AllocateMisses++;
+    Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
+                                    Lookaside->L.Size,
+                                    Lookaside->L.Tag);
+  }
+  return Entry;
 }
 
 static __inline VOID
-ExFreeToPagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside,
-    IN PVOID  Entry)
+ExFreeToNPagedLookasideList(
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside,
+  IN PVOID Entry)
 {
-    Lookaside->L.TotalFrees++;
-    if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
-        Lookaside->L.FreeMisses++;
-        (Lookaside->L.Free)(Entry);
-    } else {
-        InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
-    }
+  Lookaside->L.TotalFrees++;
+  if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
+    Lookaside->L.FreeMisses++;
+    (Lookaside->L.Free)(Entry);
+  } else {
+#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
+      ExInterlockedPushEntrySList(&Lookaside->L.ListHead,
+                                  (PSLIST_ENTRY)Entry,
+                                  &Lookaside->Lock__ObsoleteButDoNotDelete);
+#else
+      InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
+#endif
+   }
 }
 
-#endif // !defined(MIDL_PASS)
-
-$endif
-
+$endif  (_WDMDDK_)