diff --git a/SMPInstr.cpp b/SMPInstr.cpp index 8a78386d3037d66d6020348277bd3c51987c00ac..d18ce18d8c743577620cfc9a31ac4b251f123ce9 100644 --- a/SMPInstr.cpp +++ b/SMPInstr.cpp @@ -914,7 +914,11 @@ void SMPInstr::Analyze(void) { return; // Fill cmd structure with disassembly of instr +#if IDA_SDK_VERSION < 600 + int InstrLen = ua_ana0(this->address); +#else int InstrLen = decode_insn(this->address); +#endif if (0 >= InstrLen) { msg("ERROR: decode_insn failed at %x \n", this->address); this->SMPcmd = cmd; diff --git a/SMPProgram.cpp b/SMPProgram.cpp index 61a314604872508847b8e83ed848a3639d2f2a67..ce6a1439fdd9aaf72d30f67c3efeb19e32eaef14 100644 --- a/SMPProgram.cpp +++ b/SMPProgram.cpp @@ -43,6 +43,7 @@ #include <cstdlib> #include <pro.h> +#include <ua.hpp> #include <assert.h> #include <ida.hpp> #include <idp.hpp> @@ -86,7 +87,11 @@ ea_t HighestCodeAddress; // Does the instruction at InstAddr access the global data offset in GlobalAddr // using an index register? bool MDIsIndexedAccess(ea_t InstAddr, ea_t GlobalAddr) { +#if IDA_SDK_VERSION < 600 + int InstrLen = ua_anao(InstAddr); +#else int InstLen = decode_insn(InstAddr); +#endif bool DebugFlag = (InstAddr == 0x80502d3); #if SMP_DETECT_INDEXED_ACCESSES if (0 >= InstLen) @@ -158,7 +163,12 @@ void SMPProgram::InitStaticDataTable(void) { // Loop through all segments. ea_t RecentAddr = BADADDR; +#if IDA_SDK_VERSION < 600 + for (int SegIndex = 0; SegIndex < get_segm_qty(); ++SegIndex) { + segment_t *seg = getnseg(SegIndex); +#else for (segment_t *seg = get_first_seg(); NULL != seg; seg = get_next_seg(RecentAddr)) { +#endif char SegName[MAXSTR]; RecentAddr = seg->startEA; ssize_t SegNameSize = get_segm_name(seg, SegName, sizeof(SegName) - 1); @@ -327,7 +337,12 @@ void SMPProgram::Analyze(ProfilerInformation *pi) { // Collect initial info about all functions. // Loop through all segments. ea_t RecentAddr = BADADDR; +#if IDA_SDK_VERSION < 600 + for (int SegIndex = 0; SegIndex < get_segm_qty(); ++SegIndex) { + segment_t *seg = getnseg(SegIndex); +#else for (segment_t *seg = get_first_seg(); NULL != seg; seg = get_next_seg(RecentAddr)) { +#endif char SegName[MAXSTR]; RecentAddr = seg->startEA; ssize_t SegNameSize = get_segm_name(seg, SegName, sizeof(SegName) - 1); diff --git a/SMPStaticAnalyzer.cpp b/SMPStaticAnalyzer.cpp index d2ee95280562bf203b3fd7d65e6f9e871e3bd537..31db49c74bef78ae5ffca5712edae6447732ad43 100644 --- a/SMPStaticAnalyzer.cpp +++ b/SMPStaticAnalyzer.cpp @@ -36,6 +36,7 @@ #include <string> +#include <pro.h> #include <ida.hpp> #include <idp.hpp> #include <allins.hpp> @@ -286,8 +287,13 @@ void IDAP_run(int arg) { #if SMP_FIND_ORPHANS ea_t RecentAddr = BADADDR; +#if IDA_SDK_VERSION < 600 + for (int SegIndex = 0; SegIndex < get_segm_qty(); ++SegIndex) { + segment_t *seg = getnseg(SegIndex); +#else for (segment_t *seg = get_first_seg(); NULL != seg; seg = get_next_seg(RecentAddr)) { RecentAddr = seg->startEA; +#endif if (seg->type == SEG_CODE) FindOrphanedCode(seg, SymsFile); } @@ -363,8 +369,13 @@ void FindCodeAddresses(void) { // Find all the code locs in the IDA Pro database. As we find // them, store them in IDAProLocs. ea_t RecentAddr = BADADDR; +#if IDA_SDK_VERSION < 600 + for (int SegIndex = 0; SegIndex < get_segm_qty(); ++SegIndex) { + segment_t *seg = getnseg(SegIndex); +#else for (segment_t *seg = get_first_seg(); NULL != seg; seg = get_next_seg(RecentAddr)) { RecentAddr = seg->startEA; +#endif if (SEG_CODE != seg->type) continue; @@ -498,8 +509,13 @@ void FindDataInCode(void) { int InstrLen; ea_t RecentAddr = BADADDR; +#if IDA_SDK_VERSION < 600 + for (int SegIndex = 0; SegIndex < get_segm_qty(); ++SegIndex) { + segment_t *seg = getnseg(SegIndex); +#else for (segment_t *seg = get_first_seg(); NULL != seg; seg = get_next_seg(RecentAddr)) { RecentAddr = seg->startEA; +#endif if (SEG_CODE != seg->type) continue; #if SMP_DEBUG_FIXUP_IDB @@ -562,7 +578,11 @@ void FindDataInCode(void) { #if SMP_DEBUG_FIXUP_IDB msg("DataRunLen: %d at %x\n", DataRunLen, addr); #endif +#if IDA_SDK_VERSION < 600 + InstrLen = ua_ana0(addr); +#else InstrLen = decode_insn(addr); +#endif // We don't check the returned InstrLen for validity because IsCodeMisaligned() // will check for validity immediately below. #if SMP_DEBUG_FIXUP_IDB @@ -919,7 +939,11 @@ bool MDPatchUnconvertedBytes(ea_t CurrDisasmAddr) { #if SMP_DEBUG_FIXUP_IDB msg("Patched %d bytes successfully at %x\n", InstrLen, CurrDisasmAddr); #endif +#if IDA_SDK_VERSION < 600 + InstrLen = ua_code(CurrDisasmAddr); +#else InstrLen = create_insn(CurrDisasmAddr); +#endif if (0 >= InstrLen) { #if SMP_DEBUG_FIXUP_IDB msg(" ... but ua_code() still failed!\n"); @@ -1022,7 +1046,11 @@ void FixCodeIdentification(void) { msg("Sync problem in FixCodeID: %x\n", CurrDisasmAddr); } else { +#if IDA_SDK_VERSION < 600 + InstrLen = ua_code(CurrDisasmAddr); +#else InstrLen = create_insn(CurrDisasmAddr); +#endif if (InstrLen > 0) { // Successfully converted to code SMPInstr NewInstr(CurrDisasmAddr); NewInstr.Analyze(); @@ -1144,7 +1172,11 @@ int FixupNewCodeChunks(void) { } list<ea_t>::iterator CurrInstr; for (CurrInstr = CurrRegion->FixupInstrs.begin(); CurrInstr != CurrRegion->FixupInstrs.end(); ++CurrInstr) { +#if IDA_SDK_VERSION < 600 + int InstrLen = ua_code(*CurrInstr); +#else int InstrLen = create_insn(*CurrInstr); +#endif if (InstrLen > 0) { // Successfully converted to code SMPInstr NewInstr(*CurrInstr); NewInstr.Analyze(); @@ -1291,7 +1323,12 @@ void FindOrphanedCode(segment_t *CurrSeg, FILE *AnnotFile) { msg("Unanalyzed byte at %x\n", addr); #endif // Can IDA analyze this to be code? - int InstrLen = create_insn(addr); + int InstrLen; +#if IDA_SDK_VERSION < 600 + InstrLen = ua_code(addr); +#else + InstrLen = create_insn(addr); +#endif if (InstrLen > 0) { bool IDAsuccess = generate_disasm_line(addr, disasm, sizeof(disasm) - 1); if (IDAsuccess) { @@ -1457,7 +1494,11 @@ void SpecialDebugOutput(void) { ea_t addr = ProblemAddrs[index]; flags_t InstrFlags = getFlags(addr); if (isCode(InstrFlags) && isHead(InstrFlags)) { +#if IDA_SDK_VERSION < 600 + InstLen = ua_ana0(addr); +#else InstLen = decode_insn(addr); +#endif if (0 < InstLen) { IDAsuccess = generate_disasm_line(addr, disasm, sizeof(disasm) - 1); if (IDAsuccess) {