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.
This commit is contained in:
Jason Hood 2019-02-03 18:49:28 +10:00
parent eccbbe7a54
commit a1bf74dff9
5 changed files with 23 additions and 10 deletions

9
ANSI.c
View File

@ -219,6 +219,10 @@
v1.86, 4 November, 2018: v1.86, 4 November, 2018:
always unhook, even on terminate; always unhook, even on terminate;
check the DLL still exists before adding to imports. check the DLL still exists before adding to imports.
v1.87, 3 February, 2019:
some hooked functions are not imported, so myimport wasn't set;
add missing SetCurrentConsoleFontEx to list of hooks.
*/ */
#include "ansicon.h" #include "ansicon.h"
@ -2802,6 +2806,10 @@ BOOL HookAPIOneMod(
hook->myimport = &pThunk->u1.Function; hook->myimport = &pThunk->u1.Function;
DEBUGSTR( 3, " %s%s", sp, hook->name ); DEBUGSTR( 3, " %s%s", sp, hook->name );
} }
else if (hook->myimport == 0)
{
patch = hook->newfunc;
}
else else
{ {
// Don't hook if our import already points to the module being // Don't hook if our import already points to the module being
@ -3979,6 +3987,7 @@ HookFn Hooks[] = {
HOOK( APIConsole, SetConsoleScreenBufferSize ), HOOK( APIConsole, SetConsoleScreenBufferSize ),
HOOK( APIConsole, SetConsoleTextAttribute ), HOOK( APIConsole, SetConsoleTextAttribute ),
HOOK( APIConsole, SetConsoleWindowInfo ), HOOK( APIConsole, SetConsoleWindowInfo ),
HOOK( APIConsole, SetCurrentConsoleFontEx ),
HOOK( APIConsole, WriteConsoleOutputA ), HOOK( APIConsole, WriteConsoleOutputA ),
HOOK( APIConsole, WriteConsoleOutputW ), HOOK( APIConsole, WriteConsoleOutputW ),
HOOK( APIConsole, WriteConsoleOutputAttribute ), HOOK( APIConsole, WriteConsoleOutputAttribute ),

View File

@ -1,4 +1,4 @@
Copyright (C) 2005-2018 Jason Hood Copyright (C) 2005-2019 Jason Hood
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages warranty. In no event will the author be held liable for any damages

View File

@ -99,7 +99,7 @@
add log level 32 to log CreateFile. add log level 32 to log CreateFile.
*/ */
#define PDATE L"4 November, 2018" #define PDATE L"3 February, 2019"
#include "ansicon.h" #include "ansicon.h"
#include "version.h" #include "version.h"

View File

@ -1,9 +1,9 @@
ANSICON ANSICON
Copyright 2005-2018 Jason Hood Copyright 2005-2019 Jason Hood
Version 1.86. Freeware Version 1.87. Freeware
Description Description
@ -340,6 +340,10 @@ Version History
Legend: + added, - bug-fixed, * changed. Legend: + added, - bug-fixed, * changed.
1.87 - 3 February, 2019:
- fix crash when some programs start (bug during hooking);
- properly hook SetCurrentConsoleFontEx.
1.86 - 4 November, 2018: 1.86 - 4 November, 2018:
- check the DLL exists before importing it (allows renaming to update); - check the DLL exists before importing it (allows renaming to update);
- unhook on terminate, as well (fixes issues with Vista and MinGW). - unhook on terminate, as well (fixes issues with Vista and MinGW).
@ -641,4 +645,4 @@ Distribution
============================= =============================
Jason Hood, 4 November, 2018. Jason Hood, 3 February, 2019.

View File

@ -2,11 +2,11 @@
version.h - Version defines. version.h - Version defines.
*/ */
#define PVERS L"1.86" // wide string #define PVERS L"1.87" // wide string
#define PVERSA "1.86" // ANSI string (windres 2.16.91 didn't like L) #define PVERSA "1.87" // ANSI string (windres 2.16.91 didn't like L)
#define PVERE L"186" // wide environment string #define PVERE L"187" // wide environment string
#define PVEREA "186" // ANSI environment string #define PVEREA "187" // ANSI environment string
#define PVERB 1,8,6,0 // binary (resource) #define PVERB 1,8,7,0 // binary (resource)
#ifdef _WIN64 #ifdef _WIN64
# define BITS L"64" # define BITS L"64"