PDA

View Full Version : QPluginloader load plugin from RAM



meCHAoT
1st February 2011, 10:34
Hi,

I have an application that supports plugins via QPluginLoader and everything's working fine. Now I would like to load a Plugin from some memory location (e.g. char* or QByteArray) instead of loading it directly from a file denoted by its filename.

The background is as follows: I would like to encrypt the myplugin.dll file (say to encryptedplugin.cdll) and then load all file content to some memory location, do a raw byte decryption and then pass the decrypted content to the QPluginLoader:

pseudocode:
char* encryptedcode = LoadFile(encryptedplugin.cdll)
char* code = decryptCode(encryptedcode, key) //provided separately
QPluginLoader loader
loader.loadFromRAM(code)
....

Is there any possibility to do that? (PS: I don't want to create a decrypted temporary dll-file on the file system)

high_flyer
1st February 2011, 12:41
I think you will need some RAM disk utility to which you can in runtime create your decrypted DLL, then load it from there.
If this is considered by your requirements as not secure, I think you will have to implement such RAM disk functionality by your self, which you then can contain in your executable.
But would explore throughly the options of available RAM disk utilities/libs, or similar solutions.

Another way would be to take the original code for QLibrary (on which QPluginLoader is based) and and change it to take your binary content.

Not trivial.

wysota
1st February 2011, 12:57
There is no security here anyway so I don't really see why to do all that in the first place. If you keep a decrypted image of the library in memory, one can just dump this block of memory to the disk to have a decrypted version of the dll. Besides, this is more an OS-level issue than a Qt one.

meCHAoT
3rd February 2011, 17:23
Maybe you're right and the gain of security is minimal... so it's probably not worth the effort...

Thanks anyway!