Atelier des rouesLab FR
Objects/Documentation

entete32.py

Identifying a hidden width and offset · entete32.py

Download ↓
"""Identify width and a fixed header-padding offset using adaptive exact byte-gap queries."""
from functools import lru_cache
from itertools import product
import json

def gap(n,w,h):
    b=n.bit_length();body=1+13*((n+63)//64)+n*w+h
    return (body+2*b+6)//8-(body+7)//8-(b+6)//7

def design(states,max_n=2048):
    masks={};full=(1<<len(states))-1
    for n in range(1,max_n+1):
        values=[gap(n,*z) for z in states];a,b=min(values),max(values)
        if a==b:continue
        assert b==a+1
        mask=sum(1<<i for i,x in enumerate(values) if x==b)

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.