Skip to main content

my windows does not want to update my driver sample RRS feed

  • Question

  • hello

    the problem is on windows 7, the target computer in driver developpement, the pnp manager does not want to update my driver status unless if i restart that target computer.

    what i could to do to fix the problem?

    Sunday, December 30, 2018 8:45 AM

All replies

  • There are a number of possibilities on this.   First is your driver being used, for example it is needed for Windows or your test program is running with the device open?   Have you debugged the release of resources and other shutdown code in your driver?  If your driver is not shutting down and releasing all resources you have a problem.

    Turn on SetupAPI logging  this can potentially give you a clue to the problem.   Also, step through the shutdown/cleanup code to see if there is a problem.

    Don Burn Windows Driver Consulting Website:

    Sunday, December 30, 2018 5:48 PM
  • i have encountred another problem wich is the Device cannot start (code 10) :

    there is no problem if i comment/remove the line of adding the add_device_routine to the device extension in the DriverEntry:

    here is my code:

        NTSTATUS s;
        PUNICODE_STRING regpath;

        KdPrint(("DriverEntry %s---%s", __TIME__, __DATE__));

        s = IoAllocateDriverObjectExtension(d_o, (PVOID)1, sizeof(UNICODE_STRING), (PVOID*)&regpath);

        if (regpath)
            regpath->MaximumLength = rp->Length + sizeof(UNICODE_NULL);
            regpath->Length = rp->Length;
            regpath->Buffer = ExAllocatePool(NonPagedPool, regpath->MaximumLength);

            if (regpath->Buffer)
                RtlZeroMemory(regpath->Buffer, regpath->MaximumLength);

                RtlMoveMemory(regpath->Buffer, rp->Buffer, rp->Length);

                regpath->MaximumLength = regpath->Length = 0;

        // Set up the device driver entry points and leave
        d_o->DriverUnload = SerialMouseUnload;
        d_o->DriverExtension->AddDevice = SerialMouseAddDevice;// this the line

        return STATUS_SUCCESS;

        KdPrint(("SerialMouseUnload %s---%s", __TIME__, __DATE__));
        PUNICODE_STRING regpath;


        //d_o->DeviceObject = NULL;
        ASSERT(NULL == d_o->DeviceObject);

        regpath = (PUNICODE_STRING)IoGetDriverObjectExtension(d_o, (PVOID)1); // = regpath = SerialMouseGetRegistryPath(d_o);
        if (regpath && regpath->Buffer) {

        IN PDRIVER_OBJECT   d_o,
        IN PDEVICE_OBJECT   pdo
        NTSTATUS            status = STATUS_SUCCESS;
        PDEVICE_EXTENSION   deviceExtension;
        PDEVICE_OBJECT      d;
        KIRQL               oldIrql;
        KdPrint(("SerialMouseAddDevice %s---%s", __TIME__, __DATE__));

        status = IoCreateDevice(d_o,

        KdPrint(("IoCreateDevice 0x%x\n", status));

        if (!NT_SUCCESS(status))
            KdPrint(("IoCreateDevice failed with 0x%x\n", status));
            return status;

        deviceExtension = (PDEVICE_EXTENSION)d->DeviceExtension;

        RtlZeroMemory(deviceExtension, sizeof(DEVICE_EXTENSION));

        deviceExtension->TopOfStack = IoAttachDeviceToDeviceStack(d, pdo);

        if (deviceExtension->TopOfStack == NULL)
            KdPrint(("IoAttachDeviceToDeviceStack failed\n"));


        deviceExtension->PDO = pdo;
        deviceExtension->Self = d;
        deviceExtension->Removed = FALSE;
        deviceExtension->Started = FALSE;
        deviceExtension->Stopped = FALSE;

        deviceExtension->PowerState = PowerDeviceD0;
        deviceExtension->WaitWakePending = FALSE;

        KeInitializeEvent(&deviceExtension->StopEvent, SynchronizationEvent, FALSE);
        IoInitializeRemoveLock(&deviceExtension->RemoveLock, SERMOU_POOL_TAG, 0, 10);

        deviceExtension->ReadIrp = IoAllocateIrp(d->StackSize, FALSE);

        if (deviceExtension->ReadIrp == NULL)
            IoDetachDevice(deviceExtension->TopOfStack );


        deviceExtension->WmiLibInfo.GuidCount = sizeof(WmiGuidList) / sizeof(WMIGUIDREGINFO);
        deviceExtension->WmiLibInfo.GuidList = WmiGuidList;
        deviceExtension->WmiLibInfo.QueryWmiRegInfo = SerialMouseQueryWmiRegInfo;
        deviceExtension->WmiLibInfo.QueryWmiDataBlock = Serialmousequerywmidatablock;
        deviceExtension->WmiLibInfo.SetWmiDataBlock = serialmousesetwmidatablock;
        deviceExtension->WmiLibInfo.SetWmiDataItem = serialmousesetwmidataitem;

        deviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
        deviceExtension->WmiLibInfo.WmiFunctionControl = NULL;

        status = IoWMIRegistrationControl(deviceExtension->Self, WMIREG_ACTION_REGISTER);

        if (!NT_SUCCESS(status))
            KdPrint(("IoWMIRegistrationControl fialed with 0x%x\n", status));
            return STATUS_WMI_NOT_SUPPORTED;


        d->Flags &= DO_DEVICE_INITIALIZING;
        d->Flags |= DO_BUFFERED_IO;
        d->Flags |= DO_POWER_PAGABLE;

        KdPrint(("succeeded\n")); // this is rendred in the dbgview application
        return status;

    i have the same result if i install the serial mouse driver from Microsoft web site (the device cannto start code 10).
    Monday, December 31, 2018 2:03 PM
  • You have a problem in the IRP_MJ_PNP handling of your driver, that is not cleaning up the work from AddDevice.   Problems with PNP are why most of the driver writers have abandoned WDF drivers for things like what you are doing.   If you used KMDF most of the problems would be solved by the framework.

    Don Burn Windows Driver Consulting Website:

    Monday, December 31, 2018 2:17 PM
  • How, exactly, are you installing this driver?  Please be detailed.  Do you have it driving a real piece of hardware?

    By using AddDevice, you are telling the system that you are a PnP driver, but you are not handling any PnP requests at all. 

    Is this a 64-bit system?  Are you signing your driver package?

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Wednesday, January 2, 2019 9:37 PM
  • i have added the pnp request with START_DEVICE case now how i can handle these things if the driver is a serial mouse driver?

    also, if i add a dbgprint or kdprint to the top of the code in the pnp request routine , the PRITNS does not seem to be rendered at all, i mean that the pnp request is not called at all!

    Thursday, January 31, 2019 9:43 AM