Add another IDA script

This commit is contained in:
meepingsnesroms
2019-11-16 13:02:12 -08:00
parent 3b009d7131
commit 8d386d8027
2 changed files with 38 additions and 1 deletions

View File

@@ -528,7 +528,7 @@ void do_arm_instruction(Instruction i)
arm.reg[15] += (int32_t) (i.branch.immed << 8) >> 6;//TODO: this signed int shift is undefined behavior by the C standard
arm.reg[15] += 4;
if(arm.reg[15] >= 0x2009B130 && arm.reg[15] <= 0x200C7EEB && i.branch.l)
gui_debug_printf("ARM DAL function called:0x%08X from 0x%08X\n", arm.reg[15], arm.reg[14] - 4);
gui_debug_printf("ARM DAL function call, jump from 0x%08X to 0x%08X\n", arm.reg[14] - 4, arm.reg[15]);
}
else if((insn & 0xF000F10) == 0xE000F10)
do_cp15_instruction(i);

View File

@@ -0,0 +1,37 @@
# jumps to DAL address when given execution address
import idc
import ida_bytes
import ctypes
DAL_JUMP_TABLE = 0x00000024
def getBranchOffset(opcode):
offset = opcode & 0x007FFFFF;
if opcode & 0x00800000:
offset |= 0xFF800000;
offset = ctypes.c_int(offset).value;
offset *= 4
offset += 8 # account for PC weirdness
return ctypes.c_int(offset).value
def writeAddrName(addr, name):
idc.set_name(addr, name + "Entrypoint", SN_NOCHECK)
idc.set_name(addr + getBranchOffset(ida_bytes.get_dword(addr)), name, SN_NOCHECK)
print hex(addr + getBranchOffset(ida_bytes.get_dword(addr)))
def applyHalTable():
with open("C:/Users/Emily/Desktop/Projects/PalmOSEmulator/halTable.txt", 'r') as tblFile:
halTable = tblFile.read().split()
for x in range(0, len(halTable) / 3):
writeAddrName(DAL_JUMP_TABLE + int(halTable[x * 3 + 1], 16), halTable[x * 3 + 2])
applyHalTable()