1
0
Fork 0

Show XMM floating-point value in info box

This commit is contained in:
torusrxxx 2020-05-23 00:37:26 +08:00 committed by Duncan Ogilvie
parent 6f5e786a54
commit 82ba40e6ec
3 changed files with 61 additions and 5 deletions

View File

@ -3,6 +3,7 @@
#include "WordEditDialog.h"
#include "XrefBrowseDialog.h"
#include "Bridge.h"
#include "zydis_wrapper.h"
CPUInfoBox::CPUInfoBox(StdTable* parent) : StdTable(parent)
{
@ -200,12 +201,41 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
if(DbgMemRead(arg.value, data.data(), data.size()))
{
QString hex;
hex.reserve(data.size() * 3);
for(int k = 0; k < data.size(); k++)
Zydis myinstruction;
bool isXMMdecoded = false;
unsigned char instructiondata[MAX_DISASM_BUFFER];
if(basicinfo.memory.size == 16 && DbgMemRead(parVA, &instructiondata, MAX_DISASM_BUFFER))
{
if(k)
hex.append(' ');
hex.append(ToByteString(data[k]));
myinstruction.Disassemble(parVA, instructiondata);
if(myinstruction.Success())
{
switch(myinstruction.getVectorElementType(i))
{
case Zydis::VETFloat32:
hex = "%1 %2 %3 %4";
hex = hex.arg(((const float*)data.data())[0]).arg(((const float*)data.data())[1]).arg(((const float*)data.data())[2]).arg(((const float*)data.data())[3]);
isXMMdecoded = true;
break;
case Zydis::VETFloat64:
hex = "%1 %2";
hex = hex.arg(((const double*)data.data())[0]).arg(((const double*)data.data())[1]);
isXMMdecoded = true;
break;
default:
isXMMdecoded = false;
}
}
}
if(!isXMMdecoded)
{
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);
}

View File

@ -691,6 +691,22 @@ size_t Zydis::ResolveOpValue(int opindex, const std::function<size_t(ZydisRegist
return dest;
}
Zydis::VectorElementType Zydis::getVectorElementType(int opindex) const
{
if(!Success())
return Zydis::VETDefault;
const auto & op = mInstr.operands[opindex];
switch(op.elementType)
{
case ZYDIS_ELEMENT_TYPE_FLOAT32:
return Zydis::VETFloat32;
case ZYDIS_ELEMENT_TYPE_FLOAT64:
return Zydis::VETFloat64;
default:
return Zydis::VETDefault;
}
}
bool Zydis::IsBranchGoingToExecute(size_t cflags, size_t ccx) const
{
if(!Success())

View File

@ -91,6 +91,16 @@ public:
bool IsBranchType(std::underlying_type_t<BranchType> bt) const;
enum VectorElementType
{
VETDefault,
VETFloat32,
VETFloat64,
VETInt32,
VETInt64
};
VectorElementType getVectorElementType(int opindex) const;
// Shortcuts.
bool IsRet() const { return IsBranchType(BTRet); }
bool IsCall() const { return IsBranchType(BTCall); }