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) if(mShowMnemonicBrief)
{ {
char brief[MAX_STRING_SIZE] = ""; 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(' '); int index = mnem.indexOf(' ');
if(index != -1) if(index != -1)
mnem.truncate(index); mnem.truncate(index);

View File

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

View File

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