Skip to content

Commit

Permalink
Fix crash when some programs start
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adoxa committed Feb 3, 2019
1 parent eccbbe7 commit a1bf74d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
9 changes: 9 additions & 0 deletions ANSI.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@
v1.86, 4 November, 2018:
always unhook, even on terminate;
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"
Expand Down Expand Up @@ -2802,6 +2806,10 @@ BOOL HookAPIOneMod(
hook->myimport = &pThunk->u1.Function;
DEBUGSTR( 3, " %s%s", sp, hook->name );
}
else if (hook->myimport == 0)
{
patch = hook->newfunc;
}
else
{
// Don't hook if our import already points to the module being
Expand Down Expand Up @@ -3979,6 +3987,7 @@ HookFn Hooks[] = {
HOOK( APIConsole, SetConsoleScreenBufferSize ),
HOOK( APIConsole, SetConsoleTextAttribute ),
HOOK( APIConsole, SetConsoleWindowInfo ),
HOOK( APIConsole, SetCurrentConsoleFontEx ),
HOOK( APIConsole, WriteConsoleOutputA ),
HOOK( APIConsole, WriteConsoleOutputW ),
HOOK( APIConsole, WriteConsoleOutputAttribute ),
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
warranty. In no event will the author be held liable for any damages
Expand Down
2 changes: 1 addition & 1 deletion ansicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
add log level 32 to log CreateFile.
*/

#define PDATE L"4 November, 2018"
#define PDATE L"3 February, 2019"

#include "ansicon.h"
#include "version.h"
Expand Down
10 changes: 7 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

ANSICON

Copyright 2005-2018 Jason Hood
Copyright 2005-2019 Jason Hood

Version 1.86. Freeware
Version 1.87. Freeware


Description
Expand Down Expand Up @@ -340,6 +340,10 @@ Version History

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:
- check the DLL exists before importing it (allows renaming to update);
- unhook on terminate, as well (fixes issues with Vista and MinGW).
Expand Down Expand Up @@ -641,4 +645,4 @@ Distribution


=============================
Jason Hood, 4 November, 2018.
Jason Hood, 3 February, 2019.
10 changes: 5 additions & 5 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
version.h - Version defines.
*/

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

#ifdef _WIN64
# define BITS L"64"
Expand Down

0 comments on commit a1bf74d

Please sign in to comment.