From a995352ff117c000f8b076ac5e557974bdf3f9e9 Mon Sep 17 00:00:00 2001 From: Jason Hood Date: Tue, 13 Feb 2018 12:31:40 +1000 Subject: [PATCH] Use `APIConsole` for all console imports Windows 10 has defined more console functions outside of `kernel32.dll`. --- ANSI.c | 53 +++++++++++++++++++++++++++++------------------------ ansicon.c | 2 +- readme.txt | 10 ++++++---- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/ANSI.c b/ANSI.c index f06f145..c7c3d83 100644 --- a/ANSI.c +++ b/ANSI.c @@ -188,8 +188,11 @@ check for the empty buffer within the critical section; palette improvements. - v1.82-wip, 12 February, 2018: - add ANSICON_WRAP environment variable for programs that expect the wrap. + v1.82-wip, 12 & 13 February, 2018: + add ANSICON_WRAP environment variable for programs that expect the wrap; + flush and invalidate the cache on CloseHandle; + make IsConsoleHandle a critical section, for multithreaded processes; + use APIConsole for all console functions (needed for Windows 10). */ #include "ansicon.h" @@ -3648,6 +3651,7 @@ FLUSH5( ReadConsoleOutputCharacterW, LPWSTR, DWORD, COORD, LPDWORD ) FLUSH5( ScrollConsoleScreenBufferA, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* ) FLUSH5( ScrollConsoleScreenBufferW, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* ) FLUSH2( SetConsoleCursorPosition, COORD ) +FLUSH2X( SetConsoleScreenBufferInfo, PCONSOLE_SCREEN_BUFFER_INFOX ) FLUSH2( SetConsoleScreenBufferSize, COORD ) FLUSH2( SetConsoleTextAttribute, WORD ) FLUSH3( SetConsoleWindowInfo, BOOL, const SMALL_RECT* ) @@ -3761,34 +3765,35 @@ HookFn Hooks[] = { HOOK( APILibraryLoader, FreeLibrary ), HOOK( APIFile, CreateFileA ), HOOK( APIFile, CreateFileW ), - HOOK( APIKernel, CreateConsoleScreenBuffer ), + HOOK( APIConsole, CreateConsoleScreenBuffer ), HOOK( APIHandle, CloseHandle ), - HOOK( APIKernel, FillConsoleOutputAttribute ), - HOOK( APIKernel, FillConsoleOutputCharacterA ), - HOOK( APIKernel, FillConsoleOutputCharacterW ), - HOOK( APIKernel, GetConsoleScreenBufferInfo ), - HOOK( APIKernel, GetConsoleScreenBufferInfoEx ), + HOOK( APIConsole, FillConsoleOutputAttribute ), + HOOK( APIConsole, FillConsoleOutputCharacterA ), + HOOK( APIConsole, FillConsoleOutputCharacterW ), + HOOK( APIConsole, GetConsoleScreenBufferInfo ), + HOOK( APIConsole, GetConsoleScreenBufferInfoEx ), HOOK( APIFile, ReadFile ), HOOK( APIConsole, ReadConsoleA ), HOOK( APIConsole, ReadConsoleW ), HOOK( APIConsole, ReadConsoleInputA ), HOOK( APIConsole, ReadConsoleInputW ), - HOOK( APIKernel, ReadConsoleOutputA ), - HOOK( APIKernel, ReadConsoleOutputW ), - HOOK( APIKernel, ReadConsoleOutputAttribute ), - HOOK( APIKernel, ReadConsoleOutputCharacterA ), - HOOK( APIKernel, ReadConsoleOutputCharacterW ), - HOOK( APIKernel, ScrollConsoleScreenBufferA ), - HOOK( APIKernel, ScrollConsoleScreenBufferW ), - HOOK( APIKernel, SetConsoleCursorPosition ), - HOOK( APIKernel, SetConsoleScreenBufferSize ), - HOOK( APIKernel, SetConsoleTextAttribute ), - HOOK( APIKernel, SetConsoleWindowInfo ), - HOOK( APIKernel, WriteConsoleOutputA ), - HOOK( APIKernel, WriteConsoleOutputW ), - HOOK( APIKernel, WriteConsoleOutputAttribute ), - HOOK( APIKernel, WriteConsoleOutputCharacterA ), - HOOK( APIKernel, WriteConsoleOutputCharacterW ), + HOOK( APIConsole, ReadConsoleOutputA ), + HOOK( APIConsole, ReadConsoleOutputW ), + HOOK( APIConsole, ReadConsoleOutputAttribute ), + HOOK( APIConsole, ReadConsoleOutputCharacterA ), + HOOK( APIConsole, ReadConsoleOutputCharacterW ), + HOOK( APIConsole, ScrollConsoleScreenBufferA ), + HOOK( APIConsole, ScrollConsoleScreenBufferW ), + HOOK( APIConsole, SetConsoleCursorPosition ), + HOOK( APIConsole, SetConsoleScreenBufferInfoEx ), + HOOK( APIConsole, SetConsoleScreenBufferSize ), + HOOK( APIConsole, SetConsoleTextAttribute ), + HOOK( APIConsole, SetConsoleWindowInfo ), + HOOK( APIConsole, WriteConsoleOutputA ), + HOOK( APIConsole, WriteConsoleOutputW ), + HOOK( APIConsole, WriteConsoleOutputAttribute ), + HOOK( APIConsole, WriteConsoleOutputCharacterA ), + HOOK( APIConsole, WriteConsoleOutputCharacterW ), { NULL, NULL, NULL, NULL, NULL, NULL } }; diff --git a/ansicon.c b/ansicon.c index ff36aff..de15e10 100644 --- a/ansicon.c +++ b/ansicon.c @@ -91,7 +91,7 @@ use -pu to unload from the parent. */ -#define PDATE L"12 February, 2018" +#define PDATE L"13 February, 2018" #include "ansicon.h" #include "version.h" diff --git a/readme.txt b/readme.txt index 1df7aae..812d90d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ ANSICON - Copyright 2005-2017 Jason Hood + Copyright 2005-2018 Jason Hood Version 1.82-wip. Freeware @@ -339,8 +339,10 @@ Version History Legend: + added, - bug-fixed, * changed. - 1.82-wip - 12 February, 2018: - - add ANSICON_WRAP for programs that expect the wrap at right margin. + 1.82-wip - 13 February, 2018: + - add ANSICON_WRAP for programs that expect the wrap at right margin; + - make IsConsoleHandle a critical section, for multithreaded processes; + - use APIConsole for all console functions (Windows 10). 1.81 - 28 December, 2017: - fix multiple CRs before LF (including preventing an immediate flush); @@ -608,4 +610,4 @@ Distribution ============================== -Jason Hood, 12 February, 2018. +Jason Hood, 13 February, 2018.