#!/usr/bin/env python3 """Recover qagame authentication announcement tables and bounded recipient paths.""" import json import gzip from pathlib import Path import re import struct from analyze_auth_drop import ascii_literal from analyze_deferred_auth import partition_function, trace_slice from analyze_engine_control import control_flow from analyze_native_dispatch import recover from analyze_qvm import decode, write_json from analyze_vm_extensions import native_functions, verified def recover_table(data, header, instructions, base, lower, upper, entry, end): start = base + lower*4 size = (upper-lower+1)*4 if lower > upper or start < 0 or start+size > header['data_length']: raise ValueError('jump table outside initialized data') if instructions[entry]['opcode'] != 'ENTER' or not entry < end <= len(instructions): raise ValueError('invalid function interval') rows = [] for value in range(lower, upper+1): address = base+value*4 offset = header['data_offset']+address if offset+4 > len(data): raise ValueError('truncated jump table') target = struct.unpack_from('