From 20a4d53b22f347f26368fe89b6e4423e18b61d4d Mon Sep 17 00:00:00 2001 From: Daniel Seiller Date: Wed, 20 Nov 2019 20:50:31 +0100 Subject: [PATCH] Detach and reattach console on start --- ScrapHacks/ScrapHack/Util.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ScrapHacks/ScrapHack/Util.h b/ScrapHacks/ScrapHack/Util.h index cf461d6..b0da991 100644 --- a/ScrapHacks/ScrapHack/Util.h +++ b/ScrapHacks/ScrapHack/Util.h @@ -37,12 +37,14 @@ void SetupStreams() void SetupConsole() { - if (!AllocConsole()) - { - FreeConsole(); - AllocConsole(); + if (!AttachConsole(-1)) { + if (!AllocConsole()) + { + FreeConsole(); + AllocConsole(); + } + AttachConsole(GetCurrentProcessId()); } - AttachConsole(GetCurrentProcessId()); SetupStreams(); }