From bfeacfde75e293d58165ee762ed817bb2c8f41e2 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 28 May 2016 14:46:54 +0200 Subject: [PATCH] Automatically increase console size on windows if it's too small --- src/hashcat.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/hashcat.c b/src/hashcat.c index e083bf8..7c9e77f 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -5332,8 +5332,43 @@ static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, cons * main */ +#ifdef _WIN +void SetConsoleWindowSize (const int x, const int y) +{ + HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE); + + if (h == INVALID_HANDLE_VALUE) return; + + CONSOLE_SCREEN_BUFFER_INFO bufferInfo; + + if (!GetConsoleScreenBufferInfo (h, &bufferInfo)) return; + + SMALL_RECT *sr = &bufferInfo.srWindow; + + sr->Left = 0; + sr->Top = 0; + sr->Right = MAX (sr->Right, x - 1); + sr->Bottom = MAX (sr->Bottom, y - 1); + + COORD co; + + co.X = sr->Right + 1; + co.Y = sr->Bottom + 1; + + co.Y = MAX (co.Y, 1337); + + if (!SetConsoleScreenBufferSize (h, co)) return; + + if (!SetConsoleWindowInfo (h, TRUE, sr)) return; +} +#endif + int main (int argc, char **argv) { + #ifdef _WIN + SetConsoleWindowSize (132, 44); + #endif + /** * To help users a bit */ -- 2.25.1