#!/home/geodd/.local/opt/rea-python/bin/python """Run original proprietary timer init; intercept only OS/MMIO/diagnostic leaves.""" import argparse,hashlib,itertools,json,struct,warnings from pathlib import Path warnings.filterwarnings('ignore',category=UserWarning,module='unicorn') from elftools.elf.elffile import ELFFile from unicorn import Uc,UC_ARCH_X86,UC_MODE_64,UC_HOOK_CODE from unicorn.x86_const import * parser=argparse.ArgumentParser();parser.add_argument('--check',action='store_true');options=parser.parse_args() R=Path(__file__).resolve().parents[1] P=Path('/home/geodd/nvidia-driver/analysis-580.178.04/extracted/kernel/nvidia/nv-kernel.o_binary') SHA='5269a23ffba19a17fe16f076463e7ad4151254659441d1711bee6c6221ff6f4b' assert hashlib.sha256(P.read_bytes()).hexdigest()==SHA TEXT,DATA,STACK,STOP,RODATA=0x10000000,0x30000000,0x40000000,0x50000000,0x60000000 names=['_nv059663rm','_nv059661rm','_nv049684rm'];undefined={};bindings=[] with P.open('rb') as stream: e=ELFFile(stream);symbols=list(e.get_section_by_name('.symtab').iter_symbols());syms={s.name:s for s in symbols} for n in names+['_nv006696rm','_nv059665rm','_nv003164rm']: assert len([s for s in symbols if s.name==n])==1,('ambiguous symbol',n) text=bytearray(e.get_section_by_name('.text').data());tx=e.get_section_index('.text');rd=e.get_section_index('.rodata') spans=[(syms[n]['st_value'],syms[n]['st_size']) for n in names] # Prove static table identity from the real constructor's relocation, not # the unrelated per-instance HAL slot offsets or the public GSP vtable. rorels={r['r_offset']:r for r in e.get_section_by_name('.rela.rodata').iter_relocations()} ctor=syms['_nv006696rm'];tables=[] for rel in e.get_section_by_name('.rela.text').iter_relocations(): off=rel['r_offset'];symbol=symbols[rel['r_info_sym']] if ctor['st_value']<=off