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
19
ANSI.c
19
ANSI.c
@ -223,6 +223,9 @@
|
|||||||
v1.87, 3 February, 2019:
|
v1.87, 3 February, 2019:
|
||||||
some hooked functions are not imported, so myimport wasn't set;
|
some hooked functions are not imported, so myimport wasn't set;
|
||||||
add missing SetCurrentConsoleFontEx to list of hooks.
|
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"
|
#include "ansicon.h"
|
||||||
@ -3874,8 +3877,20 @@ void set_ansicon( PCONSOLE_SCREEN_BUFFER_INFO pcsbi )
|
|||||||
hConOut = CreateFile( L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
hConOut = CreateFile( L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
NULL, OPEN_EXISTING, 0, NULL );
|
NULL, OPEN_EXISTING, 0, NULL );
|
||||||
GetConsoleScreenBufferInfo( hConOut, &csbi );
|
if (hConOut == INVALID_HANDLE_VALUE)
|
||||||
CloseHandle( hConOut );
|
{
|
||||||
|
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;
|
pcsbi = &csbi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
add log level 32 to log CreateFile.
|
add log level 32 to log CreateFile.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PDATE L"3 February, 2019"
|
#define PDATE L"1 March, 2019"
|
||||||
|
|
||||||
#include "ansicon.h"
|
#include "ansicon.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Copyright 2005-2019 Jason Hood
|
Copyright 2005-2019 Jason Hood
|
||||||
|
|
||||||
Version 1.87. Freeware
|
Version 1.88. Freeware
|
||||||
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
@ -340,6 +340,9 @@ Version History
|
|||||||
|
|
||||||
Legend: + added, - bug-fixed, * changed.
|
Legend: + added, - bug-fixed, * changed.
|
||||||
|
|
||||||
|
1.88 - 1 March, 2019:
|
||||||
|
- fix ANSICON environment variable when there is no console.
|
||||||
|
|
||||||
1.87 - 3 February, 2019:
|
1.87 - 3 February, 2019:
|
||||||
- fix crash when some programs start (bug during hooking);
|
- fix crash when some programs start (bug during hooking);
|
||||||
- properly hook SetCurrentConsoleFontEx.
|
- properly hook SetCurrentConsoleFontEx.
|
||||||
@ -644,5 +647,5 @@ Distribution
|
|||||||
in LICENSE.txt.
|
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.
|
version.h - Version defines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PVERS L"1.87" // wide string
|
#define PVERS L"1.88" // wide string
|
||||||
#define PVERSA "1.87" // ANSI string (windres 2.16.91 didn't like L)
|
#define PVERSA "1.88" // ANSI string (windres 2.16.91 didn't like L)
|
||||||
#define PVERE L"187" // wide environment string
|
#define PVERE L"188" // wide environment string
|
||||||
#define PVEREA "187" // ANSI environment string
|
#define PVEREA "188" // ANSI environment string
|
||||||
#define PVERB 1,8,7,0 // binary (resource)
|
#define PVERB 1,8,8,0 // binary (resource)
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
# define BITS L"64"
|
# define BITS L"64"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user