Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneau
From: bonneau@hyper.hyper.com (Paul Bonneau)
Subject: Re: HELP! Calling fopen() in DLL
Message-ID: <1991May16.215933.544@hyper.hyper.com>
Reply-To: bonneau@hyper.UUCP (Paul Bonneau,,)
Organization: HyperCube Inc.
References: <394.28314261@cai.com>
Date: Thu, 16 May 1991 21:59:33 GMT

In article <394.28314261@cai.com> dxg@cai.com writes:
>
>First some info: I am using MS-C 6.0a and MS-C 3.0a.
>
>I am calling a function from a .exe that is in a DLL.  This
>function does an fopen() and then returns a FILE *.  Within the DLL
>I am able to fprintf() to the file, but when I try to call
>fprintf() from my .exe it fails, with the following pop up box
>in CodeView: Trap 13 (0DH) - General Protection Fault
>
The problem is that the FILE * is based on the data segment
of the DLL.  When you pass it to the app, it does not
correspond to any stdio buffer of the app.

If you pass it back from the DLL as a FILE FAR *, you will
have to use the large model versions of the stdio routines.
This can mean some mucking around with the lib utility (to
extract the stdio routines into .obj files) if your app's
model is not large.

cheers - Paul Bonneau.
