![]() |
| Home |
|
|
Function RTGetProcessPhysMemHeapApplications which need to dynamically allocate memory guaranteed to have virtual addresses equal to physical addresses can use the Win32 heap API (HeapAlloc, HeapFree, etc) with a special heap handle returned by function: HANDLE RTGetProcessPhysMemHeap(void); This Physical Memory Heap is subject to more fragmentation than the standard heap accessible through GetProcessHeap(). RTGetProcessPhysMemHeap() will return NULL (no Physical Memory Heap available) if paging is enabled, but the fixed memory manager (RT_MM_FIXED) is being used. Example:
#include <windows.h>
#include <rttarget.h>
void * PhysMalloc(UINT Bytes)
{
return HeapAlloc(RTGetProcessPhysMemHeap(), 0, Bytes);
}
void PhysFree(void * B)
{
HeapFree(RTGetProcessPhysMemHeap(), 0, B);
}
|