From ba2df16277d7d4deae118ed11e1e92cd478045ec Mon Sep 17 00:00:00 2001 From: Florent Monjalet Date: Mon, 30 Nov 2015 16:00:26 +0100 Subject: MemStruct/Types: Renamed analysis.mem to core.types --- example/jitter/types.py | 234 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 example/jitter/types.py (limited to 'example/jitter/types.py') diff --git a/example/jitter/types.py b/example/jitter/types.py new file mode 100644 index 00000000..6d8543b4 --- /dev/null +++ b/example/jitter/types.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python +"""This script is just a short example of common usages for miasm2.core.types. +For a more complete view of what is possible, tests/core/types.py covers +most of the module possibilities, and the module doc gives useful information +as well. +""" + +from miasm2.analysis.machine import Machine +from miasm2.core.types import MemStruct, Self, Void, Str, Array, 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 MemType subclasses (like 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 "