Pool Allocation and Free Routines

RDBSS provides a number of routines to use for pool allocation. Normally, these routines are called using macros, not by calling these routines directly. The macros automatically handle the differences between retail and checked builds.

On a checked build, these routines were designed to add wrappers around the normal kernel allocation and free routines. These wrappers for pool allocation and free routines provide additional debugging information and call a set of routines that perform various kinds of checking and guarding before calling the kernel pool allocation and free routines. However, these features are not currently implemented in these allocation and free routines, but might be added in future releases.

On a free build, these routines become direct calls to the kernel allocation and free routines, ExAllocatePoolWithTag and ExFreePool.

The following table lists the RDBSS pool allocation and free routines.

Routine Description

_RxAllocatePoolWithTag

This routine allocates memory from a pool with a four-byte tag at the beginning of the block that can help catch memory problems.

It is recommended that the RxAllocatePoolWithTag macro be called instead of using this routine directly.

_RxCheckMemoryBlock

This routine checks a memory block for a special RX_POOL_HEADER header signature. Note that a network mini-redirector driver would need to add this special signature block to memory allocated in order to use the routine.

This routine should not be used since this special header block has not been implemented.

_RxFreePool

This routine frees a memory pool.

It is recommended that the RxFreePool macro be called instead of using this routine directly.

A number of macros, which are defined in the ntrxdef.h header file, call these routines. Instead of calling the routines listed in the previous table directly, the following macros are normally used.

Macro Description

RxAllocatePoolWithTag (type, size, tag)

On checked builds, this macro allocates memory from a pool with a four-byte tag at the beginning of the block that can help catch instances of memory trashing.

On retail builds, this macro becomes a direct call to ExAllocatePoolWithTag.

RxCheckMemoryBlock (ptr)

On checked builds, this macro checks a memory block for a special RX_POOL_HEADER header signature.

On retail builds, this macro does nothing.

RxFreePool (ptr)

On checked builds, this macro frees a memory pool.

On retail builds, this macro becomes a direct call to ExFreePool.