If you leave the hEvent as NULL, DeviceIoControl (or Read/WriteFor that matter) do *NOT* convert the I/O request to a synchronous operation. They I/O operations are still asynchronous. Leaving the hEvent NULL means that when the i/o complets, the i/o manager will not set an event. If you leave hEvent NULL you must poll for the result of the operation to know when it completes.
d
– I can spell, I just can’t type.
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Monday, July 17, 2006 3:48 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] DeviceIoControl in OVERLAPPED mode always Got ERROR_IO_PENDING?
ERROR_IO_PENDING means what it says, the driver has accepted the ioctl and will complete it some time in the future.
You have two possible approaches here.? You can leave the overlapped hEvent as NULL, in which case DeviceIoControl completes synchronously.? Or if you wish to continue using an event for asynchronous completion, then whenever you receive ERROR_IO_PENDING you need to call WaitForSingleObject for your IoWaiter event to trigger.
See the PSDK samples, there are a few that show both methods.
At 09:34 AM 7/17/2006, Yu Zhou wrote:
Hi Experts,
??? With the same .sys file,DeviceIoControl in normal mode read/write
correctly,while OVERLAPPED mode always Got ERROR_IO_PENDING?
??? Below are console application codes:
hRead = CreateFile(CompleteDeviceName,
??? GENERIC_WRITE|GENERIC_READ,
??? FILE_SHARE_WRITE|FILE_SHARE_READ,
??? NULL,
??? OPEN_EXISTING,
??? FILE_FLAG_OVERLAPPED,
??? NULL);
IoWaiter = CreateEvent(NULL,TRUE,FLASE,NULL);
ol.Offset = 0;
ol.OffsetHigh = 0;
ol.hEvent = IoWaiter;
pinBuf = malloc(8);
poutBuf = malloc(8);
pinBuf[0] = 0x09;
pinBuf[1] = 0x03;
pinBuf[2] = 0x04;
pinBuf[3] = 0x05;
ResetEvent(IoWaiter);
if(!DeviceIoControl(
??? hRead,
??? READ_COUNTER,
??? pinBuf,
??? 8,
??? poutBuf,
??? 8,
??? &nBytesRead,
??? &ol))
{
??? printf(“err %6.6d”\n",GetLastError());
}
Could you advice?
Mp3???-?¸??ȸ??? — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer