simple software (0xCC) breakpoints working + examples with lambda functions

This commit is contained in:
Mr. eXoDia 2015-08-15 20:13:47 +02:00
parent a2fbad713b
commit 26c71cc6e4
2 changed files with 25 additions and 17 deletions

View File

@ -24,6 +24,16 @@ namespace GleeBug
//set continue status
_continueStatus = DBG_CONTINUE;
//set back the instruction pointer
_registers->Gip = info.address;
//restore the original breakpoint byte and do an internal step
_process->MemWrite(info.address, info.internal.software.oldbytes, info.internal.software.size);
_thread->StepInternal(std::bind([this, info]()
{
_process->MemWrite(info.address, info.internal.software.newbytes, info.internal.software.size);
}));
//call the generic callback
cbBreakpoint(info);
@ -39,7 +49,7 @@ namespace GleeBug
if (_thread->isInternalStepping) //handle internal steps
{
//set internal status
_thread->isSingleStepping = false;
_thread->isInternalStepping = false;
_continueStatus = DBG_CONTINUE;
//call the internal step callback

View File

@ -8,9 +8,15 @@ using namespace GleeBug;
class MyDebugger : public Debugger
{
protected:
void myBreakpoint(const BreakpointInfo & info)
void cbEntryBreakpoint(const BreakpointInfo & info)
{
puts("myBreakpoint()");
printf("Reached entry breakpoint! GIP: 0x%p\n",
_registers->Gip());
_thread->StepInto(std::bind([this]()
{
printf("Step after entry breakpoint! GIP: 0x%p\n",
_registers->Gip());
}));
}
void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const ProcessInfo & process) override
@ -19,7 +25,7 @@ protected:
printf("Process %d created with entry 0x%p\n",
_debugEvent.dwProcessId,
entry);
if(_process->SetBreakpoint(entry, this, &MyDebugger::myBreakpoint))
if(_process->SetBreakpoint(entry, this, &MyDebugger::cbEntryBreakpoint))
printf("Breakpoint set at 0x%p!\n", entry);
else
printf("Failed to set breakpoint at 0x%p...\b", entry);
@ -81,25 +87,17 @@ protected:
rip.dwError);
}
void boobs()
void cbStepSystem()
{
printf("(.)Y(.) 0x%p\n",
_registers->Gip.Get());
}
void gax()
{
printf("GAX: 0x%p = 0x%p = 0x%p\n",
_registers->Get(Registers::R::GAX),
_registers->Gax.Get(),
_registers->Gax());
printf("Reached step after system breakpoint, GIP: 0x%p!\n",
_registers->Gip());
}
void cbSystemBreakpoint() override
{
printf("System breakpoint reached, CIP: 0x%p\n",
printf("System breakpoint reached, GIP: 0x%p\n",
_registers->Gip.Get());
_thread->StepInto(this, &MyDebugger::boobs);
_thread->StepInto(this, &MyDebugger::cbStepSystem);
}
void cbInternalError(const std::string & error) override