Crusader_Decomp/tmp_compare_regret_debugger_export.py

72 lines
2.3 KiB
Python
Raw Normal View History

2026-04-10 18:14:55 +02:00
from pathlib import Path
exported = Path(r'F:\Apps\Crusader No Regret\REGRET.EXE')
hand = Path(r'F:\Apps\Crusader No Regret\REGRET-DEBUGGER.EXE')
original = Path(r'F:\Apps\Crusader No Regret\REGRET - Copy.EXE')
files = {
'exported': exported.read_bytes(),
'hand': hand.read_bytes(),
'original': original.read_bytes(),
}
for name, data in files.items():
print(f'{name}: size={len(data)}')
print('')
pairs = [('exported', 'hand'), ('exported', 'original'), ('hand', 'original')]
for left, right in pairs:
a = files[left]
b = files[right]
diff_offsets = [index for index, (ba, bb) in enumerate(zip(a, b)) if ba != bb]
if len(a) != len(b):
print(f'{left} vs {right}: different sizes')
print(f'{left} vs {right}: differing byte positions={len(diff_offsets)}')
if diff_offsets:
preview = diff_offsets[:20]
print(f' first offsets: {preview}')
print('')
patterns = {
'call_bootstrap': bytes.fromhex('9a00009813'),
'call_open_modal': bytes.fromhex('9a0d029813'),
'call_old_dialog': bytes.fromhex('9a46005013'),
}
for name, data in files.items():
print(f'Pattern scan in {name}:')
for pattern_name, pattern in patterns.items():
hits = []
start = 0
while True:
offset = data.find(pattern, start)
if offset == -1:
break
hits.append(offset)
start = offset + 1
print(f' {pattern_name}: {len(hits)} hits; first 20={hits[:20]}')
print('')
active_branch_context_original = bytes.fromhex(
'6aff6affc41e985c268a4705501e68d5306a006a0083ec06c746e800008b46e8f7d08946eac646ec006a006a009a4600501383c414'
)
active_branch_context_patched = bytes.fromhex(
'6aff6affc41e985c268a4705501e68d5306a006a0083ec06c746e800008b46e8f7d08946eac646ec006a006a009a0d02981383c414'
)
for name, data in files.items():
orig_hit = data.find(active_branch_context_original)
patch_hit = data.find(active_branch_context_patched)
print(f'{name}: active-branch old-context offset={orig_hit}, patched-context offset={patch_hit}')
print('')
diff_offsets = [506633, 506649, 506665]
for offset in diff_offsets:
print(f'Context around offset {offset}:')
start = max(0, offset - 6)
end = offset + 10
for name, data in files.items():
print(f' {name}: {data[start:end].hex()}')
print('')