Conversation
Refactor CUsbDkFilterStrategy::OnClose() in a way that the process id can be passed from the beginning of the call-chain. This is just a technical change needed for the next commit.
Add reference counting, since the previously used 'PID-based' method might not work reliably: for example, if the program doing redirection is forcefully closed from the task manager, the USB redirection could remain stuck. After this commit, we are always stopping redirection if the reference count drops to zero.
|
@kvojacheck What happens in following flow: app1 redirects the device and uses it, app2 opens the device and closes it? |
|
Probably the proper thing is to use file context (WDFFILECONTEXT) instead of process identifier |
At the time app2 closes the device, the refcount is still 1 (since app1 is still using the device), therefore we would go to the PID-based identification as before: as the returned PID value by |
Thank you for the tip, I will definitely look into this! |
Proposed reference counting workaround to issue #105
Please kindly review, since I'm quite new to Windows driver developement.