And also while OP is skipping percent characters, the code needs to check
for the end of buffer.
"HMS Surprise" <john@datavoiceint.com> wrote in message
news:1173793517.220687.95970@t69g2000cwt.googlegroups.com...
Specifically, we need to know if you're using overlapped I/O, completion
routines, anything like that.
Thanks for posting. Here's a rough example of the code, as you can see
it uses overlapped reads and WaitForSingleObject.
Since you are using a local variable as a buffer, you must not allow the
function to exit while the operation is pending. Cancellation is also
unreliable, and I think that's what is going wrong. You issue a request
and wait for it, that's fine, the buffer is still valid. But when you
timeout, you exit your function, allowing the stack space occupied by the
buffer to be reused. You may have issued a cancellation request, but that
doesn't prevent the operation from using the buffer after CancelIo
returns. Only when the event is triggered, can you be sure that the
kernel is done using your buffer.