VirtualBox

Ignore:
Timestamp:
Apr 28, 2015 8:52:30 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99820
Message:

USB: Increased the number of supported drivers to 5, added Event Log error message when out of slots.

Location:
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUSBMon.inf

    r36968 r55473  
    3535
    3636[DefaultInstall.NT.Services]
    37 AddService = VBoxUSBMon, 0x00000002, VBoxUSBMon_Service_Inst
     37AddService = VBoxUSBMon, 0x00000002, VBoxUSBMon_Service_Inst, VBoxUSBMon_EventLog_Inst
    3838
    3939[VBoxUSBMon_Service_Inst]
     
    4444ErrorControl   = 1                  ; SERVICE_ERROR_NORMAL
    4545ServiceBinary  = %12%\VBoxUSBMon.sys
     46
     47[VBoxUSBMon_EventLog_Inst]
     48AddReg         = VBoxUSBMon_EventLog_AddReg
     49
     50[VBoxUSBMon_EventLog_AddReg]
     51HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll"
     52HKR,,TypesSupported,0x00010001,7
    4653
    4754[SourceDisksNames]
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp

    r54826 r55473  
    6868
    6969#ifdef VBOX_USB3PORT
    70 #define VBOXUSBMON_MAXDRIVERS 3
     70#define VBOXUSBMON_MAXDRIVERS 5
    7171typedef struct VBOXUSB_PNPDRIVER
    7272{
     
    11371137VBOX_PNPHOOKSTUB(1)
    11381138VBOX_PNPHOOKSTUB(2)
    1139 AssertCompile(VBOXUSBMON_MAXDRIVERS == 3);
     1139VBOX_PNPHOOKSTUB(3)
     1140VBOX_PNPHOOKSTUB(4)
     1141AssertCompile(VBOXUSBMON_MAXDRIVERS == 5);
    11401142
    11411143typedef struct VBOXUSBMONHOOKDRIVERWALKER
     
    11431145    PDRIVER_OBJECT pDrvObj;
    11441146} VBOXUSBMONHOOKDRIVERWALKER, *PVBOXUSBMONHOOKDRIVERWALKER;
     1147
     1148/**
     1149 * Logs an error to the system event log.
     1150 *
     1151 * @param   ErrCode        Error to report to event log.
     1152 * @param   ReturnedStatus Error that was reported by the driver to the caller.
     1153 * @param   uErrId         Unique error id representing the location in the driver.
     1154 * @param   cbDumpData     Number of bytes at pDumpData.
     1155 * @param   pDumpData      Pointer to data that will be added to the message (see 'details' tab).
     1156 */
     1157static void vboxUsbMonLogError(NTSTATUS ErrCode, NTSTATUS ReturnedStatus, ULONG uErrId, USHORT cbDumpData, PVOID pDumpData)
     1158{
     1159    PIO_ERROR_LOG_PACKET pErrEntry;
     1160   
     1161
     1162    /* Truncate dumps that do not fit into IO_ERROR_LOG_PACKET. */
     1163    if (FIELD_OFFSET(IO_ERROR_LOG_PACKET, DumpData) + cbDumpData > ERROR_LOG_MAXIMUM_SIZE)
     1164        cbDumpData = ERROR_LOG_MAXIMUM_SIZE - FIELD_OFFSET(IO_ERROR_LOG_PACKET, DumpData);
     1165
     1166    pErrEntry = (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(g_VBoxUsbMonGlobals.pDevObj,
     1167                                                              FIELD_OFFSET(IO_ERROR_LOG_PACKET, DumpData) + cbDumpData);
     1168    if (pErrEntry)
     1169    {
     1170        uint8_t *pDump = (uint8_t *)pErrEntry->DumpData;
     1171        if (cbDumpData)
     1172            memcpy(pDump, pDumpData, cbDumpData);
     1173        pErrEntry->MajorFunctionCode = 0;
     1174        pErrEntry->RetryCount = 0;
     1175        pErrEntry->DumpDataSize = cbDumpData;
     1176        pErrEntry->NumberOfStrings = 0;
     1177        pErrEntry->StringOffset = 0;
     1178        pErrEntry->ErrorCode = ErrCode;
     1179        pErrEntry->UniqueErrorValue = uErrId;
     1180        pErrEntry->FinalStatus = ReturnedStatus;
     1181        pErrEntry->IoControlCode = 0;
     1182        IoWriteErrorLogEntry(pErrEntry);
     1183    }
     1184    else
     1185    {
     1186        LOG(("Failed to allocate error log entry (cb=%d)\n", FIELD_OFFSET(IO_ERROR_LOG_PACKET, DumpData) + cbDumpData));
     1187    }
     1188}
    11451189
    11461190static DECLCALLBACK(BOOLEAN) vboxUsbMonHookDrvObjWalker(PFILE_OBJECT pFile, PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pHubDo, PVOID pvContext)
     
    11811225    /* No empty slots! No reason to continue. */
    11821226    LOG(("No empty slots!\n"));
     1227    ANSI_STRING ansiDrvName;
     1228    NTSTATUS Status = RtlUnicodeStringToAnsiString(&ansiDrvName, &pDrvObj->DriverName, true);
     1229    if (Status != STATUS_SUCCESS)
     1230    {
     1231        ansiDrvName.Length = 0;
     1232        LOG(("RtlUnicodeStringToAnsiString failed with 0x%x", Status));
     1233    }
     1234    vboxUsbMonLogError(IO_ERR_INSUFFICIENT_RESOURCES, STATUS_SUCCESS, 1, ansiDrvName.Length, ansiDrvName.Buffer);
     1235    if (Status == STATUS_SUCCESS)
     1236        RtlFreeAnsiString(&ansiDrvName);
    11831237    return FALSE;
    11841238}
     
    18601914    VBOX_PNPHOOKSTUB_INIT(1);
    18611915    VBOX_PNPHOOKSTUB_INIT(2);
    1862     AssertCompile(VBOXUSBMON_MAXDRIVERS == 3);
     1916    VBOX_PNPHOOKSTUB_INIT(3);
     1917    VBOX_PNPHOOKSTUB_INIT(4);
     1918    AssertCompile(VBOXUSBMON_MAXDRIVERS == 5);
    18631919#endif /* VBOX_USB3PORT */
    18641920    KeInitializeEvent(&g_VBoxUsbMonGlobals.OpenSynchEvent, SynchronizationEvent, TRUE /* signaled */);
Note: See TracChangeset for help on using the changeset viewer.

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