DBG: slightly changed various command behaviors.
This commit is contained in:
parent
f69bb6d42c
commit
101ba59d37
|
@ -13,6 +13,11 @@ const DBGFUNCTIONS* dbgfunctionsget()
|
|||
return &_dbgfunctions;
|
||||
}
|
||||
|
||||
static bool _assembleatex(duint addr, const char* instruction, char* error, bool fillnop)
|
||||
{
|
||||
return assembleat(addr, instruction, 0, error, fillnop);
|
||||
}
|
||||
|
||||
static bool _sectionfromaddr(duint addr, char* section)
|
||||
{
|
||||
HMODULE hMod=(HMODULE)modbasefromaddr(addr);
|
||||
|
@ -96,7 +101,7 @@ static int _modpathfromname(const char* modname, char* path, int size)
|
|||
|
||||
void dbgfunctionsinit()
|
||||
{
|
||||
_dbgfunctions.AssembleAtEx=assembleat;
|
||||
_dbgfunctions.AssembleAtEx=_assembleatex;
|
||||
_dbgfunctions.SectionFromAddr=_sectionfromaddr;
|
||||
_dbgfunctions.ModNameFromAddr=modnamefromaddr;
|
||||
_dbgfunctions.ModBaseFromAddr=modbasefromaddr;
|
||||
|
|
|
@ -768,7 +768,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
|
||||
case DBG_ASSEMBLE_AT:
|
||||
{
|
||||
return assembleat((duint)param1, (const char*)param2, 0, false);
|
||||
return assembleat((duint)param1, (const char*)param2, 0, 0, false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction
|
|||
return true;
|
||||
}
|
||||
|
||||
bool assembleat(uint addr, const char* instruction, char* error, bool fillnop)
|
||||
bool assembleat(uint addr, const char* instruction, int* size, char* error, bool fillnop)
|
||||
{
|
||||
int destSize;
|
||||
unsigned char dest[16];
|
||||
|
@ -60,10 +60,17 @@ bool assembleat(uint addr, const char* instruction, char* error, bool fillnop)
|
|||
unsigned char nops[16];
|
||||
memset(nops, 0x90, sizeof(nops));
|
||||
|
||||
if(size)
|
||||
*size=destSize;
|
||||
|
||||
bool ret=mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0);
|
||||
if(ret && fillnop && nopsize)
|
||||
{
|
||||
if(size)
|
||||
*size+=nopsize;
|
||||
if(!mempatch(fdProcessInfo->hProcess, (void*)(addr+destSize), nops, nopsize, 0))
|
||||
ret=false;
|
||||
}
|
||||
GuiUpdatePatches();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
#include "_global.h"
|
||||
|
||||
bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction, char* error);
|
||||
bool assembleat(uint addr, const char* instruction, char* error, bool fillnop);
|
||||
bool assembleat(uint addr, const char* instruction, int* size, char* error, bool fillnop);
|
||||
|
||||
#endif // _ASSEMBLE_H
|
||||
|
|
|
@ -373,11 +373,14 @@ CMDRESULT cbAssemble(int argc, char* argv[])
|
|||
if(argc>3)
|
||||
fillnop=true;
|
||||
char error[256]="";
|
||||
if(!assembleat(addr, argv[2], error, fillnop))
|
||||
int size=0;
|
||||
if(!assembleat(addr, argv[2], &size, error, fillnop))
|
||||
{
|
||||
varset("$result", size, false);
|
||||
dprintf("failed to assemble \"%s\" (%s)\n", argv[2], error);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
varset("$result", size, false);
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
@ -1213,6 +1216,7 @@ CMDRESULT cbInstrCommentList(int argc, char* argv[])
|
|||
GuiReferenceSetCellContent(i, 2, comments[i].text);
|
||||
}
|
||||
efree(comments, "cbInstrCommentList:comments");
|
||||
varset("$result", loops, false);
|
||||
dprintf("%d comment(s) listed in Reference View\n", count);
|
||||
GuiReferenceReloadData();
|
||||
return STATUS_CONTINUE;
|
||||
|
@ -1248,6 +1252,7 @@ CMDRESULT cbInstrLabelList(int argc, char* argv[])
|
|||
GuiReferenceSetCellContent(i, 2, labels[i].text);
|
||||
}
|
||||
efree(labels, "cbInstrLabelList:labels");
|
||||
varset("$result", loops, false);
|
||||
dprintf("%d label(s) listed in Reference View\n", count);
|
||||
GuiReferenceReloadData();
|
||||
return STATUS_CONTINUE;
|
||||
|
@ -1281,6 +1286,7 @@ CMDRESULT cbInstrBookmarkList(int argc, char* argv[])
|
|||
GuiReferenceSetCellContent(i, 1, disassembly);
|
||||
}
|
||||
efree(bookmarks, "cbInstrBookmarkList:bookmarks");
|
||||
varset("$result", loops, false);
|
||||
dprintf("%d bookmark(s) listed in Reference View\n", count);
|
||||
GuiReferenceReloadData();
|
||||
return STATUS_CONTINUE;
|
||||
|
@ -1327,6 +1333,7 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
efree(functions, "cbInstrFunctionList:functions");
|
||||
varset("$result", loops, false);
|
||||
dprintf("%d function(s) listed in Reference View\n", count);
|
||||
GuiReferenceReloadData();
|
||||
return STATUS_CONTINUE;
|
||||
|
@ -1373,6 +1380,7 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
efree(loops, "cbInstrLoopList:loops");
|
||||
varset("$result", loops, false);
|
||||
dprintf("%d loop(s) listed in Reference View\n", count);
|
||||
GuiReferenceReloadData();
|
||||
return STATUS_CONTINUE;
|
||||
|
|
|
@ -92,6 +92,9 @@ static void registercommands()
|
|||
dbgcmdnew("eSingleStep\1esstep\1esst", cbDebugeSingleStep, true); //SingleStep arg1:count + skip first chance exceptions
|
||||
dbgcmdnew("StepOut\1rtr", cbDebugRtr, true); //rtr
|
||||
dbgcmdnew("eStepOut\1ertr", cbDebugeRtr, true); //rtr + skip first chance exceptions
|
||||
dbgcmdnew("DebugContinue\1con", cbDebugContinue, true); //set continue status
|
||||
dbgcmdnew("LibrarianSetBreakPoint\1bpdll", cbBpDll, true); //set dll breakpoint
|
||||
dbgcmdnew("LibrarianRemoveBreakPoint\1bcdll", cbBcDll, true); //remove dll breakpoint
|
||||
|
||||
//breakpoints
|
||||
dbgcmdnew("bplist", cbDebugBplist, true); //breakpoint list
|
||||
|
@ -119,6 +122,9 @@ static void registercommands()
|
|||
dbgcmdnew("HideDebugger\1dbh\1hide", cbDebugHide, true); //HideDebugger
|
||||
dbgcmdnew("dump", cbDebugDump, true); //dump at address
|
||||
dbgcmdnew("sdump", cbDebugStackDump, true); //dump at stack address
|
||||
dbgcmdnew("refinit", cbInstrRefinit, false);
|
||||
dbgcmdnew("refadd", cbInstrRefadd, false);
|
||||
dbgcmdnew("asm", cbAssemble, true); //assemble instruction
|
||||
|
||||
//user database
|
||||
dbgcmdnew("cmt\1cmtset\1commentset", cbInstrCmt, true); //set/edit comment
|
||||
|
@ -131,6 +137,10 @@ static void registercommands()
|
|||
dbgcmdnew("loaddb\1dbload", cbLoaddb, true); //load program database
|
||||
dbgcmdnew("functionadd\1func", cbFunctionAdd, true); //function
|
||||
dbgcmdnew("functiondel\1funcc", cbFunctionDel, true); //function
|
||||
dbgcmdnew("commentlist", cbInstrCommentList, true); //list comments
|
||||
dbgcmdnew("labellist", cbInstrLabelList, true); //list labels
|
||||
dbgcmdnew("bookmarklist", cbInstrBookmarkList, true); //list bookmarks
|
||||
dbgcmdnew("functionlist", cbInstrFunctionList, true); //list functions
|
||||
|
||||
//memory operations
|
||||
dbgcmdnew("alloc", cbDebugAlloc, true); //allocate memory
|
||||
|
@ -170,25 +180,15 @@ static void registercommands()
|
|||
dbgcmdnew("refstr\1strref", cbInstrRefStr, true);
|
||||
dbgcmdnew("find", cbInstrFind, true); //find a pattern
|
||||
dbgcmdnew("findall", cbInstrFindAll, true); //find all patterns
|
||||
dbgcmdnew("modcallfind", cbInstrModCallFind, true); //find intermodular calls
|
||||
|
||||
//undocumented
|
||||
dbgcmdnew("bench", cbBenchmark, true); //benchmark test (readmem etc)
|
||||
dbgcmdnew("memwrite", cbMemWrite, true); //memwrite test
|
||||
dbgcmdnew("asm", cbAssemble, true); //assemble instruction
|
||||
dbgcmdnew("dprintf", cbPrintf, false); //printf
|
||||
dbgcmdnew("refinit", cbInstrRefinit, false);
|
||||
dbgcmdnew("refadd", cbInstrRefadd, false);
|
||||
dbgcmdnew("setstr\1strset", cbInstrSetstr, false); //set a string variable
|
||||
dbgcmdnew("getstr\1strget", cbInstrGetstr, false); //get a string variable
|
||||
dbgcmdnew("copystr\1strcpy", cbInstrCopystr, true); //write a string variable to memory
|
||||
dbgcmdnew("DebugContinue\1con", cbDebugContinue, true); //set continue status
|
||||
dbgcmdnew("bpdll", cbBpDll, true); //set dll breakpoint
|
||||
dbgcmdnew("bcdll", cbBcDll, true); //remove dll breakpoint
|
||||
dbgcmdnew("modcallfind", cbInstrModCallFind, true); //find intermodular calls
|
||||
dbgcmdnew("commentlist", cbInstrCommentList, true); //list comments
|
||||
dbgcmdnew("labellist", cbInstrLabelList, true); //list labels
|
||||
dbgcmdnew("bookmarklist", cbInstrBookmarkList, true); //list bookmarks
|
||||
dbgcmdnew("functionlist", cbInstrFunctionList, true); //list functions
|
||||
dbgcmdnew("looplist", cbInstrLoopList, true); //list loops
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue