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