Skip to content

Instantly share code, notes, and snippets.

def spoils(f):
"""return the list of spoiled registers
default is r0-r3
not too smart, but safe - i.e. if list of spoiled registers is smaller than 4 - it's quite safe to assume only these registers are spoiled
the opposite is false
"""
spoiled = ['R0', 'R1', 'R2', 'R3']
if any(f.xrefs_from):
return spoiled
@yannayl
yannayl / populate_ram.py
Last active January 20, 2019 07:23
Populates the RAM and adds references according to a memory dump
import sark
import construct as ct
import ida_xref
## I have dumped the memory content to ram.bin
dump = open("ram.bin", "rb").read()
ram = sark.Segment(name='RAM')
## memoizing can make it more efficient but IDC
def in_segs(ea, segs):
def db(word_size, alphabet_size):
L1 = alphabet_size**(word_size-1)
lookup_table = {}
i = 0
for _ in range(L1*alphabet_size):
if i not in lookup_table:
lookup_table[i] = alphabet_size - 1
s = lookup_table[i]
yield alphabet_size - s - 1