1 From 9d6fbddfd031852f7c6d1a10aff9fa5ef690858b Mon Sep 17 00:00:00 2001
2 From: Steve Lhomme <robux4@ycbcr.xyz>
3 Date: Fri, 3 Apr 2020 13:33:26 +0200
4 Subject: [PATCH 1/2] Don't call Console APIs on Winstore builds
6 The API's are only available on desktop builds.
7 https://docs.microsoft.com/en-us/windows/console/getstdhandle
8 https://docs.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo
9 https://docs.microsoft.com/en-us/windows/console/writeconsole
11 Instead send logs to the debug output
13 src/share/win_utf8_io/win_utf8_io.c | 8 ++++++++
14 1 file changed, 8 insertions(+)
16 diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
17 index bbb6a74a..1e0c1e86 100644
18 --- a/src/share/win_utf8_io/win_utf8_io.c
19 +++ b/src/share/win_utf8_io/win_utf8_io.c
24 +#include <winapifamily.h>
25 #include "share/win_utf8_io.h"
26 #include "share/windows_unicode_filenames.h"
28 @@ -182,11 +183,13 @@ size_t strlen_utf8(const char *str)
29 int win_get_console_width(void)
32 +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
33 CONSOLE_SCREEN_BUFFER_INFO csbi;
34 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
35 if(hOut != INVALID_HANDLE_VALUE && hOut != NULL)
36 if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0)
37 width = csbi.dwSize.X;
42 @@ -194,6 +197,10 @@ int win_get_console_width(void)
44 static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
46 +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
48 + OutputDebugStringW(text);
53 @@ -219,6 +226,7 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
54 ret = fputws(text, stream);