36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
from ghidra_assistant.utils.utils import *
|
|
from ghidra_assistant.utils.archs.arm64.arm64_emulator import ARM64UC_Emulator
|
|
from unicorn.arm64_const import *
|
|
from unicorn.unicorn_const import *
|
|
|
|
class ExynosEmulator(ARM64UC_Emulator):
|
|
def __init__(self, rom_path):
|
|
super().__init__()
|
|
self.rom_path = rom_path
|
|
self.setup()
|
|
|
|
def setup(self):
|
|
self.setup_memory()
|
|
self.setup_registers()
|
|
|
|
def setup_memory(self):
|
|
#ROM
|
|
self.uc.mem_map(0x0, 128 * KB, UC_PROT_READ | UC_PROT_EXEC)
|
|
self.uc.mem_write(0x0, open(self.rom_path, "rb").read())
|
|
pass
|
|
|
|
def setup_registers(self):
|
|
self.pc = 0x0
|
|
self.uc.reg_write(UC_ARM64_REG_PC, self.pc)
|
|
|
|
def run(self):
|
|
try:
|
|
self.uc.emu_start(self.pc, self.pc + 1)
|
|
pass
|
|
except Exception as e:
|
|
self.print_ctx(print)
|
|
pass
|
|
|
|
if __name__ == '__main__':
|
|
emulator = ExynosEmulator("../S7/rom.bin")
|
|
emulator.run() |