Skip to content

Commit

Permalink
Fix running directly via ansicon
Browse files Browse the repository at this point in the history
A program run directly by `ansicon` should always be hooked, regardless
if it's GUI or excluded.  This was broken in v1.84 due to the DLL being
imported.
  • Loading branch information
adoxa committed Aug 23, 2018
1 parent eec487a commit 4e84582
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions ANSI.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@
workaround Windows 10 1803 console bug.
v1.85, 22 August, 2018:
fix creating the wrap buffer.
fix creating the wrap buffer;
always inject from ansicon.exe, even if it's GUI or excluded.
*/

#include "ansicon.h"
Expand All @@ -236,6 +237,7 @@ DWORD orgmode; // original mode
CONSOLE_CURSOR_INFO orgcci; // original cursor state
HANDLE hHeap; // local memory heap
HANDLE hBell, hFlush;
BOOL ansicon; // are we in ansicon.exe?

#define CACHE 5
struct Cache
Expand Down Expand Up @@ -3003,15 +3005,15 @@ void Inject( DWORD dwCreationFlags, LPPROCESS_INFORMATION lpi,

name = get_program( app, child_pi->hProcess, wide, lpApp, lpCmd );
DEBUGSTR( 1, "%S (%u)", name, child_pi->dwProcessId );
if (search_env( L"ANSICON_EXC", name ))
if (!ansicon && search_env( L"ANSICON_EXC", name ))
{
DEBUGSTR( 1, " Excluded" );
type = 0;
}
else
{
type = ProcessType( child_pi, &base, &gui );
if (gui && type > 0)
if (!ansicon && gui && type > 0)
{
if (!search_env( L"ANSICON_GUI", name ))
{
Expand Down Expand Up @@ -3927,6 +3929,7 @@ void OriginalAttr( PVOID lpReserved )
else
{
// We also want to restore the original attributes for ansicon.exe.
ansicon =
org = (pNTHeader->OptionalHeader.MajorImageVersion == 20033 && // 'AN'
pNTHeader->OptionalHeader.MinorImageVersion == 18771); // 'SI'
}
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ Version History
1.85 - 22 August, 2018:
- fix wrap issues with a buffer bigger than the window;
- fix -e et al when redirecting to NUL;
- prevent -p from injecting when already injected.
- prevent -p from injecting when already injected;
- fix running directly via ansicon (hook even if it's GUI or excluded).

1.84 - 11 May, 2018:
- close the flush handles on detach;
Expand Down

0 comments on commit 4e84582

Please sign in to comment.