This however creates
1 | UpdateAndRender was 0xFFFFFFFFFFFFFFFF |
I'm trying to accomplish this without using #define macros.
Any ideas or help would be much appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | typedef void (*UpdateAndRender_t)(); struct win32_dll_code { bool32 valid; HMODULE DLL; UpdateAndRender_t *UpdateAndRender; }; static struct win32_dll_code Win32LoadCode(wchar *src_file) { struct win32_dll_code res = {0}; res.DLL = LoadLibraryW(src_file); if (res.DLL) { res.UpdateAndRender = (UpdateAndRender_t *) GetProcAddress(res.DLL, "UpdateAndRender"); if (res.UpdateAndRender) res.valid = TRUE; } if (!res.valid) res.UpdateAndRender = 0; return res; } // ... int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) { struct win32_dll_code game = Win32LoadCode(L"game.dll"); HWND wnd_handle = Win32CreateWindow(hInstance); if (!wnd_handle) return -1; while (Running) { ProcessMessages(); if (game.valid) (*game.UpdateAndRender)(); // Crash is here } return 0; } |
The function UpdateAndRender is shown as been exported by dumpbin and is just a quick test:
1 2 3 4 | void UpdateAndRender() { // Lots of output debugs not being triggered } |