Click here to Skip to main content
11,490,973 members (60,984 online)
Click here to Skip to main content
Add your own
alternative version

Write Your Own Debugger to Handle Breakpoints

, 17 May 2011 CPOL 22.4K 1.1K 43
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

Asif Bahrainwala
Instructor / Trainer
India India
Hi,
I have been working with computers since my eight grade, programming the ZX Spectrum. I have always had an interest in assembly language and computer theory (and is still the reason for taking tons of online courses), actively code using C/C++ on Windows (using VS) and Linux (using QT).

I also provide training on data structures, algorithms, parallel patterns library , Graphics (DX11), GPGPUs (DX11-CS,AMP) and programming for performance on x86.
Feel free to call me at 0091-9823018914 (UTC +5:30)



(All views expressed here do not reflect the views of my employer).
Follow on   LinkedIn

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150520.1 | Last Updated 17 May 2011
Article Copyright 2011 by Asif Bahrainwala
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid