This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: DLL musings


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
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]