DBG: updated TitanEngine

DBG: fixed terribly slow _dbg_memread export (became slow when you set more then two breakpoints)
DBG: fixed various bugs in breakpoint.cpp
DBG: added bpfixmemory to breakpoint.cpp (this restores the original breakpoint bytes)
DBG: re-enabled memory breakpoints
DBG: remove breakpoints outside of modules
DBG: fixed a bug in "bplist"
DBG: silent breakpoint
BRIDGE: renamed breakpoint types
This commit is contained in:
mr.exodia 2013-11-19 22:41:04 +01:00
parent 67f5a6ae8e
commit b12a05f627
14 changed files with 150 additions and 155 deletions

Binary file not shown.

Binary file not shown.

View File

@ -63,10 +63,10 @@ enum ADDRINFOFLAGS
enum BPXTYPE
{
bpnone=0,
bpnormal=1,
bphardware=2,
bpmemory=4
bp_none=0,
bp_normal=1,
bp_hardware=2,
bp_memory=4
};
//Debugger structs
@ -145,6 +145,7 @@ DLL_IMPEXP void DbgMemRead(duint va, unsigned char* dest, duint size);
DLL_IMPEXP duint DbgMemGetPageSize(duint base);
DLL_IMPEXP duint DbgMemFindBaseAddr(duint addr, duint* size);
DLL_IMPEXP bool DbgCmdExec(const char* cmd);
DLL_IMPEXP bool DbgCmdExecWait(const char* cmd);
DLL_IMPEXP bool DbgMemMap(MEMMAP* memmap);
DLL_IMPEXP bool DbgIsValidExpression(const char* expression);
DLL_IMPEXP bool DbgIsDebugging();

View File

@ -5,6 +5,7 @@
#include "addrinfo.h"
#include "console.h"
#include "threading.h"
#include "breakpoint.h"
extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size)
{
@ -13,10 +14,11 @@ extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size)
extern "C" DLL_EXPORT bool _dbg_memread(duint addr, unsigned char* dest, duint size, duint* read)
{
dbgdisablebpx();
bool res=memread(fdProcessInfo->hProcess, (void*)addr, dest, size, read);
dbgenablebpx();
return res;
bool ret=memread(fdProcessInfo->hProcess, (void*)addr, dest, size, read);
if(!ret)
return false;
bpfixmemory(addr, dest, size);
return true;
}
extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
@ -180,18 +182,27 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo)
extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
{
BREAKPOINT bp;
int result=0;
if(bpget(addr, BPNORMAL, 0, &bp))
if(bp.enabled)
result|=bpnormal;
if(bpget(addr, BPHARDWARE, 0, &bp))
if(bp.enabled)
result|=bphardware;
if(bpget(addr, BPMEMORY, 0, &bp))
if(bp.enabled)
result|=bpmemory;
return result;
static uint cacheAddr;
static int cacheBpCount;
static int cacheResult;
int bpcount=bpgetlist(0);
if(cacheAddr!=addr or cacheBpCount!=bpcount)
{
BREAKPOINT bp;
cacheAddr=addr;
cacheResult=0;
cacheBpCount=bpcount;
if(bpget(addr, BPNORMAL, 0, &bp))
if(bp.enabled)
cacheResult|=bp_normal;
if(bpget(addr, BPHARDWARE, 0, &bp))
if(bp.enabled)
cacheResult|=bp_hardware;
if(bpget(addr, BPMEMORY, 0, &bp))
if(bp.enabled)
cacheResult|=bp_memory;
}
return cacheResult;
}
extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)

View File

@ -45,6 +45,9 @@ bool dbsave()
void dbclose()
{
//NOTE: remove breakpoints without module
if(!sqlexec(userdb, "DELETE FROM breakpoints WHERE mod IS NULL"))
dprintf("SQL Error: %s\n", sqllasterror());
dbsave();
sqlite3_db_release_memory(userdb);
sqlite3_close(userdb); //close user database
@ -230,7 +233,7 @@ bool commentset(uint addr, const char* text)
}
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
GuiUpdateAllViews();
@ -271,7 +274,7 @@ bool commentdel(uint addr)
sprintf(sql, "DELETE FROM comments WHERE id=%d", del_id);
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
GuiUpdateAllViews();
@ -310,7 +313,7 @@ bool labelset(uint addr, const char* text)
}
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
GuiUpdateAllViews();
@ -351,7 +354,7 @@ bool labeldel(uint addr)
sprintf(sql, "DELETE FROM labels WHERE id=%d", del_id);
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
dbsave();

View File

@ -14,26 +14,37 @@ int bpgetlist(BREAKPOINT** list)
return bpcount;
}
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, int titantype, const char* name)
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name)
{
char modname[256]="";
if(!modnamefromaddr(addr, modname)) //no module
return false;
char sql[deflen]="";
uint modbase=modbasefromaddr(addr);
if(bpget(addr, type, name, 0)) //breakpoint found
return false;
char modname[256]="";
char sql[deflen]="";
char bpname[MAX_BREAKPOINT_NAME]="";
if(name and *name)
if(modnamefromaddr(addr, modname)) //no module
{
sqlstringescape(name, bpname);
sprintf(sql, "INSERT INTO breakpoints (addr,enabled,singleshoot,oldbytes,type,titantype,mod,name) VALUES (%"fext"d,%d,%d,%d,%d,%d,'%s','%s')", addr-modbase, enabled, singleshoot, oldbytes, type, titantype, modname, bpname);
uint modbase=modbasefromaddr(addr);
if(name and *name)
{
sqlstringescape(name, bpname);
sprintf(sql, "INSERT INTO breakpoints (addr,enabled,singleshoot,oldbytes,type,titantype,mod,name) VALUES (%"fext"d,%d,%d,%d,%d,%d,'%s','%s')", addr-modbase, enabled, singleshoot, oldbytes, type, titantype, modname, bpname);
}
else
sprintf(sql, "INSERT INTO breakpoints (addr,enabled,singleshoot,oldbytes,type,titantype,mod) VALUES (%"fext"d,%d,%d,%d,%d,%d,'%s')", addr-modbase, enabled, singleshoot, oldbytes, type, titantype, modname);
}
else
sprintf(sql, "INSERT INTO breakpoints (addr,enabled,singleshoot,oldbytes,type,titantype,mod) VALUES (%"fext"d,%d,%d,%d,%d,%d,'%s')", addr-modbase, enabled, singleshoot, oldbytes, type, titantype, modname);
{
if(name and *name)
{
sqlstringescape(name, bpname);
sprintf(sql, "INSERT INTO breakpoints (addr,enabled,singleshoot,oldbytes,type,titantype,name) VALUES (%"fext"d,%d,%d,%d,%d,%d,'%s')", addr, enabled, singleshoot, oldbytes, type, titantype, bpname);
}
else
sprintf(sql, "INSERT INTO breakpoints (addr,enabled,singleshoot,oldbytes,type,titantype) VALUES (%"fext"d,%d,%d,%d,%d,%d)", addr, enabled, singleshoot, oldbytes, type, titantype);
}
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
bpenumall(0); //update breakpoint list
@ -68,7 +79,6 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
{
sqlstringescape(name, bpname);
sprintf(sql, "SELECT addr,enabled,singleshoot,oldbytes,type,titantype,mod,name FROM breakpoints WHERE (addr=%"fext"d AND type=%d AND mod='%s') OR name='%s'", addr-modbase, type, modname, bpname);
puts(sql);
}
else
sprintf(sql, "SELECT addr,enabled,singleshoot,oldbytes,type,titantype,mod,name FROM breakpoints WHERE (addr=%"fext"d AND type=%d AND mod='%s')", addr-modbase, type, modname);
@ -91,34 +101,27 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
}
if(!modbase)
{
const char* mod=(const char*)sqlite3_column_text(stmt, 6);
const char* mod=(const char*)sqlite3_column_text(stmt, 6); //mod
if(mod)
modbase=modbasefromname(mod);
}
//addr
#ifdef _WIN64
bp->addr=sqlite3_column_int64(stmt, 0)+modbase; //addr
#else
bp->addr=sqlite3_column_int(stmt, 0)+modbase; //addr
#endif // _WIN64
//enabled
if(sqlite3_column_int(stmt, 1))
if(sqlite3_column_int(stmt, 1)) //enabled
bp->enabled=true;
else
bp->enabled=false;
//singleshoot
if(sqlite3_column_int(stmt, 2))
if(sqlite3_column_int(stmt, 2)) //singleshoot
bp->singleshoot=true;
else
bp->singleshoot=false;
//oldbytes
bp->oldbytes=(short)(sqlite3_column_int(stmt, 3)&0xFFFF);
//type
bp->type=(BP_TYPE)sqlite3_column_int(stmt, 4);
//titantype
bp->titantype=sqlite3_column_int(stmt, 5);
//name
const char* bpname_=(const char*)sqlite3_column_text(stmt, 7);
bp->oldbytes=(short)(sqlite3_column_int(stmt, 3)&0xFFFF); //oldbytes
bp->type=(BP_TYPE)sqlite3_column_int(stmt, 4); //type
bp->titantype=sqlite3_column_int(stmt, 5); //titantype
const char* bpname_=(const char*)sqlite3_column_text(stmt, 7); //name
if(bpname_)
strcpy(bp->name, bpname_);
else
@ -135,12 +138,12 @@ bool bpdel(uint addr, BP_TYPE type)
char modname[256]="";
char sql[deflen]="";
if(!modnamefromaddr(addr, modname)) //no module
sprintf(sql, "DELETE FROM breakpoints WHERE addr=%"fext"d AND IS NULL AND type=%d", addr, type);
sprintf(sql, "DELETE FROM breakpoints WHERE addr=%"fext"d AND mod IS NULL AND type=%d", addr, type);
else
sprintf(sql, "DELETE FROM breakpoints WHERE addr=%"fext"d AND mod='%s' AND type=%d", addr-modbasefromaddr(addr), modname, type);
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
bpenumall(0); //update breakpoint list
@ -161,7 +164,7 @@ bool bpenable(uint addr, BP_TYPE type, bool enable)
sprintf(sql, "UPDATE breakpoints SET enabled=%d WHERE addr=%"fext"d AND mod='%s' AND type=%d", enable, addr-modbasefromaddr(addr), modname, type);
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
dbsave();
@ -183,7 +186,7 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name)
sprintf(sql, "UPDATE breakpoints SET name='%s' WHERE addr=%"fext"d AND mod='%s' AND type=%d", bpname, addr-modbasefromaddr(addr), modname, type);
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\n", sqllasterror());
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
dbsave();
@ -267,3 +270,22 @@ int bpgetcount(BP_TYPE type)
sprintf(sql, "SELECT * FROM breakpoints WHERE type=%d", type);
return sqlrowcount(userdb, sql);
}
void bpfixmemory(uint addr, unsigned char* dest, uint size)
{
uint start=addr;
uint end=addr+size;
unsigned char oldbytes[2];
for(int i=0; i<bpcount; i++)
{
memcpy(oldbytes, &bpall[i].oldbytes, sizeof(short));
uint cur_addr=bpall[i].addr;
if(cur_addr>=start and cur_addr<end) //breakpoint is in range of current memory
{
uint index=cur_addr-start;
dest[index]=oldbytes[0];
if(size>1 and index!=(size-1)) //restore second byte
dest[index+1]=oldbytes[1];
}
}
}

View File

@ -23,7 +23,7 @@ struct BREAKPOINT
bool singleshoot;
short oldbytes;
BP_TYPE type;
int titantype;
DWORD titantype;
char name[MAX_BREAKPOINT_NAME];
char mod[32];
};
@ -34,7 +34,7 @@ typedef bool (*BPENUMCALLBACK)(const BREAKPOINT* bp);
//functions
int bpgetlist(BREAKPOINT** list);
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, int titantype, const char* name);
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name);
bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp);
bool bpdel(uint addr, BP_TYPE type);
bool bpenable(uint addr, BP_TYPE type, bool enable);
@ -42,5 +42,6 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name);
bool bpenumall(BPENUMCALLBACK cbEnum);
bool bpenumall(BPENUMCALLBACK cbEnum, const char* module);
int bpgetcount(BP_TYPE type);
void bpfixmemory(uint addr, unsigned char* dest, uint size);
#endif // _BREAKPOINT_H

View File

@ -135,22 +135,21 @@ static void cbMemoryBreakpoint(void* ExceptionAddress)
uint cip=GetContextData(UE_CIP);
uint size;
uint base=memfindbaseaddr(fdProcessInfo->hProcess, (uint)ExceptionAddress, &size);
//TODO: restore bp
/*BREAKPOINT* cur=bpfind(bplist, 0, base, 0, BPMEMORY);
if(!cur)
BREAKPOINT found;
if(!bpget(base, BPMEMORY, 0, &found))
dputs("memory breakpoint reached not in list!");
else
{
//unsigned char type=cur->oldbytes&0xF;
char log[50]="";
if(cur->name)
sprintf(log, "memory breakpoint \"%s\" on "fhex"!", cur->name, cur->addr);
if(*found.name)
sprintf(log, "memory breakpoint \"%s\" on "fhex"!", found.name, found.addr);
else
sprintf(log, "memory breakpoint on "fhex"!", cur->addr);
sprintf(log, "memory breakpoint on "fhex"!", found.addr);
dputs(log);
}
if(!(cur->oldbytes>>4)) //is auto-restoring?
bpdel(bplist, 0, base, BPMEMORY); //delete from breakpoint list*/
if(found.singleshoot)
bpdel(found.addr, BPMEMORY); //delete from breakpoint list
DebugUpdateGui(cip);
GuiSetDebugState(paused);
//lock
@ -256,6 +255,16 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
}
break;
case BPMEMORY:
if(bp->enabled)
{
uint size=0;
memfindbaseaddr(fdProcessInfo->hProcess, bp->addr, &size);
bool restore=false;
if(!bp->singleshoot)
restore=true;
if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, restore, (void*)cbMemoryBreakpoint))
dprintf("could not set memory breakpoint "fhex"!\n", bp->addr);
}
break;
case BPHARDWARE:
if(bp->enabled)
@ -401,10 +410,10 @@ static void cbRtrFinalStep()
static unsigned char getCIPch()
{
char ch;
dbgdisablebpx();
memread(fdProcessInfo->hProcess, (void*)GetContextData(UE_CIP), &ch, 1, 0);
dbgenablebpx();
unsigned char ch=0x90;
uint cip=GetContextData(UE_CIP);
memread(fdProcessInfo->hProcess, (void*)cip, &ch, 1, 0);
bpfixmemory(cip, &ch, 1);
return ch;
}
@ -583,7 +592,7 @@ CMDRESULT cbDebugSetBPX(const char* cmd) //bp addr [,name [,type]]
}
_strlwr(argtype);
uint addr=0;
if(!valfromstring(argaddr, &addr, 0, 0, false, 0))
if(!valfromstring(argaddr, &addr, 0, 0, true, 0))
{
dprintf("invalid addr: \"%s\"\n", argaddr);
return STATUS_ERROR;
@ -793,10 +802,13 @@ CMDRESULT cbDebugDisableBPX(const char* cmd)
static bool cbBreakpointList(const BREAKPOINT* bp)
{
const char* type=0;
if(bp->singleshoot)
type="SS";
else if(bp->type==BPNORMAL)
type="BP";
if(bp->type==BPNORMAL)
{
if(bp->singleshoot)
type="SS";
else
type="BP";
}
else if(bp->type==BPHARDWARE)
type="HW";
else if(bp->type==BPMEMORY)
@ -864,15 +876,13 @@ CMDRESULT cbDebugDisasm(const char* cmd)
return STATUS_CONTINUE;
}
CMDRESULT cbDebugMemoryBpx(const char* cmd)
CMDRESULT cbDebugSetMemoryBpx(const char* cmd)
{
//TODO: restore bp
/*
char arg1[deflen]=""; //addr
if(!argget(cmd, arg1, 0, false))
return STATUS_ERROR;
uint addr;
if(!valfromstring(arg1, &addr, 0, 0, false, 0))
if(!valfromstring(arg1, &addr, 0, 0, true, 0))
return STATUS_ERROR;
bool restore=false;
char arg2[deflen]=""; //restore
@ -908,17 +918,16 @@ CMDRESULT cbDebugMemoryBpx(const char* cmd)
}
uint size=0;
uint base=memfindbaseaddr(fdProcessInfo->hProcess, addr, &size);
BREAKPOINT* found=bpfind(bplist, 0, base, 0, BPMEMORY);
if(found or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint))
bool singleshoot=false;
if(!restore)
singleshoot=true;
if(bpget(base, BPMEMORY, 0, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint) or !bpnew(base, true, singleshoot, 0, BPMEMORY, 0, 0))
{
dputs("error setting memory breakpoint!");
return STATUS_ERROR;
}
if(bpnew(bplist, 0, addr, (restore<<4)|type, BPMEMORY))
dprintf("memory breakpoint at "fhex" set!\n", addr);
else
dputs("problem setting breakpoint (report please)!");
GuiUpdateAllViews();*/
dprintf("memory breakpoint at "fhex" set!\n", addr);
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
@ -929,44 +938,13 @@ CMDRESULT cbDebugRtr(const char* cmd)
return STATUS_CONTINUE;
}
static bool SetGlobalHardwareBreakpoint(ULONG_PTR bpxAddress, DWORD IndexOfRegister, DWORD bpxType, DWORD bpxSize, LPVOID bpxCallback)
{
HANDLE hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, fdProcessInfo->dwProcessId);
if(hProcessSnap==INVALID_HANDLE_VALUE)
return SetHardwareBreakPoint(bpxAddress, IndexOfRegister, bpxType, bpxSize, bpxCallback);
THREADENTRY32 threadEntry32;
threadEntry32.dwSize=sizeof(THREADENTRY32);
if(!Thread32First(hProcessSnap, &threadEntry32))
{
CloseHandle(hProcessSnap);
return SetHardwareBreakPoint(bpxAddress, IndexOfRegister, bpxType, bpxSize, bpxCallback);
}
HANDLE hThread=INVALID_HANDLE_VALUE;
do
{
if(fdProcessInfo->dwProcessId==threadEntry32.th32OwnerProcessID)
{
hThread=OpenThread(THREAD_ALL_ACCESS,false,threadEntry32.th32ThreadID);
if(hThread==INVALID_HANDLE_VALUE)
return SetHardwareBreakPoint(bpxAddress, IndexOfRegister, bpxType, bpxSize, bpxCallback);
if(!SetHardwareBreakPointEx(hThread, bpxAddress, IndexOfRegister, bpxType, bpxSize, bpxCallback, 0))
return false;
CloseHandle(hThread);
hThread=INVALID_HANDLE_VALUE;
}
}
while(Thread32Next(hProcessSnap, &threadEntry32));
CloseHandle(hProcessSnap);
return false;
}
CMDRESULT cbDebugSetHardwareBreakpoint(const char* cmd)
{
char arg1[deflen]=""; //addr
if(!argget(cmd, arg1, 0, false))
return STATUS_ERROR;
uint addr;
if(!valfromstring(arg1, &addr, 0, 0, false, 0))
if(!valfromstring(arg1, &addr, 0, 0, true, 0))
return STATUS_ERROR;
uint type=UE_HARDWARE_EXECUTE;
char arg2[deflen]=""; //type
@ -991,7 +969,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(const char* cmd)
uint size=UE_HARDWARE_SIZE_1;
if(argget(cmd, arg3, 2, true))
{
if(!valfromstring(arg3, &size, 0, 0, false, 0))
if(!valfromstring(arg3, &size, 0, 0, true, 0))
return STATUS_ERROR;
switch(size)
{

View File

@ -34,7 +34,7 @@ CMDRESULT cbDebugStepOver(const char* cmd);
CMDRESULT cbDebugSingleStep(const char* cmd);
CMDRESULT cbDebugHide(const char* cmd);
CMDRESULT cbDebugDisasm(const char* cmd);
CMDRESULT cbDebugMemoryBpx(const char* cmd);
CMDRESULT cbDebugSetMemoryBpx(const char* cmd);
CMDRESULT cbDebugRtr(const char* cmd);
CMDRESULT cbDebugSetHardwareBreakpoint(const char* cmd);
CMDRESULT cbDebugAlloc(const char* cmd);

View File

@ -1018,7 +1018,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
if(kernelbase!=-1)
{
*value=addrfound[kernelbase];
if(!printall)
if(!printall or silent)
return true;
for(int i=0; i<found; i++)
if(i!=kernelbase)
@ -1143,18 +1143,13 @@ bool valfromstring(const char* string, uint* value, int* value_size, bool* isvar
return false;
uint addr=*value;
*value=0;
bool isrunning=dbgisrunning();
if(!isrunning)
dbgdisablebpx();
bool rpm=memread(fdProcessInfo->hProcess, (void*)addr, value, read_size, 0);
if(!isrunning)
dbgenablebpx();
if(!rpm)
if(!memread(fdProcessInfo->hProcess, (void*)addr, value, read_size, 0))
{
if(!silent)
dputs("failed to read memory");
return false;
}
bpfixmemory(addr, (unsigned char*)value, read_size);
if(value_size)
*value_size=read_size;
if(isvar)

View File

@ -24,11 +24,6 @@ static CMDRESULT cbStrLen(const char* cmd)
return STATUS_CONTINUE;
}
static CMDRESULT cbExit(const char* cmd)
{
return STATUS_EXIT;
}
static CMDRESULT cbCls(const char* cmd)
{
GuiLogClear();
@ -59,7 +54,7 @@ static void registercommands()
cmdnew(cmd, "SingleStep\1sstep\1sst", cbDebugSingleStep, true); //SingleStep arg1:count
cmdnew(cmd, "HideDebugger\1dbh\1hide", cbDebugHide, true); //HideDebugger
cmdnew(cmd, "disasm\1dis\1d", cbDebugDisasm, true); //doDisasm
cmdnew(cmd, "SetMemoryBPX\1membp\1bpm", cbDebugMemoryBpx, true); //SetMemoryBPX
cmdnew(cmd, "SetMemoryBPX\1membp\1bpm", cbDebugSetMemoryBpx, true); //SetMemoryBPX
cmdnew(cmd, "chd", cbInstrChd, false); //Change directory
cmdnew(cmd, "rtr", cbDebugRtr, true); //rtr
cmdnew(cmd, "SetHardwareBreakpoint\1bph\1bphws", cbDebugSetHardwareBreakpoint, true); //hardware breakpoint
@ -100,19 +95,6 @@ extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
return msgsend(gMsgStack, 0, (uint)newcmd, 0);
}
static DWORD WINAPI ConsoleReadLoopThread(void* a)
{
char cmd[deflen];
while(1)
{
fgets(cmd, deflen, stdin);
cmd[strlen(cmd)-1]=0;
while(!_dbg_dbgcmdexec(cmd)) //retry until the command came through
Sleep(100);
}
return 0;
}
static DWORD WINAPI DbgCommandLoopThread(void* a)
{
cmdloop(command_list, cbBadCmd, cbCommandProvider, cmdfindmain, false);

View File

@ -9,8 +9,9 @@
<Target title="x32">
<Option output="../bin/x32/x32_dbg" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/x32" />
<Option type="0" />
<Option type="1" />
<Option compiler="gcc" />
<Option use_console_runner="0" />
<Compiler>
<Add option="-O2" />
</Compiler>
@ -22,8 +23,9 @@
<Target title="x64">
<Option output="../bin/x64/x64_dbg" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/x64" />
<Option type="0" />
<Option type="1" />
<Option compiler="gnu_gcc_compiler_x64" />
<Option use_console_runner="0" />
<Compiler>
<Add option="-O2" />
</Compiler>

View File

@ -130,7 +130,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
if(mInstBuffer.at(rowOffset).rva == mCipRva) //cip
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor(0,0,0)));
if(bpxtype&bpnormal) //breakpoint
if(bpxtype&bp_normal) //breakpoint
{
painter->setPen(QPen(QColor("#ff0000")));
}
@ -143,11 +143,11 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
if(*label) //label
{
if(bpxtype==bpnone) //label only
if(bpxtype==bp_none) //label only
painter->setPen(QPen(QColor("#ff0000"))); //red -> address + label text
else //label+breakpoint
{
if(bpxtype&bpnormal)
if(bpxtype&bp_normal)
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#ff0000"))); //fill red
}
@ -159,7 +159,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else //no label
{
if(bpxtype==bpnone) //no label, no breakpoint
if(bpxtype==bp_none) //no label, no breakpoint
{
if(wIsSelected)
painter->setPen(QPen(QColor("#000000"))); //black address
@ -168,7 +168,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else //breakpoint only
{
if(bpxtype&bpnormal)
if(bpxtype&bp_normal)
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#ff0000"))); //fill red
}

View File

@ -23,7 +23,7 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
int_t wVA = rvaToVa(getInitialSelection());
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
if((wBpType & bphardware) == bphardware)
if((wBpType & bp_hardware) == bp_hardware)
{
mToggleHwBpAction->setText("Remove Hardware");
}
@ -81,7 +81,7 @@ void CPUDisassembly::toggleInt3BPAction()
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
if((wBpType & bpnormal) == bpnormal)
if((wBpType & bp_normal) == bp_normal)
{
wCmd = "bc " + QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
}
@ -100,7 +100,7 @@ void CPUDisassembly::toggleHwBpActionSlot()
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
if((wBpType & bphardware) == bphardware)
if((wBpType & bp_hardware) == bp_hardware)
{
wCmd = "bphwc " + QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
}