diff --git a/source/detours/funchook_detour/scripts/download.bat.in b/source/detours/funchook_detour/scripts/download.bat.in index 8f1fd3842a..a2702001b5 100755 --- a/source/detours/funchook_detour/scripts/download.bat.in +++ b/source/detours/funchook_detour/scripts/download.bat.in @@ -1,11 +1,11 @@ @echo on rem Download repository if it does not exist -if not exist @FUNCHOOK_SOURCE_DIR@/.git ( - if exist @FUNCHOOK_SOURCE_DIR@ ( +if not exist "@FUNCHOOK_SOURCE_DIR@/.git" ( + if exist "@FUNCHOOK_SOURCE_DIR@" ( rmdir /S /Q "@FUNCHOOK_SOURCE_DIR@" ) - "@GIT_EXECUTABLE@" clone --single-branch --branch v@FUNCHOOK_VERSION@ --recursive https://github.com/kubo/funchook.git @FUNCHOOK_SOURCE_DIR@ + "@GIT_EXECUTABLE@" clone --single-branch --branch v@FUNCHOOK_VERSION@ --recursive https://github.com/kubo/funchook.git "@FUNCHOOK_SOURCE_DIR@" ) rem Write empty CMake file to avoid cmake warnings diff --git a/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h b/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h index 670ece3712..d1c946fc86 100644 --- a/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h +++ b/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h @@ -28,7 +28,8 @@ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif /* -- Definitions -- */ @@ -43,11 +44,27 @@ extern "C" { char name; \ } PREPROCESSOR_CONCAT(dynlink_no_export_, name) -#define DYNLINK_SYMBOL_GET(name) name +#if defined(__MINGW32__) || defined(__MINGW64__) + #define DYNLINK_SYMBOL_GET(name) \ + (((dynlink_symbol_addr_win32)(name))->symbol) +#else + #define DYNLINK_SYMBOL_GET(name) name +#endif /* -- Type definitions -- */ +#if defined(__MINGW32__) || defined(__MINGW64__) +/* MinGW-compatible definition */ +typedef void (*dynlink_symbol_addr_win32_impl)(void); + +typedef struct dynlink_symbol_addr_win32_type +{ + dynlink_symbol_addr_win32_impl symbol; +} *dynlink_symbol_addr_win32; + +#else typedef void (*dynlink_symbol_addr_win32)(void); +#endif typedef dynlink_symbol_addr_win32 dynlink_symbol_addr; diff --git a/source/dynlink/source/dynlink_impl_win32.c b/source/dynlink/source/dynlink_impl_win32.c index 8ea74bb24f..ff0a895336 100644 --- a/source/dynlink/source/dynlink_impl_win32.c +++ b/source/dynlink/source/dynlink_impl_win32.c @@ -76,8 +76,13 @@ int dynlink_impl_interface_symbol_win32(dynlink handle, dynlink_impl impl, dynli (void)handle; +#if defined(__MINGW32__) || defined(__MINGW64__) + // For MinGW, set the symbol member of the struct + (*addr)->symbol = (dynlink_symbol_addr_win32_impl)proc_addr; +#else + // For MSVC or other compilers, cast directly *addr = (dynlink_symbol_addr)proc_addr; - +#endif return (*addr == NULL); }