|
// Debugger.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
PROCESS_INFORMATION pi={};
void EnterDebugLoop()
{
DEBUG_EVENT de;
while(1)
{
WaitForDebugEvent(&de, INFINITE);
switch (de.dwDebugEventCode)
{
case EXCEPTION_DEBUG_EVENT:
switch(de.u.Exception.ExceptionRecord.ExceptionCode)
{
case EXCEPTION_BREAKPOINT:
MessageBoxA(0,"Found break point","",0);
break;
}
break;
case OUTPUT_DEBUG_STRING_EVENT:
{
char a[100];
ReadProcessMemory(pi.hProcess,de.u.DebugString.lpDebugStringData,a,de.u.DebugString.nDebugStringLength,NULL);
printf("output from debug string is: %s",a);
}
break;
}
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, DBG_CONTINUE);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFOA si={};
::CreateProcessA("..\\Debug\\Debuggee.exe","",0,0,0,CREATE_NEW_CONSOLE, 0,0,&si,&pi);
/*BYTE p[]={0xcc}; //0xcc=int 3
DWORD d=0;
::WriteProcessMemory(pi.hProcess,(void*)0x00F21460,p,sizeof(p),&d);*/
BOOL bo=DebugActiveProcess(pi.dwProcessId);
if(bo==0)
printf("Could not attach debugger, GetLastError: %u \n",GetLastError());
EnterDebugLoop();
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.