_HeapAllocate

include vmm.inc

VMMcall _HeapAllocate, <nbytes, flags>

or eax, eax ; zero if error

jz not_allocated

mov [Address], eax ; address of memory block


The _HeapAllocate service allocates a block of memory from the heap.

Parameters

nbytes

Specifies the size in bytes of the block to allocate. This parameter must not be zero.

flags

Specifies the allocation flags. It can be the following value:

Value Meaning

HeapZeroInit Fills the memory block with zeros. If this value is not given, the initial content of the memory block is undefined.

All other values are reserved.

Return Value

The EAX register contains the ring-0 address of the block if the service is successful. Otherwise, EAX contains zero to indicate an error such as insufficient memory to satisfy the request.

Comments

This service aligns allocated block on doubleword boundaries, however, the block size does not have to be a multiple of 4.

Since the system offers no protection on the heap, virtual devices must provide their own protection to prevent overrunning allocated blocks.

The system offers no compaction on the heap; all memory blocks on the heap are fixed. Virtual devices must not to use the heap in such a way as to severely fragment it.

Uses

EAX

See Also

_HeapFree, _HeapReAllocate