Thanks very much Nick Ryan.
I set the DO_DIRECT_IO flag, and it worked as expected !!
Continuing further, is there any sample code that accomplishes something
like this.
Register an IRQ service for serial port IRQ number. This registered
function should be called whenever an interrupt occurs on the serial
port. (ex:On DCD high/low,)
What are the APIs required to be called to accompish these ?
Thanx in advance
Kiran
-----Original Message-----
From: Nick Ryan [mailto:xxxxx@nryan.com]
Sent: Tuesday, August 19, 2003 10:41 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: ReadIRP crash…
You are assuming pIrp->MdlAddress is valid. This is only the case if
your device has the DO_DIRECT_IO flag set.
Kiran wrote:
Hi
I am not doubting RtlCopyBytes, but the
“RtlCopyMemory(currentAddress,
pool, 1);” statement few lines later. That is becoz when I comment the
“RtlCopyMemory” the driver code does not crash.
So the moral => the pointer currentAddress is not ok. (may be
pointing
to some illegal mem location)
But the coorect way of getting pointer to user space memory, where I
need
to copy some data from my driver, is to call
“MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);”
Infact I have simplified the driver code for Read dispacth as
static NTSTATUS STDCALL
kiran_dispatch_read(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
PUCHAR currentAddress;
PIO_STACK_LOCATION irpStack;
char c = ‘z’;
irpStack = IoGetCurrentIrpStackLocation(Irp);
currentAddress = MmGetSystemAddressForMdlSafe(Irp->MdlAddress,
NormalPagePriority);
RtlCopyMemory(currentAddress, &c, 1);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
Now this code “crashes” when I call in my app code
char buf;
DWORD len;
ReadFile(handle, &buf, 1, &len, NULL);
However if I comment out the “RtlCopyMemory(currentAddress, &c, 1)”
then it does not crash. So I assume that currentAddress pointer is
illegal.
Can someone please tell me is there any API that I have to use in
addition.
Something like “convert to virtual address, or physical address”, etc,
etc
Thanx
Kiran
–
Nick Ryan (MVP for DDK)
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@wipro.com
To unsubscribe send a blank email to xxxxx@lists.osr.com