Hi!
I have what i guess is a simple problem when i know the solution…
I want to make a driver that takes an IRP and just “forwards” it to the serial port. (for now that would be enough to make me happy…)
My code…
Opening the serial port:
<…>
RtlInitUnicodeString(&com_port, L"\Device\Serial0");
status = IoGetDeviceObjectPointer( &com_port,
FILE_ALL_ACCESS,
&DeviceExtension->lowerFilObject,
&DeviceExtension->lowerDeviceObject);
<…>
lowerDevice = IoAttachDeviceToDeviceStack(DeviceObject,DeviceExtension->lowerDeviceObject);
<…>
DeviceExtension->lowerDeviceObject = lowerDevice;
<…>
With portmon I can see that this sends a “IRP_MJ_CREATE” to COM1.
My DispatchWrite:
NTSTATUS DispatchWrite(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
{
PDEVICE_EXTENTION MyDeviceExtension;MyDeviceExtension = DeviceObject->DeviceExtension;
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(MyDeviceExtension->lowerDeviceObject,Irp);
}
I immidiatly get a BSOD when I try to write from my user space app:
hCOM=CreateFile(L"\\.\ABC0",GENERIC_WRITE | GENERIC_READ,0,NULL,OPEN_EXISTING,NULL,NULL);
wchar_t *data = L"ABCDEFGHIJ";
ULONG noofbytes;
WriteFile(hCOM,(LPCVOID)data,10,&noofbytes,NULL);
CloseHandle(hCOM);
The BSOD happens sometime after I call IoCallDriver and is caused by Page fault.
Why cant I use the “forward and forget” that everyone writes about in their examples?
With Regards
Mats Soderhall
###########################################
This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/