summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Benditovich <yuri.benditovich@daynix.com>2020-01-02 15:05:29 +0200
committerYan Vugenfirer <yan@daynix.com>2020-01-02 21:47:41 +0200
commit4de57a9ff6d3a52316889a7901610ffab56c49fb (patch)
tree791562f7f4906c9820721b157ab0f1f16df16881
parent14dd054ae3b332337a652c34ee57b681e710ccbd (diff)
driver: pass current process id in file close flow
https://github.com/daynix/UsbDk/issues/81 OnClose -> RemoveRedirect -> NotifyRedirectorRemovalStarted NotifyRedirectorRemovalStarted passes process id to ModifyOne in order to avoid stopping redirection if another not related process just opens the filter device and then closes it. Example (before this commit): Start VM and use remote-viewer to it. Separate application 'App' registers notification on USB device interface arrival. When new device comes, the application opens a file using symbolic link name and closes it. Redirect USB device to VM. The UsbDk forces device to be reenumerated. Open-close operation from the 'App' unexpectedly discards device redirection. After this commit: because the 'App' process is not an owner of the redirection, OnClose will not cause removal of the redirection. Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
-rw-r--r--UsbDk/ControlDevice.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/UsbDk/ControlDevice.cpp b/UsbDk/ControlDevice.cpp
index 74cd2c4..75b09e3 100644
--- a/UsbDk/ControlDevice.cpp
+++ b/UsbDk/ControlDevice.cpp
@@ -1081,7 +1081,8 @@ bool CUsbDkControlDevice::NotifyRedirectorAttached(CRegText *DeviceID, CRegText
bool CUsbDkControlDevice::NotifyRedirectorRemovalStarted(const USB_DK_DEVICE_ID &ID)
{
- return m_Redirections.ModifyOne(&ID, [](CUsbDkRedirection *R){ R->NotifyRedirectionRemovalStarted(); });
+ ULONG pid = (ULONG)(ULONG_PTR)PsGetCurrentProcessId();
+ return m_Redirections.ModifyOne(&ID, [](CUsbDkRedirection *R){ R->NotifyRedirectionRemovalStarted(); }, pid);
}
bool CUsbDkControlDevice::WaitForDetachment(const USB_DK_DEVICE_ID &ID)