How to query interface of pcmcia.sys?

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

Michael,

Without seeing the implementation of CallWaitComplete or your completion
routine, my question is what is the return value from IoCallDriver? If
this status is pending (0x103), then your interface structure is empty
because the pcmcia driver has not completed the IRP.

Dave

Michael Grimard wrote:

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


You are currently subscribed to ntdev as: xxxxx@okena.com
To unsubscribe send a blank email to %%email.unsub%%

Thanks Dave.

I change my code to use the LowerDevice that DriverWorks give me,
instead of creating a new one, and it is working fine now.

Is it possible that, from a driver that is made for a PCI device, to
query the interface of pcmcia.sys? This time, I guess I will need to
create a pointer to the pcmcia device object using
IoGetDeviceObjectPointer, but what should I give as ObjectName
parameter?

Thanks,
Michael

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dave McCowan
Sent: Thursday, October 24, 2002 10:18 AM
To: NT Developers Interest List
Subject: [ntdev] Re: How to query interface of pcmcia.sys?

Michael,

Without seeing the implementation of CallWaitComplete or your
completion
routine, my question is what is the return value from
IoCallDriver? If
this status is pending (0x103), then your interface structure
is empty
because the pcmcia driver has not completed the IRP.

Dave

Michael Grimard wrote:

>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
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@okena.com
>To unsubscribe send a blank email to %%email.unsub%%
>
>
>


You are currently subscribed to ntdev as: xxxxx@maxt.com
To unsubscribe send a blank email to %%email.unsub%%