Handmade Hero»Forums»Code
ambiguous panda
11 posts
proxy dll
Edited by ambiguous panda on
day 21 was alot of fun, is there a name for recompiling at runtime?

i asked the following question on the stream but i didn’t understand, i asked if someone can now use a dummy or “proxy” dll between handmade.exe and handmade.dll to intercept the GameUpdateAndRender function to get a pointer to the game_memory struct it passes.

i have see this used to intercept d3d calls and draw on screen menus, the handmade.dll has a pointer to the game state and the off screen buffer, all in one place.

call chain would look like this:
handmade.exe > handmade.dll(proxy) > handmade_original.dll(real dll)


1
2
3
4
5
6
7
8
BOOL WINAPI DllMaind(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
    if (reason == DLL_PROCESS_ATTACH)
    {
        HMODULE originalHandmadeDll = LoadLibrary(".\\handmade_original.dll");
        GAMEUPDATEANDRENDER GameUpdateAndRender = (GAMEUPDATEANDRENDER)GetProcAddress(originalHandmadeDll, "GameUpdateAndRender");
    }
}
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.
proxy dll
Yes, you should definitely be able to do this. I'm not sure why one would ever need to, since unlike most games, Handmade Hero comes with its own source, so you'd presumably be much better off just building your own full DLL.

- Casey
38 posts
proxy dll
Edited by theinternetftw on Reason: much better link, to the actual code even
This is how things like DSFix work, with the added detail that they override system dlls (directx and friends) by taking advantage of the fact that windows will check for a local copy in the working folder before checking for its own version. That way nobody even has to rename anything: just put a file in the exe folder.
ambiguous panda
11 posts
proxy dll
srry, i was asking the question under the context of security, i was suggesting that this introduces a security hole for closed source commercial games, where recompiling the original code is not an option.
38 posts
proxy dll
I know, I just thought it was worth mentioning.

As for having everything in one file somehow protecting you security-wise, that's just not the case. Almost every "no-cd" crack in the world is a patched binary.