ExAllocatePool

The ExAllocatePool routine is obsolete, and is exported only for existing binaries. Use ExAllocatePoolWithTag instead.

Exallocatepool 例程已過時的,並只由現有的二進制檔案輸出。使用 ExAllocatePoolWithTag 代替。

ExAllocatePool allocates pool memory of the specified type and returns a pointer to the allocated block.

Exallocatepool 按指定的類型分配記憶體池並返回所分配的此記憶體塊的指針。

基本介紹

  • 中文名:ExAllocatePool 例程
  • 外文名:ExAllocatePool routine
語法,參數,返回值,

語法

PVOID ExAllocatePool(
_In_POOL_TYPE PoolType,
_In_SIZE_T NumberOfBytes
);

參數

  • PoolType[in] 地址池類型[輸入參數]
    Specifies the type of pool memory to allocate. For a description of the available pool memory types, seePOOL_TYPE.
    指定要分配的記憶體池類型。關於可使用的記憶體類型,參看pool_type
    You can modifyPoolTypeby using a bitwise OR with the POOL_COLD_ALLOCATION flag as a hint to the kernel to allocate the memory from pages that are likely to be paged out quickly. To reduce the amount of resident pool memory as much as possible, you should not reference these allocations frequently. The POOL_COLD_ALLOCATION flag is only advisory and is available for Windows XP and later versions of the Windows operating system.
  • NumberOfBytes[in] 位元組數[輸入參數]
    Specifies the number of bytes to allocate.

返回值

ExAllocatePoolreturnsNULLif there is insufficient memory in the free pool to satisfy the request. Otherwise the routine returns a pointer to the allocated memory.
This routine is used for the general pool allocation of memory.
IfNumberOfBytesis PAGE_SIZE or greater, a page-aligned buffer is allocated. Memory allocations of PAGE_SIZE or less do not cross page boundaries. Memory allocations of less than PAGE_SIZE are not necessarily page-aligned but are aligned to 8-byte boundaries in 32-bit systems and to 16-byte boundaries in 64-bit systems.
A successful allocation requestingNumberOfBytes< PAGE_SIZE of nonpaged pool gives the caller exactly the number of requested bytes of memory. If an allocation request forNumberOfBytes> PAGE_SIZE succeeds andNumberOfBytesis not an exact multiple of PAGE_SIZE, the last page in the allocation contains bytes that are not part of the caller's allocation. If possible, the pool allocator uses these bytes. To avoid corrupting data that belongs to other kernel-mode components, drivers must access only storage addresses that they have explicitly allocated.
IfExAllocatePoolreturnsNULL, the caller should return the NTSTATUS value STATUS_INSUFFICIENT_RESOURCES or should delay processing to another point in time.
Callers ofExAllocatePoolmust be executing at IRQL <= DISPATCH_LEVEL. A caller executing at DISPATCH_LEVEL must specify aNonPagedXxxvalue forPoolType. A caller executing at IRQL <= APC_LEVEL can specify anyPOOL_TYPEvalue, but the IRQL and environment must also be considered for determining the page type.
NoteDo not setNumberOfBytes= 0. Avoid zero-length allocations because they waste pool header space and, in many cases, indicate a potential validation issue in the calling code. For this reason,Driver Verifierflags such allocations as possible errors.
The system automatically sets certain standard event objects when the amount of pool (paged or nonpaged) is high or low. Drivers can wait for these events to tune their pool usage. For more information, seeStandard Event Objects.
NoteMemory thatExAllocatePoolallocates is uninitialized. A kernel-mode driver must first zero this memory if it is going to make it visible to user-mode software (to avoid leaking potentially privileged contents).
Target platform
Version
Obsolete. This routine is exported only for existing binaries. UseExAllocatePoolWithTaginstead.
Header
Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)
Library
Ntoskrnl.lib
IRQL
<= DISPATCH_LEVEL (see Remarks section)
DDI compliance rules
HwStorPortProhibitedDDIs,SpNoWait,StorPortStartIo

相關詞條

熱門詞條

聯絡我們