Closed gwgill closed 9 months ago
A partial work-around is to intercept process termination with (say) a sighandler, keep track of outstanding transactions and their OVERLAPPED objects, and on termination issue UsbDk_AbortPipe() to all end points and then GetOverlappedResult() on all the outstanding OVERLAPPED objects. This doesn't solve the problem if the process is killed in a way that doesn't invoke the sighandler though.
It seems that kvojacheck's fix for #105 is a 90% fix for this problem. It seems to prevent the need for a system re-boot, but does sometimes require a device re-plug to recover, which is not ideal.
If a USB device is opened and a transfer started, but the device is then closed before calling GetOverlappedResult() on the OVERLAPPED object, it is not possible to re-open the device. This can happen as a result of the process being terminated. Re-plugging the device doesn't fix it. Attempts to stop and re-start the UsbDk driver fail. The only way to fix it is to re-boot the machine. (Windows 10 22H2, UsbDk 1.00-22)