Click here to Skip to main content
15,894,546 members
Articles / Desktop Programming / WTL

Mechanism of OutputDebugString

Rate me:
Please Sign up or sign in to vote.
4.88/5 (16 votes)
21 Feb 2008CPOL4 min read 115.3K   3.4K   79  
Write a monitoring application to capture debug messages
//////////////////////////////////////////////////////////////
//
//         File: WinDebugMonitor.h
//  Description: Interface of class CWinDebugMonitor
//      Created: 2007-12-6
//       Author: Ken Zhang
//       E-Mail: cpp.china@hotmail.com
//
//////////////////////////////////////////////////////////////

#ifndef __WIN_DEBUG_BUFFER_H__
#define __WIN_DEBUG_BUFFER_H__

#include <windows.h>
#include <atlbase.h>
#include <atlstr.h>

class CWinDebugMonitor
{
private:
	enum {
		TIMEOUT_WIN_DEBUG	=	100,
	};

	struct dbwin_buffer
	{
		DWORD   dwProcessId;
		char    data[4096-sizeof(DWORD)];
	};

private:
	HANDLE m_hDBWinMutex;
	HANDLE m_hDBMonBuffer;
	HANDLE m_hEventBufferReady;
	HANDLE m_hEventDataReady;

	HANDLE m_hWinDebugMonitorThread;
	BOOL m_bWinDebugMonStopped;
	struct dbwin_buffer *m_pDBBuffer;

private:
	DWORD Initialize();
	void Unintialize();
	DWORD WinDebugMonitorProcess();
	static DWORD WINAPI WinDebugMonitorThread(void *pData);

public:
	CWinDebugMonitor();
	~CWinDebugMonitor();

public:
	virtual void OutputWinDebugString(const char *str) {};
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) New Dimension
China China
Programming since 1997
Favorite language: C++, C#
Interest: OS, algorithm, embedded-system, UI design

Comments and Discussions