So, I’ve read and re-read the documentation pertaining to Overlapped I/O operation for IOCTL requests here:
http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx
And, even though I see the statement:
“Return Value
If the operation completes successfully, the return value is nonzero.
If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.”
I’m not clear on how I handle errors returned from an overlapped DeviceIoControl() call. It looks like I get a ‘0’ back for a successful overlapped call, which typically means fail for non-overlapped operation. Is this basically telling me the call is ‘pending’, since it’s waiting for my driver to ‘singal’ the handle associated w/ the overlapped call?
If my overlapped DeviceIoControl() call fails because of whatever reason (bad handle or something), what is the return code?
I just want to ensure that I handle the return code properly.
Here’s an excerpt of my code using the inverted call method:
Board::Board()
{
…
handle_ = CreateFile(DEV_NAME,
access, share, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
…
}
void BoardImpl::signalAtTimeCode(VideoTimeCode vtc, HANDLE h)
{
ULONG nbytes;
TimeCodeSignalParams tcsp;
// We do this so that we can associate the even handle, h, with
// this IOCTL request. The driver will pend the irp, and signal
// the handle when the proper VITC comes around.
OVERLAPPED overlapped;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = h;
tcsp.handle = handle_;
tcsp.eventHandle = h;
tcsp.signalTime.hour = vtc.hour;
tcsp.signalTime.minute = vtc.minute;
tcsp.signalTime.second = vtc.second;
tcsp.signalTime.frame = vtc.frame;
// This will return immediately…
ULONG rc = DeviceIoControl(
handle_, IOCTL_TSII_BOARD_SIGNAL_AT_TIMECODE,
&tcsp, sizeof(tcsp), NULL, NULL, &nbytes, &overlapped);
// How do I handle this???
if (rc == 0)
{
if (GetLastError() == ???)
{
throw Exception(“overlapped i/o exception\n”);
}
}
}
Thanks guys!
Jason