I created a logging service that listens to debug messages (calls to OutputDebugString) from other applications. My starting point was DbMon.Net (http://www.codeproject.com/KB/trace/DbMonNET.aspx?msg=2612567) but I had to fix the following issues:
- Security descriptor was not used and as a result I did not see messages from applications running under another user.
- Created two listeners - one local and one global, to listen to all messages.
The service can run as a regular application as well (for debugging).
On Win XP everything works well and the service gets all debug messages from all applications, no matter whether they are services or running under a different user. On Vista/Win2K3, however, one case still does not work. The service does not get messages from applications running under a logged-in user. It does get messages from other users and from IIS (which runs under a special IUSR account). When I run the logging service as a regular application to debug this, everything works fine again.
I am pretty sure this is a permission issue which is caused by the different sessions in Vista (sessions 0 for services, sessions 1..n to other users) but I cannot figure out how to fix this last case. Any ideas?