diff --git a/src/yr_util.c b/src/yr_util.c index d00c007..dfe3209 100644 --- a/src/yr_util.c +++ b/src/yr_util.c @@ -20,15 +20,15 @@ hook_wwdebug_printf(char const *fmt, ...) va_list ap; va_start(ap,fmt); static bool already_consoled = false; + static HANDLE h = 0; if (!already_consoled) { AllocConsole(); already_consoled = true; + h = GetStdHandle(STD_OUTPUT_HANDLE); WWDebug_Printf("Allocated the console\n"); } - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - size_t fmt_len = strnlen(fmt,99); if (fmt_len >= 99) @@ -41,7 +41,9 @@ hook_wwdebug_printf(char const *fmt, ...) return; LPDWORD ret; - WriteConsole(h,wwdebug_buf,len, 0, 0); + // In some terminals (e.g., mintty from Git-Bash), "WriteConsole(h, ...)" + // writes NOTHING because "GetFileType(h) == FILE_TYPE_PIPE". + WriteFile(h,wwdebug_buf,len, 0, 0); return; } diff --git a/sym.asm b/sym.asm index 0136aee..382ee2e 100644 --- a/sym.asm +++ b/sym.asm @@ -13,7 +13,7 @@ setcglob 0x004068E0, WWDebug_Printf setcglob 0x00A8ED6B, Debug_Map setcglob 0x007E12CC, _imp__GetStdHandle -setcglob 0x007E1344, _imp__WriteConsoleA +setcglob 0x007E11A0, _imp__WriteFile setcglob 0x007E1218, _imp__AllocConsole setcglob 0x007E11A8, _imp__GetModuleFileNameA setcglob 0x007E11A4, _imp__GetCurrentProcess_hack