Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature MemStruct #284
This PR introduces an API to easily interact with C structures in miasm's sandbox.
class ListNode(MemStruct): fields = [ # The "<I" is the struct-like format of the pointer in memory, in this # case a Little Endian 32 bits unsigned int # One way to handle reference to ListNode in ListNode is to use the # special marker MemSelf. # You could also set or modify ListNode.fields after the class # declaration and call ListNode.gen_fields() ("next", Ptr("<I", MemSelf)), # Ptr(_, MemVoid) is analogous to void*, MemVoid is just an empty # MemStruct type ("data", Ptr("<I", MemVoid)), ] class LinkedList(MemStruct): fields = [ ("head", Ptr("<I", ListNode)), ("tail", Ptr("<I", ListNode)), # Num can take any one-field struct-like format, including floats and # doubles ("size", Num("<I")), ] # [...] link = LinkedList(jitter.vm, some_addr) link.deref_head.data = other_addr link.size += 1 # etc
Lots of FIXME/TODO are left there for now and lots of choices can be discussed, please tell me what you think!