DBG: fixed a bug in fillbasicinfo
DBG: added function 'disasmispossiblestirng' (faster then disasmgetstringat) DBG: fixed a bug in cbRefFind DBG: added string references (command: 'strref') GUI: fixed a bug in deleteAllColumns (from reference view)
This commit is contained in:
parent
e5ab01f63f
commit
db9f14ed69
|
@ -23,6 +23,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
|
|||
//find immidiat
|
||||
if(disasm->Instruction.BranchType==0) //no branch
|
||||
{
|
||||
basicinfo->branch=false;
|
||||
if((disasm->Argument1.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE)
|
||||
{
|
||||
basicinfo->type|=TYPE_VALUE;
|
||||
|
|
|
@ -305,6 +305,21 @@ static bool isunicodestring(const unsigned char* data, int maxlen)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool disasmispossiblestring(uint addr)
|
||||
{
|
||||
unsigned char data[11];
|
||||
memset(data, 0, sizeof(data));
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data)-3, 0))
|
||||
return false;
|
||||
uint test=0;
|
||||
memcpy(&test, data, sizeof(uint));
|
||||
if(memisvalidreadptr(fdProcessInfo->hProcess, test))
|
||||
return false;
|
||||
if(isasciistring(data, sizeof(data)) or isunicodestring(data, sizeof(data)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
|
||||
{
|
||||
if(type)
|
||||
|
@ -312,6 +327,13 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
unsigned char* data=(unsigned char*)emalloc((maxlen+1)*2, "disasmgetstringat:data");
|
||||
memset(data, 0, (maxlen+1)*2);
|
||||
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen+1)*2, 0))
|
||||
{
|
||||
efree(data, "disasmgetstringat:data");
|
||||
return false;
|
||||
}
|
||||
uint test=0;
|
||||
memcpy(&test, data, sizeof(uint));
|
||||
if(memisvalidreadptr(fdProcessInfo->hProcess, test))
|
||||
return false;
|
||||
if(isasciistring(data, maxlen))
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ const char* disasmtext(uint addr);
|
|||
void disasmprint(uint addr);
|
||||
void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr);
|
||||
void disasmget(uint addr, DISASM_INSTR* instr);
|
||||
bool disasmispossiblestring(uint addr);
|
||||
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen);
|
||||
|
||||
#endif // _DISASM_HELPER_H
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "x64_dbg.h"
|
||||
#include "disasm_fast.h"
|
||||
#include "reference.h"
|
||||
#include "disasm_helper.h"
|
||||
|
||||
static bool bRefinit=false;
|
||||
|
||||
|
@ -740,6 +741,7 @@ static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO
|
|||
{
|
||||
if(!refinfo) //initialize
|
||||
{
|
||||
GuiReferenceDeleteAllColumns();
|
||||
GuiReferenceAddColumn(2*sizeof(uint), "Address");
|
||||
GuiReferenceAddColumn(0, "Disassembly");
|
||||
return true;
|
||||
|
@ -792,6 +794,63 @@ CMDRESULT cbInstrRefFind(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
//refstr [page]
|
||||
bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
{
|
||||
if(!refinfo) //initialize
|
||||
{
|
||||
GuiReferenceDeleteAllColumns();
|
||||
GuiReferenceAddColumn(2*sizeof(uint), "Address");
|
||||
GuiReferenceAddColumn(64, "Disassembly");
|
||||
GuiReferenceAddColumn(0, "String");
|
||||
return true;
|
||||
}
|
||||
bool found=false;
|
||||
STRING_TYPE strtype;
|
||||
char string[512]="";
|
||||
if(basicinfo->branch) //branches have no strings
|
||||
return false;
|
||||
if((basicinfo->type&TYPE_VALUE)==TYPE_VALUE)
|
||||
{
|
||||
if(disasmispossiblestring(basicinfo->value.value) and disasmgetstringat(basicinfo->value.value, &strtype, string, string, 500))
|
||||
found=true;
|
||||
}
|
||||
if((basicinfo->type&TYPE_MEMORY)==TYPE_MEMORY)
|
||||
{
|
||||
if(!found and disasmispossiblestring(basicinfo->memory.value) and disasmgetstringat(basicinfo->memory.value, &strtype, string, string, 500))
|
||||
found=true;
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
char addrText[20]="";
|
||||
sprintf(addrText, "%p", disasm->VirtualAddr);
|
||||
GuiReferenceSetRowCount(refinfo->refcount+1);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->CompleteInstr);
|
||||
char dispString[1024]="";
|
||||
if(strtype==str_ascii)
|
||||
sprintf(dispString, "\"%s\"", string);
|
||||
else
|
||||
sprintf(dispString, "L\"%s\"", string);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 2, dispString);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrRefStr(int argc, char* argv[])
|
||||
{
|
||||
uint addr;
|
||||
if(argc<2 or !valfromstring(argv[1], &addr, true))
|
||||
addr=GetContextData(UE_CIP);
|
||||
uint ticks=GetTickCount();
|
||||
int found=reffind(addr, cbRefStr, 0, false);
|
||||
dprintf("%ums\n", GetTickCount()-ticks);
|
||||
char cmd[256]="";
|
||||
sprintf(cmd, "$result=%u", found);
|
||||
DbgCmdExec(cmd);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrSetstr(int argc, char* argv[])
|
||||
{
|
||||
if(argc<3)
|
||||
|
|
|
@ -45,6 +45,7 @@ CMDRESULT cbInstrXor(int argc, char* argv[]);
|
|||
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 cbInstrSetstr(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrGetstr(int argc, char* argv[]);
|
||||
|
|
|
@ -148,6 +148,7 @@ static void registercommands()
|
|||
cmdnew(cmd, "refinit", cbInstrRefinit, false);
|
||||
cmdnew(cmd, "refadd", cbInstrRefadd, false);
|
||||
cmdnew(cmd, "reffind\1findref\1ref", cbInstrRefFind, true);
|
||||
cmdnew(cmd, "refstr\1strref", cbInstrRefStr, true);
|
||||
|
||||
cmdnew(cmd, "setstr\1strset", cbInstrSetstr, false); //set a string variable
|
||||
cmdnew(cmd, "getstr\1strget", cbInstrGetstr, false); //get a string variable
|
||||
|
|
|
@ -59,7 +59,10 @@ void ReferenceView::setRowCount(int_t count)
|
|||
|
||||
void ReferenceView::deleteAllColumns()
|
||||
{
|
||||
mList->setTableOffset(0);
|
||||
mList->setSingleSelection(0);
|
||||
mList->deleteAllColumns();
|
||||
mList->reloadData();
|
||||
}
|
||||
|
||||
void ReferenceView::setCellContent(int r, int c, QString s)
|
||||
|
|
|
@ -263,9 +263,6 @@ void StdTable::deleteAllColumns()
|
|||
AbstractTableView::deleteAllColumns();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void StdTable::setCellContent(int r, int c, QString s)
|
||||
{
|
||||
if(isValidIndex(r, c) == true)
|
||||
|
|
Loading…
Reference in New Issue