From e53ac5b2a65f79d6342b1820c68efc126c8e4986 Mon Sep 17 00:00:00 2001 From: Florent Monjalet Date: Sun, 8 Nov 2015 21:27:40 +0100 Subject: MemStruct: minor fixes + toy example script --- example/jitter/memstruct.py | 229 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 example/jitter/memstruct.py (limited to 'example') diff --git a/example/jitter/memstruct.py b/example/jitter/memstruct.py new file mode 100644 index 00000000..f2e9f8dc --- /dev/null +++ b/example/jitter/memstruct.py @@ -0,0 +1,229 @@ +#!/usr/bin/env python +"""This script is just a short example of common usages for miasm2.analysis.mem. +For a more complete view of what is possible, tests/analysis/mem.py covers +most of the module possibilities, and the module doc gives useful information +as well. +""" + +from miasm2.analysis.machine import Machine +from miasm2.analysis.mem import MemStruct, MemSelf, MemVoid, MemStr,\ + Ptr, Num, Array, set_allocator +from miasm2.os_dep.common import heap + +# Instanciate a heap +my_heap = heap() +# And set it as the default memory allocator, to avoid manual allocation and +# explicit address passing to the MemStruct constructor +set_allocator(my_heap.vm_alloc) + +# Let's reimplement a simple C generic linked list mapped on a VmMngr! + +# All the structures and methods will use the python objects but all the data +# is in fact stored in the VmMngr + +class ListNode(MemStruct): + fields = [ + # The "