|
Writing Windows WDM Device DriversLonger delays usually mean writing code in a very different way. For example, you could use custom timers, as described in the next chapter. Alternatively, a system thread could use the KeDelayExecutionThread function for longer delays. Listing 16.1 WriteByte and ReadByte void WriteByte(IN PWDMIO_DEVICE_EXTENSION dx, IN ULONG offset, IN UCHAR byte) { if (offset>=dx->PortLength) return; PUCHAR Port = dx->PortBase+offset; if (dx->PortInIOSpace) WRITE_PORT_UCHAR(Port, byte); else WRITE_REGISTER_UCHAR(Port, byte); } UCHAR ReadByte(IN PWDMIO_DEVICE_EXTENSION dx, IN ULONG offset) { if (offset>=dx->PortLength) return 0; PUCHAR Port = dx->PortBase+offset; UCHAR b; if (dx->PortInIOSpace) b = READ_PORT_UCHAR(Port); else b = READ_REGISTER_UCHAR(Port); return b; } Finally, note that the WdmIo driver read and write dispatch routines and the IOCTLs all use Buffered I/O. IRP Queuing Device Queues The DebugPrint in Chapter 14 used doubly-linked lists as a means of storing blocks of memory for later processing ...» |
Код для вставки книги в блог HTML
phpBB
текст
|
|