core: load exchndl.dll at runtime

This allows the game to run without exchndl.dll present.
This commit is contained in:
Eidolon 2023-01-04 17:54:22 -06:00
parent 4a7463d134
commit d53efbdace
2 changed files with 16 additions and 15 deletions

View file

@ -310,15 +310,6 @@ if("${SRB2_CONFIG_HWRENDER}")
endif()
endif()
# TODO: build this with the game
if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32)
target_link_libraries(SRB2SDL2 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libexchndl.a"
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libmgwhelp.a"
)
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/include")
endif()
if(${SRB2_CONFIG_USEASM})
#SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm.
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")

View file

@ -71,10 +71,6 @@ char logfilename[1024];
#endif
#endif
#if defined (_WIN32)
#include <exchndl.h>
#endif
#if defined (_WIN32)
extern "C" {
#include "../win32/win_dbg.h"
@ -202,6 +198,20 @@ static void InitLogging(void)
}
#endif
static void init_exchndl()
{
#ifdef _WIN32
HMODULE exchndl_module = LoadLibraryA("exchndl.dll");
if (exchndl_module != NULL)
{
using PFN_ExcHndlInit = void(*)(void);
PFN_ExcHndlInit pfnExcHndlInit = reinterpret_cast<PFN_ExcHndlInit>(
GetProcAddress(exchndl_module, "ExcHndlInit"));
if (pfnExcHndlInit != NULL)
(pfnExcHndlInit)();
}
#endif
}
#ifdef _WIN32
static void
@ -294,7 +304,7 @@ int main(int argc, char **argv)
)
#endif
{
ExcHndlInit();
init_exchndl();
}
}
#ifndef __MINGW32__