From c168bc73362c935a52ab69056b976d224ad69963 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Wed, 25 Jun 2014 23:35:24 +0200 Subject: [PATCH] DBG: enum functions for database --- x64_dbg_dbg/addrinfo.cpp | 94 ++++++++++++++++++++++++++++++++++++++++ x64_dbg_dbg/addrinfo.h | 5 +++ 2 files changed, 99 insertions(+) diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index 528f3301..77e7bcf6 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -393,6 +393,24 @@ void commentcacheload(JSON root) } } +bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize) +{ + if(!commentlist && !cbsize) + return false; + if(!commentlist && cbsize) + { + *cbsize=comments.size()*sizeof(COMMENTSINFO); + return true; + } + int j=0; + for(CommentsInfo::iterator i=comments.begin(); i!=comments.end(); ++i,j++) + { + commentlist[j]=i->second; + commentlist[j].addr+=modbasefromname(commentlist[j].mod); + } + return true; +} + ///label functions bool labelset(uint addr, const char* text, bool manual) { @@ -550,6 +568,24 @@ void labelcacheload(JSON root) } } +bool labelenum(LABELSINFO* labellist, size_t* cbsize) +{ + if(!labellist && !cbsize) + return false; + if(!labellist && cbsize) + { + *cbsize=labels.size()*sizeof(LABELSINFO); + return true; + } + int j=0; + for(LabelsInfo::iterator i=labels.begin(); i!=labels.end(); ++i,j++) + { + labellist[j]=i->second; + labellist[j].addr+=modbasefromname(labellist[j].mod); + } + return true; +} + ///bookmark functions bool bookmarkset(uint addr, bool manual) { @@ -669,6 +705,24 @@ void bookmarkcacheload(JSON root) } } +bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) +{ + if(!bookmarklist && !cbsize) + return false; + if(!bookmarklist && cbsize) + { + *cbsize=bookmarks.size()*sizeof(BOOKMARKSINFO); + return true; + } + int j=0; + for(BookmarksInfo::iterator i=bookmarks.begin(); i!=bookmarks.end(); ++i,j++) + { + bookmarklist[j]=i->second; + bookmarklist[j].addr+=modbasefromname(bookmarklist[j].mod); + } + return true; +} + ///function database bool functionadd(uint start, uint end, bool manual) { @@ -815,6 +869,26 @@ void functioncacheload(JSON root) } } +bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize) +{ + if(!functionlist && !cbsize) + return false; + if(!functionlist && cbsize) + { + *cbsize=functions.size()*sizeof(FUNCTIONSINFO); + return true; + } + int j=0; + for(FunctionsInfo::iterator i=functions.begin(); i!=functions.end(); ++i,j++) + { + functionlist[j]=i->second; + uint modbase=modbasefromname(functionlist[j].mod); + functionlist[j].start+=modbase; + functionlist[j].end+=modbase; + } + return true; +} + //loop database bool loopadd(uint start, uint end, bool manual) { @@ -971,4 +1045,24 @@ void loopcacheload(JSON root) loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); } } +} + +bool loopenum(LOOPSINFO* looplist, size_t* cbsize) +{ + if(!looplist && !cbsize) + return false; + if(!looplist && cbsize) + { + *cbsize=loops.size()*sizeof(LOOPSINFO); + return true; + } + int j=0; + for(LoopsInfo::iterator i=loops.begin(); i!=loops.end(); ++i,j++) + { + looplist[j]=i->second; + uint modbase=modbasefromname(looplist[j].mod); + looplist[j].start+=modbase; + looplist[j].end+=modbase; + } + return true; } \ No newline at end of file diff --git a/x64_dbg_dbg/addrinfo.h b/x64_dbg_dbg/addrinfo.h index 01d27c73..f38f2f8e 100644 --- a/x64_dbg_dbg/addrinfo.h +++ b/x64_dbg_dbg/addrinfo.h @@ -133,6 +133,7 @@ bool commentdel(uint addr); void commentdelrange(uint start, uint end); void commentcachesave(JSON root); void commentcacheload(JSON root); +bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize); bool labelset(uint addr, const char* text, bool manual); bool labelfromstring(const char* text, uint* addr); @@ -141,6 +142,7 @@ bool labeldel(uint addr); void labeldelrange(uint start, uint end); void labelcachesave(JSON root); void labelcacheload(JSON root); +bool labelenum(LABELSINFO* labellist, size_t* cbsize); bool bookmarkset(uint addr, bool manual); bool bookmarkget(uint addr); @@ -148,6 +150,7 @@ bool bookmarkdel(uint addr); void bookmarkdelrange(uint start, uint end); void bookmarkcachesave(JSON root); void bookmarkcacheload(JSON root); +bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize); bool functionadd(uint start, uint end, bool manual); bool functionget(uint addr, uint* start, uint* end); @@ -156,6 +159,7 @@ bool functiondel(uint addr); void functiondelrange(uint start, uint end); void functioncachesave(JSON root); void functioncacheload(JSON root); +bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize); bool loopadd(uint start, uint end, bool manual); bool loopget(int depth, uint addr, uint* start, uint* end); @@ -163,5 +167,6 @@ bool loopoverlaps(int depth, uint start, uint end, int* finaldepth); bool loopdel(int depth, uint addr); void loopcachesave(JSON root); void loopcacheload(JSON root); +bool loopenum(LOOPSINFO* looplist, size_t* cbsize); #endif // _ADDRINFO_H