DBG: added command 'findrefrange'
This commit is contained in:
parent
6fce9d917b
commit
684dad5773
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>reffindrange/findrefrange/refrange</title>
|
||||
<meta name="GENERATOR" content="WinCHM">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<style>
|
||||
html,body {
|
||||
/* Default Font */
|
||||
font-family: Courier New;
|
||||
font-size: 11pt;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<P><STRONG>reffindrange[,findrefrange,ref</STRONG><STRONG>range</STRONG><STRONG>]<BR></STRONG>Find references to a certain range of values.</P>
|
||||
<P class=rvps3>
|
||||
<SPAN class=rvts11>
|
||||
<U>
|
||||
arguments
|
||||
|
||||
</U>
|
||||
<BR>
|
||||
</SPAN>
|
||||
<SPAN class=rvts9 > arg1: Start of the range (will be
|
||||
included in the results when found).</SPAN></P>
|
||||
<P class=rvps3>
|
||||
<SPAN class=rvts9 >
|
||||
[arg2]: End of range (will be included in the results when
|
||||
found). When not specified the first argument will be used.</SPAN></P>
|
||||
<P class=rvps3 >
|
||||
|
||||
<SPAN class=rvts9>
|
||||
[arg3]: Address of/inside a memory page to look in.
|
||||
When not specified CIP will be used. </SPAN></P>
|
||||
<P class=rvps3><SPAN class=rvts9>[arg4]: The size of the data to search in. </SPAN></P>
|
||||
<P class=rvps3><SPAN class=rvts11><U>result <BR></U></SPAN><SPAN
|
||||
class=rvts9>The $result variable is set to the number of
|
||||
references found.</SPAN> </P>
|
||||
<P> </P></body>
|
||||
</html>
|
BIN
help/x64_dbg.wcp
BIN
help/x64_dbg.wcp
Binary file not shown.
|
@ -741,6 +741,12 @@ CMDRESULT cbInstrRefadd(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
struct VALUERANGE
|
||||
{
|
||||
uint start;
|
||||
uint end;
|
||||
};
|
||||
|
||||
//reffind value[,page]
|
||||
static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
{
|
||||
|
@ -753,20 +759,25 @@ static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO
|
|||
return true;
|
||||
}
|
||||
bool found = false;
|
||||
uint value = (uint)refinfo->userinfo;
|
||||
VALUERANGE* range = (VALUERANGE*)refinfo->userinfo;
|
||||
uint start = range->start;
|
||||
uint end = range->end;
|
||||
if((basicinfo->type & TYPE_VALUE) == TYPE_VALUE)
|
||||
{
|
||||
if(basicinfo->value.value == value)
|
||||
uint value = basicinfo->value.value;
|
||||
if(value >= start && value <= end)
|
||||
found = true;
|
||||
}
|
||||
if((basicinfo->type & TYPE_MEMORY) == TYPE_MEMORY)
|
||||
{
|
||||
if(basicinfo->memory.value == value)
|
||||
uint value = basicinfo->memory.value;
|
||||
if(value >= start && value <= end)
|
||||
found = true;
|
||||
}
|
||||
if((basicinfo->type & TYPE_ADDR) == TYPE_ADDR)
|
||||
{
|
||||
if(basicinfo->addr == value)
|
||||
uint value = basicinfo->addr;
|
||||
if(value >= start && value <= end)
|
||||
found = true;
|
||||
}
|
||||
if(found)
|
||||
|
@ -791,18 +802,35 @@ CMDRESULT cbInstrRefFind(int argc, char* argv[])
|
|||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
uint value = 0;
|
||||
if(!valfromstring(argv[1], &value, false))
|
||||
std::string newCommand = std::string("reffindrange ") + argv[1] + std::string(",") + argv[1];
|
||||
if(argc > 2)
|
||||
newCommand += std::string(",") + argv[2];
|
||||
if(argc > 3)
|
||||
newCommand += std::string(",") + argv[3];
|
||||
return cmddirectexec(dbggetcommandlist(), newCommand.c_str());
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrRefFindRange(int argc, char* argv[])
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
VALUERANGE range;
|
||||
if(!valfromstring(argv[1], &range.start, false))
|
||||
return STATUS_ERROR;
|
||||
if(argc < 3 or !valfromstring(argv[2], &range.end, false))
|
||||
range.end = range.start;
|
||||
uint addr = 0;
|
||||
if(argc < 3 or !valfromstring(argv[2], &addr))
|
||||
if(argc < 4 or !valfromstring(argv[3], &addr))
|
||||
addr = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
uint size = 0;
|
||||
if(argc >= 4)
|
||||
if(!valfromstring(argv[3], &size))
|
||||
if(argc >= 5)
|
||||
if(!valfromstring(argv[4], &size))
|
||||
size = 0;
|
||||
uint ticks = GetTickCount();
|
||||
int found = reffind(addr, size, cbRefFind, (void*)value, false);
|
||||
int found = reffind(addr, size, cbRefFind, &range, false);
|
||||
dprintf("%u reference(s) in %ums\n", found, GetTickCount() - ticks);
|
||||
varset("$result", found, false);
|
||||
return STATUS_CONTINUE;
|
||||
|
|
|
@ -46,6 +46,7 @@ CMDRESULT cbInstrRefinit(int argc, char* argv[]);
|
|||
CMDRESULT cbInstrRefadd(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrRefFind(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrRefStr(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrRefFindRange(int argc, char* argv[]);
|
||||
|
||||
CMDRESULT cbInstrSetstr(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrGetstr(int argc, char* argv[]);
|
||||
|
|
|
@ -170,12 +170,13 @@ static void registercommands()
|
|||
dbgcmdnew("msgyn", cbScriptMsgyn, false);
|
||||
|
||||
//data
|
||||
dbgcmdnew("reffind\1findref\1ref", cbInstrRefFind, true);
|
||||
dbgcmdnew("refstr\1strref", cbInstrRefStr, true);
|
||||
dbgcmdnew("reffind\1findref\1ref", cbInstrRefFind, true); //find references to a value
|
||||
dbgcmdnew("refstr\1strref", cbInstrRefStr, true); //find string references
|
||||
dbgcmdnew("find", cbInstrFind, true); //find a pattern
|
||||
dbgcmdnew("findall", cbInstrFindAll, true); //find all patterns
|
||||
dbgcmdnew("modcallfind", cbInstrModCallFind, true); //find intermodular calls
|
||||
dbgcmdnew("findasm\1asmfind", cbInstrFindAsm, true); //find instruction
|
||||
dbgcmdnew("reffindrange\1findrefrange\1refrange", cbInstrRefFindRange, true);
|
||||
|
||||
//undocumented
|
||||
dbgcmdnew("bench", cbDebugBenchmark, true); //benchmark test (readmem etc)
|
||||
|
@ -300,7 +301,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
|
|||
if(memleaks())
|
||||
{
|
||||
char msg[256] = "";
|
||||
sprintf(msg, "%d memory leak(s) found!\n\nPlease contact the authors of x64_dbg.", memleaks());
|
||||
sprintf(msg, "%d memory leak(s) found!\n\nPlease send contact the authors of x64_dbg.", memleaks());
|
||||
MessageBoxA(0, msg, "error", MB_ICONERROR | MB_SYSTEMMODAL);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue