1
0
Fork 0

GUI: improve InfoBox for bigger memory sizes

This commit is contained in:
Duncan Ogilvie 2017-12-03 22:19:43 +01:00
parent d780df76df
commit e11701d7c3
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
3 changed files with 36 additions and 25 deletions

View File

@ -8,22 +8,6 @@
#include "memory.h" #include "memory.h"
#include "datainst_helper.h" #include "datainst_helper.h"
static MEMORY_SIZE argsize2memsize(int argsize)
{
switch(argsize)
{
case 8:
return size_byte;
case 16:
return size_word;
case 32:
return size_dword;
case 64:
return size_qword;
}
return size_byte;
}
void fillbasicinfo(Zydis* cp, BASIC_INSTRUCTION_INFO* basicinfo, bool instrText) void fillbasicinfo(Zydis* cp, BASIC_INSTRUCTION_INFO* basicinfo, bool instrText)
{ {
//zero basicinfo //zero basicinfo

View File

@ -134,8 +134,8 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
valText = valTextSym; valText = valTextSym;
argMnemonic = !ok ? QString("%1]=[%2").arg(argMnemonic).arg(valText) : valText; argMnemonic = !ok ? QString("%1]=[%2").arg(argMnemonic).arg(valText) : valText;
QString sizeName = ""; QString sizeName = "";
int memsize = basicinfo.memory.size; bool knownsize = true;
switch(memsize) switch(basicinfo.memory.size)
{ {
case size_byte: case size_byte:
sizeName = "byte ptr "; sizeName = "byte ptr ";
@ -149,8 +149,10 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
case size_qword: case size_qword:
sizeName = "qword ptr "; sizeName = "qword ptr ";
break; break;
default:
knownsize = false;
break;
} }
sizeName.append(' ');
sizeName += [](SEGMENTREG seg) sizeName += [](SEGMENTREG seg)
{ {
@ -177,12 +179,38 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
sizeName = sizeName.toUpper(); sizeName = sizeName.toUpper();
if(!DbgMemIsValidReadPtr(arg.value)) if(!DbgMemIsValidReadPtr(arg.value))
{
setInfoLine(j, sizeName + "[" + argMnemonic + "]=???"); setInfoLine(j, sizeName + "[" + argMnemonic + "]=???");
else }
else if(knownsize)
{ {
QString addrText = getSymbolicNameStr(arg.memvalue); QString addrText = getSymbolicNameStr(arg.memvalue);
setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + addrText); setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + addrText);
} }
else
{
//TODO: properly support XMM constants
QVector<unsigned char> data;
data.resize(basicinfo.memory.size);
memset(data.data(), 0, data.size());
if(DbgMemRead(arg.value, data.data(), data.size()))
{
QString hex;
hex.reserve(data.size() * 3);
for(int k = 0; k < data.size(); k++)
{
if(k)
hex.append(' ');
hex.append(ToByteString(data[k]));
}
setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + hex);
}
else
{
setInfoLine(j, sizeName + "[" + argMnemonic + "]=???");
}
}
j++; j++;
} }
else else

View File

@ -4,7 +4,6 @@
#include "MiscUtil.h" #include "MiscUtil.h"
#include "ldconvert.h" #include "ldconvert.h"
QString ToLongDoubleString(void* buffer) QString ToLongDoubleString(void* buffer)
{ {
char str[32]; char str[32];