--- winddk.h.orig Fri Sep 12 10:14:08 2003 +++ winddk.h Sat Aug 21 17:54:28 2004 @@ -5039,37 +5039,6 @@ IN PERESOURCE Resource, IN BOOLEAN Wait); -static __inline PVOID -ExAllocateFromNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside) -{ - PVOID Entry; - - Lookaside->TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->ListHead); - if (Entry == NULL) { - Lookaside->AllocateMisses++; - Entry = (Lookaside->Allocate)(Lookaside->Type, Lookaside->Size, Lookaside->Tag); - } - return Entry; -} - -static __inline PVOID -ExAllocateFromPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside) -{ - PVOID Entry; - - Lookaside->TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->ListHead); - if (Entry == NULL) { - Lookaside->AllocateMisses++; - Entry = (Lookaside->Allocate)(Lookaside->Type, - Lookaside->Size, Lookaside->Tag); - } - return Entry; -} - NTOSAPI PVOID DDKAPI @@ -5170,37 +5139,6 @@ IN PVOID P, IN ULONG Tag); -#define ExQueryDepthSList(ListHead) QueryDepthSList(ListHead) - -static __inline VOID -ExFreeToNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->TotalFrees++; - if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { - Lookaside->FreeMisses++; - (Lookaside->Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->ListHead, - (PSLIST_ENTRY)Entry); - } -} - -static __inline VOID -ExFreeToPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->TotalFrees++; - if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { - Lookaside->FreeMisses++; - (Lookaside->Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->ListHead, (PSLIST_ENTRY)Entry); - } -} - /* * ERESOURCE_THREAD * ExGetCurrentResourceThread( @@ -5348,6 +5286,14 @@ IN PSINGLE_LIST_ENTRY ListHead, IN PKSPIN_LOCK Lock); +#if (WINVER <= 0x0500) // Use ntoskrnl.exe exported function for Win2K +NTOSAPI +PSINGLE_LIST_ENTRY +DDKFASTAPI +ExInterlockedPopEntrySList( + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); +#else /* * PSINGLE_LIST_ENTRY * ExInterlockedPopEntrySList( @@ -5357,6 +5303,7 @@ #define ExInterlockedPopEntrySList(_ListHead, \ _Lock) \ InterlockedPopEntrySList(_ListHead) +#endif NTOSAPI PSINGLE_LIST_ENTRY @@ -5366,6 +5313,15 @@ IN PSINGLE_LIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock); +#if (WINVER <= 0x0500) // Use ntoskrnl.exe exported function for Win2K +NTOSAPI +PSINGLE_LIST_ENTRY +DDKFASTAPI +ExInterlockedPushEntrySList( + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); +#else /* * PSINGLE_LIST_ENTRY FASTCALL * ExInterlockedPushEntrySList( @@ -5377,6 +5333,7 @@ _ListEntry, \ _Lock) \ InterlockedPushEntrySList(_ListHead, _ListEntry) +#endif NTOSAPI PLIST_ENTRY @@ -5384,6 +5341,99 @@ ExInterlockedRemoveHeadList( IN PLIST_ENTRY ListHead, IN PKSPIN_LOCK Lock); + +// Moved down ... +static __inline PVOID +ExAllocateFromNPagedLookasideList( + IN PNPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->TotalAllocates++; +#if (WINVER <= 0x0500) + Entry = ExInterlockedPopEntrySList(&Lookaside->ListHead, &Lookaside->Obsoleted); +#else + Entry = InterlockedPopEntrySList(&Lookaside->ListHead); +#endif + if (Entry == NULL) { + Lookaside->AllocateMisses++; + Entry = (Lookaside->Allocate)(Lookaside->Type, Lookaside->Size, Lookaside->Tag); + } + + return Entry; +} + +#if (WINVER <= 0x0500) // Use ntoskrnl.exe exported function for Win2K +NTOSAPI +PVOID +DDKAPI +ExAllocateFromPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside); +#else +static __inline PVOID +ExAllocateFromPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->ListHead); + if (Entry == NULL) { + Lookaside->AllocateMisses++; + Entry = (Lookaside->Allocate)(Lookaside->Type, + Lookaside->Size, Lookaside->Tag); + } + return Entry; +} +#endif + +#define ExQueryDepthSList(ListHead) QueryDepthSList(ListHead) + +static __inline VOID +ExFreeToNPagedLookasideList( + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->TotalFrees++; + if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { + Lookaside->FreeMisses++; + (Lookaside->Free)(Entry); + } else { +#if (WINVER <= 0x0500) + ExInterlockedPushEntrySList(&Lookaside->ListHead, + (PSINGLE_LIST_ENTRY)Entry, + &Lookaside->Obsoleted); +#else + InterlockedPushEntrySList(&Lookaside->ListHead, + (PSLIST_ENTRY)Entry); +#endif + } +} + +#if (WINVER <= 0x0500) // Use ntoskrnl.exe exported function for Win2K +NTOSAPI +VOID +DDKAPI +ExFreeToPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry); +#else +static __inline VOID +ExFreeToPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->TotalFrees++; + if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { + Lookaside->FreeMisses++; + (Lookaside->Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->ListHead, (PSLIST_ENTRY)Entry); + } +} +#endif + +// End NTOSAPI BOOLEAN