From c049a8f85392a919b68f4fe24dacb5722e0d30b2 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 16 Oct 2020 14:17:22 +0200 Subject: [PATCH] api: make logger callback return a dummy value Go supports only callbacks that return "something" of a size up to uintptr. It panics on void-returning callbacks. Signed-off-by: Simon Rozman --- api/logger.c | 3 ++- api/logger.h | 2 +- api/rundll32.c | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/logger.c b/api/logger.c index a4400b9..b314f9c 100644 --- a/api/logger.c +++ b/api/logger.c @@ -5,11 +5,12 @@ #include "pch.h" -static VOID CALLBACK +static BOOL CALLBACK NopLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *LogLine) { UNREFERENCED_PARAMETER(Level); UNREFERENCED_PARAMETER(LogLine); + return TRUE; } WINTUN_LOGGER_FUNC Logger = NopLogger; diff --git a/api/logger.h b/api/logger.h index e7e3d35..64cbef3 100644 --- a/api/logger.h +++ b/api/logger.h @@ -14,7 +14,7 @@ typedef enum _WINTUN_LOGGER_LEVEL WINTUN_LOG_ERR } WINTUN_LOGGER_LEVEL; -typedef VOID(CALLBACK *WINTUN_LOGGER_FUNC)(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *Message); +typedef BOOL(CALLBACK *WINTUN_LOGGER_FUNC)(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *Message); extern WINTUN_LOGGER_FUNC Logger; diff --git a/api/rundll32.c b/api/rundll32.c index 3925ad1..ed1d9e1 100644 --- a/api/rundll32.c +++ b/api/rundll32.c @@ -7,7 +7,7 @@ #if defined(_M_AMD64) || defined(_M_ARM64) -static VOID CALLBACK +static BOOL CALLBACK ConsoleLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_ const WCHAR *LogLine) { const WCHAR *Template; @@ -23,9 +23,10 @@ ConsoleLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_ const WCHAR *LogLine) Template = L"[!] %s\n"; break; default: - return; + return FALSE; } fwprintf(stderr, Template, LogLine); + return TRUE; } static BOOL ElevateToSystem(VOID)