Skip to content
Snippets Groups Projects
Commit 12d167a2 authored by jdh8d's avatar jdh8d
Browse files

added getAddress and hasRepPrefix support to capstone

Former-commit-id: 939c01951a64c43cb0c46ef19ee2361a9269568c
parent f8cd9c36
No related branches found
No related tags found
No related merge requests found
......@@ -95,14 +95,14 @@ class STARS_IRDB_Instruction_t : public STARS_Instruction_t
// Query methods
virtual bool HasRepeatIfEqualPrefix(void) const
{ return disasm.hasRepnePrefix(); /*disasm.Prefix.RepnePrefix!=NotUsedPrefix;*/ }
{ return disasm.hasRelevantRepnePrefix(); /*disasm.Prefix.RepnePrefix!=NotUsedPrefix;*/ }
virtual bool HasRepeatIfNotEqualPrefix(void) const
{ return disasm.hasRepPrefix(); /* disasm.Prefix.RepPrefix!=NotUsedPrefix; */ }
{ return disasm.hasRelevantRepPrefix(); /* disasm.Prefix.RepPrefix!=NotUsedPrefix; */ }
virtual bool HasAnyRepeatPrefix(void) const
{ return HasRepeatIfEqualPrefix() || HasRepeatIfNotEqualPrefix(); }
virtual bool HasOperandSizePrefix(void) const
{ return disasm.hasOperandSizePrefix(); /* Prefix.OperandSize!=NotUsedPrefix; */}
{ return disasm.hasRelevantOperandSizePrefix(); /* Prefix.OperandSize!=NotUsedPrefix; */}
virtual bool HasREXWPrefix(void) const
{ return disasm.hasRexWPrefix(); /*disasm.Prefix.REX.W_!=0; */}
......@@ -131,7 +131,7 @@ class STARS_IRDB_Instruction_t : public STARS_Instruction_t
return true;
// no size prefix and opcode defaults to 64-bit
if (!this->HasOperandSizePrefix() && this->OpcodeDefaultsTo64BitOperands() )
if ( this->OpcodeDefaultsTo64BitOperands() && !this->HasOperandSizePrefix() )
return true;
// size prefix or non-64 bit operand
......
......@@ -4796,7 +4796,7 @@ void SMPFunction::AnalyzeFunc(void) {
InstAddr = CurrInst->GetAddr();
pair<STARS_ea_t, SMPBasicBlock *> MapItem(InstAddr, CurrBlock);
this->InstBlockMap.insert(MapItem);
if (CurrInst->MDHasAnyRepeatPrefix() && CurrInst->MDIsPossibleStringLoopingOpcode()) {
if ( CurrInst->MDIsPossibleStringLoopingOpcode() && CurrInst->MDHasAnyRepeatPrefix() ) {
CurrBlock->SetHasLoopingStringOpcode();
}
}
......
......@@ -19174,7 +19174,6 @@ bool SMPInstr::BuildMoveRTL(SMPoperator GuardOp) {
bool SourceFound = false;
bool MemSrc = this->HasSourceMemoryOperand();
bool MemDest = this->HasDestMemoryOperand();
bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix();
bool AltersRSI = false; // for string operations
bool AltersRDI = false; // for string operations
unsigned short opcode = this->GetIDAOpcode();
......@@ -19363,6 +19362,7 @@ bool SMPInstr::BuildMoveRTL(SMPoperator GuardOp) {
STARSOpndTypePtr FirstOpnd = this->GetOperand(0);
uint16_t ByteWidth = FirstOpnd->GetByteWidth();
STARSOpndTypePtr IncrementOp = this->MakeImmediateOpnd((STARS_uval_t) ByteWidth);
bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix();
if (HasRepeatPrefix) { // Must be MOVS or STOS or INS or OUTS
// The repeat causes USE and DEF of ECX as a counter
STARSOpndTypePtr CountOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_cx);
......@@ -19522,7 +19522,6 @@ bool SMPInstr::BuildCompareStringRTL(void) {
std::size_t OpNum;
bool Src1Found = false;
bool Src2Found = false;
bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix();
 
STARSOpndTypePtr FlagsOp = this->STARSInstPtr->MakeRegOpnd(X86_FLAGS_REG);
 
......@@ -19578,6 +19577,7 @@ bool SMPInstr::BuildCompareStringRTL(void) {
else {
this->RTL.push_back(TempRT);
// Now, create the repeat prefix effects
bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix();
if (HasRepeatPrefix) {
// The repeat causes USE and DEF of ECX as a counter
SMPRegTransfer *CounterRT = new SMPRegTransfer;
......@@ -19871,7 +19871,6 @@ bool SMPInstr::BuildFlagsDestBinaryRTL(SMPoperator BinaryOp) {
bool Source1Found = false;
bool Source2Found = false;
bool NoOperandsRequired = ((STARS_NN_scas == opcode) || (STARS_NN_cmps == opcode));
bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix();
 
SMPRegTransfer *TempRT = new SMPRegTransfer;
TempRT->SetParentInst(this);
......@@ -19950,6 +19949,7 @@ bool SMPInstr::BuildFlagsDestBinaryRTL(SMPoperator BinaryOp) {
else {
this->RTL.push_back(TempRT);
// Now, create the repeat prefix effects
bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix();
if (HasRepeatPrefix) { // Must be CMPS or SCAS
// The repeat causes USE and DEF of ECX as a counter
SMPRegTransfer *CounterRT = new SMPRegTransfer;
......
......@@ -34,7 +34,11 @@ old_stty=`stty -g`
# jdh - added -B for batch mode, avoids any prompts.
# jdh - note: can't use -B, as the plugin doesn't run!
# time ${IDAROOT}/idal -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null
TVHEADLESS=1 time ${IDAROOT}/idal -A -SSMP.idc $1 > $1.idaoutput
if [[ -f ${IDAROOT}/idal ]] ; then
TVHEADLESS=1 time ${IDAROOT}/idal -A -SSMP.idc $1 > $1.idaoutput
else
TVHEADLESS=1 time ${IDAROOT}/idat -A -SSMP.idc $1 > $1.idaoutput
fi
# valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --log-file=$1.valgrind.log ${IDAROOT}/idal -A -SSMP.idc $1
......
......@@ -34,8 +34,11 @@ old_stty=`stty -g`
# jdh - added -B for batch mode, avoids any prompts.
# jdh - note: can't use -B, as the plugin doesn't run!
# TVHEADLESS=1 time ${IDAROOT}/idal64 -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null
echo "TVHEADLESS=1 time ${IDAROOT}/idal64 -A -SSMP.idc $1 > $1.idaoutput"
TVHEADLESS=1 time ${IDAROOT}/idal64 -A -SSMP.idc $1 > $1.idaoutput
if [[ -f ${IDAROOT}/idal64 ]]; then
(set -x; TVHEADLESS=1 time ${IDAROOT}/idal64 -A -SSMP.idc $1 > $1.idaoutput )
else
(set -x ; TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP.idc $1 > $1.idaoutput )
fi
# TVHEADLESS=1 valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --log-file=$1.valgrind.log ${IDAROOT}/idal64 -A -SSMP.idc $1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment