Executes a single read/write instruction to an I/O port or to a memory address.
DWORD WD_Transfer(
HANDLE hWD,
WD_TRANSFER *pTrans);
| Name | Type | Input/Output |
|---|---|---|
| hWD | HANDLE | Input |
| pTrans | WD_TRANSFER* | |
| • cmdTrans | DWORD | Input |
| • dwPort | KPTR | Input |
| • dwBytes | DWORD | Input |
| • fAutoinc | DWORD | Input |
| • dwOptions | DWORD | Input |
| • Data | union | |
| * Byte | BYTE | Input/Output |
| * Word | WORD | Input/Output |
| * Dword | UINT32 | Input/Output |
| * Qword | UINT64 | Input/Output |
| * pBuffer | PVOID | Input/Output |
| Name | Description |
|---|---|
| hWD | Handle to WinDriver's kernel-mode driver as
received from WD_Open() |
| pTrans | Pointer to a transfer information structure: |
| • cmdTrans |
A value indicating the type of transfer to perform — see definition
of the
In calls to |
| • dwPort |
The memory or I/O address to access.
For a memory transfer, use the kernel-mapping of the base address received
from
For an I/O transfer, use the base address received from
|
| • dwBytes | Used in string transfers — number of bytes to transfer |
| • fAutoinc |
Used for string transfers. If TRUE, I/O or memory address should be incremented for
transfer.If FALSE, all data is transferred to the same port/address.
|
| • dwOptions | Must be set to 0 |
| • Data | The transfer data — input for read transfers, output for write transfers: |
| * Byte | Used for 8-bit transfers |
| * Word | Used for 16-bit transfers |
| * Dword | Used for 32-bit transfers |
| * Qword | Used for 64-bit transfers |
| * pBuffer | Used for string (block) transfers |
Returns WD_STATUS_SUCCESS (0) on success, or an appropriate
error code otherwise
WD_Transfer() do
not require 64-bit operating system/CPU).
WD_Transfer(), it is important to align the base
address according to the size of the data type, especially when issuing
string transfer commands. Otherwise, the transfers are split into smaller
portions. The easiest way to align data is to use basic types when defining
a buffer, i.e.:
BYTE buf[len]; /* For BYTE transfers - not aligned */ WORD buf[len]; /* For WORD transfers - aligned on 2-byte boundary */ UINT32 buf[len]; /* For DWORD transfers - aligned on 4-byte boundary */ UINT64 buf[len]; /* For QWORD transfers - aligned on 8-byte boundary */
WD_TRANSFER Trans; BYTE read_data; BZERO(Trans); Trans.cmdTrans = RP_BYTE; /* Read Port BYTE */ Trans.dwPort = 0x210; WD_Transfer(hWD, &Trans); read_data = Trans.Data.Byte;