
Untitled
By: a guest on
May 1st, 2015 | syntax:
C++ | size: 1.25 KB | views:
240 | expires: Never
#define UNLOADED_FILE 1
#include <idc.idc>
static main(void) {
auto addr;
auto val;
// Start from the first piece of code found...
addr = FindCode(0x00000000, SEARCH_DOWN);
// ... and keep going until we run out of code to process
while (addr != BADADDR) {
// Get opcode and check it
val = Word(addr);
if ((val & 0xFFBF) == 0x4EB8) {
// (jmp|jsr) (XXX).w
FixupIns(addr, "(%s).w");
} else if ((val & 0xFFBF) == 0x4EB9) {
// (jmp|jsr) (XXX).l
FixupIns(addr, "(%s).l");
} else if ((val & 0xF1FF) == 0x41FA || (val & 0xFFBF) == 0x4EBA || val == 0x487A) {
// (jmp|jsr|lea|pea) XXX(pc)
FixupIns(addr, "%s(pc)");
}
addr = FindCode(addr, SEARCH_DOWN);
}
}
static FixupIns(addr, fmt) {
auto mnem;
auto opnd;
auto name;
// Get current disassembly line for comparison
mnem = GetDisasm(addr);
// Reset offset (fixes an issue with pc-relative addresses)
OpOff(addr, 0, 0);
// Get value of operand (the instructions we are looking for only have one)
opnd = GetOpnd(addr, 0);
// Generate new representation
name = sprintf(fmt, opnd);
// Set manual operand representation
OpAlt(addr, 0, name);
// Log what we did
Message("%s:%08X: %-60s\t%-60s\n", SegName(addr), addr, mnem, GetDisasm(addr));
}