Skip to content

Commit 80d84e7

Browse files
committed
DBG: implement symunload command
1 parent d969087 commit 80d84e7

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/dbg/commands/cmd-analysis.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,31 @@ bool cbDebugLoadSymbol(int argc, char* argv[])
226226
return true;
227227
}
228228

229+
bool cbDebugUnloadSymbol(int argc, char* argv[])
230+
{
231+
if(IsArgumentsLessThan(argc, 2))
232+
return false;
233+
//get some module information
234+
duint modbase = ModBaseFromName(argv[1]);
235+
if(!modbase)
236+
{
237+
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid module \"%s\"!\n"), argv[1]);
238+
return false;
239+
}
240+
EXCLUSIVE_ACQUIRE(LockModules);
241+
auto info = ModInfoFromAddr(modbase);
242+
if(!info)
243+
{
244+
// TODO: this really isn't supposed to happen, but could if the module is suddenly unloaded
245+
dputs("module not found...");
246+
return false;
247+
}
248+
info->unloadSymbols();
249+
GuiRepaintTableView();
250+
dputs(QT_TRANSLATE_NOOP("DBG", "Done!"));
251+
return true;
252+
}
253+
229254
bool cbInstrImageinfo(int argc, char* argv[])
230255
{
231256
duint address;

src/dbg/commands/cmd-analysis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ bool cbInstrAnalyseadv(int argc, char* argv[]);
1313
bool cbInstrVirtualmod(int argc, char* argv[]);
1414
bool cbDebugDownloadSymbol(int argc, char* argv[]);
1515
bool cbDebugLoadSymbol(int argc, char* argv[]);
16+
bool cbDebugUnloadSymbol(int argc, char* argv[]);
1617
bool cbInstrImageinfo(int argc, char* argv[]);
1718
bool cbInstrGetRelocSize(int argc, char* argv[]);
1819
bool cbInstrExhandlers(int argc, char* argv[]);

src/dbg/x64dbg.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ static void registercommands()
325325
dbgcmdnew("virtualmod", cbInstrVirtualmod, true); //virtual module
326326
dbgcmdnew("symdownload,downloadsym", cbDebugDownloadSymbol, true); //download symbols
327327
dbgcmdnew("symload,loadsym", cbDebugLoadSymbol, true); //load symbols
328+
dbgcmdnew("symunload,unloadsym", cbDebugUnloadSymbol, true); //unload symbols
328329
dbgcmdnew("imageinfo,modimageinfo", cbInstrImageinfo, true); //print module image information
329330
dbgcmdnew("GetRelocSize,grs", cbInstrGetRelocSize, true); //get relocation table size
330331
dbgcmdnew("exhandlers", cbInstrExhandlers, true); //enumerate exception handlers

0 commit comments

Comments
 (0)