示例#1
0
 def typedobj(typestr, ea=None):
     """
     Parses a type string and returns an appcall object.
     One can then use retrieve() member method
     @param ea: Optional parameter that later can be used to retrieve the type
     @return: Appcall object or raises ValueError exception
     """
     # parse the type
     result = _idaapi.idc_parse_decl(_idaapi.cvar.idati, typestr, 1 | 2 | 4) # PT_SIL | PT_NDC | PT_TYP
     if result is None:
         raise ValueError, "Could not parse type: " + typestr
     # Return the callable method with type info
     return Appcall_callable__(ea, result[1], result[2])
示例#2
0
    def proto(name_or_ea, prototype, flags = None):
        """
        Allows you to instantiate an appcall (callable object) with the desired prototype
        @param name_or_ea: The name of the function (will be resolved with LocByName())
        @param prototype:
        @return:
            - On failure it raises an exception if the prototype could not be parsed
              or the address is not resolvable
            - Returns a callbable Appcall instance with the given prototypes and flags
        """

        # resolve and raise exception on error
        ea = Appcall__.__name_or_ea(name_or_ea)
        # parse the type
        if flags is None:
            flags = 1 | 2 | 4 # PT_SIL | PT_NDC | PT_TYP

        result = _idaapi.idc_parse_decl(_idaapi.cvar.idati, prototype, flags)
        if result is None:
            raise ValueError, "Could not parse type: " + prototype

        # Return the callable method with type info
        return Appcall_callable__(ea, result[1], result[2])