Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com Subject: Can open() from console app, not from dll From: Massimiliano Mirra Date: Tue, 01 Apr 2003 22:44:21 +0200 Message-ID: <874r5ine1m.fsf@prism.localnet> User-Agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I am able to open a file and write into it from a console application, but the same fails when done from within a function that is stored in a DLL and called from a Visual Basic application. This is the console app: ,---- | #include | | int main (int argc, char * argv[]) { | int fd; | char *msg = "Hello, world\n"; | | fd = open ("file.txt", O_CREAT | O_RDWR); | if (fd == -1) { | perror ("open()"); | exit (-1); | } | | write (fd, msg, strlen (msg)); | } `---- And this is the source of foo.dll: ,---- | #include | | int WINAPI DllMain (HINSTANCE H, DWORD d, PVOID p) { | return TRUE; | } | | int OpenSomething () { | int fd; | | char *msg = "Hello, world\n"; | | fd = open ("file.txt", O_CREAT | O_RDWR); | if (fd == -1) { | perror ("open()"); | exit (-1); | } | | write (fd, msg, strlen (msg)); | return TRUE; | } `---- The DLL is compiled with (found in the archives): $(LD) --dll --subsystem windows -e _DllMain AT 12 -o jnk --base-file foo.base \ foo.o -L $(LIB)/w32api -luser32 -c $(DLLTOOL) --dllname foo.dll --base-file foo.base --def foo.def --output-lib \ foo.a --output-exp foo.exp $(LD) --dll --subsystem windows -e _DllMain AT 12 -o foo.dll foo.o -L \ $(LIB)/w32api -luser32 -c foo.exp rm jnk foo.base foo.exp When run under Wine, the VB app hangs on the open() and causes this: err:ntdll:RtlpWaitForCriticalSection section 0x610d1ef8 "?" wait timed out, retrying (60 sec) tid=080771f8 When run on a w98 box, it crashes on the open() with an ``Invalid Page Fault'' (sort of, I'm translating from Italian). The console application works just fine both on the box and under Wine. What am I missing? -- 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/