Skip to content

Commit a1bf74d

Browse files
committed
Fix crash when some programs start
A few functions that are hooked are not imported, so testing if my import was already hooked would fail. SetCurrentConsoleFontEx should have been hooked, but wasn't.
1 parent eccbbe7 commit a1bf74d

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

ANSI.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@
219219
v1.86, 4 November, 2018:
220220
always unhook, even on terminate;
221221
check the DLL still exists before adding to imports.
222+
223+
v1.87, 3 February, 2019:
224+
some hooked functions are not imported, so myimport wasn't set;
225+
add missing SetCurrentConsoleFontEx to list of hooks.
222226
*/
223227

224228
#include "ansicon.h"
@@ -2802,6 +2806,10 @@ BOOL HookAPIOneMod(
28022806
hook->myimport = &pThunk->u1.Function;
28032807
DEBUGSTR( 3, " %s%s", sp, hook->name );
28042808
}
2809+
else if (hook->myimport == 0)
2810+
{
2811+
patch = hook->newfunc;
2812+
}
28052813
else
28062814
{
28072815
// Don't hook if our import already points to the module being
@@ -3979,6 +3987,7 @@ HookFn Hooks[] = {
39793987
HOOK( APIConsole, SetConsoleScreenBufferSize ),
39803988
HOOK( APIConsole, SetConsoleTextAttribute ),
39813989
HOOK( APIConsole, SetConsoleWindowInfo ),
3990+
HOOK( APIConsole, SetCurrentConsoleFontEx ),
39823991
HOOK( APIConsole, WriteConsoleOutputA ),
39833992
HOOK( APIConsole, WriteConsoleOutputW ),
39843993
HOOK( APIConsole, WriteConsoleOutputAttribute ),

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2005-2018 Jason Hood
1+
Copyright (C) 2005-2019 Jason Hood
22

33
This software is provided 'as-is', without any express or implied
44
warranty. In no event will the author be held liable for any damages

ansicon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
add log level 32 to log CreateFile.
100100
*/
101101

102-
#define PDATE L"4 November, 2018"
102+
#define PDATE L"3 February, 2019"
103103

104104
#include "ansicon.h"
105105
#include "version.h"

readme.txt

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

22
ANSICON
33

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

6-
Version 1.86. Freeware
6+
Version 1.87. Freeware
77

88

99
Description
@@ -340,6 +340,10 @@ Version History
340340

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

343+
1.87 - 3 February, 2019:
344+
- fix crash when some programs start (bug during hooking);
345+
- properly hook SetCurrentConsoleFontEx.
346+
343347
1.86 - 4 November, 2018:
344348
- check the DLL exists before importing it (allows renaming to update);
345349
- unhook on terminate, as well (fixes issues with Vista and MinGW).
@@ -641,4 +645,4 @@ Distribution
641645

642646

643647
=============================
644-
Jason Hood, 4 November, 2018.
648+
Jason Hood, 3 February, 2019.

version.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
version.h - Version defines.
33
*/
44

5-
#define PVERS L"1.86" // wide string
6-
#define PVERSA "1.86" // ANSI string (windres 2.16.91 didn't like L)
7-
#define PVERE L"186" // wide environment string
8-
#define PVEREA "186" // ANSI environment string
9-
#define PVERB 1,8,6,0 // binary (resource)
5+
#define PVERS L"1.87" // wide string
6+
#define PVERSA "1.87" // ANSI string (windres 2.16.91 didn't like L)
7+
#define PVERE L"187" // wide environment string
8+
#define PVEREA "187" // ANSI environment string
9+
#define PVERB 1,8,7,0 // binary (resource)
1010

1111
#ifdef _WIN64
1212
# define BITS L"64"

0 commit comments

Comments
 (0)