Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

vbisme

Crash on DLL function call

This topic is 5908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Hehehe, I found the problem before I read the post and it''s exactly what you said AlanKemp. Thanks a lot everyone.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!