Hook the printf outputs

Apr 17, 2021 at 9:43am
I want to get the printf outputs of a foreign C++ dll in my C# application. Is there a way to install a hook?

The foreign c++ dll is encapsulated via my own C++ dll (interface C++ -> C#). I tried to overwrite printf there - unfortunately without success.

Thank you for any hints.
Apr 24, 2021 at 3:02pm
1. You execute code via a small console executable of your own which include the DLL
2. You launch that console executable hidden from your main application and capture the output via interprocess communication.
May 28, 2021 at 12:02pm
can you reassign stdout to another stream and use it? I forget the details on this, so I apologize in advance, but I seem to recall that you could override the streams to use other devices (where a device can just be a buffer you share?!)

https://www.geeksforgeeks.org/io-redirection-c/ maybe?

I do not know if this will work: does the dll use the overridden printf or its own local instance? All I can say is, try it... it isnt much code to test one example maybe?
Last edited on May 28, 2021 at 12:06pm
Topic archived. No new replies allowed.