Test if the real WriteFile handle is console
This commit is contained in:
parent
d7a2be9964
commit
f4697b59fa
8
ANSI.c
8
ANSI.c
@ -202,7 +202,8 @@
|
|||||||
dynamically load WINMM.DLL;
|
dynamically load WINMM.DLL;
|
||||||
use sprintf/_snprintf/_snwprintf instead of wsprintf, avoiding USER32.DLL;
|
use sprintf/_snprintf/_snwprintf instead of wsprintf, avoiding USER32.DLL;
|
||||||
replace bsearch (in procrva.c) with specific code;
|
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"
|
#include "ansicon.h"
|
||||||
@ -3489,13 +3490,12 @@ WINAPI MyWriteConsoleW( HANDLE hCon, LPCVOID lpBuffer,
|
|||||||
BOOL
|
BOOL
|
||||||
WINAPI MyWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
WINAPI MyWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
||||||
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped )
|
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped )
|
||||||
{
|
|
||||||
if (nNumberOfBytesToWrite != 0 && IsConsoleHandle( hFile ))
|
|
||||||
{
|
{
|
||||||
if (HandleToULong( hFile ) == STD_OUTPUT_HANDLE ||
|
if (HandleToULong( hFile ) == STD_OUTPUT_HANDLE ||
|
||||||
HandleToULong( hFile ) == STD_ERROR_HANDLE)
|
HandleToULong( hFile ) == STD_ERROR_HANDLE)
|
||||||
hFile = GetStdHandle( HandleToULong( hFile ) );
|
hFile = GetStdHandle( HandleToULong( hFile ) );
|
||||||
|
if (nNumberOfBytesToWrite != 0 && IsConsoleHandle( hFile ))
|
||||||
|
{
|
||||||
write_func = "WriteFile";
|
write_func = "WriteFile";
|
||||||
MyWriteConsoleA( hFile, lpBuffer,nNumberOfBytesToWrite, NULL,lpOverlapped );
|
MyWriteConsoleA( hFile, lpBuffer,nNumberOfBytesToWrite, NULL,lpOverlapped );
|
||||||
if (lpNumberOfBytesWritten != NULL)
|
if (lpNumberOfBytesWritten != NULL)
|
||||||
|
@ -339,8 +339,10 @@ Version History
|
|||||||
|
|
||||||
Legend: + added, - bug-fixed, * changed.
|
Legend: + added, - bug-fixed, * changed.
|
||||||
|
|
||||||
1.84-wip - 2 May, 2018:
|
1.84-wip - 3 May, 2018:
|
||||||
- close the flush handles on detach;
|
- 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;
|
* remove dependency on USER32, dynamically load WINMM;
|
||||||
* exit process if the primary thread is detached (for processes on Win10
|
* exit process if the primary thread is detached (for processes on Win10
|
||||||
that return, rather than call ExitProcess).
|
that return, rather than call ExitProcess).
|
||||||
@ -619,4 +621,4 @@ Distribution
|
|||||||
|
|
||||||
|
|
||||||
========================
|
========================
|
||||||
Jason Hood, 2 May, 2018.
|
Jason Hood, 3 May, 2018.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user