I wanted to call _popen to get the results from an executable but it was blanking out.
I looked in debugger and found out the program uses Kernel32.WriteConsoleW to write a unicode string to the console, instead of using stdout.
How do I capture it?
Any output generated with WriteConsole
will not be written to the redirection pipe. If a handle to a pipe or a file or anything else than a console is given to WriteConsole
, it will fail with ERROR_INVALID_HANDLE
(6).
From High-Level Console Input and Output Functions on MSDN:
ReadConsole and WriteConsole can only be used with console handles; ReadFile and WriteFile can be used with other handles (such as files or pipes). ReadConsole and WriteConsole fail if used with a standard handle that has been redirected and is no longer a console handle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With