Subject: RE: DLL musings
From: [email-masked] (Michael Pymm)

13 Jan 1998 17:50:59 -0800
Message-ID: <01BD1FB4.71E2B860.cygnus.gnu-win32@cerebus>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
To: "[email-masked]'" <[email-masked]>

Further to my last post, I've got a partial solution, although it's a little urgh.
(this is only for the glide2x.dll, a library to use the 3Dfx card - I've got other
3rd party dlls to work using the SOP).

Say there's a function (void)grGlideInit(void) in the DLL. My code looks like

void (*pgrGlideInit)(void);

void LoadFuncs(void) {
	HINSTANCE m;
	FARPROC f;

	m = LoadLibrary(<path to glide2x.dll>);
	f = GetProcAddress(m, "_grGlideInit@0"); pgrGlideInit = (void (*)()) f;
	
	return;
}

int main(void) {
	LoadFuncs();

	(*pgrGlideInit)();

	return(0);
}

This works! The function LoadFuncs is quite easy to generate from a .def
file, as long as all the DLL functions return void.

I suppose a c preprocessor could be used to extract function definitions
from the glide.h file and construct the (*p<funcname>) stuff at the top and
do proper casting in the LoadFuncs procedure (any ideas?)

dlltool probably creates a library that provides wrapper functions with the
same name as the DLL functions that simply call what I've called (*p<funcname>).

Obviously, my approach is very unportable but I suppose is slightly faster
as it doesn't use a wrapper function.

The question is that if the above works, why does dlltool and ld produce
an executable that Win95 OSR2 says is in the wrong format?

Michael

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".