Dll and exe memory

Hey!

I have an Dll which get´s an instance of a static member. (a singelton)
And this singelton was initialized in the main exe.
But when i try to acces the singelton in the dll it crashes due to that it points to null.

How do i make it possible for the dll to gain the correct pointer for my singelton?
You need to show your code. Otherwise it is impossible to predict what you have and why it fails.

If the code is too long, create a new project with minimal code that reproduces the problem.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

//in the lib.
class MyClassDLL
{
    public:
static MyClassDLL* mySingeltonPointer;

void Houlabdoula(void);

};

//in the exe

MyClassDLL::mySingeltonPointer = new MyClassDLL();


//in the dll
MyClassDLL::mySingeltonPointer->Houlabdoula(); //<--- this is where the error occurs becus of //that mySingeltonPinter now is null..

Ok, that is something. Now you need to show the flow of the code. Does the line in the exe file run before or after the line in the DLL? I guess I know the answer: The exe line runs AFTER the dll line, but what I'm looking for is really more detail as to where those lines are placed in each project.

So show a bit more.
cant give you the real code or the real projects.
I have to Post psudocode for this.


but the exe is run befor the dll, some parts that are run by the exe is coded in a dll file.

The only thing i´m looking for is a easy way to enable this singelton to access the same memory as the exe.. and not have their own memory.
1
2
3
4
5
6
7
8
9
10
11
int main(Void)
{
 MyClassDLL::mySingeltonPointer = new MyClassDLL();

 MyDllFileStuff->Run(); //in this function 
//MyClassDLL::mySingeltonPointer->Houlabdoula(); this function is called.

return 0; 
}

your dll and exe use different memory, so your singleton should be placed at dll or at separated dll with it own heap.
as I remember this question called: inprocess and outprocess dll's
Last edited on
Topic archived. No new replies allowed.