Handmade Hero»Forums»Code
Özgür Cerlet
1 posts
Hot loading a DLL from memory
I'm wondering if we can "load" a dll while its still in the memory(after compilation) so that we can do our hot-loading without the disk access?
Mārtiņš Možeiko
2562 posts / 2 projects
Hot loading a DLL from memory
Yes, you can do it. But as explained on stream, you will loose ability to debug source code - debugger will have no information about this virtual "dll file". Of course you will still have ability to debug machine code (assembly).

For example code see this library: https://github.com/fancycode/MemoryModule It is very small and easy to understand. It basically provides similar functions to "LoadLibrary" and "GetProcAddress" to operate on dll file in memory.

Here's the description how it works: http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/
ambiguous panda
11 posts
Hot loading a DLL from memory
Edited by ambiguous panda on
can we use LoadLibrary on the first load, then overwrite its memory with the new recompiled dlls, then call ReBaseImage to fix the debugging information.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Hot loading a DLL from memory
It is unlikely there will be a disk access anyway. Since the compiler just wrote it, it's probably in the Windows IO cache.

- Casey