Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Write Your Own Debugger to Handle Breakpoints

, 17 May 2011
Basic debugger, Breakpoints, OutputDebugString
Debugger.zip
Debugger
Debugger.vcxproj.filters
Debugger.vcxproj.user
Debuggee
Debuggee.vcxproj.filters
Debuggee.vcxproj.user
// Debuggee.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<Windows.h>
#include<comdef.h>

int _tmain(int argc, _TCHAR* argv[])
{
	MessageBoxA(0,"Debuggee started","placing break point",0);

	//find IP  (mov eax,eip :invalid opcode)
	UINT EIP=0;
	_asm 
	{
		call f
		jmp finish

f:		pop eax
		mov EIP,eax
		push eax
		ret
finish:
	}
	EIP+=50;

	BYTE *b=(BYTE*)EIP;
	for(int i=0;i<100;i++)
		printf("%x : %x \n",EIP+i,b[i]);

	::DebugBreak();  //notice that instruction 0xcc is placed here (which is Interrupt 3), the debug memory dump window will not show this

	::OutputDebugString(_bstr_t::bstr_t("debug string"));
	MessageBoxA(0,"Debuggee ending","",0);
	return 0;
}

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)

Share

About the Author

No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 17 May 2011
Article Copyright 2011 by Asif Bahrainwala
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid