1
0
Fork 0

GUI: mnemonic help and brief now work better with prefixes

This commit is contained in:
Duncan Ogilvie 2017-12-29 15:52:11 +01:00
parent 16fdf57f41
commit 289a6b1911
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
3 changed files with 19 additions and 9 deletions

View File

@ -664,7 +664,18 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
if(mShowMnemonicBrief)
{
char brief[MAX_STRING_SIZE] = "";
QString mnem = mInstBuffer.at(rowOffset).instStr;
QString mnem;
for(const CapstoneTokenizer::SingleToken & token : mInstBuffer.at(rowOffset).tokens.tokens)
{
if(token.type != CapstoneTokenizer::TokenType::Space && token.type != CapstoneTokenizer::TokenType::Prefix)
{
mnem = token.text;
break;
}
}
if(mnem.isEmpty())
mnem = mInstBuffer.at(rowOffset).instStr;
int index = mnem.indexOf(' ');
if(index != -1)
mnem.truncate(index);

View File

@ -367,6 +367,7 @@ QString CapstoneTokenizer::printValue(const TokenValue & value, bool expandModul
bool CapstoneTokenizer::tokenizePrefix()
{
//TODO: what happens with multiple prefixes?
bool hasPrefix = true;
QStringList prefixText;

View File

@ -1909,14 +1909,12 @@ void CPUDisassembly::mnemonicBriefSlot()
void CPUDisassembly::mnemonicHelpSlot()
{
BASIC_INSTRUCTION_INFO disasm;
DbgDisasmFastAt(rvaToVa(getInitialSelection()), &disasm);
if(!*disasm.instruction)
return;
char* space = strstr(disasm.instruction, " ");
if(space)
*space = '\0';
DbgCmdExecDirect(QString("mnemonichelp %1").arg(disasm.instruction).toUtf8().constData());
unsigned char data[16] = { 0xCC };
auto addr = rvaToVa(getInitialSelection());
DbgMemRead(addr, data, sizeof(data));
Zydis zydis;
zydis.Disassemble(addr, data);
DbgCmdExecDirect(QString("mnemonichelp %1").arg(zydis.Mnemonic().c_str()).toUtf8().constData());
emit displayLogWidget();
}