Skip to content

Commit

Permalink
adding_MinGW_support_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanKrMahato committed Nov 24, 2024
1 parent 433e310 commit d97f393
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions source/detours/funchook_detour/scripts/download.bat.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 17 additions & 1 deletion source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,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;

Expand Down
7 changes: 6 additions & 1 deletion source/dynlink/source/dynlink_impl_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit d97f393

Please sign in to comment.