Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp	(revision 79311)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp	(revision 79334)
@@ -47,28 +47,4 @@
 #include <devguid.h>
 
-/*
- * Note: Must match the VID & PID in the USB driver .inf file!!
- */
-/*
-  BusQueryDeviceID USB\Vid_80EE&Pid_CAFE
-  BusQueryInstanceID 2
-  BusQueryHardwareIDs USB\Vid_80EE&Pid_CAFE&Rev_0100
-  BusQueryHardwareIDs USB\Vid_80EE&Pid_CAFE
-  BusQueryCompatibleIDs USB\Class_ff&SubClass_00&Prot_00
-  BusQueryCompatibleIDs USB\Class_ff&SubClass_00
-  BusQueryCompatibleIDs USB\Class_ff
-*/
-
-#define szBusQueryDeviceId                  L"USB\\Vid_80EE&Pid_CAFE"
-#define szBusQueryHardwareIDs               L"USB\\Vid_80EE&Pid_CAFE&Rev_0100\0USB\\Vid_80EE&Pid_CAFE\0\0"
-#define szBusQueryCompatibleIDs             L"USB\\Class_ff&SubClass_00&Prot_00\0USB\\Class_ff&SubClass_00\0USB\\Class_ff\0\0"
-
-#define szDeviceTextDescription             L"VirtualBox USB"
-
-/* Possible USB bus driver names. */
-static LPWSTR lpszStandardControllerName[1] =
-{
-    L"\\Driver\\usbhub",
-};
 
 /*
Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp	(revision 79311)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp	(revision 79334)
@@ -171,10 +171,4 @@
 }
 
-void vboxUsbDbgPrintUnicodeString(PUNICODE_STRING pUnicodeString)
-{
-    RT_NOREF1(pUnicodeString);
-    Log(("%.*ls", pUnicodeString->Length / 2, pUnicodeString->Buffer));
-}
-
 /**
  * Send IRP_MN_QUERY_DEVICE_RELATIONS
@@ -240,304 +234,4 @@
     LOG(("IoCallDriver returned %x", Status));
     return Status;
-}
-
-RT_C_DECLS_BEGIN
-/* these two come from IFS Kit, which is not included in 2K DDK we use,
- * although they are documented and exported in ntoskrnl,
- * and both should be present for >= XP according to MSDN */
-NTKERNELAPI
-NTSTATUS
-ObQueryNameString(
-    __in PVOID Object,
-    __out_bcount_opt(Length) POBJECT_NAME_INFORMATION ObjectNameInfo,
-    __in ULONG Length,
-    __out PULONG ReturnLength
-    );
-
-NTKERNELAPI
-PDEVICE_OBJECT
-IoGetLowerDeviceObject(
-    __in  PDEVICE_OBJECT  DeviceObject
-    );
-
-RT_C_DECLS_END
-
-typedef DECLCALLBACK(VOID) FNVBOXUSBDEVNAMEMATCHER(PDEVICE_OBJECT pDo, PUNICODE_STRING pName, PVOID pvMatcher);
-typedef FNVBOXUSBDEVNAMEMATCHER *PFNVBOXUSBDEVNAMEMATCHER;
-
-static NTSTATUS vboxUsbObjCheckName(PDEVICE_OBJECT pDo, PFNVBOXUSBDEVNAMEMATCHER pfnMatcher, PVOID pvMatcher)
-{
-    union
-    {
-        OBJECT_NAME_INFORMATION Info;
-        char buf[1024];
-    } buf;
-    ULONG cbLength = 0;
-
-    POBJECT_NAME_INFORMATION pInfo = &buf.Info;
-    NTSTATUS Status = ObQueryNameString(pDo, &buf.Info, sizeof (buf), &cbLength);
-    if (!NT_SUCCESS(Status))
-    {
-        if (STATUS_INFO_LENGTH_MISMATCH != Status)
-        {
-            WARN(("ObQueryNameString failed 0x%x", Status));
-            return Status;
-        }
-
-        LOG(("ObQueryNameString returned STATUS_INFO_LENGTH_MISMATCH, required size %d", cbLength));
-
-        pInfo = (POBJECT_NAME_INFORMATION)VBoxUsbMonMemAlloc(cbLength);
-        if (!pInfo)
-        {
-            WARN(("VBoxUsbMonMemAlloc failed"));
-            return STATUS_NO_MEMORY;
-        }
-        Status = ObQueryNameString(pDo, pInfo, cbLength, &cbLength);
-        if (!NT_SUCCESS(Status))
-        {
-            WARN(("ObQueryNameString second try failed 0x%x", Status));
-            VBoxUsbMonMemFree(pInfo);
-            return Status;
-        }
-    }
-
-    /* we've got the name! */
-    LOG(("got the name:"));
-    LOG_USTR(&pInfo->Name);
-    pfnMatcher(pDo, &pInfo->Name, pvMatcher);
-
-    if (&buf.Info != pInfo)
-    {
-        LOG(("freeing allocated pInfo(0x%p)", pInfo));
-        VBoxUsbMonMemFree(pInfo);
-    }
-    else
-    {
-        LOG(("no freeing info needed"));
-    }
-
-    return STATUS_SUCCESS;
-}
-
-
-typedef DECLCALLBACK(BOOLEAN) FNVBOXUSBDEVSTACKWALKER(PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pCurDo, PVOID pvContext);
-typedef FNVBOXUSBDEVSTACKWALKER *PFNVBOXUSBDEVSTACKWALKER;
-
-VOID vboxUsbObjDevStackWalk(PDEVICE_OBJECT pDo, PFNVBOXUSBDEVSTACKWALKER pfnWalker, PVOID pvWalker)
-{
-    LOG(("==>tree walk for Do 0x%p", pDo));
-    PDEVICE_OBJECT pCurDo = pDo;
-    ObReferenceObject(pCurDo); /* <- to make sure the dereferencing logic below works correctly */
-    do
-    {
-        LOG(("==Do 0x%p", pCurDo));
-#ifdef VBOX_USB_WITH_VERBOSE_LOGGING
-        {
-            union
-            {
-                OBJECT_NAME_INFORMATION Info;
-                char buf[1024];
-            } buf;
-            ULONG cbLength = 0;
-
-            NTSTATUS tmpStatus = ObQueryNameString(pCurDo, &buf.Info, sizeof (buf), &cbLength);
-            if (NT_SUCCESS(tmpStatus))
-            {
-                LOG(("  Obj name:"));
-                LOG_USTR(&buf.Info.Name);
-            }
-            else
-            {
-                if (STATUS_INFO_LENGTH_MISMATCH != tmpStatus)
-                {
-                    WARN(("ObQueryNameString failed 0x%x", tmpStatus));
-                }
-                else
-                {
-                    WARN(("ObQueryNameString STATUS_INFO_LENGTH_MISMATCH, required %d", cbLength));
-                }
-            }
-
-            if (pCurDo->DriverObject
-                && pCurDo->DriverObject->DriverName.Buffer
-                && pCurDo->DriverObject->DriverName.Length)
-            {
-                LOG(("  Drv Obj(0x%p), name:", pCurDo->DriverObject));
-                LOG_USTR(&pCurDo->DriverObject->DriverName);
-            }
-            else
-            {
-                LOG(("  No Drv Name, Drv Obj(0x%p)", pCurDo->DriverObject));
-                if (pCurDo->DriverObject)
-                {
-                    LOG(("  driver name is zero, Length(%d), Buffer(0x%p)",
-                                pCurDo->DriverObject->DriverName.Length, pCurDo->DriverObject->DriverName.Buffer));
-                }
-                else
-                {
-                    LOG(("  driver object is NULL"));
-                }
-            }
-        }
-#endif
-        if (!pfnWalker(pDo, pCurDo, pvWalker))
-        {
-            LOG(("the walker said to stop"));
-            ObDereferenceObject(pCurDo);
-            break;
-        }
-
-        PDEVICE_OBJECT pLowerDo = IoGetLowerDeviceObject(pCurDo);
-        ObDereferenceObject(pCurDo);
-        if (!pLowerDo)
-        {
-            LOG(("IoGetLowerDeviceObject returnned NULL, stop"));
-            break;
-        }
-        pCurDo = pLowerDo;
-    } while (1);
-
-    LOG(("<==tree walk"));
-}
-
-static DECLCALLBACK(BOOLEAN) vboxUsbObjNamePrefixMatch(PUNICODE_STRING pName, PUNICODE_STRING pNamePrefix, BOOLEAN fCaseInSensitive)
-{
-    LOG(("Matching prefix:"));
-    LOG_USTR(pNamePrefix);
-    if (pNamePrefix->Length > pName->Length)
-    {
-        LOG(("Pregix Length(%d) > Name Length(%d)", pNamePrefix->Length, pName->Length));
-        return FALSE;
-    }
-
-    LOG(("Pregix Length(%d) <= Name Length(%d)", pNamePrefix->Length, pName->Length));
-
-    UNICODE_STRING NamePrefix = *pName;
-    NamePrefix.Length = pNamePrefix->Length;
-    LONG rc = RtlCompareUnicodeString(&NamePrefix, pNamePrefix, fCaseInSensitive);
-
-    if (!rc)
-    {
-        LOG(("prefix MATCHED!"));
-        return TRUE;
-    }
-
-    LOG(("prefix NOT matched!"));
-    return FALSE;
-}
-
-typedef struct VBOXUSBOBJNAMEPREFIXMATCHER
-{
-    PUNICODE_STRING pNamePrefix;
-    BOOLEAN fMatched;
-} VBOXUSBOBJNAMEPREFIXMATCHER, *PVBOXUSBOBJNAMEPREFIXMATCHER;
-
-static DECLCALLBACK(VOID) vboxUsbObjDevNamePrefixMatcher(PDEVICE_OBJECT pDo, PUNICODE_STRING pName, PVOID pvMatcher)
-{
-    RT_NOREF1(pDo);
-    PVBOXUSBOBJNAMEPREFIXMATCHER pData = (PVBOXUSBOBJNAMEPREFIXMATCHER)pvMatcher;
-    PUNICODE_STRING pNamePrefix = pData->pNamePrefix;
-    ASSERT_WARN(!pData->fMatched, ("match flag already set!"));
-    pData->fMatched = vboxUsbObjNamePrefixMatch(pName, pNamePrefix, TRUE /* fCaseInSensitive */);
-    LOG(("match result (%d)", (int)pData->fMatched));
-}
-
-typedef struct VBOXUSBOBJDRVOBJSEARCHER
-{
-    PDEVICE_OBJECT pDevObj;
-    PUNICODE_STRING pDrvName;
-    PUNICODE_STRING pPdoNamePrefix;
-    ULONG fFlags;
-} VBOXUSBOBJDRVOBJSEARCHER, *PVBOXUSBOBJDRVOBJSEARCHER;
-
-static DECLCALLBACK(BOOLEAN) vboxUsbObjDevObjSearcherWalker(PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pCurDo, PVOID pvContext)
-{
-    RT_NOREF1(pTopDo);
-    PVBOXUSBOBJDRVOBJSEARCHER pData = (PVBOXUSBOBJDRVOBJSEARCHER)pvContext;
-    ASSERT_WARN(!pData->pDevObj, ("non-null dev object (0x%p) on enter", pData->pDevObj));
-    pData->pDevObj = NULL;
-    if (pCurDo->DriverObject
-        && pCurDo->DriverObject->DriverName.Buffer
-        && pCurDo->DriverObject->DriverName.Length
-        && !RtlCompareUnicodeString(pData->pDrvName, &pCurDo->DriverObject->DriverName, TRUE /* case insensitive */))
-    {
-        LOG(("MATCHED driver:"));
-        LOG_USTR(&pCurDo->DriverObject->DriverName);
-        if ((pData->fFlags & VBOXUSBMONHUBWALK_F_ALL) != VBOXUSBMONHUBWALK_F_ALL)
-        {
-            VBOXUSBOBJNAMEPREFIXMATCHER Data = {0};
-            Data.pNamePrefix = pData->pPdoNamePrefix;
-            NTSTATUS Status = vboxUsbObjCheckName(pCurDo, vboxUsbObjDevNamePrefixMatcher, &Data);
-            if (!NT_SUCCESS(Status))
-            {
-                WARN(("vboxUsbObjCheckName failed Status (0x%x)", Status));
-                return TRUE;
-            }
-
-
-            LOG(("prefix match result (%d)", Data.fMatched));
-            if ((pData->fFlags & VBOXUSBMONHUBWALK_F_FDO) == VBOXUSBMONHUBWALK_F_FDO)
-            {
-                LOG(("VBOXUSBMONHUBWALK_F_FDO"));
-                if (Data.fMatched)
-                {
-                    LOG(("this is a PDO object, skip it and stop search"));
-                    /* stop search as we will not find FDO here */
-                    return FALSE;
-                }
-
-                LOG(("this is a FDO object, MATCHED!!"));
-            }
-            else if ((pData->fFlags & VBOXUSBMONHUBWALK_F_PDO) == VBOXUSBMONHUBWALK_F_PDO)
-            {
-                LOG(("VBOXUSBMONHUBWALK_F_PDO"));
-                if (!Data.fMatched)
-                {
-                    LOG(("this is a FDO object, skip it and continue search"));
-                    /* continue seach since since this could be a nested hub that would have a usbhub-originated PDO */
-                    return TRUE;
-                }
-
-                LOG(("this is a PDO object, MATCHED!!"));
-            }
-
-        }
-        else
-        {
-            LOG(("VBOXUSBMONHUBWALK_F_ALL"));
-            LOG(("either PDO or FDO, MATCHED!!"));
-        }
-
-        /* ensure the dev object is not destroyed */
-        ObReferenceObject(pCurDo);
-        pData->pDevObj = pCurDo;
-        /* we are done */
-        return FALSE;
-    }
-    else
-    {
-        LOG(("driver object (0x%p) no match", pCurDo->DriverObject));
-        if (pCurDo->DriverObject)
-        {
-            if (   pCurDo->DriverObject->DriverName.Buffer
-                && pCurDo->DriverObject->DriverName.Length)
-            {
-                LOG(("driver name not match, was:"));
-                LOG_USTR(&pCurDo->DriverObject->DriverName);
-                LOG(("but expected:"));
-                LOG_USTR(pData->pDrvName);
-            }
-            else
-            {
-                LOG(("driver name is zero, Length(%d), Buffer(0x%p)",
-                        pCurDo->DriverObject->DriverName.Length, pCurDo->DriverObject->DriverName.Buffer));
-            }
-        }
-        else
-        {
-            LOG(("driver object is NULL"));
-        }
-    }
-    return TRUE;
 }
 
@@ -583,46 +277,4 @@
         ExFreePool(szwHubList);
     }
-}
-
-typedef struct VBOXUSBMONFINDHUBWALKER
-{
-    PDRIVER_OBJECT pDrvObj;
-} VBOXUSBMONFINDHUBWALKER, *PVBOXUSBMONFINDHUBWALKER;
-
-static DECLCALLBACK(BOOLEAN) vboxUsbMonFindHubDrvObjWalker(PFILE_OBJECT pFile, PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pHubDo, PVOID pvContext)
-{
-    RT_NOREF2(pFile, pTopDo);
-    PVBOXUSBMONFINDHUBWALKER pData = (PVBOXUSBMONFINDHUBWALKER)pvContext;
-    PDRIVER_OBJECT pDrvObj = pHubDo->DriverObject;
-
-    ASSERT_WARN(!pData->pDrvObj, ("pDrvObj expected null on enter, but was(0x%p)", pData->pDrvObj));
-    if (pDrvObj)
-    {
-        LOG(("found driver object 0x%p", pDrvObj));
-        ObReferenceObject(pDrvObj);
-        pData->pDrvObj = pDrvObj;
-        return FALSE;
-    }
-
-    WARN(("null pDrvObj!"));
-    return TRUE;
-}
-
-static PDRIVER_OBJECT vboxUsbMonHookFindHubDrvObj()
-{
-    UNICODE_STRING szStandardHubName;
-    szStandardHubName.Length = 0;
-    szStandardHubName.MaximumLength = 0;
-    szStandardHubName.Buffer = 0;
-    RtlInitUnicodeString(&szStandardHubName, L"\\Driver\\usbhub");
-
-    LOG(("Search USB hub"));
-    VBOXUSBMONFINDHUBWALKER Data = {0};
-    vboxUsbMonHubDevWalk(vboxUsbMonFindHubDrvObjWalker, &Data, VBOXUSBMONHUBWALK_F_ALL);
-    if (Data.pDrvObj)
-        LOG(("returning driver object 0x%p", Data.pDrvObj));
-    else
-        WARN(("no hub driver object found!"));
-    return Data.pDrvObj;
 }
 
