|
Writing Windows WDM Device DriversRemember that the first four bytes of the output buffer are always used for the error code and location. Listing 15.2 shows how the ReadStatus commands are issued. It simply reads a byte value from the Status port. After DeviceIoControl has returned, the fifth byte of the output buffer contains the Status register contents. WdmIoTest checks that the BUSY# and ONLINE signals are 1 before continuing. Listing 15.2 Reading data BYTE ReadStatus[] = { PHDIO_READ, PARPORT_STATUS, // Read status }; int main(int argc, char* argv[]) { //… DWORD BytesReturned; WORD rv[3]; if (DeviceIoControl(hWdmIo, IOCTL_PHDIO_RUN_CMDS, ReadStatus, length(ReadStatus), // Input rv, sizeof(rv), // Output &BytesReturned, NULL)) { PBYTE pbrv = (PBYTE)&rv[2]; printf(" ReadStatus OK. rv=%d at %d status=%02X\n", rv[0], rv[l], *pbrv); if ( (*pbrv&0x88)==0x88) { busy = false; break; } } Writing Data Using Interrupt Driven I/O The WriteFile Win32 call is used to pass output data to the WdmIo driver. However, it needs to know how to process the data and handle interrupts ...» |
Код для вставки книги в блог HTML
phpBB
текст
|
|