# 新规则产物独立登记核验;不执行游戏、不信任改写器自己的摘要。 # Independent registration check of the new rule's build output; does not execute the game and does not trust the rewriter's own digest. import sys,struct,hashlib from pathlib import Path D=Path(sys.argv[1]); b=(D/'main.patched.bin').read_bytes(); orig=Path(sys.argv[2]).read_bytes() headers={};blocks=[] try: for line in (D/'main.rules.tsv').read_text().splitlines(): if line.startswith('# '):k,v=line[2:].split('\t',1);headers[k]=v else:blocks.append(line.split('\t')) assert headers['RULESET']=='touch-run-v4' assert headers['BUILD_ID']=='db0507f36b84200ac05f75d76ed5026f' assert headers['ORIGINAL_SHA256']==hashlib.sha256(orig).hexdigest()=='6843ab6909f96e1558b4b73b0fa807f3873409120cf3e1ef8a86dbebb275ee27' assert headers['IMAGE_SHA256']==hashlib.sha256(b).hexdigest() expected={0x2c620c:0x52800029,0x2c6210:0xb90e5109,0x369a90:None,0x369980:0xd503201f,0x2b2c74:0xd503201f,0x2b2dc0:0xd503201f,0x2b30fc:0x52800021,0x2b3104:0x52800021,0x6dc2c4:0x52800062,0x6dce90:0xd503201f,0x6dcec0:None,0x6c6648:None,0x6c6290:None,0x4ac368:None,0x6c6580:None} cuts={} for line in (D/'main.cuts.tsv').read_text().splitlines(): if line.startswith('#'):continue off,old,new,scope,why=line.split('\t',4) if why.startswith('touch-run-v4:'):cuts[int(off,16)]=(old,new,scope) assert set(cuts)==set(expected),('剪口集合',set(cuts)^set(expected)) def w(at):return struct.unpack_from('