Skip to content

Commit

Permalink
adding_MinGW_build_support(formatted)
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanKrMahato committed Nov 24, 2024
1 parent 433e310 commit c4b1a03
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 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
21 changes: 19 additions & 2 deletions source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include <preprocessor/preprocessor_concatenation.h>

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif

/* -- Definitions -- */
Expand All @@ -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;

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 c4b1a03

Please sign in to comment.