This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: Problem going from .o -> .dll
- From: "Dave Hooper" <dave at rebuzz dot org>
- To: "Travis Whitton" <whitton at atlantic dot net>
- Cc: cygwin at cygwin dot com
- Date: Wed, 8 Jan 2003 17:52:17 -0000 (GMT)
- Subject: Re: Problem going from .o -> .dll
- References: <20030108162949.GA16269@grub.ath.cx>
> $ ./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/