This device is working properly.There is a secondary device connected to this hardware that Windows cannot identify because it does not have a valid hardware identification number.

USB中文网 2021-07-09 00:01:31 编辑

Windows10 x64自己搞的USB总线驱动,加载驱动后设备管理器中的设备状态显示:

This device is working properly.There is a secondary device connected to this hardware that Windows cannot identify because it does not have a valid hardware identification number.

这是什么鬼问题?
待解。。。。


查遍万水千山的IRP_MN_QUERY_ID、IRP_MN_QUERY_DEVICE_TEXT、IRP_MN_QUERY_BUS_INFORMATION、IRP_MN_QUERY_INTERFACE 此锅甩给IRP_MN_QUERY_CAPABILITIES。
获取设备属性信息不能直接拷贝根设备的,是需要加一个自己的错料的。

42行之后,为加的信息
幸好没有发生蓝屏,可以快乐的去吃个中午饭


NTSTATUS
Pdo_HandleQueryCapabilities(
    IN PDEVICE_OBJECT DeviceObject,
    IN OUT PIRP Irp)
{

    NTSTATUS             ntStatus;
    PPDO_DEVICE_EXTENSION PDOdeviceExtension;
    PDEVICE_CAPABILITIES pdc;
    PIO_STACK_LOCATION   irpStack;
    DEVICE_CAPABILITIES parent_cap;

  //  BulkUsb_DbgPrint(3, ("UVCHandleQueryCapabilities - begins\n"));

    //
    // initialize variables
    //

    ntStatus = STATUS_SUCCESS;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    PDOdeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
    pdc = irpStack->Parameters.DeviceCapabilities.Capabilities;

    //
    // We will provide here an example of an IRP that is processed
    // both on its way down and on its way up: there might be no need for
    // a function driver process this Irp (the bus driver will do that).
    // The driver will wait for the lower drivers (the bus driver among 
    // them) to process this IRP, then it processes it again.
    //

    if (pdc->Version < 1 || pdc->Size < sizeof(DEVICE_CAPABILITIES)) {

     //   BulkUsb_DbgPrint(1, ("UVCHandleQueryCapabilities::request failed\n"));
        ntStatus = STATUS_UNSUCCESSFUL;
        Irp->IoStatus.Status = ntStatus;
        IoCompleteRequest(Irp, IO_NO_INCREMENT);
        return ntStatus;
    }

    RtlCopyMemory(&parent_cap, &PDOdeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));


    RtlCopyMemory(
        pdc->DeviceState,
        &parent_cap,
        (PowerSystemShutdown + 1) * sizeof(DEVICE_POWER_STATE));

    ///////Adjust the caps to what your device supports.
    // Our device just supports D0 and D3.
    pdc->DeviceState[PowerSystemWorking] = PowerDeviceD0;

    if (pdc->DeviceState[PowerSystemSleeping1] != PowerDeviceD0)
        pdc->DeviceState[PowerSystemSleeping1] = PowerDeviceD1;

    if (pdc->DeviceState[PowerSystemSleeping2] != PowerDeviceD0)
        pdc->DeviceState[PowerSystemSleeping2] = PowerDeviceD3;

    if (pdc->DeviceState[PowerSystemSleeping3] != PowerDeviceD0)
        pdc->DeviceState[PowerSystemSleeping3] = PowerDeviceD3;

    // We can wake the system from D1
    pdc->DeviceWake = PowerDeviceD1;

    /////
    pdc->DeviceD1 = TRUE; // Yes we can
    pdc->DeviceD2 = FALSE;

    // Specifies whether the device can respond to an external wake
    // signal while in the D0, D1, D2, and D3 state.
    // Set these bits explicitly.
    pdc->WakeFromD0 = FALSE;
    pdc->WakeFromD1 = TRUE; //Yes we can
    pdc->WakeFromD2 = FALSE;
    pdc->WakeFromD3 = FALSE;

    // We have no latencies
    pdc->D1Latency = 0;
    pdc->D2Latency = 0;
    pdc->D3Latency = 0;

    // Ejection supported
    pdc->EjectSupported = TRUE;

    // This flag specifies whether the device's hardware is disabled.
    // The PnP Manager only checks this bit right after the device is
    // enumerated. Once the device is started, this bit is ignored.
    pdc->HardwareDisabled = FALSE;

    // Out simulated device can be physically removed.
    pdc->Removable = TRUE;

    // Setting it to TURE prevents the warning dialog from appearing
    // whenever the device is surprise removed.
    pdc->SurpriseRemovalOK = TRUE;

    // We don't support system-wide unique IDs.
    pdc->UniqueID = FALSE;

    //
    // Specify whether the Device Manager should suppress all
    // installation pop-ups except required pop-ups such as
    // "no compatible drivers found."
    pdc->SilentInstall = FALSE;

    //
    // Specifies an address indicating where the device is located
    // on its underlying bus. The interpretation of this number is
    // bus-specific. If the address is unknown or the bus driver
    // does not support an address, the bus driver leaves this
    // member at its default value of 0xFFFFFFFF. In this example
    // the location address is same as instance id.

    pdc->Address = PDOdeviceExtension->bus_address;

    //
    // UINumber specifies a number associated with the device that can
    // be displayed in the user interface.
    //
    pdc->UINumber = PDOdeviceExtension->bus_address;

    //BulkUsb_DbgPrint(3, ("UVCHandleQueryCapabilities - ends\n"));
    ntStatus = STATUS_SUCCESS;
    Irp->IoStatus.Status = ntStatus;
    IoCompleteRequest(Irp, IO_NO_INCREMENT);
    return ntStatus;
}