VirtualBox

Ignore:
Timestamp:
Apr 18, 2020 6:20:34 PM (5 years ago)
Author:
vboxsync
Message:

VBoxUSB: VC++ 14.1 adjustments and warnings (and some cleanups). bugref:8489

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp

    r82968 r83803  
    109109*   Defined Constants And Macros                                                                                                 *
    110110*********************************************************************************************************************************/
     111#define VBOXUSBMON_MEMTAG 'MUBV'
     112
     113
     114/*********************************************************************************************************************************
     115*   Structures and Typedefs                                                                                                      *
     116*********************************************************************************************************************************/
     117typedef struct VBOXUSBMONINS
     118{
     119    void * pvDummy;
     120} VBOXUSBMONINS, *PVBOXUSBMONINS;
     121
     122typedef struct VBOXUSBMONCTX
     123{
     124    VBOXUSBFLTCTX FltCtx;
     125} VBOXUSBMONCTX, *PVBOXUSBMONCTX;
     126
     127typedef struct VBOXUSBHUB_PNPHOOK
     128{
     129    VBOXUSBHOOK_ENTRY Hook;
     130    bool fUninitFailed;
     131} VBOXUSBHUB_PNPHOOK, *PVBOXUSBHUB_PNPHOOK;
     132
     133typedef struct VBOXUSBHUB_PNPHOOK_COMPLETION
     134{
     135    VBOXUSBHOOK_REQUEST Rq;
     136} VBOXUSBHUB_PNPHOOK_COMPLETION, *PVBOXUSBHUB_PNPHOOK_COMPLETION;
     137
     138#define VBOXUSBMON_MAXDRIVERS 5
     139typedef struct VBOXUSB_PNPDRIVER
     140{
     141    PDRIVER_OBJECT     DriverObject;
     142    VBOXUSBHUB_PNPHOOK UsbHubPnPHook;
     143    PDRIVER_DISPATCH   pfnHookStub;
     144} VBOXUSB_PNPDRIVER, *PVBOXUSB_PNPDRIVER;
     145
     146typedef struct VBOXUSBMONGLOBALS
     147{
     148    PDEVICE_OBJECT pDevObj;
     149    VBOXUSB_PNPDRIVER pDrivers[VBOXUSBMON_MAXDRIVERS];
     150    KEVENT OpenSynchEvent;
     151    IO_REMOVE_LOCK RmLock;
     152    uint32_t cOpens;
     153    volatile LONG ulPreventUnloadOn;
     154    PFILE_OBJECT pPreventUnloadFileObj;
     155} VBOXUSBMONGLOBALS, *PVBOXUSBMONGLOBALS;
     156
     157
     158/*********************************************************************************************************************************
     159*   Global Variables                                                                                                             *
     160*********************************************************************************************************************************/
     161static VBOXUSBMONGLOBALS g_VBoxUsbMonGlobals;
     162
    111163/*
    112164 * Note: Must match the VID & PID in the USB driver .inf file!!
     
    122174*/
    123175
    124 #define szBusQueryDeviceId       L"USB\\Vid_80EE&Pid_CAFE"
    125 #define szBusQueryHardwareIDs    L"USB\\Vid_80EE&Pid_CAFE&Rev_0100\0USB\\Vid_80EE&Pid_CAFE\0\0"
    126 #define szBusQueryCompatibleIDs  L"USB\\Class_ff&SubClass_00&Prot_00\0USB\\Class_ff&SubClass_00\0USB\\Class_ff\0\0"
    127 
    128 #define szDeviceTextDescription          L"VirtualBox USB"
    129 
    130 
    131 #define VBOXUSBMON_MEMTAG 'MUBV'
    132 
    133 
    134 /*********************************************************************************************************************************
    135 *   Structures and Typedefs                                                                                                      *
    136 *********************************************************************************************************************************/
    137 typedef struct VBOXUSBMONINS
    138 {
    139     void * pvDummy;
    140 } VBOXUSBMONINS, *PVBOXUSBMONINS;
    141 
    142 typedef struct VBOXUSBMONCTX
    143 {
    144     VBOXUSBFLTCTX FltCtx;
    145 } VBOXUSBMONCTX, *PVBOXUSBMONCTX;
    146 
    147 typedef struct VBOXUSBHUB_PNPHOOK
    148 {
    149     VBOXUSBHOOK_ENTRY Hook;
    150     bool fUninitFailed;
    151 } VBOXUSBHUB_PNPHOOK, *PVBOXUSBHUB_PNPHOOK;
    152 
    153 typedef struct VBOXUSBHUB_PNPHOOK_COMPLETION
    154 {
    155     VBOXUSBHOOK_REQUEST Rq;
    156 } VBOXUSBHUB_PNPHOOK_COMPLETION, *PVBOXUSBHUB_PNPHOOK_COMPLETION;
    157 
    158 #define VBOXUSBMON_MAXDRIVERS 5
    159 typedef struct VBOXUSB_PNPDRIVER
    160 {
    161     PDRIVER_OBJECT     DriverObject;
    162     VBOXUSBHUB_PNPHOOK UsbHubPnPHook;
    163     PDRIVER_DISPATCH   pfnHookStub;
    164 } VBOXUSB_PNPDRIVER, *PVBOXUSB_PNPDRIVER;
    165 
    166 typedef struct VBOXUSBMONGLOBALS
    167 {
    168     PDEVICE_OBJECT pDevObj;
    169     VBOXUSB_PNPDRIVER pDrivers[VBOXUSBMON_MAXDRIVERS];
    170     KEVENT OpenSynchEvent;
    171     IO_REMOVE_LOCK RmLock;
    172     uint32_t cOpens;
    173     volatile LONG ulPreventUnloadOn;
    174     PFILE_OBJECT pPreventUnloadFileObj;
    175 } VBOXUSBMONGLOBALS, *PVBOXUSBMONGLOBALS;
    176 
    177 
    178 /*********************************************************************************************************************************
    179 *   Global Variables                                                                                                             *
    180 *********************************************************************************************************************************/
    181 static VBOXUSBMONGLOBALS g_VBoxUsbMonGlobals;
     176static WCHAR const g_szBusQueryDeviceId[]      = L"USB\\Vid_80EE&Pid_CAFE";
     177static WCHAR const g_szBusQueryHardwareIDs[]   = L"USB\\Vid_80EE&Pid_CAFE&Rev_0100\0USB\\Vid_80EE&Pid_CAFE\0\0";
     178static WCHAR const g_szBusQueryCompatibleIDs[] = L"USB\\Class_ff&SubClass_00&Prot_00\0USB\\Class_ff&SubClass_00\0USB\\Class_ff\0\0";
     179static WCHAR const g_szDeviceTextDescription[] = L"VirtualBox USB";
    182180
    183181
     
    377375                    /* IRQL should be always passive here */
    378376                    ASSERT_WARN(Iqrl == PASSIVE_LEVEL, ("irql is not PASSIVE"));
    379                     switch(pSl->Parameters.QueryDeviceText.DeviceTextType)
     377                    switch (pSl->Parameters.QueryDeviceText.DeviceTextType)
    380378                    {
    381379                        case DeviceTextLocationInformation:
     
    390388                            {
    391389                                LOG(("PDO (0x%p) is filtered", pDevObj));
    392                                 WCHAR *pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(szDeviceTextDescription));
    393                                 if (!pId)
    394                                 {
    395                                     AssertFailed();
    396                                     break;
    397                                 }
    398                                 memcpy(pId, szDeviceTextDescription, sizeof(szDeviceTextDescription));
     390                                WCHAR *pId2 = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szDeviceTextDescription));
     391                                AssertBreak(pId2);
     392                                memcpy(pId2, g_szDeviceTextDescription, sizeof(g_szDeviceTextDescription));
    399393                                LOG(("NEW szDeviceTextDescription"));
    400                                 LOG_STRW(pId);
     394                                LOG_STRW(pId2);
    401395                                ExFreePool((PVOID)pIoStatus->Information);
    402                                 pIoStatus->Information = (ULONG_PTR)pId;
     396                                pIoStatus->Information = (ULONG_PTR)pId2;
    403397                            }
    404398                            else
     
    443437                        {
    444438                            LOG(("BusQueryDeviceID"));
    445                             pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(szBusQueryDeviceId));
     439                            pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szBusQueryDeviceId));
    446440                            if (!pId)
    447441                            {
     
    468462                            LOG(("PDO (0x%p) is filtered", pDevObj));
    469463                            ExFreePool((PVOID)pIoStatus->Information);
    470                             memcpy(pId, szBusQueryDeviceId, sizeof(szBusQueryDeviceId));
     464                            memcpy(pId, g_szBusQueryDeviceId, sizeof(g_szBusQueryDeviceId));
    471465                            pIoStatus->Information = (ULONG_PTR)pId;
    472466                            break;
     
    483477                        }
    484478#endif
    485                         pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(szBusQueryHardwareIDs));
     479                        pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szBusQueryHardwareIDs));
    486480                        if (!pId)
    487481                        {
     
    508502                        LOG(("PDO (0x%p) is filtered", pDevObj));
    509503
    510                         memcpy(pId, szBusQueryHardwareIDs, sizeof(szBusQueryHardwareIDs));
     504                        memcpy(pId, g_szBusQueryHardwareIDs, sizeof(g_szBusQueryHardwareIDs));
    511505#ifdef VBOX_USB_WITH_VERBOSE_LOGGING
    512506                        LOG(("NEW BusQueryHardwareIDs"));
     
    537531                        {
    538532                            LOG(("PDO (0x%p) is filtered", pDevObj));
    539                             pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(szBusQueryCompatibleIDs));
     533                            pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szBusQueryCompatibleIDs));
    540534                            if (!pId)
    541535                            {
     
    543537                                break;
    544538                            }
    545                             memcpy(pId, szBusQueryCompatibleIDs, sizeof(szBusQueryCompatibleIDs));
     539                            memcpy(pId, g_szBusQueryCompatibleIDs, sizeof(g_szBusQueryCompatibleIDs));
    546540#ifdef VBOX_USB_WITH_VERBOSE_LOGGING
    547541                            LOG(("NEW BusQueryCompatibleIDs"));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette