Click here to Skip to main content
15,879,326 members
Articles / Desktop Programming / Win32

Writing a basic Windows debugger

Rate me:
Please Sign up or sign in to vote.
4.92/5 (81 votes)
24 Jan 2011CPOL14 min read 209.4K   12.6K   218  
Learn how you can write your own Windows debugger.
// Crude DebuggerDlg.h : header file
//

#pragma once
#include "afxcmn.h"
#include "afxwin.h"


// CCrudeDebuggerDlg dialog
class CCrudeDebuggerDlg : public CDialog
{

	// Debug Event Counts
	int TotalEvents;
	int ThreadCount, DLLCount, ExceptionCount, OutputDebugCount;	// Including Breakpoints 

	

	HANDLE m_hDebugThread;
	bool m_bIsDebugging;

public:
	CCrudeDebuggerDlg(CWnd* pParent = NULL);	// standard constructor

	// Enables or disables appropriate controls of Debugging status.
	void SetDebuggingModeUI(bool bDebug);

	CString ProcessNameToDebug;

	void DebuggerThreadProc();

// Dialog Data
	enum { IDD = IDD_CRUDEDEBUGGER_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

	LRESULT OnDebugEventMessage(WPARAM, LPARAM);


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedStartDebugging();
	afx_msg void OnBnClickedBrowse();
	CListCtrl m_cDebugEvents;
	CStatic m_cThreadCount;
	CStatic m_cDLLCount;
	CStatic m_cTotalEvents;
	CStatic m_cOutputDebug;
	CStatic m_cExceptionCount;
};

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)
India India
Started programming with GwBasic back in 1996 (Those lovely days!). Found the hidden talent!

Touched COBOL and Quick Basic for a while.

Finally learned C and C++ entirely on my own, and fell in love with C++, still in love! Began with Turbo C 2.0/3.0, then to VC6 for 4 years! Finally on VC2008/2010.

I enjoy programming, mostly the system programming, but the UI is always on top of MFC! Quite experienced on other environments and platforms, but I prefer Visual C++. Zeal to learn, and to share!

Comments and Discussions