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 <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-10-16 14:17:22 +02:00 committed by Jason A. Donenfeld
parent 9a16d4e3cc
commit c049a8f853
3 changed files with 6 additions and 4 deletions

View File

@ -5,11 +5,12 @@
#include "pch.h" #include "pch.h"
static VOID CALLBACK static BOOL CALLBACK
NopLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *LogLine) NopLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *LogLine)
{ {
UNREFERENCED_PARAMETER(Level); UNREFERENCED_PARAMETER(Level);
UNREFERENCED_PARAMETER(LogLine); UNREFERENCED_PARAMETER(LogLine);
return TRUE;
} }
WINTUN_LOGGER_FUNC Logger = NopLogger; WINTUN_LOGGER_FUNC Logger = NopLogger;

View File

@ -14,7 +14,7 @@ typedef enum _WINTUN_LOGGER_LEVEL
WINTUN_LOG_ERR WINTUN_LOG_ERR
} WINTUN_LOGGER_LEVEL; } 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; extern WINTUN_LOGGER_FUNC Logger;

View File

@ -7,7 +7,7 @@
#if defined(_M_AMD64) || defined(_M_ARM64) #if defined(_M_AMD64) || defined(_M_ARM64)
static VOID CALLBACK static BOOL CALLBACK
ConsoleLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_ const WCHAR *LogLine) ConsoleLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_ const WCHAR *LogLine)
{ {
const WCHAR *Template; const WCHAR *Template;
@ -23,9 +23,10 @@ ConsoleLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_ const WCHAR *LogLine)
Template = L"[!] %s\n"; Template = L"[!] %s\n";
break; break;
default: default:
return; return FALSE;
} }
fwprintf(stderr, Template, LogLine); fwprintf(stderr, Template, LogLine);
return TRUE;
} }
static BOOL ElevateToSystem(VOID) static BOOL ElevateToSystem(VOID)