Fix ANSICON environment variable
Creating a console handle in `set_ansicon` was assumed to succeed, but that is not the case when there is no console (if the process was started detached or freed its console). This left the console info uninitialised, causing my `printf` replacement to get stuck in a loop. Resolves #127.
This commit is contained in:
parent
a1bf74dff9
commit
d7a2d5e962
15
ANSI.c
15
ANSI.c
@ -223,6 +223,9 @@
|
||||
v1.87, 3 February, 2019:
|
||||
some hooked functions are not imported, so myimport wasn't set;
|
||||
add missing SetCurrentConsoleFontEx to list of hooks.
|
||||
|
||||
v1.88, 1 March, 2019:
|
||||
a detached process has no console handle (fixes set_ansicon).
|
||||
*/
|
||||
|
||||
#include "ansicon.h"
|
||||
@ -3874,8 +3877,20 @@ void set_ansicon( PCONSOLE_SCREEN_BUFFER_INFO pcsbi )
|
||||
hConOut = CreateFile( L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL );
|
||||
if (hConOut == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
csbi.dwSize.X =
|
||||
csbi.dwSize.Y =
|
||||
csbi.srWindow.Left =
|
||||
csbi.srWindow.Top =
|
||||
csbi.srWindow.Right =
|
||||
csbi.srWindow.Bottom = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetConsoleScreenBufferInfo( hConOut, &csbi );
|
||||
CloseHandle( hConOut );
|
||||
}
|
||||
pcsbi = &csbi;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@
|
||||
add log level 32 to log CreateFile.
|
||||
*/
|
||||
|
||||
#define PDATE L"3 February, 2019"
|
||||
#define PDATE L"1 March, 2019"
|
||||
|
||||
#include "ansicon.h"
|
||||
#include "version.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
Copyright 2005-2019 Jason Hood
|
||||
|
||||
Version 1.87. Freeware
|
||||
Version 1.88. Freeware
|
||||
|
||||
|
||||
Description
|
||||
@ -340,6 +340,9 @@ Version History
|
||||
|
||||
Legend: + added, - bug-fixed, * changed.
|
||||
|
||||
1.88 - 1 March, 2019:
|
||||
- fix ANSICON environment variable when there is no console.
|
||||
|
||||
1.87 - 3 February, 2019:
|
||||
- fix crash when some programs start (bug during hooking);
|
||||
- properly hook SetCurrentConsoleFontEx.
|
||||
@ -644,5 +647,5 @@ Distribution
|
||||
in LICENSE.txt.
|
||||
|
||||
|
||||
=============================
|
||||
Jason Hood, 3 February, 2019.
|
||||
==========================
|
||||
Jason Hood, 1 March, 2019.
|
||||
|
10
version.h
10
version.h
@ -2,11 +2,11 @@
|
||||
version.h - Version defines.
|
||||
*/
|
||||
|
||||
#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)
|
||||
#define PVERS L"1.88" // wide string
|
||||
#define PVERSA "1.88" // ANSI string (windres 2.16.91 didn't like L)
|
||||
#define PVERE L"188" // wide environment string
|
||||
#define PVEREA "188" // ANSI environment string
|
||||
#define PVERB 1,8,8,0 // binary (resource)
|
||||
|
||||
#ifdef _WIN64
|
||||
# define BITS L"64"
|
||||
|
Loading…
x
Reference in New Issue
Block a user