1
0
Fork 0

DBG: function + loop (draft) API

This commit is contained in:
Mr. eXoDia 2014-05-29 00:36:45 +02:00
parent edaa9eaffe
commit 16b36bb569
7 changed files with 170 additions and 31 deletions

View File

@ -28,5 +28,4 @@ DBGMEMISVALIDREADPTR _dbg_memisvalidreadptr;
DBGGETBPLIST _dbg_getbplist;
DBGDBGCMDEXECDIRECT _dbg_dbgcmddirectexec;
DBGGETBRANCHDESTINATION _dbg_getbranchdestination;
DBGFUNCTIONOVERLAPS _dbg_functionoverlaps;
DBGSENDMESSAGE _dbg_sendmessage;

View File

@ -36,7 +36,6 @@ typedef bool (*DBGMEMISVALIDREADPTR)(duint addr);
typedef int (*DBGGETBPLIST)(BPXTYPE type, BPMAP* bplist);
typedef bool (*DBGDBGCMDEXECDIRECT)(const char* cmd);
typedef duint (*DBGGETBRANCHDESTINATION)(duint addr);
typedef bool (*DBGFUNCTIONOVERLAPS)(duint start, duint end);
typedef duint (*DBGSENDMESSAGE)(DBGMSG type, void* param1, void* param2);
//DBG functions
@ -59,7 +58,6 @@ extern DBGMEMISVALIDREADPTR _dbg_memisvalidreadptr;
extern DBGGETBPLIST _dbg_getbplist;
extern DBGDBGCMDEXECDIRECT _dbg_dbgcmddirectexec;
extern DBGGETBRANCHDESTINATION _dbg_getbranchdestination;
extern DBGFUNCTIONOVERLAPS _dbg_functionoverlaps;
extern DBGSENDMESSAGE _dbg_sendmessage;
#endif // _GLOBAL_H

View File

@ -120,10 +120,6 @@ BRIDGE_IMPEXP const char* BridgeInit()
_dbg_getbranchdestination=(DBGGETBRANCHDESTINATION)GetProcAddress(hInstDbg, "_dbg_getbranchdestination");
if(!_dbg_getbranchdestination)
return "Export \"_dbg_getbranchdestination\" could not be found!";
//_dbg_functionoverlaps
_dbg_functionoverlaps=(DBGFUNCTIONOVERLAPS)GetProcAddress(hInstDbg, "_dbg_functionoverlaps");
if(!_dbg_functionoverlaps)
return "Export \"_dbg_functionoverlaps\" could not be found!";
//_dbg_sendmessage
_dbg_sendmessage=(DBGSENDMESSAGE)GetProcAddress(hInstDbg, "_dbg_sendmessage");
if(!_dbg_sendmessage)
@ -437,25 +433,6 @@ BRIDGE_IMPEXP duint DbgGetBranchDestination(duint addr)
return _dbg_getbranchdestination(addr);
}
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
{
return _dbg_functionoverlaps(start, end);
}
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end)
{
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagfunction;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return false;
if(start)
*start=info.function.start;
if(end)
*end=info.function.end;
return true;
}
BRIDGE_IMPEXP void DbgScriptLoad(const char* filename)
{
_dbg_sendmessage(DBG_SCRIPT_LOAD, (void*)filename, 0);
@ -568,6 +545,92 @@ BRIDGE_IMPEXP void DbgMenuEntryClicked(int hEntry)
_dbg_sendmessage(DBG_MENU_ENTRY_CLICKED, (void*)(duint)hEntry, 0);
}
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
if(!_dbg_sendmessage(DBG_FUNCTION_GET, &info, 0))
return false;
*start=info.start;
*end=info.end;
return true;
}
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
if(!_dbg_sendmessage(DBG_FUNCTION_OVERLAPS, &info, 0))
return false;
return true;
}
BRIDGE_IMPEXP bool DbgFunctionAdd(duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.manual=false;
if(!_dbg_sendmessage(DBG_FUNCTION_ADD, &info, 0))
return false;
return true;
}
BRIDGE_IMPEXP bool DbgFunctionDel(duint addr)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
if(!_dbg_sendmessage(DBG_FUNCTION_DEL, &info, 0))
return false;
return true;
}
BRIDGE_IMPEXP bool DbgLoopGet(int depth, duint addr, duint* start, duint* end)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
info.depth=depth;
if(!_dbg_sendmessage(DBG_LOOP_GET, &info, 0))
return false;
*start=info.start;
*end=info.end;
return true;
}
BRIDGE_IMPEXP bool DbgLoopOverlaps(int depth, duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.depth=depth;
if(!_dbg_sendmessage(DBG_LOOP_OVERLAPS, &info, 0))
return false;
return true;
}
BRIDGE_IMPEXP bool DbgLoopAdd(duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.manual=false;
if(!_dbg_sendmessage(DBG_LOOP_ADD, &info, 0))
return false;
return true;
}
BRIDGE_IMPEXP bool DbgLoopDel(int depth, duint addr)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
info.depth;
if(!_dbg_sendmessage(DBG_LOOP_DEL, &info, 0))
return false;
return true;
}
//GUI
BRIDGE_IMPEXP void GuiDisasmAt(duint addr, duint cip)
{

View File

@ -134,7 +134,15 @@ enum DBGMSG
DBG_GET_THREAD_LIST, // param1=THREADALLINFO* list, param2=unused
DBG_SETTINGS_UPDATED, // param1=unused, param2=unused
DBG_DISASM_FAST_AT, // param1=duint addr, param2=BASIC_INSTRUCTION_INFO* basicinfo
DBG_MENU_ENTRY_CLICKED // param1=int hEntry, param2=unused
DBG_MENU_ENTRY_CLICKED, // param1=int hEntry, param2=unused
DBG_FUNCTION_GET, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_FUNCTION_OVERLAPS, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_FUNCTION_ADD, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_FUNCTION_DEL, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_LOOP_GET, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_LOOP_OVERLAPS, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_LOOP_ADD, // param1=FUNCTION_LOOP_INFO* info, param2=unused
DBG_LOOP_DEL // param1=FUNCTION_LOOP_INFO* info, param2=unused
};
enum SCRIPTLINETYPE
@ -451,6 +459,15 @@ struct SCRIPTBRANCH
char branchlabel[256];
};
struct FUNCTION_LOOP_INFO
{
duint addr;
duint start;
duint end;
bool manual;
int depth;
};
//Debugger functions
BRIDGE_IMPEXP const char* DbgInit();
BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size);
@ -479,8 +496,6 @@ BRIDGE_IMPEXP int DbgGetBpList(BPXTYPE type, BPMAP* list);
BRIDGE_IMPEXP FUNCTYPE DbgGetFunctionTypeAt(duint addr);
BRIDGE_IMPEXP LOOPTYPE DbgGetLoopTypeAt(duint addr, int depth);
BRIDGE_IMPEXP duint DbgGetBranchDestination(duint addr);
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end);
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end);
BRIDGE_IMPEXP void DbgScriptLoad(const char* filename);
BRIDGE_IMPEXP void DbgScriptUnload();
BRIDGE_IMPEXP void DbgScriptRun(int destline);
@ -501,6 +516,14 @@ BRIDGE_IMPEXP void DbgGetThreadList(THREADLIST* list);
BRIDGE_IMPEXP void DbgSettingsUpdated();
BRIDGE_IMPEXP void DbgDisasmFastAt(duint addr, BASIC_INSTRUCTION_INFO* basicinfo);
BRIDGE_IMPEXP void DbgMenuEntryClicked(int hEntry);
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end);
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end);
BRIDGE_IMPEXP bool DbgFunctionAdd(duint start, duint end);
BRIDGE_IMPEXP bool DbgFunctionDel(duint addr);
BRIDGE_IMPEXP bool DbgLoopGet(int depth, duint addr, duint* start, duint* end);
BRIDGE_IMPEXP bool DbgLoopOverlaps(int depth, duint start, duint end);
BRIDGE_IMPEXP bool DbgLoopAdd(duint start, duint end);
BRIDGE_IMPEXP bool DbgLoopDel(int depth, duint addr);
//Gui defines
#define GUI_PLUGIN_MENU 0

View File

@ -843,6 +843,62 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
pluginmenucall(hEntry);
}
break;
case DBG_FUNCTION_GET:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)functionget(info->addr, &info->start, &info->end);
}
break;
case DBG_FUNCTION_OVERLAPS:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)functionoverlaps(info->start, info->end);
}
break;
case DBG_FUNCTION_ADD:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)functionadd(info->start, info->end, info->manual);
}
break;
case DBG_FUNCTION_DEL:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)functiondel(info->addr);
}
break;
case DBG_LOOP_GET:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)loopget(info->depth, info->addr, &info->start, &info->end);
}
break;
case DBG_LOOP_OVERLAPS:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)loopoverlaps(info->depth, info->start, info->end);
}
break;
case DBG_LOOP_ADD:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)loopadd(info->start, info->end, info->manual);
}
break;
case DBG_LOOP_DEL:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
return (uint)loopdel(info->depth, info->addr);
}
break;
}
return 0;
}

View File

@ -730,7 +730,7 @@ bool loopoverlaps(int depth, uint start, uint end)
}
bool loopdel(uint addr)
bool loopdel(int depth, uint addr)
{
return false;
}

View File

@ -46,6 +46,6 @@ bool functiondel(uint addr);
bool loopget(int depth, uint addr, uint* start, uint* end);
bool loopoverlaps(int depth, uint start, uint end);
bool loopadd(uint start, uint end, bool manual);
bool loopdel(uint addr);
bool loopdel(int depth, uint addr);
#endif // _ADDRINFO_H