Xlat_API_Calc_Len

Xlat_API_Calc_Len Segment, Offset, Calc_Proc_Addr


The Xlat_API_Calc_Len macro copies a calculated number of bytes from the protected-mode address to the translation copy buffer, and converts the address into a V86-mode address.

Parameters

Segment

Specifies the register containing the selector for the protected-mode address.

Offset

Specifies the register containing the offset for the protected-mode address.

Calc_Proc_Addr

Specifies the name of the callback procedure that calculates the length in bytes of the data to copy. For more information about the callback procedure, see the following “Comments” section.

Return Value

This macro has no return value.

Comments

The V86MMGR_Xlat_API service calls the callback procedure with the FS:ESI register pair pointing to the buffer. The procedure must return with the ECX register set to the number of bytes to copy. The procedure must preserve all registers except ECX.

This service fails if there is not enough room in the translation buffer to copy the data.

Example

Buffered Keyboard Input (Interrupt 21h Function 0Ah) can have a buffer size from 3 to 257 bytes; the size depends on the value of the first byte in the buffer. The following script and callback procedure translates this function:

VxD_DATA_SEG

Buff_Keyboard_Input_API:

Xlat_API_Calc_Len ds, dx, Calc_Input_Buff_Size

Xlat_API_Exec_Int 21h

VxD_DATA_ENDS

VxD_CODE_SEG

BeginProc Calc_Input_Buff_Size

movzx ecx, BYTE PTR fs:[esi]

add ecx, 2

ret

EndProc Calc_Input_Buff_Size

VxD_CODE_ENDS

See Also

V86MMGR_Xlat_API, Xlat_API_Exec_Int