uLib
User mode C/C++ extended API library for Win32 programmers.
|
Allocation of physical memory.
[PRELIMINARY]
These functions use Address Windowing Extension to allocate physical memory.
Memory allocated by PhysicalAlloc() must be physically present in the system.
After the memory is allocated, it is locked down and unavailable to the rest
of the virtual memory management system. The memory is always page aligned,
and it's size always a multiple of the system page size.
Note: Physical pages can reside at any physical address, and You
should make no assumptions about the contiguity of the physical pages.
See the MSDN documentation on AWE for further details.
Macros | |
#define | PHYSICAL_PTR(hmem) (*(PVOID*)hmem) |
Typedefs | |
typedef HANDLE | HPHYSICAL |
Functions | |
HPHYSICAL | PhysicalAlloc (UINT64 nBytes) |
HPHYSICAL | PhysicalFree (HPHYSICAL hMem) |
PVOID | PhysicalPtr (HPHYSICAL hMem) |
UINT64 | PhysicalSize (HPHYSICAL hMem) |
ULONG_PTR | PhysicalPageCount (HPHYSICAL hMem) |
#define PHYSICAL_PTR | ( | hmem | ) | (*(PVOID*)hmem) |
typedef HANDLE HPHYSICAL |
[PRELIMINARY]
PhysicalAlloc() allocates a physical memory block, using AWE.
nBytes | Nr of bytes to allocate. This will be rounded up to the next page boundary. |
The function returna a handle to the allocation, or NULL on failure.
Use PhysicalPtr() or PHYSICAL_PTR() to get the access pointer.
Use GetLastError() to find the reason for a failure.
Note: The function may succeed but only allocate a part of Your request.
In such a case GetLastError() returns ERROR_NOT_ENOUGH_MEMORY.
Use PhysicalSize() to check how much You actually got.
Definition at line 344 of file MemFunc.cpp.
[PRELIMINARY]
PhysicalFree() frees a physical memory allocation, and return NULL on success.
hMem | A memory handle returned from PhysicalAlloc(). |
Definition at line 428 of file MemFunc.cpp.
PVOID PhysicalPtr | ( | HPHYSICAL | hMem | ) |
PhysicalPtr() returns the R/W access pointer of Your allocation.
hMem | A memory handle returned from PhysicalAlloc(). |
Definition at line 330 of file MemFunc.cpp.
PhysicalSize() returns the size, in bytes, of Your allocation.
hMem | A memory handle returned from PhysicalAlloc(). |
Definition at line 334 of file MemFunc.cpp.
ULONG_PTR PhysicalPageCount | ( | HPHYSICAL | hMem | ) |
PhysicalPageCount() returns the nr of pages in Your allocation.
hMem | A memory handle returned from PhysicalAlloc(). |
Definition at line 338 of file MemFunc.cpp.