More formatting fixe
[reactos.git] / include / xdk / exfuncs.h
index 0c875a4..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)
 
@@ -75,9 +214,12 @@ 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
@@ -92,20 +234,70 @@ ExInterlockedPushEntrySList(
   IN PSLIST_HEADER ListHead,
   IN PSINGLE_LIST_ENTRY ListEntry,
   IN PKSPIN_LOCK Lock);
-#else
+
+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
+
+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,26 +326,55 @@ 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
@@ -170,28 +391,28 @@ NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireResourceExclusiveLite(
-  IN PERESOURCE Resource,
+  IN OUT PERESOURCE Resource,
   IN BOOLEAN Wait);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireResourceSharedLite(
-  IN PERESOURCE Resource,
+  IN OUT PERESOURCE Resource,
   IN BOOLEAN Wait);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireSharedStarveExclusive(
-  IN PERESOURCE Resource,
+  IN OUT PERESOURCE Resource,
   IN BOOLEAN Wait);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
 ExAcquireSharedWaitForExclusive(
-  IN PERESOURCE Resource,
+  IN OUT PERESOURCE Resource,
   IN BOOLEAN Wait);
 
 NTKERNELAPI
@@ -201,10 +422,6 @@ ExAllocatePool(
   IN POOL_TYPE PoolType,
   IN SIZE_T NumberOfBytes);
 
-#ifdef POOL_TAGGING
-#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD')
-#endif /* POOL_TAGGING */
-
 NTKERNELAPI
 PVOID
 NTAPI
@@ -212,10 +429,6 @@ ExAllocatePoolWithQuota(
   IN POOL_TYPE PoolType,
   IN SIZE_T NumberOfBytes);
 
-#ifdef POOL_TAGGING
-#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD')
-#endif /* POOL_TAGGING */
-
 NTKERNELAPI
 PVOID
 NTAPI
@@ -226,7 +439,7 @@ ExAllocatePoolWithQuotaTag(
 
 #ifndef POOL_TAGGING
 #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
-#endif /* POOL_TAGGING */
+#endif
 
 NTKERNELAPI
 PVOID
@@ -236,6 +449,10 @@ ExAllocatePoolWithTag(
   IN SIZE_T NumberOfBytes,
   IN ULONG Tag);
 
+#ifndef POOL_TAGGING
+#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
+#endif
+
 NTKERNELAPI
 PVOID
 NTAPI
@@ -249,7 +466,7 @@ NTKERNELAPI
 VOID
 NTAPI
 ExConvertExclusiveToSharedLite(
-  IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 NTSTATUS
@@ -264,7 +481,7 @@ NTKERNELAPI
 VOID
 NTAPI
 ExDeleteNPagedLookasideList(
-  IN PNPAGED_LOOKASIDE_LIST Lookaside);
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside);
 
 NTKERNELAPI
 VOID
@@ -276,7 +493,7 @@ NTKERNELAPI
 NTSTATUS
 NTAPI
 ExDeleteResourceLite(
-  IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
@@ -284,10 +501,6 @@ NTAPI
 ExFreePool(
   IN PVOID P);
 
-#ifdef POOL_TAGGING
-#define ExFreePool(P) ExFreePoolWithTag(P, 0)
-#endif
-
 NTKERNELAPI
 VOID
 NTAPI
@@ -340,7 +553,7 @@ NTKERNELAPI
 NTSTATUS
 NTAPI
 ExInitializeResourceLite(
-  IN PERESOURCE Resource);
+  OUT PERESOURCE Resource);
 
 NTKERNELAPI
 LARGE_INTEGER
@@ -364,7 +577,7 @@ FASTCALL
 ExInterlockedAddUlong(
   IN PULONG Addend,
   IN ULONG Increment,
-  PKSPIN_LOCK Lock);
+  IN OUT PKSPIN_LOCK Lock);
 
 #if defined(_AMD64_) || defined(_IA64_)
 
@@ -401,39 +614,39 @@ 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
@@ -467,14 +680,14 @@ VOID
 NTAPI
 ExNotifyCallback(
   IN PCALLBACK_OBJECT CallbackObject,
-  IN PVOID Argument1,
-  IN PVOID Argument2);
+  IN PVOID Argument1 OPTIONAL,
+  IN PVOID Argument2 OPTIONAL);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExQueueWorkItem(
-  IN PWORK_QUEUE_ITEM WorkItem,
+  IN OUT PWORK_QUEUE_ITEM WorkItem,
   IN WORK_QUEUE_TYPE QueueType);
 
 NTKERNELAPI
@@ -490,32 +703,32 @@ NTAPI
 ExRegisterCallback(
   IN PCALLBACK_OBJECT CallbackObject,
   IN PCALLBACK_FUNCTION CallbackFunction,
-  IN PVOID CallbackContext);
+  IN PVOID CallbackContext OPTIONAL);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
 ExReinitializeResourceLite(
-  IN PERESOURCE Resource);
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
 ExReleaseResourceForThreadLite(
-  IN PERESOURCE Resource,
+  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 OUT PERESOURCE Resource,
   IN PVOID OwnerPointer);
 
 NTKERNELAPI
@@ -536,10 +749,12 @@ NTKERNELAPI
 VOID
 NTAPI
 ExUnregisterCallback(
-  IN PVOID CbRegistration);
+  IN OUT PVOID CbRegistration);
 
+$endif  (_WDMDDK_)
 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
+$if (_WDMDDK_)
 #if (NTDDI_VERSION >= NTDDI_WINXP)
 
 NTKERNELAPI
@@ -558,7 +773,7 @@ NTKERNELAPI
 VOID
 FASTCALL
 ExReInitializeRundownProtection(
-  OUT PEX_RUNDOWN_REF RunRef);
+  IN OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 VOID
@@ -618,9 +833,91 @@ SIZE_T
 NTAPI
 ExSizeOfRundownProtectionCacheAware(VOID);
 
+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
@@ -633,35 +930,83 @@ ExInitializeLookasideListEx(
   IN SIZE_T Size,
   IN ULONG Tag,
   IN USHORT Depth);
-#endif
 
-#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++;
+  Lookaside->L.TotalAllocates += 1;
   Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
   if (Entry == NULL) {
-    Lookaside->L.AllocateMisses++;
-    Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
-                                    Lookaside->L.Size,
-                                    Lookaside->L.Tag);
+    Lookaside->L.AllocateMisses += 1;
+    Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type,
+                                      Lookaside->L.Size,
+                                      Lookaside->L.Tag,
+                                      Lookaside);
   }
   return Entry;
 }
 
+FORCEINLINE
+VOID
+ExFreeToLookasideListEx(
+  IN OUT PLOOKASIDE_LIST_EX Lookaside,
+  IN PVOID 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;
+}
+
+#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
-ExAllocateFromPagedLookasideList(
-  IN PPAGED_LOOKASIDE_LIST Lookaside)
+ExAllocateFromNPagedLookasideList(
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside)
 {
   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,
@@ -673,7 +1018,7 @@ ExAllocateFromPagedLookasideList(
 
 static __inline VOID
 ExFreeToNPagedLookasideList(
-  IN PNPAGED_LOOKASIDE_LIST Lookaside,
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside,
   IN PVOID Entry)
 {
   Lookaside->L.TotalFrees++;
@@ -681,25 +1026,14 @@ ExFreeToNPagedLookasideList(
     Lookaside->L.FreeMisses++;
     (Lookaside->L.Free)(Entry);
   } else {
-    InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
-  }
-}
-
-static __inline VOID
-ExFreeToPagedLookasideList(
-  IN 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);
-  }
+#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_)