Transferring Waveform Input Data

For waveform input operations, clients call the user-mode driver’s widMessage function. The user-mode driver should expect the client to first send a WIDM_OPEN message to open a driver instance. Next, the client allocates memory for one or more data buffers and sends WIDM_PREPARE messages to prepare the buffers for use. The client then sends a WIDM_ADDBUFFER message for each buffer, which passes the address of the empty buffer to the user-mode driver. The user-mode driver keeps a list of available empty buffers.

To start the read operation, the client sends WIDM_START. The user-mode driver then uses a separate thread to begin requesting data from the kernel-mode driver, typically by calling ReadFile or ReadFileEx, and filling the empty buffers. Each time a buffer has been filled, the user-mode driver notifies the client by sending it a WIM_DATA callback message. The client copies the data from the buffer and re-adds the buffer to the user-mode driver’s buffer list by sending another WIDM_ADDBUFFER message.

When the client has finished the input operation, it sends WIDM_STOP. It can also send WIDM_RESET, which indicates to the user-mode driver that it should not fill any remaining data buffers. The client can then send a WIDM_UNPREPARE message for each buffer and deallocate the buffers. Finally, the driver should expect the client to close the instance by sending WIDM_CLOSE.