Microsoft deprecated all of these functions except ExAllocatePool2 and ExAllocatePool3, so it's a safe bet that in Windows the old functions are just wrappers around the new ones now.
From: Alex Henrie alexhenrie24@gmail.com
--- include/ddk/wdm.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 54b9e6aa199..940c074b713 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -306,6 +306,23 @@ typedef enum _POOL_TYPE { MaxPoolType } POOL_TYPE;
+typedef ULONG64 POOL_FLAGS; + +#define POOL_FLAG_REQUIRED_START 0x00000001 +#define POOL_FLAG_USE_QUOTA 0x00000001 +#define POOL_FLAG_UNINITIALIZED 0x00000002 +#define POOL_FLAG_SESSION 0x00000004 +#define POOL_FLAG_CACHE_ALIGNED 0x00000008 +#define POOL_FLAG_RESERVED1 0x00000010 +#define POOL_FLAG_RAISE_ON_FAILURE 0x00000020 +#define POOL_FLAG_NON_PAGED 0x00000040 +#define POOL_FLAG_NON_PAGED_EXECUTE 0x00000080 +#define POOL_FLAG_PAGED 0x00000100 +#define POOL_FLAG_RESERVED2 0x00000200 +#define POOL_FLAG_RESERVED3 0x00000400 +#define POOL_FLAG_LAST_KNOWN_REQUIRED POOL_FLAG_RESERVED3 +#define POOL_FLAG_REQUIRED_END 0x80000000 + typedef struct _WAIT_CONTEXT_BLOCK { KDEVICE_QUEUE_ENTRY WaitQueueEntry; struct _DRIVER_CONTROL *DeviceRoutine;
From: Alex Henrie alexhenrie24@gmail.com
Microsoft deprecated all of these functions except ExAllocatePool2 and ExAllocatePool3, so it's a safe bet that in Windows the old functions are just wrappers around the new ones now.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54362 --- dlls/ntoskrnl.exe/ntoskrnl.c | 61 +++++++++++++++++++++++------ dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 1 + 2 files changed, 51 insertions(+), 11 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 45b8e1ab1c1..8efe58fc9de 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2212,44 +2212,83 @@ __ASM_FASTCALL_FUNC(RtlUlonglongByteSwap, 8,
#endif /* __i386__ */
+static POOL_FLAGS pool_type_to_flags( POOL_TYPE type ) +{ + switch (type & 7) + { + case NonPagedPool: + case NonPagedPoolMustSucceed: + return POOL_FLAG_NON_PAGED; + case PagedPool: + return POOL_FLAG_PAGED; + case NonPagedPoolCacheAligned: + case NonPagedPoolCacheAlignedMustS: + return POOL_FLAG_NON_PAGED|POOL_FLAG_CACHE_ALIGNED; + case PagedPoolCacheAligned: + return POOL_FLAG_PAGED|POOL_FLAG_CACHE_ALIGNED; + default: + return 0; + } +} + +/*********************************************************************** + * ExAllocatePool2 (NTOSKRNL.EXE.@) + */ +void * WINAPI ExAllocatePool2( POOL_FLAGS flags, SIZE_T size, ULONG tag ) +{ + /* FIXME: handle page alignment constraints */ + void *ret = HeapAlloc( ntoskrnl_heap, 0, size ); + TRACE( "(0x%I64x, %Iu, %s) -> %p\n", flags, size, debugstr_fourcc(tag), ret ); + return ret; +} + /*********************************************************************** * ExAllocatePool (NTOSKRNL.EXE.@) */ PVOID WINAPI ExAllocatePool( POOL_TYPE type, SIZE_T size ) { - return ExAllocatePoolWithTag( type, size, 0 ); -} + POOL_FLAGS flags = pool_type_to_flags( type ); + if (type & POOL_RAISE_IF_ALLOCATION_FAILURE) + flags |= POOL_FLAG_RAISE_ON_FAILURE;
+ return ExAllocatePool2( flags, size, 0 ); +}
/*********************************************************************** * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@) */ PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size ) { - return ExAllocatePoolWithTag( type, size, 0 ); -} + POOL_FLAGS flags = pool_type_to_flags( type ) | POOL_FLAG_USE_QUOTA; + if (!(type & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE)) + flags |= POOL_FLAG_RAISE_ON_FAILURE;
+ return ExAllocatePool2( flags, size, 0 ); +}
/*********************************************************************** * ExAllocatePoolWithTag (NTOSKRNL.EXE.@) */ PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag ) { - /* FIXME: handle page alignment constraints */ - void *ret = HeapAlloc( ntoskrnl_heap, 0, size ); - TRACE( "%Iu pool %u -> %p\n", size, type, ret ); - return ret; -} + POOL_FLAGS flags = pool_type_to_flags( type ); + if (type & POOL_RAISE_IF_ALLOCATION_FAILURE) + flags |= POOL_FLAG_RAISE_ON_FAILURE;
+ return ExAllocatePool2( flags, size, tag ); +}
/*********************************************************************** * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@) */ PVOID WINAPI ExAllocatePoolWithQuotaTag( POOL_TYPE type, SIZE_T size, ULONG tag ) { - return ExAllocatePoolWithTag( type, size, tag ); -} + POOL_FLAGS flags = pool_type_to_flags( type ) | POOL_FLAG_USE_QUOTA; + if (!(type & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE)) + flags |= POOL_FLAG_RAISE_ON_FAILURE;
+ return ExAllocatePool2( flags, size, tag ); +}
/*********************************************************************** * ExCreateCallback (NTOSKRNL.EXE.@) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index aa7831eac5f..d098cf19c78 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -135,6 +135,7 @@ @ stdcall ExAcquireSharedWaitForExclusive(ptr long) @ stub ExAllocateFromPagedLookasideList @ stdcall ExAllocatePool(long long) +@ stdcall ExAllocatePool2(int64 long long) @ stdcall ExAllocatePoolWithQuota(long long) @ stdcall ExAllocatePoolWithQuotaTag(long long long) @ stdcall ExAllocatePoolWithTag(long long long)