Problem going from .o -> .dll
Dave Hooper
dave@rebuzz.org
Mon Jan 13 03:04:00 GMT 2003
> $ ./driver.exe
> EOF
> g(smiley face)Err: Close failed
This is not a forum for debugging other peoples' code, but ...
1. You are using HANDLE * instead of HANDLE
2. Your logic for nul termination is totally wrong:
c->buffer[nBytesRead + 1] = '\0';
should be
c->buffer[nBytesRead] = '\0';
(think about why)
3. Your logic for detecting End Of File also looks wrong - Quote from
msdn.microsoft.com: "The ReadFile code to check for the end-of-file
condition (eof) differs for synchronous and asynchronous read operations.
When a synchronous read operation reaches the end of a file, ReadFile
returns TRUE and sets *lpNumberOfBytesRead to zero".
4. I would also personally check that CreateFile isn't returning NULL (as
well as your current test for INVALID_HANDLE_VALUE) as that will also
indicate an error. I also habitually set nBytesRead=0 before calling
ReadFile although I cannot honestly tell you if that will make a
difference.
Try that little lot and see what happens. At the worst it will let you
diagnose any real error correctly.
d
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list