Files
nxnative-easy/dm/host/tests/server42_rule.py
T
seedds c5955d42a6 English only: no Chinese left in code, scripts, logs, tables or docs
- Log messages, script output, test labels, Makefile errors and comments are English. Red log lines start with "[RED] " (was 【红】).
- Shader map stage column: vertex / pixel / compute / geometry / hull / domain (generators, dmsh_build / dmsh_facts and nvn_mtl.m stage_of follow).
- The NSP script's regexes match the new shader_split.py / dmsh_build.py summary lines; patch_nso cut scopes are all / host-only.
- Host UI text table (dm_i18n_tab.h) is English only; dm_lang_zh() removed.
- Text that matches game data (t_swkbd.c, t_textbox.c) is written as \x escapes.
- Shader chain: the chain files lose their bilingual comments, so every profile has a new chain version. dmsh_xlate.dll rebuilt from the translated Program.cs (SPIR-V byte-identical on 4,500 shaders of Wonder, TOTK and Age of Calamity), lock and dmsh_chain.h headers regenerated. c1_full.tsv restamped for Dread, 13 Sentinels and Wonder; the other profiles follow when their rebuild finishes.
- AGENTS.md and docs/agents: the language rule now covers logs; quoted log lines updated.
2026-10-19 15:34:57 +08:00

29 lines
2.9 KiB
Python

# disabled_bit_guard only tests in-place eligibility; a hand-made local memory fixture, which does not prove the legitimate source of the control lock of a living player.
# Executes the input validity checks and dispatch of the original full 42 handler; the decoder/downstream movement/fatal log are explicit peripheral stand-ins.
import sys,struct
from pathlib import Path
from unicorn import *
from unicorn.arm64_const import *
b=Path(sys.argv[1]).read_bytes();u=Uc(UC_ARCH_ARM64,UC_MODE_ARM);u.mem_map(0,0x4000000);u.mem_write(0,b);u.mem_map(0x7000000,0x20000)
G,U,D,C,P,PK,STOP=0x7001000,0x7002000,0x7003000,0x7004000,0x7005000,0x7006000,0x701f000
ctx={}
def hook(u,a,n,d):
if a==STOP:ctx['returned']=True;u.emu_stop();return
if a==0x4cd5f0:
v=u.reg_read(UC_ARM64_REG_W0);u.mem_write(u.reg_read(UC_ARM64_REG_X1),struct.pack('<ff',1,0));u.mem_write(u.reg_read(UC_ARM64_REG_X2),struct.pack('<f',1));u.mem_write(u.reg_read(UC_ARM64_REG_X3),bytes([v>>15]));u.reg_write(UC_ARM64_REG_PC,u.reg_read(UC_ARM64_REG_LR))
elif a==0x6cd670:ctx['move']=u.reg_read(UC_ARM64_REG_W2);u.reg_write(UC_ARM64_REG_W0,0);u.reg_write(UC_ARM64_REG_PC,u.reg_read(UC_ARM64_REG_LR))
elif a==0xde1850:ctx['fatal']=True;u.emu_stop()
u.hook_add(UC_HOOK_CODE,hook);bad=0;n=0
for bit in [0,1]:
for case in ['valid','badlen','dead0','dead17','disabled_bit_guard','far','nonplayer']:
ctx.clear();u.mem_write(G,b'\0'*0x1000);u.mem_write(U,b'\0'*0x400);u.mem_write(D,b'\0'*0x200);u.mem_write(C,b'\0'*0x1000);u.mem_write(P,b'\0'*0x300)
u.mem_write(U,struct.pack('<I',int(case=='nonplayer')));u.mem_write(U+12,struct.pack('<I',0 if case=='dead0'else 17 if case=='dead17'else 1));u.mem_write(U+0x10,struct.pack('<Q',D));u.mem_write(D+0xf0,struct.pack('<Q',C));u.mem_write(U+0x38,struct.pack('<Q',P));u.mem_write(P+2,struct.pack('<H',5826));u.mem_write(P+6,struct.pack('<H',4520));u.mem_write(U+0x126,bytes([int(case=='disabled_bit_guard')]));u.mem_write(G+0x170,struct.pack('<I',421));u.mem_write(PK,struct.pack('<BHHH',0x42,512|(31<<10)|(bit<<15),5926 if case=='far'else 5826,4520))
for r,v in [(UC_ARM64_REG_X0,G),(UC_ARM64_REG_X1,U),(UC_ARM64_REG_X2,PK),(UC_ARM64_REG_X3,6 if case=='badlen'else 7),(UC_ARM64_REG_SP,0x701fff0),(UC_ARM64_REG_LR,STOP)]:u.reg_write(r,v)
u.emu_start(0x6dc270,STOP+4,count=5000)
wantmove=3 if case=='valid'else None;wantstatus=3 if case=='badlen'else 1 if case in ['dead0','dead17','disabled_bit_guard','far']else 0
ok=(ctx.get('fatal',False) or ctx.get('returned',False)) and ctx.get('move')==wantmove and (ctx.get('fatal',False)==(case=='nonplayer')) and (case=='nonplayer'or u.reg_read(UC_ARM64_REG_W0)==wantstatus)
n+=1
if not ok:bad+=1;print('FAIL',bit,case,'expected move',wantmove,'→ got',ctx,'status',u.reg_read(UC_ARM64_REG_W0))
print(f'SERVER42_RULE {n} cases, {bad} failed; real RET to STOP / original fatal-halt criterion; bit0/1 legal requests Run3, length / death / disable bit / coordinates / non-player original checks; real downstream speed not included')
sys.exit(bool(bad))