[vbox-dev] [PATCH] VBoxUsbMon: Hook proper driver object
Yuri Benditovich
yuri.benditovich at daynix.com
Thu Jul 13 12:46:24 UTC 2017
On Thu, Jul 13, 2017 at 3:08 PM, Sameeh Jubran <sameeh at daynix.com> wrote:
>
> ---------- Forwarded message ----------
> From: Sameeh Jubran <sameeh at daynix.com>
> Date: Thu, Jul 13, 2017 at 3:05 PM
> Subject: Re: [vbox-dev] [PATCH] VBoxUsbMon: Hook proper driver object
> To: Michal Necasek <michal.necasek at oracle.com>
> Cc: vbox-dev <vbox-dev at virtualbox.org>
>
>
>
>
> On Thu, Jul 13, 2017 at 2:59 PM, Michal Necasek <michal.necasek at oracle.com
> > wrote:
>
>>
>> Hi Sameeh/Yuri,
>>
>> Thanks for the patch. For us to actually accept it, the patch needs to
>> be either explicitly licensed under MIT or submitted by someone with a
>> signed OCA (Oracle Contributors Agreement).
>>
> No problem, how should we explicitly license it under MIT?
>
I confirm this patch is contributed under MIT licence (
https://opensource.org/licenses/mit-license.php)
Thanks,
Yuri Benditovich @Daynix
>
>> Do you happen to know if the patch also solves interoperability problems
>> with USBPcap?
>>
> Probably but we haven't tested that.
>
>>
>>
>> Regards,
>> Michal
>>
>>
>> On 7/12/2017 10:39 AM, Sameeh Jubran wrote:
>>
>>> From: Yuri Benditovich <yuri.benditovich at daynix.com>
>>>
>>> VBoxUsbMon hooks PnP call in driver object of top level devices
>>> in stack of every hub. There is assumption that such a way it
>>> will receive PnP messages for PDOs of USB devices created by
>>> these hubs. This assumption is not always correct: if there is
>>> upper filter installed in stack of hub devices but not in stack
>>> of USB devices, the VBoxUsbMon does not receive devices' PnP
>>> messages and USB redirection does not work.
>>> ---
>>> src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp | 4 ++++
>>> src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp | 10 ++++++++++
>>> src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.h | 2 ++
>>> 3 files changed, 16 insertions(+)
>>>
>>> diff --git a/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
>>> b/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
>>> index bd1eeaa..63cf973 100644
>>> --- a/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
>>> +++ b/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
>>> @@ -725,6 +725,7 @@ static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE
>>> pDevice, PVBOXUSBF
>>> LOG(("Matching: Need replug"));
>>> /* the device needs to be filtered, but the owner
>>> changes, replug needed */
>>> bNeedReplug = true;
>>> + EnsureDeviceIsFiltered(pDevice->Pdo);
>>> }
>>> }
>>> else
>>> @@ -740,6 +741,7 @@ static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE
>>> pDevice, PVBOXUSBF
>>> {
>>> bNeedReplug = true;
>>> LOG(("Matching: Need replug"));
>>> + EnsureDeviceIsFiltered(pDevice->Pdo);
>>> }
>>> }
>>> }
>>> @@ -852,6 +854,7 @@ static DECLCALLBACK(BOOLEAN)
>>> vboxUsbFltFilterCheckWalker(PFILE_OBJECT pFile, PDE
>>> if (fFilter)
>>> {
>>> LOG(("Matching: This device SHOULD be filtered"));
>>> + EnsureDeviceIsFiltered(Device.Pdo);
>>> /* this device needs to be filtered, but it's not,
>>> * leave the PDO in array to issue a replug
>>> request for it
>>> * later on */
>>> @@ -1295,6 +1298,7 @@ NTSTATUS VBoxUsbFltPdoAdd(PDEVICE_OBJECT pPdo,
>>> BOOLEAN *pbFiltered)
>>> ASSERT_WARN(pCtx, ("zero ctx"));
>>> ASSERT_WARN(uId, ("zero uId"));
>>> pDevice->enmState = VBOXUSBFLT_DEVSTATE_CAPTURING;
>>> + EnsureDeviceIsFiltered(pPdo);
>>> }
>>> else
>>> {
>>> diff --git a/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
>>> b/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
>>> index dba6c1d..307abe5 100644
>>> --- a/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
>>> +++ b/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
>>> @@ -1259,6 +1259,16 @@ static DECLCALLBACK(BOOLEAN)
>>> vboxUsbMonHookDrvObjWalker(PFILE_OBJECT pFile, PDEV
>>> return FALSE;
>>> }
>>> +
>>> +/**
>>> +* Ensure PnP hooks will be installed in the driver that
>>> + serves USB device PDO
>>> +*/
>>> +void EnsureDeviceIsFiltered(PDEVICE_OBJECT Pdo)
>>> +{
>>> + vboxUsbMonHookDrvObjWalker(NULL, NULL, Pdo, NULL);
>>> +}
>>> +
>>> /**
>>> * Finds all USB drivers in the system and installs hooks if haven't
>>> done already.
>>> */
>>> diff --git a/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.h
>>> b/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.h
>>> index b218bde..c64d789 100644
>>> --- a/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.h
>>> +++ b/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.h
>>> @@ -58,4 +58,6 @@ typedef FNVBOXUSBMONDEVWALKER *PFNVBOXUSBMONDEVWALKER;
>>> VOID vboxUsbMonHubDevWalk(PFNVBOXUSBMONDEVWALKER pfnWalker, PVOID
>>> pvWalker, ULONG fFlags);
>>> +void EnsureDeviceIsFiltered(PDEVICE_OBJECT Pdo);
>>> +
>>> #endif /* #ifndef ___VBoxUsbMon_h___ */
>>>
>>>
>> _______________________________________________
>> vbox-dev mailing list
>> vbox-dev at virtualbox.org
>> https://www.virtualbox.org/mailman/listinfo/vbox-dev
>>
>
>
>
> --
> Respectfully,
> *Sameeh Jubran*
> *Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>*
> *Software Engineer @ Daynix <http://www.daynix.com>.*
>
>
>
> --
> Respectfully,
> *Sameeh Jubran*
> *Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>*
> *Software Engineer @ Daynix <http://www.daynix.com>.*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20170713/8695b801/attachment.html>
More information about the vbox-dev
mailing list