From 80d84e7108404c6fbe64825b313aa630080230ff Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Tue, 18 Jun 2019 02:50:31 +0200 Subject: [PATCH] DBG: implement symunload command --- src/dbg/commands/cmd-analysis.cpp | 25 +++++++++++++++++++++++++ src/dbg/commands/cmd-analysis.h | 1 + src/dbg/x64dbg.cpp | 1 + 3 files changed, 27 insertions(+) diff --git a/src/dbg/commands/cmd-analysis.cpp b/src/dbg/commands/cmd-analysis.cpp index 8ba52825..e93bf438 100644 --- a/src/dbg/commands/cmd-analysis.cpp +++ b/src/dbg/commands/cmd-analysis.cpp @@ -226,6 +226,31 @@ bool cbDebugLoadSymbol(int argc, char* argv[]) return true; } +bool cbDebugUnloadSymbol(int argc, char* argv[]) +{ + if(IsArgumentsLessThan(argc, 2)) + return false; + //get some module information + duint modbase = ModBaseFromName(argv[1]); + if(!modbase) + { + dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid module \"%s\"!\n"), argv[1]); + return false; + } + EXCLUSIVE_ACQUIRE(LockModules); + auto info = ModInfoFromAddr(modbase); + if(!info) + { + // TODO: this really isn't supposed to happen, but could if the module is suddenly unloaded + dputs("module not found..."); + return false; + } + info->unloadSymbols(); + GuiRepaintTableView(); + dputs(QT_TRANSLATE_NOOP("DBG", "Done!")); + return true; +} + bool cbInstrImageinfo(int argc, char* argv[]) { duint address; diff --git a/src/dbg/commands/cmd-analysis.h b/src/dbg/commands/cmd-analysis.h index e5633b9c..22ea4206 100644 --- a/src/dbg/commands/cmd-analysis.h +++ b/src/dbg/commands/cmd-analysis.h @@ -13,6 +13,7 @@ bool cbInstrAnalyseadv(int argc, char* argv[]); bool cbInstrVirtualmod(int argc, char* argv[]); bool cbDebugDownloadSymbol(int argc, char* argv[]); bool cbDebugLoadSymbol(int argc, char* argv[]); +bool cbDebugUnloadSymbol(int argc, char* argv[]); bool cbInstrImageinfo(int argc, char* argv[]); bool cbInstrGetRelocSize(int argc, char* argv[]); bool cbInstrExhandlers(int argc, char* argv[]); diff --git a/src/dbg/x64dbg.cpp b/src/dbg/x64dbg.cpp index 050268db..5aa4d0f8 100644 --- a/src/dbg/x64dbg.cpp +++ b/src/dbg/x64dbg.cpp @@ -325,6 +325,7 @@ static void registercommands() dbgcmdnew("virtualmod", cbInstrVirtualmod, true); //virtual module dbgcmdnew("symdownload,downloadsym", cbDebugDownloadSymbol, true); //download symbols dbgcmdnew("symload,loadsym", cbDebugLoadSymbol, true); //load symbols + dbgcmdnew("symunload,unloadsym", cbDebugUnloadSymbol, true); //unload symbols dbgcmdnew("imageinfo,modimageinfo", cbInstrImageinfo, true); //print module image information dbgcmdnew("GetRelocSize,grs", cbInstrGetRelocSize, true); //get relocation table size dbgcmdnew("exhandlers", cbInstrExhandlers, true); //enumerate exception handlers