Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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)
- OpAlt(addr, 0, "");
- OpOff(addr, 0, 0);
- // Get value of operand (the instructions we are looking for only have one)
- opnd = GetOpnd(addr, 0);
- // Generate new representation
- if (strstr(opnd, "(") == 0) {
- name = sprintf(fmt, substr(opnd, 1, strlen(opnd)-3));
- if (strstr(name, opnd) != -1) {
- return;
- }
- } else if (strstr(opnd, "(pc)") > -1) {
- name = sprintf(fmt, substr(opnd, 0, strlen(opnd)-4));
- if (strstr(name, opnd) != -1) {
- return;
- }
- }
- 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));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement