Пример #1
0
    def CreateAllocationMap(self, start, length):
        address_map = core.AddressMap()
        allocation = self.allocations.get_range(start)
        if allocation:
            address_map.AddRange(start, start + 16, "_HEAP_ENTRY")

        count = length / 8
        for pointer in self.profile.Array(offset=start,
                                          count=count,
                                          target="Pointer"):
            name = None
            allocation = self.allocations.get_range(pointer.v())
            if allocation:
                alloc_start, alloc_length = allocation

                # First check if the pointer points inside this allocation.
                if alloc_start == start + 16:
                    name = "+%#x(%#x)" % (pointer.v() - start, pointer.v())
                else:
                    name = "%#x(%s@%#x)" % (pointer.v(), alloc_length,
                                            alloc_start)

            else:
                # Maybe it is a resolvable address.
                name = self.session.address_resolver.format_address(
                    pointer.v(), max_distance=1024 * 1024)

            if name:
                address_map.AddRange(pointer.obj_offset,
                                     pointer.obj_offset + 8, "%s" % name)

        return address_map
Пример #2
0
    def CreateAllocationMap(self, start, length, alloc_start, alloc_type):
        address_map = core.AddressMap()
        # For backend allocs we highlight the heap entry before them.
        if alloc_type == "B":
            address_map.AddRange(alloc_start - 16, alloc_start, "_HEAP_ENTRY")

        # Try to interpret pointers to other allocations and highlight them.
        count = length / 8
        for pointer in self.profile.Array(offset=start,
                                          count=count,
                                          target="Pointer"):
            name = None
            alloc_start, alloc_length, alloc_type = (
                self.allocations.get_containing_range(pointer.v()))

            if alloc_type is not None:
                # First check if the pointer points inside this allocation.
                if alloc_start == start + 16:
                    name = "+%#x(%#x)" % (pointer.v() - start, pointer.v())
                else:
                    name = "%#x(%s@%#x)" % (pointer.v(), alloc_length,
                                            alloc_start)

            else:
                # Maybe it is a resolvable address.
                name = ",".join(
                    self.session.address_resolver.format_address(
                        pointer.v(), max_distance=1024 * 1024))

            if name:
                address_map.AddRange(
                    pointer.obj_offset,
                    pointer.obj_offset + 8,
                    # Color it using a unique color related to the address. This
                    # helps to visually relate the same address across different
                    # dumps.
                    "%s" % name,
                    color_index=pointer.obj_offset)

        return address_map