Android port (Adreno): Vulkan backend, GameActivity app, touch HUD, lifecycle, minimap quest goals
- host/android: Vulkan replay backend (nvn_vk.c) with pipeline/descriptor caching, ADPF, AChoreographer present link; Linux compat layer; Makefile.android (headless dmhost + APK lib) - android/app: GameActivity shell without Gradle (build_apk.sh), AAudio output, touch HUD port (touch_app.c + TouchOverlay.java, three layers: body / joystick / minimap goals), lifecycle save-on-background like iOS, art_from_ipa.py for touch / HUD / mapgoal art - touch: shared touch controls moved from ios/Sources to dm/touch - patch_nso.py Android ruleset, dmsh_vk.py shader pack, DM_TOUCH_PRODUCT defaults - hle_audio: AAudio resume waits through STARTING and reopens once on failure - .gitignore: local resources/ (original game data) never committed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5bc5a01087
commit
4d91f80bae
+17
-7
@@ -27,6 +27,7 @@ A = ap.parse_args()
|
||||
IB = 0x100000000
|
||||
ARENA = 0x0; ARENA_SZ = 0x1000000 # 低 16 MB 可读写随机区 | Low 16 MB readable/writable random area
|
||||
TSD = 0x2000000
|
||||
TPA = TSD + 0x8000 # linux-bionic:模拟 Bionic 线程指针区,[TPA + TP_SLOT_OFF] = TSD | linux-bionic: emulated Bionic thread pointer area, [TPA + TP_SLOT_OFF] = TSD
|
||||
SP0 = 0x800000
|
||||
DIR, MOD = A.dir, A.mod
|
||||
hdr = nsoimg.header(DIR, MOD) # 表头:段边界与写死进指令的线程槽号 | Header: segment boundaries and the thread slot numbers hard-coded into instructions
|
||||
@@ -80,12 +81,13 @@ def plain_block(a):
|
||||
"""普通改写块(stp; 键页间接读槽; 替换指令; 键页间接写槽; ...)→ 替换指令偏移。 | Ordinary rewrite block (stp; indirect slot read via key page; replaced instruction; indirect slot write via key page; ...) → offset of the replaced instruction."""
|
||||
s = btarget(pat, a); w0 = struct.unpack_from('<I', pat, s)[0]
|
||||
if w0 & 0xFFC003E0 != 0xA90003E0: return None # stp xS, xT, [sp, #off]
|
||||
ins = list(md.disasm(bytes(pat[s:s + 36]), s))
|
||||
if len(ins) < 8 or ins[1].mnemonic != 'mrs' or 'tpidrro_el0' not in ins[1].op_str:
|
||||
return None
|
||||
ins = list(md.disasm(bytes(pat[s:s + 40]), s))
|
||||
sb = nsoimg.slot_base(ins, 1, hdr)
|
||||
if not sb: return None
|
||||
T, d = sb; ins = ins[:1] + ins[d:] # 基址前缀折成一条,下标与 apple 相同 | Fold the base prefix into one so indices match apple
|
||||
if len(ins) < 8: return None
|
||||
if ins[2].mnemonic != 'adrp' or ins[2].operands[1].imm != KEY_PAGE_OFF: return None
|
||||
if ins[3].mnemonic != 'ldr' or ins[3].operands[1].mem.base != ins[2].operands[0].reg: return None
|
||||
T = ins[1].operands[0].reg
|
||||
if ins[4].mnemonic != 'add' or ins[4].operands[0].reg != T or ins[4].operands[1].reg != T: return None
|
||||
if ins[5].mnemonic != 'ldr' or ins[5].operands[1].mem.base != T: return None # ldr xS,[xT]:读槽 | ldr xS,[xT]: read the slot
|
||||
if ins[7].mnemonic != 'str' or ins[7].operands[1].mem.base != T: return None # str xS,[xT]:写回槽——只有普通块有,条件块没有(与旧版口径相同) | str xS,[xT]: write back to the slot - only ordinary blocks have it, conditional blocks do not (same convention as the old version)
|
||||
@@ -102,9 +104,14 @@ def cond_target(w, pc):
|
||||
return None
|
||||
win_br = {}
|
||||
for a0, hi0 in winend.items():
|
||||
gate = btarget(pat, a0); pre = list(md.disasm(bytes(pat[gate:gate + 24]), gate))
|
||||
assert [x.mnemonic for x in pre] == ['stp', 'mrs', 'adrp', 'ldr', 'add', 'ldr'], f'窗口块前导不是预期形状 {a0:#x}'
|
||||
copy0 = gate + 24; lst = []
|
||||
# 前导:apple = stp; mrs; adrp; ldr; add; ldr。android 的槽块基址多一条(mrs tpidr_el0; ldr [tp,#off]),窗口引用 sp 时先 sub sp / stp / str / add U——
|
||||
# 所以按「adrp 键页; ldr; add; ldr 读槽」这一串定位,副本紧跟其后
|
||||
# Prologue: apple = stp; mrs; adrp; ldr; add; ldr. android's slot base takes one more instruction (mrs tpidr_el0; ldr [tp,#off]), and a window that references sp first does sub sp / stp / str / add U --
|
||||
# so locate by the "adrp key page; ldr; add; ldr slot read" run; the copy follows right after it
|
||||
gate = btarget(pat, a0); pre = list(md.disasm(bytes(pat[gate:gate + 48]), gate)); mn = [x.mnemonic for x in pre]
|
||||
k = next((i for i in range(len(mn) - 3) if mn[i:i + 4] == ['adrp', 'ldr', 'add', 'ldr'] and pre[i].operands[1].imm == KEY_PAGE_OFF), None)
|
||||
assert mn[0] in ('stp', 'sub') and k is not None and k <= 6, f'窗口块前导不是预期形状 {a0:#x}'
|
||||
copy0 = pre[k + 3].address + 4; lst = []
|
||||
for c in range(a0, hi0, 4):
|
||||
wo = struct.unpack_from('<I', orig, c)[0]; to = cond_target(wo, c)
|
||||
if to is None: continue
|
||||
@@ -170,6 +177,9 @@ def run(u, st, start, patched, init):
|
||||
u.reg_write(UC_ARM64_REG_SP, SP0); u.reg_write(UC_ARM64_REG_NZCV, init['nzcv'])
|
||||
u.reg_write(UC_ARM64_REG_TPIDR_EL0, init['tls'])
|
||||
if not patched: u.reg_write(UC_ARM64_REG_TPIDRRO_EL0, init['tlr'])
|
||||
if patched and hdr['ABI'] != 'apple': # 改写映像不读 tpidrro;真 tpidr_el0 是宿主线程指针 | The rewritten image does not read tpidrro; the real tpidr_el0 is the host thread pointer
|
||||
u.reg_write(UC_ARM64_REG_TPIDRRO_EL0, 0)
|
||||
u.reg_write(UC_ARM64_REG_TPIDR_EL0, TPA); u.mem_write(TPA + hdr['TP_SLOT_OFF'], struct.pack('<Q', TSD))
|
||||
if patched:
|
||||
for key, idx in KEY_IDX.items():
|
||||
u.mem_write(IB + KEY_PAGE_OFF + 8 * idx, struct.pack('<Q', KEY_SLOT[key] * 8))
|
||||
|
||||
Reference in New Issue
Block a user