Yes, i have changed from using rtl routines into using hal routine. I compile the test application that call the readfile&writefile using WDK and using Visual Studio. The exe file that is compiled from WDK gives the correct result, for example if i write 60, it will read 60 also. But if i run the exe file compilation code of Visula Studio, it gives the wrong result. So whathever i write, when it reads the value is 52428. I don’t why, in fact, it is the same code.
?
And, about the bsod, it is IRQL_NOT_LESS_OR_EQUAL. Do i have to add PAGED_CODE() inside the function of DispatchRead or DispatchWrite to make sure that the IRQL is below Dispatch_Level?
Thanks
?
Regards
Sofian
— On Wed, 9/16/09, Mark Roddy wrote:
From: Mark Roddy
Subject: Re: [ntdev] dispatch write buffered method
To: “Windows System Software Devs Interest List”
Date: Wednesday, September 16, 2009, 1:16 PM
So that implies that your read routine is wrong.
Mark Roddy
On Wed, Sep 16, 2009 at 12:58 PM, sahrizal sofian wrote:
If i debug with windbg, it gives me bsod, which is the line to ioRealeaseRemoveLock. I don’t know why, so temporary i don’t use lock and it gives no bsod when i debug it.
?
About the wrong result, there is a strange thing. I make a user application that call the driver. The application write and read in the same address. The output after running the program is not the same (wrong). But when i add a code inside the driver to know what the value after writing (using hal routines read_register_ushort), it gives me the right value. I don’t know why…
— On Wed, 9/16/09, Mark Roddy wrote:
From: Mark Roddy
Subject: [ntdev] dispatch write buffered method
To: “Windows System Software Devs Interest List”
Date: Wednesday, September 16, 2009, 12:40 PM
Technically you should be using the Hal register buffer routines
instead of rtlcopy, but that is probably not your problem.
When you wrote that it gives you the wrong results, what did you mean?
And, what bsod? Using the debugger should not cause a crash unless you
used it to stomp over stack or memory.
On Wednesday, September 16, 2009, sahrizal sofian
wrote:
> Guys, i am still confuse to write the dispatchwrite/read both buffered and direct io. The example that i see in WDK pcdrv is confusing me. After searching in internet i found one understandable example from code project. So, now i try to implement dispatch write in buffered method first. I already map the?memory of pcicard using mmmapiospace and save it in device extension->regsbase. I want to write in offset of 4200 bytes, and since i am using ushort then i think the offset should be 2100.
> When i run it, it gives me wrong result and when i try to debug it, it makes bsod. Could you please tell me, what is wrong with the code? Thank you.
>
> NTSTATUS DispatchWrite(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
> {
> ??? PVOID???Buf;?//Buffer provided by user program
> ??? ULONG???BufLen; //Buffer length for user provided buffer
> ??? LONGLONG???Offset;?//Buffer Offset
> ??? PVOID???DataBuf; //Buffer provided by Driver
> ??? ULONG???DataLen; //Buffer length for Driver Data Buffer
> ??? ULONG???ByteTransferred = 4;
> ??? PIO_STACK_LOCATION??stack;
> ??? PFDO_DATA???devExt;
> ??? NTSTATUS???status = STATUS_SUCCESS;
>
> ??? //Get I/o Stack Location & Device Extension
> ??? stack?= IoGetCurrentIrpStackLocation(Irp);
> ??? devExt?= (PFDO_DATA)DeviceObject->DeviceExtension;
> ??? //Get User Input Buffer & Length
> ??? BufLen?= stack->Parameters.Write.Length;
> ??? Offset?= stack->Parameters.Read.ByteOffset.QuadPart;
> ??? Buf??= (PUSHORT)(Irp->AssociatedIrp.SystemBuffer) + Offset;
> ??? IoAcquireRemoveLock(&devExt->RmLock, Irp);
> ??? ByteTransferred = BufLen;
> ??? RtlZeroMemory(((USHORT *)devExt->RegsBase) + 2100,ByteTransferred);
> ??? RtlCopyMemory(((USHORT *)devExt->RegsBase) + 2100,Buf,ByteTransferred);
> ??? IoReleaseRemoveLock(&devExt->RmLock, Irp);
>
> ?Irp->IoStatus.Status = status;
> ?Irp->IoStatus.Information = ByteTransferred;
> ?IoCompleteRequest(Irp,IO_NO_INCREMENT);
>
> ??? return status;
> }
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
–
Mark Roddy
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer