IDAPython 1.3.0 / IDA Pro 5.6

(For older versions please use the 1.2.90 branch)
This commit is contained in:
elias.bachaalany
2010-01-05 18:24:04 +00:00
parent ab7a03431e
commit 277facf240
20 changed files with 2104 additions and 253 deletions

View File

@ -438,10 +438,12 @@ def Eval(expr):
if err:
return "IDC_FAILURE: "+err
else:
if rv.vtype == '\x01': # string
if rv.vtype == '\x01': # VT_STR
return rv.str
elif rv.vtype == '\x02': # long
return rv.num
elif rv.vtype == '\x07': # VT_STR2
return rv.c_str()
else:
raise NotImplementedError, "Eval() supports only expressions returning strings or longs"
@ -6165,6 +6167,13 @@ def GetType(ea):
"""
return idaapi.idc_get_type(ea)
def SizeOf(typestr):
"""
Returns the size of the type. It is equivalent to IDC's sizeof().
Use name, tp, fld = idc.ParseType() ; Sizeof(fld) to retrieve the size
@return: -1 if typestring is not valid otherwise the size of the type
"""
return idaapi.get_type_size0(idaapi.cvar.idati, typestr)
def GuessType(ea):
"""
@ -6191,6 +6200,16 @@ def SetType(ea, newtype):
"""
return idaapi.apply_cdecl(ea, newtype)
def ParseType(inputtype, flags):
"""
Parse type declaration
@param inputtype: file name or C declarations (depending on the flags)
@param flags: combination of PT_... constants or 0
@return: None on failure or (name, type, fields) tuple
"""
return idaapi.idc_parse_decl(idaapi.cvar.idati, inputtype, flags)
def ParseTypes(inputtype, flags):
"""

View File

@ -113,18 +113,12 @@ sys.stdout = sys.stderr = MyStdOut()
sys.argv = [ "" ]
# Have to make sure Python finds our modules
if _idaapi.idainfo_is_64bit(_idaapi.cvar.inf):
pythonDir = "python64"
else:
pythonDir = "python"
sys.path.append(_idaapi.idadir(pythonDir))
print_banner()
sys.path.append(_idaapi.idadir("python"))
#-----------------------------------------------------------
# Import all the required modules
#-----------------------------------------------------------
from idaapi import Choose, get_user_idadir, cvar, Choose2
from idaapi import Choose, get_user_idadir, cvar, Choose2, Appcall
from idc import *
from idautils import *
import idaapi