Crash on DLL function call

Started by
7 comments, last by vbisme 21 years, 7 months ago
I successfully export and import functions from a dll. However, the program crashes whenever I call a function from the dll even if they function doesn''t do anything. Please look at the code from www.digitalextent.com/public/ The reason I don''t post it here is that it is quite different to look at it since it involve dll. Win32App is the dll producing project and Tester is the project used to test the dll. On line 96 of main.cpp in Tester is where I called a test function that doesn''t do anything. The program crashes. If anyone could take a look at this I would appreciate it much. Thanks.
Advertisement
what error message does the debugger throw at you?
The source for your DLL lacks a DLL_Main.

-----------------------------
Valkyrias: Tears of Valkyries
-----------------------------Final Frontier Trader
dll_main ISNT required as VC++ adds it its self if you dont have one
You are calling:

FreeLibrary(hWin32AppDLL);

At the end of your AppInit() function. That is telling windows that you have finished with the dll and that it can take it out of memory. Your function pointer still has a value (the address where the function was before it was unloaded) that address is no longer valid.

In short, dont FreeLibrary(..) untill you have finished with the DLL, that is, at the end of your program (probably in your GameEnd() function, after calling DestroyWindow(..)).

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
The error is:

The instruction at "0x10001028" referenced memory at "0x10001028". The memory could not be "read".

Obviously, there's something wrong while getting the address of the function. But actually, I run Pebrowse(it's a program that read functions from dll) and I check the Win32App.dll and the Test function. Its address is 0x10001028.

Idea?

[edited by - vbisme on September 12, 2002 1:46:58 PM]
See my post above. You are unloading the dll, and then trying to use it.

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
main.cpp LINE 185 remove -it.

MCO
MCO
Hehehe, I found the problem before I read the post and it''s exactly what you said AlanKemp. Thanks a lot everyone.

This topic is closed to new replies.

Advertisement