1
0
Fork 0

fixed problem with immediates

This commit is contained in:
torusrxxx 2017-10-29 08:40:49 +08:00 committed by Duncan Ogilvie
parent 712bd6f78a
commit 6c472a34e4
6 changed files with 21 additions and 15 deletions

View File

@ -465,6 +465,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
curByte.text = formatOpcodeString(mInstBuffer.at(rowOffset));
curByte.textColor = mBytesColor;
curByte.textBackground = mBytesBackgroundColor;
curByte.highlight = false;
richBytes.push_back(curByte);
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(cur_addr))
{

View File

@ -222,7 +222,7 @@ Instruction_t QBeaEngine::DisassembleAt(byte_t* data, duint size, duint origBase
wInst.length = len;
wInst.branchType = branchType;
wInst.tokens = cap;
cp.BytesGroup(&wInst.prefixSize, &wInst.opcodeSize, &wInst.group1Size, &wInst.group2Size);
cp.BytesGroup(&wInst.prefixSize, &wInst.opcodeSize, &wInst.group1Size, &wInst.group2Size, &wInst.group3Size);
if(!success)
return wInst;
@ -339,14 +339,23 @@ QString formatOpcodeString(const Instruction_t & inst)
output.insert(inst.prefixSize * 2, ':');
offset++;
}
output.insert((inst.opcodeSize + inst.prefixSize) * 2 + offset, ' ');
offset++;
if(inst.group1Size > 0)
{
output.insert((inst.opcodeSize + inst.prefixSize) * 2 + offset, ' ');
output.insert((inst.opcodeSize + inst.prefixSize + inst.group1Size) * 2 + offset, ' ');
offset++;
}
if(inst.group2Size > 0)
{
output.insert((inst.opcodeSize + inst.prefixSize + inst.group1Size) * 2 + offset, ' ');
output.insert((inst.opcodeSize + inst.prefixSize + inst.group1Size + inst.group2Size) * 2 + offset, ' ');
offset++;
}
/*if(inst.group3Size > 0)
{
output.insert((inst.opcodeSize + inst.prefixSize + inst.group1Size + inst.group2Size) * 2 + offset, '?');
}
output += QString("|%1.%2.%3.%4").arg(inst.opcodeSize).arg(inst.group1Size).arg(inst.group2Size).arg(inst.group3Size);
*/
return output;
}

View File

@ -28,7 +28,7 @@ struct Instruction_t
QString instStr;
QByteArray dump;
uint8_t prefixSize, opcodeSize, group1Size, group2Size;
uint8_t prefixSize, opcodeSize, group1Size, group2Size, group3Size;
duint rva;
int length;
duint branchDestination;

View File

@ -1497,12 +1497,7 @@ void CPUDisassembly::pushSelectionInto(bool copyBytes, QTextStream & stream, QTe
QString bytes;
if(copyBytes)
{
for(int j = 0; j < inst.dump.size(); j++)
{
if(j)
bytes += " ";
bytes += ToByteString((unsigned char)(inst.dump.at(j)));
}
bytes += formatOpcodeString(inst);
}
QString disassembly;
QString htmlDisassembly;

View File

@ -941,14 +941,15 @@ const char* Zydis::FlagName(ZydisCPUFlag flag) const
}
}
void Zydis::BytesGroup(uint8_t* prefixSize, uint8_t* opcodeSize, uint8_t* group1Size, uint8_t* group2Size) const
void Zydis::BytesGroup(uint8_t* prefixSize, uint8_t* opcodeSize, uint8_t* group1Size, uint8_t* group2Size, uint8_t* group3Size) const
{
if(Success())
{
*prefixSize = mInstr.raw.prefixes.count;
*group1Size = mInstr.raw.disp.size;
*group2Size = mInstr.raw.imm[0].size;
*opcodeSize = mInstr.length - *prefixSize - *group1Size - *group2Size;
*group1Size = mInstr.raw.disp.size / 8;
*group2Size = mInstr.raw.imm[0].size / 8;
*group3Size = mInstr.raw.imm[1].size / 8;
*opcodeSize = mInstr.length - *prefixSize - *group1Size - *group2Size - *group3Size;
}
else
{

View File

@ -39,7 +39,7 @@ public:
static bool IsBranchGoingToExecute(ZydisMnemonic id, size_t cflags, size_t ccx);
bool IsConditionalGoingToExecute(size_t cflags, size_t ccx) const;
static bool IsConditionalGoingToExecute(ZydisMnemonic id, size_t cflags, size_t ccx);
void BytesGroup(uint8_t* prefixSize, uint8_t* opcodeSize, uint8_t* group1Size, uint8_t* group2Size) const;
void BytesGroup(uint8_t* prefixSize, uint8_t* opcodeSize, uint8_t* group1Size, uint8_t* group2Size, uint8_t* group3Size) const;
enum RegAccessInfo : uint8_t
{