uLib
User mode C/C++ extended API library for Win32 programmers.
|
Page aligned virtual memory.
These functions use the VirtualAlloc() family to provide aligned memory.
The memory pages are locked into physical memory, which is essential for
e.g. streaming audio buffers to avoid nasty glitches due to page faults.
A caveat (afaik) is that this memory has to be accessed once
before it is charged to your quota and actually become read/writable.
Functions | |
PVOID | AllocMemoryPages (WORD nPages, DWORD Access=PAGE_READWRITE) |
PVOID | FreeMemoryPages (PVOID pBlk) |
DWORD | GetMemoryPageSize () |
UINT | GetPageRegionSize (PVOID pBlk) |
PVOID | GetPageBaseAddress (PVOID pBlk) |
PVOID | GetPageAllocationBase (PVOID pBlk) |
AllocMemoryPages allocates a specified number of aligned memory pages.
The pages are committed and locked into physical memory on success.
Returns the allocation base address, or NULL on failure.
See also GetMemoryPageSize(), VirtualAlloc().
Definition at line 177 of file MemFunc.cpp.
PVOID FreeMemoryPages | ( | PVOID | pBlk | ) |
FreeMemoryPages unlocks and frees pages allocated by AllocMemoryPages().
Returns NULL on success, else pBlk.
Definition at line 193 of file MemFunc.cpp.
DWORD GetMemoryPageSize | ( | ) |
GetMemoryPageSize returns the size of a memory page on this system.
The result is correct for x86, x64, and WoW64 as well.
See also GetWinSystemInfo().
Definition at line 215 of file MemFunc.cpp.
UINT GetPageRegionSize | ( | PVOID | pBlk | ) |
GetPageRegionSize returns the size of pBlk, in bytes.
Note: pBlk must be the page allocation base address.
See also AllocMemoryPages(), GetPageAllocationBase(), VirtualQuery().
Definition at line 222 of file MemFunc.cpp.
PVOID GetPageBaseAddress | ( | PVOID | pBlk | ) |
GetPageBaseAddress returns the page address to which pBlk belongs.
Note: pBlk can be practically any address, not just ones you allocated.
See also GetPageRegionSize(), GetPageAllocationBase().
Definition at line 234 of file MemFunc.cpp.
PVOID GetPageAllocationBase | ( | PVOID | pBlk | ) |
GetPageAllocationBase returns the allocation base address to which pBlk belongs.
Note: pBlk can be practically any address, not just ones you allocated.
See also GetPageRegionSize(), GetPageBaseAddress().
Definition at line 242 of file MemFunc.cpp.