Skip to main content
gamedev.net
🔒 Locked

LoadLibrary from Memory?

Started by jitspoe Apr 26, 2006 at 7:38 PM 5 replies 3.4k views
Original Post
jitspoe
jitspoe
Is it possible to load a dynamically generated DLL directly from memory, or would I have to first write it to disk and then load it?
Catafriggm
Catafriggm
There is no way to do this through any documented API. You might be able to find some internal Windows function that does this, or you could write your own loader for loading from memory.
rmsimpson
rmsimpson
Writing your own loader is a daunting task. You'll have to memory map the file, read the NT headers, stitch together the imported DLL references, fixup any relocations, and lots and lots of stuff.

It would be really cool to be able to do this, though.

Robert
taby
taby
jitspoe, your write/load method would work. It's how the PHP/OpenGL sample app did it a couple of years ago I think.
Adam Hamilton
Adam Hamilton
You could write a dummy dll file with lots off methods. In these methods you could have a bunch of NOP instructions.

I don't know about loading the dll from memory but at least you will be able to dynamically write code and reload the dll into memory. You just make a call to your dummy method an away you go.

Ignore: Sort of like self-modifying code but not in a handy sort of way.

Edit: Sort of like self-modifying code but in a handy sort of way.

[Edited by - Adam Hamilton on April 28, 2006 1:02:44 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.