Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 6  
13 Aug 18 19:42
Ryan Clements
xxxxxx@selinc.com
Join Date: 13 Aug 2018
Posts To This List: 3
Help Using the driver INTERFACE

Hi Everyone, I have a WDF bus driver that is attached directly to a PCI hw device. The bus driver creates 4 different devices. Which I then attach various other drivers to. The bus driver creates a custom INTERFACE type, and then registers that interface using WdfDeviceAddQueryInterface. That interface contains a couple of function pointer callbacks. All of my child device drivers that I create are WDF drivers except for one. From the WDF drivers I can query the interface created by the bus driver without any issues. My problem child (pun intended) is an old serial driver that is written in WDM. We're trying to convert it over to use our new bus driver. From the WDM serial driver, I am unable to query the bus driver interface. From my reading it looks like I need to generate an IRP and pass that along to the bus driver, but when I do I always receive STATUS_NOT_SUPPORTED back from the IoCallDriver function. I feel like i'm trying to talk to a device which doesn't support my INTERFACE, and i'm likely using the wrong device object to build my IRP, but I can't figure out how to retrieve the device object of my bus driver. I've tried the following functions to retrieve the device object with the same outcome (IoCallDriver returns STATUS_NOT_SUPPORTED) - IoGetAttachedDeviceReference - IoGetDeviceAttachmentBaseRef - IoGetLowerDeviceObject Anyways, any suggestions or directions to go would be much appreciated! IRP generation code is pasted below NTSTATUS get_bus_interface(IN PDEVICE_OBJECT PDevObj) { PIRP irp = NULL; KEVENT event; NTSTATUS status = STATUS_SUCCESS; PDEVICE_OBJECT pvmf_device = NULL; IO_STATUS_BLOCK ioStatus = { 0 }; PIO_STACK_LOCATION irpStack = NULL; PVMF_BUS_INTERFACE bus_interface; pvmf_device = IoGetAttachedDeviceReference(PDevObj); irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, pvmf_device, NULL, 0, 0, &event, &ioStatus); if (irp == NULL) { goto cleanup; } irp->IoStatus.Status = STATUS_NOT_SUPPORTED; irp->IoStatus.Information = 0; irpStack = IoGetNextIrpStackLocation(irp); irpStack->MinorFunction = IRP_MN_QUERY_INTERFACE; irpStack->Parameters.QueryInterface.InterfaceType = (LPGUID)&GUID_SEL_PVMF_BUS_INTERFACE; irpStack->Parameters.QueryInterface.Size = sizeof(PVMF_BUS_INTERFACE); irpStack->Parameters.QueryInterface.Version = SEL_PVMF_BUS_INTERFACE_VERSION; irpStack->Parameters.QueryInterface.Interface = (PINTERFACE)&bus_interface; irpStack->Parameters.QueryInterface.InterfaceSpecificData = NULL; status = IoCallDriver(pvmf_device, irp); if (status == STATUS_PENDING) { KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); status = ioStatus.Status; } if (!NT_SUCCESS(status)) { goto cleanup; } cleanup: ObDereferenceObject(pvmf_device); return status; } Thanks! Ryan
  Message 2 of 6  
13 Aug 18 20:06
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10238
Help Using the driver INTERFACE

This Wdm driver is a pnp driver, right? If so, you already have the device object you want to send the query interface to. It will be the device object returned by IoAttachDeviceToDeviceStack that you store in your device extension. You can confirm that this is the right device by breaking into the debugger and running !devstack <device object> And you should see your pdo listed at the bottom of the stack along with the instance id path. d Bent from my phone ________________________________ From: 30321470000n behalf of Sent: Monday, August 13, 2018 4:43 PM To: Windows System Software Devs Interest List Subject: [ntdev] Help Using the driver INTERFACE Hi Everyone, I have a WDF bus driver that is attached directly to a PCI hw device. The bus driver creates 4 different devices. Which I then attach various other drivers to. The bus driver creates a custom INTERFACE type, and then registers that interface using WdfDeviceAddQueryInterface. That interface contains a couple of function pointer callbacks. All of my child device drivers that I create are WDF drivers except for one. From the WDF drivers I can query the interface created by the bus driver without any issues. My problem child (pun intended) is an old serial driver that is written in WDM. We're trying to convert it over to use our new bus driver. From the WDM serial driver, I am unable to query the bus driver interface. From my reading it looks like I need to generate an IRP and pass that along to the bus driver, but when I do I always receive STATUS_NOT_SUPPORTED back from the IoCallDriver function. I feel like i'm trying to talk to a device which doesn't support my INTERFACE, and i'm likely using the wrong device object to build my IRP, but I can't figure out how to retrieve the device object of my bus driver. I've tried the following functions to retrieve the device object with the same outcome (IoCallDriver returns STATUS_NOT_SUPPORTED) - IoGetAttachedDeviceReference - IoGetDeviceAttachmentBaseRef - IoGetLowerDeviceObject Anyways, any suggestions or directions to go would be much appreciated! IRP generation code is pasted below NTSTATUS get_bus_interface(IN PDEVICE_OBJECT PDevObj) { PIRP irp = NULL; KEVENT event; NTSTATUS status = STATUS_SUCCESS; PDEVICE_OBJECT pvmf_device = NULL; IO_STATUS_BLOCK ioStatus = { 0 }; PIO_STACK_LOCATION irpStack = NULL; PVMF_BUS_INTERFACE bus_interface; pvmf_device = IoGetAttachedDeviceReference(PDevObj); irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, pvmf_device, NULL, 0, 0, &event, &ioStatus); if (irp == NULL) { goto cleanup; } irp->IoStatus.Status = STATUS_NOT_SUPPORTED; irp->IoStatus.Information = 0; irpStack = IoGetNextIrpStackLocation(irp); irpStack->MinorFunction = IRP_MN_QUERY_INTERFACE; irpStack->Parameters.QueryInterface.InterfaceType = (LPGUID)&GUID_SEL_PVMF_BUS_INTERFACE; irpStack->Parameters.QueryInterface.Size = sizeof(PVMF_BUS_INTERFACE); irpStack->Parameters.QueryInterface.Version = SEL_PVMF_BUS_INTERFACE_VERSION; irpStack->Parameters.QueryInterface.Interface = (PINTERFACE)&bus_interface; irpStack->Parameters.QueryInterface.InterfaceSpecificData = NULL; status = IoCallDriver(pvmf_device, irp); if (status == STATUS_PENDING) { KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); status = ioStatus.Status; } if (!NT_SUCCESS(status)) { goto cleanup; } cleanup: ObDereferenceObject(pvmf_device); return status; } Thanks! Ryan --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fshowlists.cfm%3Flist%3Dntdev&amp;data=3D02%7C01%7CDoron.Holan%40microsoft.com %7C3d64170fcaeb4b56c1a208d601767f91%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C 636698005802472949&amp;sdata=3DkzUdbi5vZ%2ByLW5GfoO57c0h7S4IZ4cV5eaqTz3SYPRU%3D&a mp;reserved=0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fse minars&amp;data=02%7C01%7CDoron.Holan%40microsoft.com%7C3d64170fcaeb4b56c1a208d60 1767f91%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636698005802472949&amp;sdata =zFrj4jY9cDQ5kBn7m9pUi7jdOzGrkq%2B9K4PCFkWR6cA%3D&amp;reserved=0> To unsubscribe, visit the List Server section of OSR Online at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fpage.cfm%3Fname%3DListServer&amp;data=02%7C01%7CDoron.Holan%40microsoft.com%7 C3d64170fcaeb4b56c1a208d601767f91%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63 6698005802472949&amp;sdata=2aivjjwIAPf1uld6QiH6yKKoDS667aCRT952uW3wJwo%3D&amp;res erved=0> --
  Message 3 of 6  
14 Aug 18 12:12
Ryan Clements
xxxxxx@selinc.com
Join Date: 13 Aug 2018
Posts To This List: 3
Help Using the driver INTERFACE

Thanks Doron, The WDM driver is definitely a PnP driver. Using the output from the IoAttachDeviceToDeviceStack call makes complete sense. I have updated the function to use the attached device for my generate the IRP, but I am still receiving a STATUS_NOT_SUPPORTED from the IoCallDriver call. I hooked the debugger up and ran !devstack <device object> as you suggested, I received the following output: 6: kd> !devstack 0xffff8000`eb8e8690 !DevObj !DrvObj !DevExt ObjectName ffff8000ec080bd0 \Driver\Serenum ffff8000ec080d20 ffff8000eb993070 \Driver\SEL_Serial_Instffff8000eb9931c0 SELSerial0 > ffff8000eb8e8690 \Driver\PnpManager 00000000 00000052 !DevNode ffff8000eaf525b0 : DeviceInst is "ROOT\PORTS\0000" ServiceName is "SEL_Serial_Inst" I was expecting to see the bus driver that I had written as the next device below my SEL_Serial_Inst driver, but instead I see the PnpManager device. It's possible i'm misunderstanding how the driver stack works here. I guess I see two paths ways of going forward here... If its weird that I'm not seeing my bus driver underneath the WDM serial driver on the stack then, I can chase the reasoning for that. Otherwise, if it's normal to see the PnpManager there, then it's seems likely that my interface is not set up correctly and I should pursue that.
  Message 4 of 6  
14 Aug 18 16:10
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10238
Help Using the driver INTERFACE

How did you install the driver? Looks like devcon install. This will create a root enumerated device not connected to your bus. You need to use devcon update or use device manager and update driver on the bus enumerated child device. Bent from my phone --
  Message 5 of 6  
14 Aug 18 17:05
Ryan Clements
xxxxxx@selinc.com
Join Date: 13 Aug 2018
Posts To This List: 3
Help Using the driver INTERFACE

Yep, that was it. Looks like the Visual Studio deployment system bit me there. My bus driver now shows up in the stack when I use !devstack and I can retrieve the interface. Thanks so much for your help!
  Message 6 of 6  
15 Aug 18 10:18
Mark Roddy
xxxxxx@gmail.com
Join Date: 25 Feb 2000
Posts To This List: 4104
Help Using the driver INTERFACE

I never use the VS deployment system. I prefer knowing what just happened. Mark Roddy On Tue, Aug 14, 2018 at 5:05 PM xxxxx@selinc.com < xxxxx@lists.osr.com> wrote: > Yep, that was it. Looks like the Visual Studio deployment system bit me > there. > > My bus driver now shows up in the stack when I use !devstack and I can > retrieve the interface. > > Thanks so much for your help! > > --- > NTDEV is sponsored by OSR <...excess quoted lines suppressed...> --
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 18:44.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license