diff --git a/x64_dbg_bridge/_global.cpp b/x64_dbg_bridge/_global.cpp index 96b23878..344a009f 100644 --- a/x64_dbg_bridge/_global.cpp +++ b/x64_dbg_bridge/_global.cpp @@ -28,5 +28,4 @@ DBGMEMISVALIDREADPTR _dbg_memisvalidreadptr; DBGGETBPLIST _dbg_getbplist; DBGDBGCMDEXECDIRECT _dbg_dbgcmddirectexec; DBGGETBRANCHDESTINATION _dbg_getbranchdestination; -DBGFUNCTIONOVERLAPS _dbg_functionoverlaps; DBGSENDMESSAGE _dbg_sendmessage; diff --git a/x64_dbg_bridge/_global.h b/x64_dbg_bridge/_global.h index 94fbddbc..1a964680 100644 --- a/x64_dbg_bridge/_global.h +++ b/x64_dbg_bridge/_global.h @@ -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 diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index 84161158..746d15a1 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -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) { diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index dc7a345e..20cb6f9f 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -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 diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index 3bf1ccc8..f861ac23 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -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; } diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index b54af351..e96fb908 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -730,7 +730,7 @@ bool loopoverlaps(int depth, uint start, uint end) } -bool loopdel(uint addr) +bool loopdel(int depth, uint addr) { return false; } diff --git a/x64_dbg_dbg/addrinfo.h b/x64_dbg_dbg/addrinfo.h index f64f8a91..5f72515a 100644 --- a/x64_dbg_dbg/addrinfo.h +++ b/x64_dbg_dbg/addrinfo.h @@ -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