Something like this won't work - DllFunction is in dll that is reloaded, pass sizeof(void*) memory to it from main executable:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | struct Base
{
void nonvirtual() {}
virtual void run() = 0;
};
struct Derived : Base
{
void run() {}
};
void DllFunction(void* memory)
{
Base** obj = (Base**)memory;
// first time create new object
if (!*obj) *obj = new Derived();
// this will work always, regardless of dll reloads
(*obj)->nonvirtual();
// this will work until dll is reloaded
(*obj)->run();
}
|