V86MMGR_Allocate_Buffer

include v86mmgr.inc

mov     ebp, OFFSET32 ClientRegisters
mov     ebx, VMHandle
mov     ecx, NumBytes
stc                      ; set carry flag to copy, clear otherwise
lfs     esi, FarPtrMem   ; extended memory to copy if carry set
VxDcall V86MMGR_Allocate_Buffer
jc      error_handler
mov     [BytesCopied], ecx
mov     [FarPtrBuffer], edi
 

Allocates a portion of the current virtual machine's translation buffer, and optionally copies data into the buffer. Uses ECX, EDI, Flags.

ECX Actual number of bytes allocated in the translation buffer. Because this may be less than than the NumBytes parameter, you should preserve this value to pass to the V86MMGR_Free_Buffer service. For more information, see below.
EDI Virtual 8086-mode address of the allocated portion of the translation buffer. The segment address is in the high-order word, the offset address in the low-order word.

ClientRegisters
Address of a Client_Reg_Struc structure containing the register values of the current VM.
VMHandle
Handle of the current VM. The VM must be in protected mode.
NumBytes
Number of bytes to copy if the carry flag is set, or the size of the buffer to allocate otherwise.
FarPtrMem
Selector and offset address (in FS and ESI) of the extended memory to copy, if the carry flag is set. This parameter is ignored if the carry flag is clear.

If the carry flag is set on entry, the service may return successfully (with the carry flag clear) yet allocate fewer bytes than are specified by NumBytes parameter. This is because the service ensures that number of bytes to copy plus the offset in ESI does not extend beyond the segment limit for the selector in FS.

The buffers are maintained as a stack. Therefore, the last buffer allocated must be the first buffer freed. To free a buffer allocated by this service, use the V86MMGR_Free_Buffer service.