Ejemplo n.º 1
0
    def switch_inverted(self, address):
        if self.__id == -1:
            self.__id = idc.CreateArray(self.__name)
            idc.SetArrayString(self.__id, 0, str(address))
        else:
            inverted = self.get_inverted()
            try:
                inverted.remove(address)
                if not inverted:
                    idc.DeleteArray(self.__id)

            except KeyError:
                inverted.add(address)

            idc.SetArrayString(self.__id, 0, " ".join(map(str, inverted)))
Ejemplo n.º 2
0
def invert(func_ea, if_ea):
    # Store information about swaps (affected through actions)
    iv_rva = if_ea - idaapi.get_imagebase()
    func_rva = func_ea - idaapi.get_imagebase()
    internal_name = _ARRAY_STORAGE_PREFIX + hex(int(func_rva))
    internal_id = idc.GetArrayId(internal_name)
    if internal_id == -1:
        internal_id = idc.CreateArray(internal_name)
        idc.SetArrayString(internal_id, 0, str(iv_rva))
    else:
        inverted = get_inverted(func_ea)
        try:
            inverted.remove(iv_rva)
            if not inverted:
                idc.DeleteArray(internal_id)

        except KeyError:
            inverted.add(iv_rva)

        idc.SetArrayString(internal_id, 0, " ".join(list(map(str, inverted))))