mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2026-09-22 22:28:03 +03:00
patch/piuio-exit: Bugfix when using with more usb devices than just piuio
If you also have the piubtn connected, it will be opened as well, hitting the open section in the module. It did forward everything correctly, but the warning didn't make any sense because the same device was not opened again. Re-work the code to create a meaningful flow. Also return the open handle if it ever happens that the device gets re-opened without being closed.
This commit is contained in:
@@ -26,20 +26,22 @@ static enum cnh_result patch_piuio_exit_usbhook(struct cnh_usbhook_irp *irp)
|
||||
switch (irp->op) {
|
||||
case CNH_USBHOOK_IRP_OP_OPEN:
|
||||
{
|
||||
if (_patch_piuio_exit_usb_handle) {
|
||||
log_warn("Already detected PIUIO previously, ignore re-detection?");
|
||||
result = cnh_usbhook_invoke_next(irp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (irp->open_usb_dev->descriptor.idVendor == PIUIO_DRV_VID &&
|
||||
irp->open_usb_dev->descriptor.idProduct == PIUIO_DRV_PID) {
|
||||
log_info("Detected PIUIO");
|
||||
|
||||
result = cnh_usbhook_invoke_next(irp);
|
||||
if (_patch_piuio_exit_usb_handle) {
|
||||
log_warn("Already detected PIUIO previously, ignore re-detection?");
|
||||
|
||||
if (result == CNH_RESULT_SUCCESS) {
|
||||
_patch_piuio_exit_usb_handle = irp->handle;
|
||||
irp->handle = _patch_piuio_exit_usb_handle;
|
||||
result = CNH_RESULT_SUCCESS;
|
||||
} else {
|
||||
log_info("Detected PIUIO");
|
||||
|
||||
result = cnh_usbhook_invoke_next(irp);
|
||||
|
||||
if (result == CNH_RESULT_SUCCESS) {
|
||||
_patch_piuio_exit_usb_handle = irp->handle;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = cnh_usbhook_invoke_next(irp);
|
||||
|
||||
Reference in New Issue
Block a user