include vmm.inc
VxD_IO Port, IOCallback
Adds an I/O callback procedure and I/O port number to an I/O table. Virtual devices use the macro in conjunction with the Begin_VxD_IO_Table and End_VxD_IO_Table macros to create a table of I/O callback procedures for the Install_Mult_IO_Handlers service.
The I/O table can contain any number of VxD_IO macros. Each macro must specify an unique I/O port number, but the same I/O callback procedure can be assigned to more than one port. In such case, the I/O callback procedure can use the EDX register to determine which port was accessed by the virtual machine.
After a virtual device installs the callback procedures, the system calls a procedure whenever a program in the virtual machine attempts to access the corresponding port. The system calls the procedure as follows:
mov ebx, VM ; current VM handle
mov ecx, IOType ; type of I/O
mov edx, Port ; port number
mov ebp, OFFSET32 crs ; points to a Client_Reg_Struc
mov eax, Data ; output data (if I/O type is output)
call [IOCallback]
mov [Data], eax ; input data (if I/O type is input)
The VM parameter specifies the current virtual machine, Port specifies the I/O port, and crs points to a Client_Reg_Struc structure containing the register contents for the current virtual machine.
The IOType parameter specifies the type of input or output operation requested, and determines whether the callback procedure receives data in the EAX register or must return data in the EAX register. The IOType parameter can be a combination of the following values:
Value | Meaning |
---|---|
Addr_32_IO | Use 32-bit address offsets for input or output string operations. If this value is not given, the 16-bit offsets are used. |
Byte_Input | Input a single byte; place in AL if String_IO not given. |
Byte_Output | Output a single byte from AL if String_IO not given. |
Dword_Input | Input a double word; place in EAX if String_IO not given. |
Dword_Output | Output a double word from EAX if String_IO not given. |
Rep_IO | Repeat the input or output string operation the number of times specified by the Client_CX field in the Client_Reg_Struc structure. (Client_ECX if Addr_32_IO is set.) |
Reverse_IO | Decrement string address on each input or output operation. If this value is not given, the string address is incremented on each operation. |
String_IO | Input or output a string. The high 16-bits specifies segment address of buffer containing the string to output or to receive the string input. |
Word_Input | Input a word; place in AX if String_IO not given. |
Word_Output | Output a word from AX if String_IO not given. |
In memory, an I/O table consists of a VxD_IOT_Hdr structure followed by one or more VxD_IO_Struc structures. The first word in the table specified the number of entries. Each entry consists of a word specifying the port number and a double word specifying the 32-bit offset of the callback procedure.
The Data parameter is used only when I/O type is for output.
Begin_VxD_IO_Table, End_VxD_IO_Table, Install_Mult_IO_Handlers