Use APIConsole for all console imports

Windows 10 has defined more console functions outside of `kernel32.dll`.
This commit is contained in:
Jason Hood 2018-02-13 12:31:40 +10:00
parent 392337b3b1
commit a995352ff1
3 changed files with 36 additions and 29 deletions

53
ANSI.c
View File

@ -188,8 +188,11 @@
check for the empty buffer within the critical section; check for the empty buffer within the critical section;
palette improvements. palette improvements.
v1.82-wip, 12 February, 2018: v1.82-wip, 12 & 13 February, 2018:
add ANSICON_WRAP environment variable for programs that expect the wrap. 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" #include "ansicon.h"
@ -3648,6 +3651,7 @@ FLUSH5( ReadConsoleOutputCharacterW, LPWSTR, DWORD, COORD, LPDWORD )
FLUSH5( ScrollConsoleScreenBufferA, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* ) FLUSH5( ScrollConsoleScreenBufferA, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* )
FLUSH5( ScrollConsoleScreenBufferW, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* ) FLUSH5( ScrollConsoleScreenBufferW, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* )
FLUSH2( SetConsoleCursorPosition, COORD ) FLUSH2( SetConsoleCursorPosition, COORD )
FLUSH2X( SetConsoleScreenBufferInfo, PCONSOLE_SCREEN_BUFFER_INFOX )
FLUSH2( SetConsoleScreenBufferSize, COORD ) FLUSH2( SetConsoleScreenBufferSize, COORD )
FLUSH2( SetConsoleTextAttribute, WORD ) FLUSH2( SetConsoleTextAttribute, WORD )
FLUSH3( SetConsoleWindowInfo, BOOL, const SMALL_RECT* ) FLUSH3( SetConsoleWindowInfo, BOOL, const SMALL_RECT* )
@ -3761,34 +3765,35 @@ HookFn Hooks[] = {
HOOK( APILibraryLoader, FreeLibrary ), HOOK( APILibraryLoader, FreeLibrary ),
HOOK( APIFile, CreateFileA ), HOOK( APIFile, CreateFileA ),
HOOK( APIFile, CreateFileW ), HOOK( APIFile, CreateFileW ),
HOOK( APIKernel, CreateConsoleScreenBuffer ), HOOK( APIConsole, CreateConsoleScreenBuffer ),
HOOK( APIHandle, CloseHandle ), HOOK( APIHandle, CloseHandle ),
HOOK( APIKernel, FillConsoleOutputAttribute ), HOOK( APIConsole, FillConsoleOutputAttribute ),
HOOK( APIKernel, FillConsoleOutputCharacterA ), HOOK( APIConsole, FillConsoleOutputCharacterA ),
HOOK( APIKernel, FillConsoleOutputCharacterW ), HOOK( APIConsole, FillConsoleOutputCharacterW ),
HOOK( APIKernel, GetConsoleScreenBufferInfo ), HOOK( APIConsole, GetConsoleScreenBufferInfo ),
HOOK( APIKernel, GetConsoleScreenBufferInfoEx ), HOOK( APIConsole, GetConsoleScreenBufferInfoEx ),
HOOK( APIFile, ReadFile ), HOOK( APIFile, ReadFile ),
HOOK( APIConsole, ReadConsoleA ), HOOK( APIConsole, ReadConsoleA ),
HOOK( APIConsole, ReadConsoleW ), HOOK( APIConsole, ReadConsoleW ),
HOOK( APIConsole, ReadConsoleInputA ), HOOK( APIConsole, ReadConsoleInputA ),
HOOK( APIConsole, ReadConsoleInputW ), HOOK( APIConsole, ReadConsoleInputW ),
HOOK( APIKernel, ReadConsoleOutputA ), HOOK( APIConsole, ReadConsoleOutputA ),
HOOK( APIKernel, ReadConsoleOutputW ), HOOK( APIConsole, ReadConsoleOutputW ),
HOOK( APIKernel, ReadConsoleOutputAttribute ), HOOK( APIConsole, ReadConsoleOutputAttribute ),
HOOK( APIKernel, ReadConsoleOutputCharacterA ), HOOK( APIConsole, ReadConsoleOutputCharacterA ),
HOOK( APIKernel, ReadConsoleOutputCharacterW ), HOOK( APIConsole, ReadConsoleOutputCharacterW ),
HOOK( APIKernel, ScrollConsoleScreenBufferA ), HOOK( APIConsole, ScrollConsoleScreenBufferA ),
HOOK( APIKernel, ScrollConsoleScreenBufferW ), HOOK( APIConsole, ScrollConsoleScreenBufferW ),
HOOK( APIKernel, SetConsoleCursorPosition ), HOOK( APIConsole, SetConsoleCursorPosition ),
HOOK( APIKernel, SetConsoleScreenBufferSize ), HOOK( APIConsole, SetConsoleScreenBufferInfoEx ),
HOOK( APIKernel, SetConsoleTextAttribute ), HOOK( APIConsole, SetConsoleScreenBufferSize ),
HOOK( APIKernel, SetConsoleWindowInfo ), HOOK( APIConsole, SetConsoleTextAttribute ),
HOOK( APIKernel, WriteConsoleOutputA ), HOOK( APIConsole, SetConsoleWindowInfo ),
HOOK( APIKernel, WriteConsoleOutputW ), HOOK( APIConsole, WriteConsoleOutputA ),
HOOK( APIKernel, WriteConsoleOutputAttribute ), HOOK( APIConsole, WriteConsoleOutputW ),
HOOK( APIKernel, WriteConsoleOutputCharacterA ), HOOK( APIConsole, WriteConsoleOutputAttribute ),
HOOK( APIKernel, WriteConsoleOutputCharacterW ), HOOK( APIConsole, WriteConsoleOutputCharacterA ),
HOOK( APIConsole, WriteConsoleOutputCharacterW ),
{ NULL, NULL, NULL, NULL, NULL, NULL } { NULL, NULL, NULL, NULL, NULL, NULL }
}; };

View File

@ -91,7 +91,7 @@
use -pu to unload from the parent. use -pu to unload from the parent.
*/ */
#define PDATE L"12 February, 2018" #define PDATE L"13 February, 2018"
#include "ansicon.h" #include "ansicon.h"
#include "version.h" #include "version.h"

View File

@ -1,7 +1,7 @@
ANSICON ANSICON
Copyright 2005-2017 Jason Hood Copyright 2005-2018 Jason Hood
Version 1.82-wip. Freeware Version 1.82-wip. Freeware
@ -339,8 +339,10 @@ Version History
Legend: + added, - bug-fixed, * changed. Legend: + added, - bug-fixed, * changed.
1.82-wip - 12 February, 2018: 1.82-wip - 13 February, 2018:
- add ANSICON_WRAP for programs that expect the wrap at right margin. - 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: 1.81 - 28 December, 2017:
- fix multiple CRs before LF (including preventing an immediate flush); - 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.