本文整理汇总了Python中idaapi.print_tinfo方法的典型用法代码示例。如果您正苦于以下问题:Python idaapi.print_tinfo方法的具体用法?Python idaapi.print_tinfo怎么用?Python idaapi.print_tinfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idaapi
的用法示例。
在下文中一共展示了idaapi.print_tinfo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkSupportedType
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def checkSupportedType(self, type):
"""
Check if a type name string is supported
@param type: IDA type_into_t object
@return: True if type name is supported or otherwise False
"""
try:
tname = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, type, '', '')
type_name = None
if self.typeName_norm_cb is not None:
type_name = self.typeName_norm_cb(tname)
for (stype, sparams) in self.supported_types:
if type_name == stype:
self.type_params = sparams
return True
return False
except Exception as ex:
self.logger.exception("Error while checking for supported type: %s", ex)
示例2: __get_enum_values
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def __get_enum_values(self):
try:
enum_name = idaapi.print_tinfo("", 0, 0, idaapi.PRTYPE_1LINE, self.type, "", "")
enum = sark.Enum(name=enum_name)
for member in enum.members:
if member.value == self.rawValue:
self.parsedValues.append(
ParsedValue("{}.{}".format(
enum_name, member.name), "Enum", MAX_SCORE, hex(self.rawValue), "enum"
)
)
return True
return False
except Exception as ex:
self.logger.exception("Error while retrieving enum values: %s", ex)
return False
示例3: __init__
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def __init__(self, type):
self.logger = logging.getLogger(__name__)
self.name = ""
self.size = 0
self.element_num = 0
self.is_union = False
self.elements = []
self.type_info = type
self.udt_type_data = idaapi.udt_type_data_t()
try:
if self.getStructData():
self.getElements()
except Exception as ex:
self.logger.exception("Error while extracting Struct data: %s",
idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, type, '', ''), ex)
return False
示例4: getStructData
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def getStructData(self):
"""
Extract the struct data from tinfo_t object and populate all relevant class properties.
@return: True if successful, otherwise False
"""
if self.type_info.is_udt():
if self.type_info.get_udt_details(self.udt_type_data):
self.name = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, self.type_info, '', '')
self.size = self.udt_type_data.size
self.element_num = len(self.udt_type_data)
self.is_union = self.udt_type_data.is_union
return True
return False
示例5: export
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def export(self):
if self.existed() and not self.f_update:
info('{}: The sample records are present in DB. skipped.'.format(self.sha256))
return False
self.cur.execute("REPLACE INTO sample values(?, ?)", (self.sha256, self.idb_path))
pnum = tnum = 0
records = []
for fva in idautils.Functions():
fname = get_func_name(fva)
tnum += 1
if self.exclude_libthunk(fva, fname):
continue
fhd, bsize = self.calc_fn_ssdeep(fva, fname)
fhm, cfgnum = self.calc_fn_machoc(fva, fname)
if fhd and fhm:
pnum += 1
f_ana = bool(self.ana_pat.search(fname)) if self.f_ana_exp else False
tinfo = idaapi.tinfo_t()
idaapi.get_tinfo(fva, tinfo)
ptype = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, tinfo, fname, '')
ptype = ptype + ';' if ptype is not None else ptype
# fva is 64-bit int causing OverflowError
records.append((self.sha256, '{:#x}'.format(fva), fname, fhd, fhm, f_ana, bsize, ptype))
self.debug('EXPORT {} at {:#x}: ssdeep={} (size={}), machoc={} (num of CFG={})'.format(fname, fva, fhd, bsize, fhm, cfgnum))
self.cur.executemany("REPLACE INTO function values (?, ?, ?, ?, ?, ?, ?, ?)", records)
success ('{} of {} functions exported'.format(pnum, tnum))
return True
示例6: typeName
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def typeName(self):
"""
Get the type human readable ASCII based name (in all upper case letters)
"""
if self.type is None:
return None
typeName = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, self.type, '', '')
if typeName is None or typeName == "":
return None
return typeName.upper()
示例7: type_str
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def type_str(self):
"""
A string representation of the argument type
"""
typeStr = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, self.argtype, '', '')
return typeStr
示例8: string
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def string(ti):
prefix = ''
name, indent = '', 4
cmt, cindent = '', 4
flags = idaapi.PRTYPE_DEF | idaapi.PRTYPE_MULTI
return idaapi.print_tinfo(prefix, indent, cindent, flags, ti, name, cmt)
示例9: __new__
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def __new__(cls, func, info):
'''Apply the ``idaapi.tinfo_t`` typeinfo in `info` to the function `func`.'''
_, ea = interface.addressOfRuntimeOrStatic(func)
# In order to apply the typeinfo with idaapi.apply_cdecl, we need the
# typeinfo as a string. To accomplish this, we need need the typeinfo
# with its name attached.
fname = database.name(ea)
realname = internal.declaration.unmangle_name(fname)
# Filter out invalid characters from the function name since we're going
# to use this to render the declaration next.
valid = {item for item in string.digits}
valid |= {item for item in ':'}
filtered = str().join(item if item in valid or idaapi.is_valid_typename(utils.string.to(item)) else '_' for item in realname)
# Now we have the name and its filtered, we can simply render it.
try:
tinfo_s = idaapi.print_tinfo('', 0, 0, 0, info, utils.string.to(filtered), '')
# If we caught an error, then we couldn't render the string for some reason.
except Exception:
raise E.DisassemblerError(u"{:s}({:#x}, \"{:s}\") : Unable to render `idaapi.tinfo_t()` with name (\"{!s}\") to a string.".format('.'.join((__name__, cls.__name__)), ea, utils.string.escape("{!s}".format(info), '"'), utils.string.escape(realname, '"')))
# Recurse back into ourselves in order to call idaapi.apply_cdecl
return cls(ea, tinfo_s)
示例10: ParseData
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def ParseData(self, rawData, type=None, loc=None, custom_parser=None):
"""
Parse Data
@param rawData: The raw data to be parsed
@param type: The data type (If unknown should be None)
@param loc: raw value (memory) location
@param custom_parser: A custom parser to use.
@return: A list of ParsedValue objects (containing the guessed\exact parsed values)
"""
parsedValues = []
try:
# If custom parser was defined
if custom_parser is not None:
custom_parser.run(rawData, type, match_override=True)
ret_vals = custom_parser.getParsedValues()
parsedValues.extend(ret_vals)
return parsedValues
# if type is known, try to look it up in the parser_type dict
if type is not None:
type_name = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, type, '', '')
type_name = self.typeName_norm(type_name)
if type_name in self.type_parsers:
for parser_plugin in self.type_parsers[type_name]:
parser_plugin.run(rawData, type)
ret_vals = parser_plugin.getParsedValues()
parsedValues.extend(ret_vals)
return parsedValues
# Otherwise, the entire plugin list has to be iterated
for pluginInfo in self.pManager.getAllPlugins():
if pluginInfo.is_activated:
pluginInfo.plugin_object.run(rawData, type)
ret_vals = pluginInfo.plugin_object.getParsedValues()
parsedValues.extend(ret_vals)
return parsedValues
except Exception as ex:
self.logger.exception("Error while parsing data: %s", ex)
示例11: tag
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def tag(func):
'''Returns all the tags defined for the function `func`.'''
try:
rt, ea = interface.addressOfRuntimeOrStatic(func)
except E.FunctionNotFoundError:
logging.warn(u"{:s}.tag({:s}) : Attempted to read tag from a non-function. Falling back to a database tag.".format(__name__, ("{:#x}" if isinstance(func, six.integer_types) else "{!r}").format(func)))
return database.tag(func)
if rt:
logging.warn(u"{:s}.tag({:#x}) : Attempted to read tag from a runtime-linked address. Falling back to a database tag.".format(__name__, ea))
return database.tag(ea)
fn, repeatable = by_address(ea), True
res = comment(fn, repeatable=False)
d1 = internal.comment.decode(res)
res = comment(fn, repeatable=True)
d2 = internal.comment.decode(res)
if d1.viewkeys() & d2.viewkeys():
logging.info(u"{:s}.tag({:#x}) : Contents of both the repeatable and non-repeatable comment conflict with one another due to using the same keys ({!r}). Giving the {:s} comment priority.".format(__name__, ea, ', '.join(d1.viewkeys() & d2.viewkeys()), 'repeatable' if repeatable else 'non-repeatable'))
res = {}
map(res.update, (d1, d2) if repeatable else (d2, d1))
# add the function's name to the result
fname = name(fn)
if fname and database.type.flags(interface.range.start(fn), idaapi.FF_NAME):
res.setdefault('__name__', fname)
# add the function's typeinfo to the result
if type.has_prototype(fn):
ti, fname = type(fn), database.name(interface.range.start(fn))
# Demangle the name if necessary, and render it to a string.
realname = internal.declaration.unmangle_name(fname)
fprototype = idaapi.print_tinfo('', 0, 0, 0, ti, utils.string.to(realname), '')
# And then return it to the user
res.setdefault('__typeinfo__', fprototype)
# ..and now hand it off.
return res
示例12: run
# 需要导入模块: import idaapi [as 别名]
# 或者: from idaapi import print_tinfo [as 别名]
def run(self):
'''Start the plugin.'''
if not idaapi.init_hexrays_plugin():
print "HRDEV Error: Failed to initialise Hex-Rays plugin."
return
function_name = idaapi.get_func_name(idaapi.get_screen_ea())
demangled_name = self.tools.demangle_name(function_name)
src = idaapi.decompile(idaapi.get_screen_ea())
file_name = '{}.cpp'.format(self.tools.to_file_name(demangled_name))
cache_path = os.path.sep.join([tempfile.gettempdir(),
'hrdev_cache',
self._bin_name])
# Create required directories if they dont exist
tmp_dir_path = os.path.sep.join([tempfile.gettempdir(), 'hrdev_cache'])
if not os.path.isdir(tmp_dir_path):
os.mkdir(tmp_dir_path)
if not os.path.isdir(cache_path):
os.mkdir(cache_path)
complete_path = os.path.sep.join([cache_path, file_name])
idaapi.msg("HRDEV cache path: {}\n".format(complete_path))
# Check if file is already in cache
if not os.path.isfile(complete_path) or \
self.config_main.getboolean('etc', 'disable_cache'):
self.tools.save_file(complete_path, str(src))
self.tools.set_file_path(complete_path)
lvars = {}
for v in src.lvars:
_type = idaapi.print_tinfo('', 0, 0, idaapi.PRTYPE_1LINE, v.tif, '', '')
lvars[str(v.name)] = "{} {} {}".\
format(_type, str(v.name), str(v.cmt))
max_title = self.config_main.getint('etc', 'max_title')
self.gui = hrdev_plugin.include.gui.Canvas(self.config_main,
self.config_theme,
self.tools,
lvars,
demangled_name[:max_title])
self.gui.Show('HRDEV')
self.parser = hrdev_plugin.include.syntax.Parser(self, lvars)
self.parser.run(complete_path)
return