From 143770e9390e1d97f49b19e16e459a807e70768e Mon Sep 17 00:00:00 2001 From: Kriper1111 <31844440+Kriper1111@users.noreply.github.com> Date: Sat, 17 Aug 2024 12:24:26 +0300 Subject: [PATCH 1/3] fix: Handle ordinals in GetProcAddress detour see: https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress --- src/windows/entrypoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windows/entrypoint.c b/src/windows/entrypoint.c index 7b542f4..5fc0cfa 100644 --- a/src/windows/entrypoint.c +++ b/src/windows/entrypoint.c @@ -138,7 +138,7 @@ void capture_mono_path(void *handle) { bool_t initialized = FALSE; void *WINAPI get_proc_address_detour(void *module, char *name) { #define REDIRECT_INIT(init_name, init_func, target, extra_init) \ - if (lstrcmpA(name, init_name) == 0) { \ + if (HIWORD(name) && lstrcmpA(name, init_name) == 0) { \ if (!initialized) { \ initialized = TRUE; \ LOG("Got %S at %p", init_name, module); \ From ca783863723d2c27500ed1a694559cb8b4891eba Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Mon, 21 Apr 2025 11:13:52 +0200 Subject: [PATCH 2/3] Update src/windows/entrypoint.c --- src/windows/entrypoint.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/windows/entrypoint.c b/src/windows/entrypoint.c index 5fc0cfa..679e38f 100644 --- a/src/windows/entrypoint.c +++ b/src/windows/entrypoint.c @@ -138,6 +138,7 @@ void capture_mono_path(void *handle) { bool_t initialized = FALSE; void *WINAPI get_proc_address_detour(void *module, char *name) { #define REDIRECT_INIT(init_name, init_func, target, extra_init) \ + // If the lpProcName pointer contains an ordinal rather than a string, high-word value of the pointer is zero (see PR #66) if (HIWORD(name) && lstrcmpA(name, init_name) == 0) { \ if (!initialized) { \ initialized = TRUE; \ From a0073fdec81cde2b8c1b37331436c7b623371ef2 Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Mon, 21 Apr 2025 11:16:57 +0200 Subject: [PATCH 3/3] Update entrypoint.c --- src/windows/entrypoint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/windows/entrypoint.c b/src/windows/entrypoint.c index 679e38f..f798129 100644 --- a/src/windows/entrypoint.c +++ b/src/windows/entrypoint.c @@ -137,8 +137,9 @@ void capture_mono_path(void *handle) { bool_t initialized = FALSE; void *WINAPI get_proc_address_detour(void *module, char *name) { + // If the lpProcName pointer contains an ordinal rather than a string, + // high-word value of the pointer is zero (see PR #66) #define REDIRECT_INIT(init_name, init_func, target, extra_init) \ - // If the lpProcName pointer contains an ordinal rather than a string, high-word value of the pointer is zero (see PR #66) if (HIWORD(name) && lstrcmpA(name, init_name) == 0) { \ if (!initialized) { \ initialized = TRUE; \