IRP_MN_QUERY_INTERFACE problem

Hi,
I’m need to be able to read/write PCI config regs of multiple PCI devices in my driver. To get our validation driver working on Vista I managed to port it into a PCI bus filter driver which is working. The IRP_MN_QUERY_INTERFACE call to the lower bus driver (pci.sys) however is returning STATUS_NOT_SUPPORTED. This piece of code looks almost the same as what is posted in MS KB Q253232.

VOID SvAccessQueryBusInterface( IN PDEVICE_OBJECT DeviceObject ) {
PCONTROL_DEVICE_EXTENSION deviceExtension;
IO_STATUS_BLOCK ioStatus;
NTSTATUS status;
KEVENT kevent;
PIRP pIrp;
PIO_STACK_LOCATION pIrpSp;
PDEVICE_OBJECT targetObject;

deviceExtension = (PCONTROL_DEVICE_EXTENSION)ControlDeviceObject->DeviceExtension;

targetObject = IoGetAttachedDeviceReference( DeviceObject );

//
// initialize the kernel event to block on
KeInitializeEvent( &kevent, NotificationEvent, FALSE );

// build the IRP
pIrp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, targetObject,
NULL, 0, NULL, &kevent, &ioStatus );
if( !pIrp )
return;

pIrp->RequestorMode = KernelMode;
pIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
pIrp->IoStatus.Information = 0;

// get next stack location
pIrpSp = IoGetNextIrpStackLocation( pIrp );

// use QUERY_INTERFACE to get address of direct call ACPI interface
pIrpSp->MajorFunction = IRP_MJ_PNP;
pIrpSp->MinorFunction = IRP_MN_QUERY_INTERFACE;
pIrpSp->Parameters.QueryInterface.InterfaceType = (LPGUID) &GUID_BUS_INTERFACE_STANDARD;
pIrpSp->Parameters.QueryInterface.Version = 1;
pIrpSp->Parameters.QueryInterface.Size = sizeof( BUS_INTERFACE_STANDARD );
pIrpSp->Parameters.QueryInterface.Interface = (PINTERFACE)&deviceExtension->busInterface;
pIrpSp->Parameters.QueryInterface.InterfaceSpecificData = NULL;

// send the request to lower driver
status = IoCallDriver( targetObject, pIrp );
if( status == STATUS_PENDING ) {
KeWaitForSingleObject( &kevent, Executive, KernelMode, FALSE, NULL );
status = ioStatus.Status;
}

if( NT_SUCCESS(status) ) {
deviceExtension->bBusInterfaceInitialized = TRUE;
}
else
{
KdPrint( (“Query interface failed, Status = %x\n”, status ) );
}
}

Isn’t this call valid from a PCI upper filter driver?

Regards,
Uday

Are you sure you are sending it to a PCI enumerated stack? What is the outout of !devstack ?

d

Is this working on releases prior to vista?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@intel.com
Sent: Wednesday, January 17, 2007 10:11 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRP_MN_QUERY_INTERFACE problem

Hi,
I’m need to be able to read/write PCI config regs of multiple PCI
devices in my driver. To get our validation driver working on Vista I
managed to port it into a PCI bus filter driver which is working. The
IRP_MN_QUERY_INTERFACE call to the lower bus driver (pci.sys) however is
returning STATUS_NOT_SUPPORTED. This piece of code looks almost the same
as what is posted in MS KB Q253232.

VOID SvAccessQueryBusInterface( IN PDEVICE_OBJECT DeviceObject ) {
PCONTROL_DEVICE_EXTENSION deviceExtension;
IO_STATUS_BLOCK ioStatus;
NTSTATUS status;
KEVENT kevent;
PIRP pIrp;
PIO_STACK_LOCATION pIrpSp;
PDEVICE_OBJECT targetObject;

deviceExtension =
(PCONTROL_DEVICE_EXTENSION)ControlDeviceObject->DeviceExtension;

targetObject = IoGetAttachedDeviceReference( DeviceObject );

//
// initialize the kernel event to block on
KeInitializeEvent( &kevent, NotificationEvent, FALSE );

// build the IRP
pIrp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, targetObject,
NULL, 0, NULL, &kevent, &ioStatus );
if( !pIrp )
return;

pIrp->RequestorMode = KernelMode;
pIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
pIrp->IoStatus.Information = 0;

// get next stack location
pIrpSp = IoGetNextIrpStackLocation( pIrp );

// use QUERY_INTERFACE to get address of direct call ACPI interface
pIrpSp->MajorFunction =
IRP_MJ_PNP;
pIrpSp->MinorFunction =
IRP_MN_QUERY_INTERFACE;
pIrpSp->Parameters.QueryInterface.InterfaceType = (LPGUID)
&GUID_BUS_INTERFACE_STANDARD;
pIrpSp->Parameters.QueryInterface.Version = 1;
pIrpSp->Parameters.QueryInterface.Size = sizeof(
BUS_INTERFACE_STANDARD );
pIrpSp->Parameters.QueryInterface.Interface =
(PINTERFACE)&deviceExtension->busInterface;
pIrpSp->Parameters.QueryInterface.InterfaceSpecificData = NULL;

// send the request to lower driver
status = IoCallDriver( targetObject, pIrp );
if( status == STATUS_PENDING ) {
KeWaitForSingleObject( &kevent, Executive, KernelMode, FALSE,
NULL );
status = ioStatus.Status;
}

if( NT_SUCCESS(status) ) {
deviceExtension->bBusInterfaceInitialized = TRUE;
}
else
{
KdPrint( (“Query interface failed, Status = %x\n”, status ) );
}
}

Isn’t this call valid from a PCI upper filter driver?

Regards,
Uday


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I remember checking !devstack and the stack looked like (not the exact output,i’m remote logged in right now and can’t copy paste).

\SvAccess
\PCI
\ACPI

Device manager shows up SvAccess instead of the usual PCI.sys driver under the system devices.

The code I posted above BSODs. The proper (non BSOD, non working code) has the IoGetAttachedDeviceReference removed and replaced by proper device object.

I’ve not checked it on Vista yet, debugging for XP target right now.

Any tips on what to check for next?

I will try writing a function driver for the MCH (bus 0, dev 0, fn 0) and then try query the underlying PCI driver. I guess that is the proper way for me.

Regards,
Uday