Asked by:
my windows does not want to update my driver sample

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?
- Edited by AbdEllah Gogop Sunday, December 30, 2018 9:00 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 https://docs.microsoft.com/en-us/windows-hardware/drivers/install/setupapi-logging--windows-vista-and-later- 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: http://www.windrvr.com
-
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 DriverEntry(PDRIVER_OBJECT d_o, PUNICODE_STRING rp)
{
NTSTATUS s;
PUNICODE_STRING regpath;
KdPrint(("DriverEntry %s---%s", __TIME__, __DATE__));
s = IoAllocateDriverObjectExtension(d_o, (PVOID)1, sizeof(UNICODE_STRING), (PVOID*)®path);
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);
}
else
{
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;
}
VOID
SerialMouseUnload(
IN PDRIVER_OBJECT d_o
)
{
KdPrint(("SerialMouseUnload %s---%s", __TIME__, __DATE__));
PUNICODE_STRING regpath;
//PAGED_CODE();
//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) {
ExFreePool(regpath->Buffer);
}
}
NTSTATUS
SerialMouseAddDevice(
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,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_SERIAL_MOUSE_PORT,
0,
FALSE,
&d);
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"));
IoDeleteDevice(d);
return STATUS_DEVICE_NOT_CONNECTED;
}
deviceExtension->PDO = pdo;
deviceExtension->Self = d;
deviceExtension->Removed = FALSE;
deviceExtension->Started = FALSE;
deviceExtension->Stopped = FALSE;
deviceExtension->PowerState = PowerDeviceD0;
deviceExtension->WaitWakePending = FALSE;
KeInitializeSpinLock(&deviceExtension->PnpStateLock);
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 );
IoDeleteDevice(d);
return STATUS_INSUFFICIENT_RESOURCES;
}
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;
}
KeInitializeTimer(&deviceExtension->DelayTimer);
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).- Edited by AbdEllah Gogop Monday, December 31, 2018 2:05 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: http://www.windrvr.com
-
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.
-
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!
- Edited by AbdEllah Gogop Thursday, January 31, 2019 9:46 AM