My program uses a ton of third party libraries that sometimes put useful error messages into debugger output (using OutputDebugString()).

Can my program somehow programmatically access that output so that it can parse it and report it to me in some more convenient manner?

有帮助吗?

解决方案

There is no API that gives you access to strings output through OutputDebugString.

There are two ways of getting the data:

The OutputDebugString protocol only supports a single listener so the first approach isn't compatible with multiple instances of your application, other applications doing the same thing or debuggers. It would also capture output from all applications. It is not a good idea. I mention it only because it is an obvious but wrong solution.

OutputDebugStringW is (unusually) a wrapper around OutputDebugStringA so the latter is the function to hook. There are lots of libraries that make hooking easy so every call to OutputDebugString will become a call to a function you define, and you can do anything you like with the data.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top