ISOUSB + FILE_FLAG_OVERLAPPED. Does it work?
- From: "greg1x" <greg1x@xxxxxxxxx>
- Date: Tue, 14 Mar 2006 09:49:43 +0100
Hi!
Do I have to modify the ISOUSB (WinXP DDK) sample to make it work properly
with overlapped I/O?
I got it work well with blocking I/O, but not with overlapped I/O. I was
somehow instable.
Before I get into heavy driver debugging, I'd like to ask some experienced
people if it should work this way:
I've changed a few things in my well working stable code to avoid blocking
of its write() function.
I've changed my CreateFile call to:
CreateFile(devnames[dev_id],
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
/*0*/ FILE_FLAG_OVERLAPPED, // (adding FILE_FLAG_NO_BUFFERING
didn't help me out)
NULL);
//Global variables:
OVERLAPPED m_osWrite[1024];
int overlap_index = 0;
...
...
//the write function looks something like this:
void write(...............)
{
ZeroMemory(&(m_osWrite[overlap_index]), sizeof(m_osWrite[overlap_index]));
m_osWrite[overlap_index].hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
WriteFile(filehandles[dev_id],
writebuffs[dev_id],
buffsize*4,
/*&nBytesWrite*/ NULL, // leaving &nBytesWrite here didn't change
anything
/*NULL*/ &(m_osWrite[overlap_index]))
overlap_index++;
if (overlap_index>=1024)
overlap_index = 0;
}
The reason for the global overlap_index and the plenty of global OVERLAPPED
structs is that the DDK doc states out that the OVERLAPPED stuct must not
run out of scope and it has to be valid until the I/O has been completed.
Now, if I call write() like this:
int a;
for (a=0;a<100;a++)
write(.............);
...it should work, I think (overlap_index didn't spin around, so every
WriteFile got its own overlapped struct).
The first 100 OVERLAPPED structs will be used and they will remain always
valid, since they are simple gobal variables.
I don't need a completion routine, so I'm not using WriteFileEx.
Should the ISOUSB example work with this code, or do I have to modify
something?
(it works well without overlapped I/O)
Thanks,
greg1x
.
- Follow-Ups:
- Re: ISOUSB + FILE_FLAG_OVERLAPPED. Does it work?
- From: Vetzak
- Re: ISOUSB + FILE_FLAG_OVERLAPPED. Does it work?
- Prev by Date: Re: How can I use MMX instructions on amd64 processors?
- Next by Date: Re: Windows XP Checked Build on AMD64 X2?
- Previous by thread: NDIS filter driver crash during bootup
- Next by thread: Re: ISOUSB + FILE_FLAG_OVERLAPPED. Does it work?
- Index(es):
Relevant Pages
|