#!/home/geodd/.local/opt/rea-python/bin/python """Original complete020153 instructions; inspect actual native constructor calls. Private Unicorn memory only. External queries/diagnostics/MMIO are recorders. """ from pathlib import Path import argparse,hashlib,json,struct,warnings 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 * p=argparse.ArgumentParser();p.add_argument('--check',action='store_true');p.add_argument('--dump-private-images');options=p.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') TEXT=0x10000000;RO=0x18000000;DATA=0x24000000;STACK=0x40000000;STUB=0x50000000;STOP=0x60000000 names=['_nv020153rm','_nv020711rm','_nv020712rm','_nv020418rm','_nv045098rm'] with P.open('rb') as f: e=ELFFile(f);symbols=list(e.get_section_by_name('.symtab').iter_symbols());defined={s.name:s for s in symbols};text=bytearray(e.get_section_by_name('.text').data());rodata=bytearray(e.get_section_by_name('.rodata').data());functions={n:(defined[n]['st_value'],defined[n]['st_size']) for n in names};maps={e.get_section_index('.text'):TEXT,e.get_section_index('.rodata'):RO,e.get_section_index('.data'):0x21000000,e.get_section_index('.bss'):0x22000000};undefined={};hooks={} for name in ['_nv044886rm','_nv053907rm','_nv020158rm','_nv047869rm','_nv046745rm']: hooks[TEXT+defined[name]['st_value']]=name for section,buffer,base in [('.rela.text',text,TEXT),('.rela.rodata',rodata,RO)]: for rel in e.get_section_by_name(section).iter_relocations(): off=rel['r_offset'] if section=='.rela.text' and not any(start<=off