Commit cba29adf authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

ntoskrnl: Reimplement ExAllocatePool* on top of ExAllocatePool2.

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
parent 87761a8a
......@@ -2213,43 +2213,82 @@ __ASM_FASTCALL_FUNC(RtlUlonglongByteSwap, 8,
#endif /* __i386__ */
/***********************************************************************
* 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;
}
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;
}
}
/***********************************************************************
* 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.@)
......
......@@ -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)
......
......@@ -1704,6 +1704,7 @@ BOOLEAN WINAPI ExAcquireSharedStarveExclusive(ERESOURCE*,BOOLEAN);
BOOLEAN WINAPI ExAcquireSharedWaitForExclusive(ERESOURCE*,BOOLEAN);
void WINAPI ExFreePool(PVOID);
PVOID WINAPI ExAllocatePool(POOL_TYPE,SIZE_T) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePool) __WINE_MALLOC;
PVOID WINAPI ExAllocatePool2(POOL_FLAGS,SIZE_T,ULONG) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePool) __WINE_MALLOC;
PVOID WINAPI ExAllocatePoolWithQuota(POOL_TYPE,SIZE_T) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePool) __WINE_MALLOC;
void WINAPI ExFreePoolWithTag(PVOID,ULONG);
PVOID WINAPI ExAllocatePoolWithTag(POOL_TYPE,SIZE_T,ULONG) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePoolWithTag) __WINE_MALLOC;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment