diff --git a/ANSI.c b/ANSI.c index 84f4ebd..55ec3c0 100644 --- a/ANSI.c +++ b/ANSI.c @@ -202,7 +202,8 @@ dynamically load WINMM.DLL; use sprintf/_snprintf/_snwprintf instead of wsprintf, avoiding USER32.DLL; replace bsearch (in procrva.c) with specific code; - if the primary thread is detached exit the process. + if the primary thread is detached exit the process; + get real WriteFile handle before testing for console. */ #include "ansicon.h" @@ -3490,12 +3491,11 @@ BOOL WINAPI MyWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped ) { + if (HandleToULong( hFile ) == STD_OUTPUT_HANDLE || + HandleToULong( hFile ) == STD_ERROR_HANDLE) + hFile = GetStdHandle( HandleToULong( hFile ) ); if (nNumberOfBytesToWrite != 0 && IsConsoleHandle( hFile )) { - if (HandleToULong( hFile ) == STD_OUTPUT_HANDLE || - HandleToULong( hFile ) == STD_ERROR_HANDLE) - hFile = GetStdHandle( HandleToULong( hFile ) ); - write_func = "WriteFile"; MyWriteConsoleA( hFile, lpBuffer,nNumberOfBytesToWrite, NULL,lpOverlapped ); if (lpNumberOfBytesWritten != NULL) diff --git a/readme.txt b/readme.txt index da783db..123bc1e 100644 --- a/readme.txt +++ b/readme.txt @@ -339,8 +339,10 @@ Version History Legend: + added, - bug-fixed, * changed. - 1.84-wip - 2 May, 2018: + 1.84-wip - 3 May, 2018: - close the flush handles on detach; + - use remote load on Win8+ if the process has no IAT; + - WriteFile wasn't properly testing if its handle was for a console; * remove dependency on USER32, dynamically load WINMM; * exit process if the primary thread is detached (for processes on Win10 that return, rather than call ExitProcess). @@ -619,4 +621,4 @@ Distribution ======================== -Jason Hood, 2 May, 2018. +Jason Hood, 3 May, 2018.