INtime SDK Help
AllocateRtMemoryEx
INtime SDK v6 > About INtime > INtime Kernel > Memory management > AllocateRtMemoryEx

Allocates memory from the current process' memory pool to the current thread's virtual address space.

PVOID AllocateRtMemoryEx(
    DWORD cbSize          // number of bytes to allocate
    QWORD qwLowFilter,    // low physical address limit 
    QWORD qwHighFilter,   // high physical address limit
    DWORD cbAlignment     // physical alignment
);

Parameters

cbSize
Number of bytes to allocate to the virtual segment.
qwLowFilter
The physical address above which the memory should be allocated.
qwHighFilter
The physical address below which the memory should be allocated.
cbAlignment
The requested alignment of the returned memory.

Remarks

Each process is created with its own virtual address space. All threads within this process share their virtual address space. This call allocates page-aligned pages of physical memory into this virtual address space for use by the calling thread. The call automatically rounds up cbSize (in bytes) to a multiple of 4K. The allocated pages are contiguous; they start and end on 4K boundaries.

The filter parameters cause the memory manager to seek available memory in the range of physical addresses defined by qwLowFIlter and qwHighFilter. For example, to request physical memory from below 4 GBytes you would specify 0 and 0x100000000 for qwLowFIlter and qwHighFilter respectively. If insufficient memory is available between the bounds specified then the call with fail with status E_MEM. To allocate memory from above 4 GBytes you would specify 0x100000000 and 0xffffffffffffff for qwLowFIlter and qwHighFilter respectively.

Note: the filter values are used to filter a memory area, not to generate a buffer in that range. If an entire memory area does not lie within the filter parameters then the call will fail with an E_MEM status.

the cbAlignment parameter allows you to specify a physical alignment for the allocation. The alignment must be specified as a multiple of one page (4 Kbytes). A value of zero specifies the default alignment of one page.

The virtual address space manager finds an available space within the virtual address space of the process and returns a near pointer to the allocated physical memory. The call fails if cbSize bytes of contiguous physical memory are not available, or if there is not enough virtual address space available in the virtual segment. The memory required for page tables is charged to the memory pool of the calling thread's process.

Return Values

A pointer to the address to where the memory has been allocated in the thread's virtual address space.
Success.
NULL
Failure. To determine the status, call GetLastRtError.

Status

E_OK 0x0000
No exceptional conditions occurred.
E_MEM 0x0002
This request requires more available physical memory than currently exists.
E_VMEM 0x00F0
Satisfying this request requires more virtual memory than is available to the process.
E_PARAM 0x8004
One of the following conditions is true:
cbSize contains a value larger than the virtual segment size, or 0 (zero).
The value of qwLowFilter is greater than the value of qwHighFilter.
The value of cbAlignement is not a multiple of 4096.

Requirements

Versions Defined in Include Link to
INtime 6.2 intime/rt/include/rtbase.h rt.h rt.lib
   
See Also