Is there some compelling reason for not using IoBuildDeviceIoControlRequest?
Also what are you doing with the FileObject returned from
IoGetDeviceObjectPointer?
=====================
Mark Roddy
-----Original Message-----
From: David West [mailto:David.West@cs.tcd.ie]
Sent: Thursday, October 09, 2003 11:48 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem manually creating IRP to submit from one driver
to another
Oh, and one other weird thing I observe about this problem.
After the calling driver calls IoGetDeviceObjectPointer, the driver being
called receives an IRP_MJ_CREATE, followed immediately by an IRP_MJ_CLEANUP.
Only later does it receive the IRP_MJ_INTERNAL_DEVICE_CONTROL after the
calling driver calls IoCallDriver. During processing of this IRP, the
called driver crashes while calling the IoCompleteRequest function.
In the user mode application, I notice the called driver receives the IRPs
in the different order IRP_MJ_CREATE, IRP_MJ_INTERNAL_DEVICE_CONTROL,
IRP_MJ_CLEANUP, IRP_MJ_CLOSE.
Thanks
----- Original Message -----
From: David West
To: Windows System Software Devs Interest List
Sent: Thursday, October 09, 2003 4:40 PM
Subject: [ntdev] Problem manually creating IRP to submit from one driver to
another
Hi,
I'm trying to send a simple IOCTL to a driver from another driver, by
manually creating an IRP and submitting it (Is there another way to do this
from within a driver?). Unfortunately I am getting a BugCheck 7E,
(exception c0000005, indicating a memory access violation), when the driver
that is being called calls the IoComplete request function.
When I test sending the IOCTL with a user mode application, using the
DeviceIoControl function, it executes without any problems.
This is the code I am using, is there any obvious problems/ommisions? Am I
forgetting to initialise some part of the IRP or something? I've been stuck
on this for ages, please help!
ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
status = IoGetDeviceObjectPointer(
&usDeviceName,
FILE_READ_DATA,
&m_pMyFileObject,
&m_pMyDeviceObject
);
if(!NT_SUCCESS(status)){
return STATUS_ERROR;
}
pIrp = IoAllocateIrp(m_pMyDeviceObject->StackSize, FALSE);
if(pIrp == NULL){
return STATUS_INSUFFICIENT_RESOURCES;
}
{
PIO_STACK_LOCATION _IRPSP;
pIrp->AssociatedIrp.SystemBuffer = pBuffer;
IoSetCompletionRoutine(pIrp, NULL, NULL, FALSE, FALSE, FALSE);
_IRPSP = IoGetNextIrpStackLocation(pIrp);
_IRPSP->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
_IRPSP->MinorFunction = 0;
_IRPSP->DeviceObject = m_pMyDeviceObject;
_IRPSP->FileObject = m_pMyFileObject;
_IRPSP->Parameters.DeviceIoControl.IoControlCode = IOCTL_DO_SOMETHING;
_IRPSP->Parameters.DeviceIoControl.InputBufferLength =
sizeof(BUFFER_TYPE);
_IRPSP->Parameters.DeviceIoControl.OutputBufferLength = 0;
_IRPSP->Parameters.DeviceIoControl.Type3InputBuffer = 0;
}
//Go ahead and submit the request
status = IoCallDriver(m_pMyDeviceObject, pIrp);
Thanks,
David
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@tcd.ie
To unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com