Skip to content

Commit a995352

Browse files
committed
Use APIConsole for all console imports
Windows 10 has defined more console functions outside of `kernel32.dll`.
1 parent 392337b commit a995352

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

ANSI.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@
188188
check for the empty buffer within the critical section;
189189
palette improvements.
190190
191-
v1.82-wip, 12 February, 2018:
192-
add ANSICON_WRAP environment variable for programs that expect the wrap.
191+
v1.82-wip, 12 & 13 February, 2018:
192+
add ANSICON_WRAP environment variable for programs that expect the wrap;
193+
flush and invalidate the cache on CloseHandle;
194+
make IsConsoleHandle a critical section, for multithreaded processes;
195+
use APIConsole for all console functions (needed for Windows 10).
193196
*/
194197

195198
#include "ansicon.h"
@@ -3648,6 +3651,7 @@ FLUSH5( ReadConsoleOutputCharacterW, LPWSTR, DWORD, COORD, LPDWORD )
36483651
FLUSH5( ScrollConsoleScreenBufferA, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* )
36493652
FLUSH5( ScrollConsoleScreenBufferW, SMALL_RECT*,SMALL_RECT*, COORD, CHAR_INFO* )
36503653
FLUSH2( SetConsoleCursorPosition, COORD )
3654+
FLUSH2X( SetConsoleScreenBufferInfo, PCONSOLE_SCREEN_BUFFER_INFOX )
36513655
FLUSH2( SetConsoleScreenBufferSize, COORD )
36523656
FLUSH2( SetConsoleTextAttribute, WORD )
36533657
FLUSH3( SetConsoleWindowInfo, BOOL, const SMALL_RECT* )
@@ -3761,34 +3765,35 @@ HookFn Hooks[] = {
37613765
HOOK( APILibraryLoader, FreeLibrary ),
37623766
HOOK( APIFile, CreateFileA ),
37633767
HOOK( APIFile, CreateFileW ),
3764-
HOOK( APIKernel, CreateConsoleScreenBuffer ),
3768+
HOOK( APIConsole, CreateConsoleScreenBuffer ),
37653769
HOOK( APIHandle, CloseHandle ),
3766-
HOOK( APIKernel, FillConsoleOutputAttribute ),
3767-
HOOK( APIKernel, FillConsoleOutputCharacterA ),
3768-
HOOK( APIKernel, FillConsoleOutputCharacterW ),
3769-
HOOK( APIKernel, GetConsoleScreenBufferInfo ),
3770-
HOOK( APIKernel, GetConsoleScreenBufferInfoEx ),
3770+
HOOK( APIConsole, FillConsoleOutputAttribute ),
3771+
HOOK( APIConsole, FillConsoleOutputCharacterA ),
3772+
HOOK( APIConsole, FillConsoleOutputCharacterW ),
3773+
HOOK( APIConsole, GetConsoleScreenBufferInfo ),
3774+
HOOK( APIConsole, GetConsoleScreenBufferInfoEx ),
37713775
HOOK( APIFile, ReadFile ),
37723776
HOOK( APIConsole, ReadConsoleA ),
37733777
HOOK( APIConsole, ReadConsoleW ),
37743778
HOOK( APIConsole, ReadConsoleInputA ),
37753779
HOOK( APIConsole, ReadConsoleInputW ),
3776-
HOOK( APIKernel, ReadConsoleOutputA ),
3777-
HOOK( APIKernel, ReadConsoleOutputW ),
3778-
HOOK( APIKernel, ReadConsoleOutputAttribute ),
3779-
HOOK( APIKernel, ReadConsoleOutputCharacterA ),
3780-
HOOK( APIKernel, ReadConsoleOutputCharacterW ),
3781-
HOOK( APIKernel, ScrollConsoleScreenBufferA ),
3782-
HOOK( APIKernel, ScrollConsoleScreenBufferW ),
3783-
HOOK( APIKernel, SetConsoleCursorPosition ),
3784-
HOOK( APIKernel, SetConsoleScreenBufferSize ),
3785-
HOOK( APIKernel, SetConsoleTextAttribute ),
3786-
HOOK( APIKernel, SetConsoleWindowInfo ),
3787-
HOOK( APIKernel, WriteConsoleOutputA ),
3788-
HOOK( APIKernel, WriteConsoleOutputW ),
3789-
HOOK( APIKernel, WriteConsoleOutputAttribute ),
3790-
HOOK( APIKernel, WriteConsoleOutputCharacterA ),
3791-
HOOK( APIKernel, WriteConsoleOutputCharacterW ),
3780+
HOOK( APIConsole, ReadConsoleOutputA ),
3781+
HOOK( APIConsole, ReadConsoleOutputW ),
3782+
HOOK( APIConsole, ReadConsoleOutputAttribute ),
3783+
HOOK( APIConsole, ReadConsoleOutputCharacterA ),
3784+
HOOK( APIConsole, ReadConsoleOutputCharacterW ),
3785+
HOOK( APIConsole, ScrollConsoleScreenBufferA ),
3786+
HOOK( APIConsole, ScrollConsoleScreenBufferW ),
3787+
HOOK( APIConsole, SetConsoleCursorPosition ),
3788+
HOOK( APIConsole, SetConsoleScreenBufferInfoEx ),
3789+
HOOK( APIConsole, SetConsoleScreenBufferSize ),
3790+
HOOK( APIConsole, SetConsoleTextAttribute ),
3791+
HOOK( APIConsole, SetConsoleWindowInfo ),
3792+
HOOK( APIConsole, WriteConsoleOutputA ),
3793+
HOOK( APIConsole, WriteConsoleOutputW ),
3794+
HOOK( APIConsole, WriteConsoleOutputAttribute ),
3795+
HOOK( APIConsole, WriteConsoleOutputCharacterA ),
3796+
HOOK( APIConsole, WriteConsoleOutputCharacterW ),
37923797
{ NULL, NULL, NULL, NULL, NULL, NULL }
37933798
};
37943799

ansicon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
use -pu to unload from the parent.
9292
*/
9393

94-
#define PDATE L"12 February, 2018"
94+
#define PDATE L"13 February, 2018"
9595

9696
#include "ansicon.h"
9797
#include "version.h"

readme.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
ANSICON
33

4-
Copyright 2005-2017 Jason Hood
4+
Copyright 2005-2018 Jason Hood
55

66
Version 1.82-wip. Freeware
77

@@ -339,8 +339,10 @@ Version History
339339

340340
Legend: + added, - bug-fixed, * changed.
341341

342-
1.82-wip - 12 February, 2018:
343-
- add ANSICON_WRAP for programs that expect the wrap at right margin.
342+
1.82-wip - 13 February, 2018:
343+
- add ANSICON_WRAP for programs that expect the wrap at right margin;
344+
- make IsConsoleHandle a critical section, for multithreaded processes;
345+
- use APIConsole for all console functions (Windows 10).
344346

345347
1.81 - 28 December, 2017:
346348
- fix multiple CRs before LF (including preventing an immediate flush);
@@ -608,4 +610,4 @@ Distribution
608610

609611

610612
==============================
611-
Jason Hood, 12 February, 2018.
613+
Jason Hood, 13 February, 2018.

0 commit comments

Comments
 (0)