Xlat_API_Calc_Len Segment, Offset, Calc_Proc_Addr
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.
Segment
Register containing the selector for the protected-mode address.
Offset
Register containing the offset for the protected-mode address.
Calc_Proc_Addr
Name of the callback procedure that calculates the length, in bytes, of the data to copy. The V86MMGR_Xlat_API service calls the callback procedure with the FS:ESI register pair pointing to the buffer. The callback procedure must return the number of bytes to copy in the ECX register, and must preserve all other registers.
The V86MMGR_Xlat_API service fails if there is not enough room in the translation buffer to copy the specified number of bytes.
For 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