Pointers and Dlls

Started by
6 comments, last by ShadowMaster 21 years, 4 months ago
I've written an OpenGl "engine" for my game, which is loaded in runtime without the use of a .lib file.. My game aslo uses Dll's, loaded the same way, for "Mods" The pipeline is a pointer class which is taken from the Render dll and then put to the mods to use.. c_Pipe * pipe = 0; GetClass(pipe); //void GetClass( c_Pipe ** my_pipe); StartMod(&pipe); //void StartMod( c_Pipe ** my_pipe); It all works fine untill I exit my Mod.. after that any time I try to use my render class I get an Unhandeled Exeption : "Access Error"... how do I use these pointers so that this does not happen?? Thanks.. -Shadow http://nap.mega.net.kg [edited by - shadowmaster on December 4, 2002 11:45:17 PM]
Home: EvilEntities ;)
Advertisement
umm damb... I've done a sort of "work around" but as I think the problem is a simple pointer misuse, I'd realy like to know where I went wrong.. If I did not explain properly please tell me and I'll give it another go..

-Shadow


http://nap.mega.net.kg



[edited by - shadowmaster on December 6, 2002 10:18:06 AM]
Home: EvilEntities ;)
I dont particular have the answer you need, but try visiting:

http://www.flipcode.com/tutorials/tut_dll01.shtml

It contains a very good / basic explanation of how to create and load dll files properly which should hopefully solve your problem.

Hope this helps, Kiel.
Thanks, I''ve seen this tutorial before.. It''s one of the ones I learned from.. Thanks any way..

-Shadow
Home: EvilEntities ;)
sounds like you''re using the mod after you''ve unloaded it. use the call stack and see which part of your code causes the access violation.
Just wondering. Are the dlls being loaded into the exe process, or being run as a seperate processes? If they are seperate then all data/info inside the dll has its own virtual memory location, which can actually have the same addresses as the exe (or most often not). The point is, if its not part of the exe process you can run into all sorts of address translation problems.

If you use LoadLibrary() this is should load your dll into your calling process. And are you loading the render.dll in the mod? You should load all dll''s from the exe (since this is the main calling process).

If you are not manually loading in the dll, then it is pretty likely the dll''s are not running in the exe thread and is the cause of your problems.

Hope this all helps. Check out LoadLibrary() on msdn for more info.
dlls don't own memory, processes do. dlls can't be run, only executables can.

each process gets its own copy of every dll it loads in its own address space.

no module (exe/dll) can have the same base address as any other module in any given process.

all resources allocated by a process, such as a loaded dll, belong to that process.

you don't have to load dlls from exes. where did you get this idea from?

he said he was loading dll explicitly at runtime.

conclusion: none of what you said has any use.

[edited by - niyaw on December 7, 2002 7:28:37 AM]
Well my render classes are loaded from the render.dll, called from the main Exe, and are used in the exe and a when running the mod, are sent to the mod.. the problem is, i think, that when I unload the mod''s dll.. it clears my render classes in the exe.. if my render classes are NULL then when I use them the error comes up..
Like I said I made a work around, by creating a nother class specialy for using in the Mods, wich calls the render funtions from it, rather than giving direct access to the mod..

will look at LoadLibrary() on msdn tho, that should be worth a look any way..

Thanks!
-Shadow



http://nap.mega.net.kg

Home: EvilEntities ;)

This topic is closed to new replies.

Advertisement