Crash on DLL function call
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.
The source for your DLL lacks a DLL_Main.
-----------------------------
Valkyrias: Tears of Valkyries
-----------------------------
Valkyrias: Tears of Valkyries
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
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
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement