in src/framework/shared/core/fxmemorybufferfromlookaside.cpp [126:190]
FxMemoryBufferFromLookaside::operator new(
__in size_t Size,
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
__inout PVOID ValidMemory,
__in size_t BufferSize,
__in PWDF_OBJECT_ATTRIBUTES Attributes
)
/*++
Routine Description:
Displacement new operator overload. Since the lookaside list actually
allocates the memory block, we just return the block given to us.
Arguments:
Size - Compiler supplied parameter indicating the
sizeof(FxMemoryBufferFromLookaside)
FxDriverGlobals - Driver's globals.
ValidMemory - Previously allocated block
BufferSize - The buffer size associated with this object
Attributes - Description of context.
Return Value:
ValidMemory pointer value
--*/
{
size_t objectSize;
UNREFERENCED_PARAMETER(Size);
ASSERT(Size >= sizeof(FxMemoryBufferFromLookaside));
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
ASSERT(BufferSize < PAGE_SIZE);
if (BufferSize >= PAGE_SIZE) {
return NULL;
}
#endif
//
// We round up the object size (via COMPUTE_OBJECT_SIZE) because the object,
// and the buffer are all in one allocation and the returned memory needs to
// match the alignment that raw pool follows.
//
// Note that FxMemoryBufferFromLookaside is used for buffer less than a page
// size so downcasting to USHORT (via COMPUTE_OBJECT_SIZE) is safe because
// size of object plus buffer (<page size) would be smaller than 64K that
// could fit in USHORT. See comments in FxMemoryObject.hpp for info on
// various fx memory objects.
//
objectSize = COMPUTE_OBJECT_SIZE(sizeof(FxMemoryBufferFromLookaside),
(ULONG) BufferSize);
return FxObjectAndHandleHeaderInit(
FxDriverGlobals,
ValidMemory,
(USHORT) objectSize,
Attributes,
FxObjectTypeExternal
);
}