Skip to content

Commit

Permalink
Solve issues from detours, plugin manager, fork safety and added supp…
Browse files Browse the repository at this point in the history
…ort to mingw in dynlink.
  • Loading branch information
viferga committed Nov 28, 2024
1 parent 355c12f commit cbbf4a4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 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
10 changes: 4 additions & 6 deletions source/detours/funchook_detour/scripts/download.sh.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env sh

# Download repository if it does not exist
if [ ! -d @FUNCHOOK_SOURCE_DIR@/.git ]
then
if [ -d @FUNCHOOK_SOURCE_DIR@ ]
then
rm -rf @FUNCHOOK_SOURCE_DIR@
if [ ! -d "@FUNCHOOK_SOURCE_DIR@/.git" ]; then
if [ -d "@FUNCHOOK_SOURCE_DIR@" ]; then
rm -rf "@FUNCHOOK_SOURCE_DIR@"
fi
@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@"
fi
6 changes: 6 additions & 0 deletions source/dynlink/source/dynlink_impl_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ const char *dynlink_impl_interface_extension_win32(void)

void dynlink_impl_interface_get_name_win32(dynlink_name name, dynlink_name_impl name_impl, size_t size)
{
#if defined(__MINGW32__) || defined(__MINGW64__)
strncpy(name_impl, "lib", size);

strncat(name_impl, name, size - 1);
#else
strncpy(name_impl, name, size);
#endif

strncat(name_impl, ".", size - 1);

Expand Down
4 changes: 2 additions & 2 deletions source/metacall/source/metacall_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ NTSTATUS NTAPI metacall_fork_hook(ULONG ProcessFlags,

void (*metacall_fork_func(void))(void)
{
return (void (*)(void)) & fork;
return (void (*)(void))(&fork);
}

pid_t metacall_fork_hook(void)
Expand Down Expand Up @@ -325,7 +325,7 @@ int metacall_fork_initialize(void)

if (metacall_detour_handle == NULL)
{
metacall_detour_handle = detour_install(metacall_detour, (void (*)(void))fork_func, (void (*)(void)) & metacall_fork_hook);
metacall_detour_handle = detour_install(metacall_detour, (void (*)(void))fork_func, (void (*)(void))(&metacall_fork_hook));

if (metacall_detour_handle == NULL)
{
Expand Down
14 changes: 7 additions & 7 deletions source/plugin/source/plugin_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@ int plugin_manager_initialize(plugin_manager manager, const char *name, const ch

return 1;
}
}

/* On Windows, pass the library path to the loader so it can find the dependencies of the plugins */
/* For more information: https://github.com/metacall/core/issues/479 */
/* On Windows, pass the library path to the loader so it can find the dependencies of the plugins */
/* For more information: https://github.com/metacall/core/issues/479 */
#if defined(WIN32) || defined(_WIN32)
if (SetDllDirectoryA(manager->library_path) == FALSE)
{
log_write("metacall", LOG_LEVEL_ERROR, "Failed to register the DLL directory %s; plugins with other dependant DLLs may fail to load", manager->library_path);
}
if (SetDllDirectoryA(manager->library_path) == FALSE)
{
log_write("metacall", LOG_LEVEL_ERROR, "Failed to register the DLL directory %s; plugins with other dependant DLLs may fail to load", manager->library_path);
}
#endif
}

/* Initialize the plugin loader */
if (manager->l == NULL)
Expand Down

0 comments on commit cbbf4a4

Please sign in to comment.