Hi,
I’m using IRP_MN_QUERY_INTERFACE to get the interface of a pcmcia
device. In my driver, I’m trying to send this Irp to the pcmcia.sys
driver of Windows to get the interface. I don’t get any error, but the
interface that is returned is always empty.
Here is my code (I’m using DriverWorks from Numega, I added the
underlying DDK in comments):
PCMCIA_INTERFACE_STANDARD pis; // Global variable to receive
interface
// This code is in the handler for IRP_MJ_PNP/IRP_MN_START_DEVICE Irp
// Create a LowerDevice for the first pcmcia device (device\pcmcia0)
ULONG Unit = 0;
KUnitizedName uname(L"\device\pcmcia", Unit);
KLowerDevice *pcmciaObj = new (NonPagedPool)
KLowerDevice((PWSTR)uname, FILE_ALL_ACCESS); // IoGetDeviceObjectPointer
// I tried with wrong value of uname like “\device\asdf” and it
failed so
// since it doesn’t fail, I’m supposed to have a valid LowerDevice
handle
if (!pcmciaObj || !NT_SUCCESS(pcmciaObj->ConstructorStatus()))
{
status = STATUS_UNSUCCESSFUL;
return status;
}
// Create the Irp
KIrp Irp = KIrp::Allocate(pcmciaObj->StackRequirement()); //
IoAllocateIrp
if(Irp.IsNull())
{
t << “Irp failed\n”;
return STATUS_INSUFFICIENT_RESOURCES;
}
// Fill the Irp for the request
RtlZeroMemory(&pis, sizeof(PCMCIA_INTERFACE_STANDARD));
ULONG info;
PIO_STACK_LOCATION pStack = Irp.NextStackLocation(); //
IoGetNextIrpStackLocation
pStack->MajorFunction = IRP_MJ_PNP;
pStack->MinorFunction = IRP_MN_QUERY_INTERFACE;
pStack->Parameters.QueryInterface.InterfaceType = (LPGUID)
&GUID_PCMCIA_INTERFACE_STANDARD;
pStack->Parameters.QueryInterface.Size =
sizeof(PCMCIA_INTERFACE_STANDARD);
pStack->Parameters.QueryInterface.Version = 0;
pStack->Parameters.QueryInterface.Interface = (PINTERFACE)(&pis);
pStack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
// Pass the Irp down the stack and wait until it is completed
status = pcmciaObj->CallWaitComplete(Irp, TRUE, &info); //
IoCallDriver
// status is Success, but info (which is IoStatus.Information) is 0,
so no byte is returned from the driver???
KIrp::Deallocate(Irp);
if(NT_SUCCESS(status))
{
// –> Here, pis is empty <–
if((ULONG)pis.SetVpp && pis.Context)
{
(*pis.SetVpp)(pis.Context, PCMCIA_VPP_12V);
t << “Set to 12V!!! \n”;
}
else
{
t << "SetVpp: " << ULONG(pis.SetVpp) << " Context: " <<
(ULONG)pis.Context << “\n”;
}
}
What am I missing?
I verified my code with the Toaster example of DDK,
ToasterGetStandardInterface function, and I don’t know what I am doing
different.
Any help will be appreciated.
Thanks,
Michael
Michael Grimard
Concepteur Logiciel/Software Designer
MAX Technologies