uLib  User mode C/C++ extended API library for Win32 programmers.
Physical Memory (AWE)

Module Description

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)
 

Macro Definition Documentation

◆ PHYSICAL_PTR

#define PHYSICAL_PTR (   hmem)    (*(PVOID*)hmem)

Get the memory pointer.

Definition at line 157 of file MemFunc.h.

Typedef Documentation

◆ HPHYSICAL

typedef HANDLE HPHYSICAL

Handle of a physical memory allocation.

Definition at line 156 of file MemFunc.h.

Function Documentation

◆ PhysicalAlloc()

HPHYSICAL PhysicalAlloc ( UINT64  nBytes)

[PRELIMINARY]
PhysicalAlloc() allocates a physical memory block, using AWE.

Parameters
nBytesNr 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.

◆ PhysicalFree()

HPHYSICAL PhysicalFree ( HPHYSICAL  hMem)

[PRELIMINARY]
PhysicalFree() frees a physical memory allocation, and return NULL on success.

Parameters
hMemA memory handle returned from PhysicalAlloc().

Definition at line 428 of file MemFunc.cpp.

◆ PhysicalPtr()

PVOID PhysicalPtr ( HPHYSICAL  hMem)

PhysicalPtr() returns the R/W access pointer of Your allocation.

Parameters
hMemA memory handle returned from PhysicalAlloc().

Definition at line 330 of file MemFunc.cpp.

◆ PhysicalSize()

UINT64 PhysicalSize ( HPHYSICAL  hMem)

PhysicalSize() returns the size, in bytes, of Your allocation.

Parameters
hMemA memory handle returned from PhysicalAlloc().

Definition at line 334 of file MemFunc.cpp.

◆ PhysicalPageCount()

ULONG_PTR PhysicalPageCount ( HPHYSICAL  hMem)

PhysicalPageCount() returns the nr of pages in Your allocation.

Parameters
hMemA memory handle returned from PhysicalAlloc().

Definition at line 338 of file MemFunc.cpp.