![]() ![]() Detour function that replaces the WriteConsoleW API. Target pointer for the uninstrumented WriteConsoleW API.Īuto WriteConsoleW_orig = &WriteConsoleW I created a hook DLL based on the example of Using Detours: #include Otherwise call the original WriteConsole() function. Reading the console screen buffer (as suggested by this answer) prooved to be unreliable, so I used Microsoft Detours library to hook the WriteConsole() API in the target process and call WriteFile() if necessary. I recently had to redirect output from a closed-source application that unconditionally called WriteConsole() so it could not be redirected normally. This is only applicable if you control the source code of the application that you want to redirect. Redirected and you should call WriteFile to perform the I/O. If the handle is not a console handle, the output is That can be redirected, determine whether the output handle is aĬonsole handle (one method is to call the GetConsoleMode function andĬheck whether it succeeds). If an application processes multilingual output WriteConsole fails if it is used with a standard handle that is This renders my original answer obsolete for Windows versions that support ConPTY. ![]() Windows 10 now has the ConPTY API (aka pseudo-console), which basically allows any program to act like the console for another program, thus enables capturing output that is directly written to the console. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |