# Path: haystack/abc/interfaces.py
# class IMemoryMapping(object):
# class IMemoryLoader(object):
# class IMemoryHandler(object):
# class IMemoryCache(object):
# class ITargetPlatform(object):
# class IHeapFinder(object):
# class IHeapWalker(object):
# class ICTypesUtils(object):
# class IConstraintsConfigHandler(object):
# class IModuleConstraints(object):
# class IRecordConstraints(object):
# class IConstraint(object):
# class IRecordConstraintsValidator(object):
# class IRecordTypeDynamicConstraintsValidator(object):
#     def _vtop(self, vaddr):
#     def _ptov(self, paddr):
#     def read_array(self, address, basetype, count):
#     def read_bytes(self, address, size):
#     def read_cstring(self, address, max_size, chunk_length=256):
#     def read_struct(self, address, struct):
#     def read_word(self, address):
#     def search(self, bytestr):
#     def __contains__(self, address):
#     def __len__(self):
#     def make_memory_handler(self):
#     def get_name(self):
#     def get_target_platform(self):
#     def get_heap_finder(self):
#     def get_model(self):
#     def get_mappings(self):
#     def reset_mappings(self):
#     def get_reverse_context(self):
#     def get_mapping_for_address(self, vaddr):
#     def iter_mapping_with_name(self, pathname):
#     def is_valid_address(self, obj, struct_type=None):
#     def is_valid_address_value(self, addr, struct_type=None):
#     def __contains__(self, vaddr):
#     def __len__(self):
#     def __getitem__(self, i):
#     def __setitem__(self, i, val):
#     def __iter__(self):
#     def reset(self):
#     def getRefs(self):
#     def printRefs(self):
#     def printRefsLite(self):
#     def hasRef(self, typ, orig_addr):
#     def getRef(self, typ, orig_addr):
#     def getRefByAddr(self, addr):
#     def keepRef(self, obj, typ=None, orig_addr=None):
#     def delRef(self, typ, orig_addr):
#     def get_word_type(self):
#     def get_word_type_char(self):
#     def get_word_size(self):
#     def get_target_ctypes(self):
#     def get_target_ctypes_utils(self):
#     def get_os_name(self):
#     def get_cpu_bits(self):
#     def list_heap_walkers(self):
#     def get_heap_module(self):
#     def get_heap_walker(self, heap):
#     def get_target_platform(self):
#     def get_heap_address(self):
#     def get_user_allocations(self):
#     def get_free_chunks(self):
#     def formatAddress(self, addr):
#     def unpackWord(self, bytes, endianess):
#     def is_address_local(self, obj, structType):
#     def get_pointee_address(self, obj):
#     def container_of(self, memberaddr, typ, membername):
#     def offsetof(self, typ, membername):
#     def ctypes_to_python_array(self, array):
#     def array2bytes(self, array):
#     def bytes2array(self, bytes, typ):
#     def pointer2bytes(self, attr, nbElement):
#     def get_subtype(self, cls):
#     def read(self, filename):
#     def get_constraints(self):
#     def set_constraints(self, record_type_name, record_constraints):
#     def get_dynamic_constraints(self):
#     def set_dynamic_constraints(self, record_type_name, record_constraints):
#     def get_fields(self):
#     def get_constraints_for_field(self, field_name):
#     def __contains__(self, obj):
#     def is_valid(self, record):
#     def load_members(self, record, max_depth):
#     def get_record_type_name(self):
#     def is_valid(self, record):


import logging
import pkg_resources
from haystack.abc import interfaces
        from haystack.allocators.libc import libcheapwalker
        from haystack.allocators.win32 import winxpheapwalker
        from haystack.allocators.win32 import win7heapwalker
# -*- coding: utf-8 -*-



log = logging.getLogger('heapwalker')

SUPPORTED_ALLOCATORS = {}


def _discover_supported_allocators():
    # TODO use it in memory dump discovery. Maybe add platform selectors to Finder interface
    for entry_point in pkg_resources.iter_entry_points("haystack.heap_finder"):
        SUPPORTED_ALLOCATORS[entry_point.name] = entry_point.resolve()


class HeapWalker(interfaces.IHeapWalker):

    def __init__(self, memory_handler, target_platform, heap_module, heap_mapping, heap_module_constraints, address):
        if not isinstance(memory_handler, interfaces.IMemoryHandler):
            raise TypeError("Feed me a IMemoryHandler")

# Path: haystack/abc/interfaces.py
# class IMemoryMapping(object):
# class IMemoryLoader(object):
# class IMemoryHandler(object):
# class IMemoryCache(object):
# class ITargetPlatform(object):
# class IHeapFinder(object):
# class IHeapWalker(object):
# class ICTypesUtils(object):
# class IConstraintsConfigHandler(object):
# class IModuleConstraints(object):
# class IRecordConstraints(object):
# class IConstraint(object):
# class IRecordConstraintsValidator(object):
# class IRecordTypeDynamicConstraintsValidator(object):
#     def _vtop(self, vaddr):
#     def _ptov(self, paddr):
#     def read_array(self, address, basetype, count):
#     def read_bytes(self, address, size):
#     def read_cstring(self, address, max_size, chunk_length=256):
#     def read_struct(self, address, struct):
#     def read_word(self, address):
#     def search(self, bytestr):
#     def __contains__(self, address):
#     def __len__(self):
#     def make_memory_handler(self):
#     def get_name(self):
#     def get_target_platform(self):
#     def get_heap_finder(self):
#     def get_model(self):
#     def get_mappings(self):
#     def reset_mappings(self):
#     def get_reverse_context(self):
#     def get_mapping_for_address(self, vaddr):
#     def iter_mapping_with_name(self, pathname):
#     def is_valid_address(self, obj, struct_type=None):
#     def is_valid_address_value(self, addr, struct_type=None):
#     def __contains__(self, vaddr):
#     def __len__(self):
#     def __getitem__(self, i):
#     def __setitem__(self, i, val):
#     def __iter__(self):
#     def reset(self):
#     def getRefs(self):
#     def printRefs(self):
#     def printRefsLite(self):
#     def hasRef(self, typ, orig_addr):
#     def getRef(self, typ, orig_addr):
#     def getRefByAddr(self, addr):
#     def keepRef(self, obj, typ=None, orig_addr=None):
#     def delRef(self, typ, orig_addr):
#     def get_word_type(self):
#     def get_word_type_char(self):
#     def get_word_size(self):
#     def get_target_ctypes(self):
#     def get_target_ctypes_utils(self):
#     def get_os_name(self):
#     def get_cpu_bits(self):
#     def list_heap_walkers(self):
#     def get_heap_module(self):
#     def get_heap_walker(self, heap):
#     def get_target_platform(self):
#     def get_heap_address(self):
#     def get_user_allocations(self):
#     def get_free_chunks(self):
#     def formatAddress(self, addr):
#     def unpackWord(self, bytes, endianess):
#     def is_address_local(self, obj, structType):
#     def get_pointee_address(self, obj):
#     def container_of(self, memberaddr, typ, membername):
#     def offsetof(self, typ, membername):
#     def ctypes_to_python_array(self, array):
#     def array2bytes(self, array):
#     def bytes2array(self, bytes, typ):
#     def pointer2bytes(self, attr, nbElement):
#     def get_subtype(self, cls):
#     def read(self, filename):
#     def get_constraints(self):
#     def set_constraints(self, record_type_name, record_constraints):
#     def get_dynamic_constraints(self):
#     def set_dynamic_constraints(self, record_type_name, record_constraints):
#     def get_fields(self):
#     def get_constraints_for_field(self, field_name):
#     def __contains__(self, obj):
#     def is_valid(self, record):
#     def load_members(self, record, max_depth):
#     def get_record_type_name(self):
#     def is_valid(self, record):


# Path: haystack/allocators/heapwalker.py
import logging
import pkg_resources
from haystack.abc import interfaces
        from haystack.allocators.libc import libcheapwalker
        from haystack.allocators.win32 import winxpheapwalker
        from haystack.allocators.win32 import win7heapwalker

# -*- coding: utf-8 -*-



log = logging.getLogger('heapwalker')

SUPPORTED_ALLOCATORS = {}


def _discover_supported_allocators():
    # TODO use it in memory dump discovery. Maybe add platform selectors to Finder interface
    for entry_point in pkg_resources.iter_entry_points("haystack.heap_finder"):
        SUPPORTED_ALLOCATORS[entry_point.name] = entry_point.resolve()


class HeapWalker(interfaces.IHeapWalker):

    def __init__(self, memory_handler, target_platform, heap_module, heap_mapping, heap_module_constraints, address):
        if not isinstance(memory_handler, interfaces.IMemoryHandler):
            raise TypeError("Feed me a IMemoryHandler")

        if not isinstance(target_platform, interfaces.ITargetPlatform):