367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
24 lines
1.4 KiB
Python
24 lines
1.4 KiB
Python
"""Read only a fixed code page at natural character-order completion entry.
|
|
The address is an investigation breakpoint, never a callable engine API.
|
|
"""
|
|
import hashlib,json,os
|
|
from pathlib import Path
|
|
ENTRY=0x142444c50
|
|
PREFIX=b''
|
|
OBSERVE_NATURAL_FIRST_USE=True
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
def capture(pid,registers):
|
|
if registers.rip!=ENTRY:return {'available':False,'reason':'wrong-observation-entry'}
|
|
page=ENTRY&~4095
|
|
rows=Path(f'/proc/{pid}/maps').read_text().splitlines()
|
|
if not any(int(r.split()[0].split('-')[0],16)<=page and page+4096<=int(r.split()[0].split('-')[1],16) and 'r' in r.split()[1] and 'x' in r.split()[1] for r in rows):return {'available':False,'reason':'code-not-naturally-readable-executable','page_protection_changed':False}
|
|
fd=os.open(f'/proc/{pid}/mem',os.O_RDONLY)
|
|
try:code=os.pread(fd,4096,page)
|
|
finally:os.close(fd)
|
|
if len(code)!=4096:raise ValueError('Fixed code page incomplete')
|
|
path=ROOT/'runtime/native-handler-code'/f'{page:x}.bin'
|
|
if path.exists() and path.read_bytes()!=code:raise ValueError('Prior code capture preserved')
|
|
if not path.exists():path.write_bytes(code);path.chmod(0o600)
|
|
return dict(kind='natural-character-order-code-only',available=True,page=hex(page),sha256=hashlib.sha256(code).hexdigest(),
|
|
parameter_buffers_read=False,authentication_buffers_read=False,engine_calls_made=False,source='actual reference completion; not a callable ABI')
|