A requirement of the project I'm working on is being able to plug the 3rd party functionality into my app while it is already running. These libraries will be provided by other colleagues in my team. I came up with the following :
typedef Foo*(*Creater)();
Creater createFn = resolveSomeHow(dllName, "create");
Foo* pFoo = createFn();
As a consequence, every library developer has to define a Foo* create()
function:
class Bar : public Foo {
}
extern "C" __declspec(dllexport) Foo* create() {
return new Bar();
}
The problem is, after the deployment, someone with bad attitude can create a DLL with Foo* create()
function which returns a Foo instance with malicious code. How can I prevent this ?
I'm looking for a solution which doesn't require me to depend on an encryption library or something like that. I'm aware that nothing can stop someone who is determined enough but just want it to be not that easy.