#!/usr/bin/env python3 """Autostart in the home screen stub, run in a Thumb emulator (unicorn). python3 test/stub_auto_test.py (needs: pip install unicorn)""" import struct, os from unicorn import Uc, UC_ARCH_ARM, UC_MODE_THUMB, UC_HOOK_CODE from unicorn.arm_const import UC_ARM_REG_SP, UC_ARM_REG_LR, UC_ARM_REG_PC here = os.path.dirname(os.path.abspath(__file__)) BASE, ORIG, DONE = 0x1009F000, 0x10100000, 0x10200000 bad = 0 def ok(c, m): global bad print(('ok ' if c else 'WRONG ') + m); bad += 0 if c else 1 def stub(tpl, auto): d = bytearray(open(tpl, 'rb').read()) for o in range(0, len(d) - 3, 2): w = struct.unpack_from('