Exemplo n.º 1
0
 def at(cls, index):
     '''Return the string at the specified `index`.'''
     string = idaapi.string_info_t()
     res = idaapi.get_strlist_item(index, string)
     if not res:
         raise internal.exceptions.DisassemblerError("{:s}.at({:d}) : The call to idaapi.get_strlist_item({:d}) returned {!r}.".format('.'.join((__name__, cls.__name__)), index, index, res))
     return string
Exemplo n.º 2
0
 def __getitem__(self, index):
     """Returns string items"""
     if index >= self.size:
         raise StopIteration
     if idaapi.get_strlist_item(index, self._si):
         return Strings.StringItem(self._si)
     return None
Exemplo n.º 3
0
 def at(cls, index):
     string = idaapi.string_info_t()
     res = idaapi.get_strlist_item(index, string)
     if not res:
         raise RuntimeError, "idaapi.get_strlist_item({:d}) -> {!r}".format(
             index, res)
     return string
Exemplo n.º 4
0
    def at(cls, index):
        '''Return the string at the specified `index`.'''
        si = idaapi.string_info_t()

        # FIXME: this isn't being used correctly
        ok = idaapi.get_strlist_item(si, index)
        if not ok:
            raise internal.exceptions.DisassemblerError(u"{:s}.at({:d}) : The call to `idaapi.get_strlist_item({:d})` returned {!r}.".format('.'.join((__name__, cls.__name__)), index, index, res))
        return si
def findMetadataCacheInitialize():
    def checkTarget(func):
        #check write to global values' count.
        hitcount = 0
        for xref in func.xrefs_from:
            segment = idaapi.getseg(xref.to)
            if idaapi.get_visible_segm_name(segment) == '.bss' and repr(
                    xref.type) == "Data_Write":
                hitcount += 1
        if hitcount >= 8 and hitcount < 12:
            return 1
        return 0

    # find addr of "global-metadata.dat"
    global_metadata = None
    s = idaapi.string_info_t()
    for i in range(0, idaapi.get_strlist_qty()):
        idaapi.get_strlist_item(s, i)
        if idaapi.get_ascii_contents(s.ea, s.length,
                                     s.type) == "global-metadata.dat":
            global_metadata = s.ea
            break

    # xref of "global-metadata.dat"
    for xref in sark.Line(global_metadata).xrefs_to:
        if sark.Function.is_function(xref.frm):
            target_func = sark.Function(xref.frm)
            if checkTarget(target_func):
                # print "find MetadataCache::Initialize at", hex(int(target_func.startEA))
                idc.set_name(target_func.startEA, "MetadataCache_Initialize",
                             SN_NOWARN | SN_NOCHECK)
                return
            else:
                for txref in target_func.xrefs_to:
                    if sark.Function.is_function(txref.frm):
                        caller = sark.Function(txref.frm)
                        if checkTarget(caller):
                            # print "find MetadataCache::Initialize at", hex(int(caller.startEA))
                            idc.set_name(caller.startEA,
                                         "MetadataCache_Initialize",
                                         SN_NOWARN | SN_NOCHECK)
                            return
    print "can't find MetadataCache_Initialize"
Exemplo n.º 6
0
    def at(cls, index):
        '''Return the string at the specified `index`.'''
        si = idaapi.string_info_t()

        # FIXME: this isn't being used correctly
        ok = idaapi.get_strlist_item(si, index)
        if not ok:
            raise internal.exceptions.DisassemblerError(
                u"{:s}.at({:d}) : The call to `idaapi.get_strlist_item({:d})` returned {!r}."
                .format('.'.join((__name__, cls.__name__)), index, index, res))
        return si
Exemplo n.º 7
0
 def _get_item(self, index):
     if not idaapi.get_strlist_item(index, self._si):
         return None
     else:
         return Strings.StringItem(self._si)
Exemplo n.º 8
0
 def _get_item(self, index):
     if not idaapi.get_strlist_item(index, self._si):
         return None
     else:
         return Strings.StringItem(self._si)