- applied patchs for IDA 6.4 SP from Hex-Rays

- fixed idc.CommentEx()
- minor mods
This commit is contained in:
elias.bachaalany@gmail.com 2013-03-08 19:33:51 +00:00
parent 223e4a5268
commit 21cd5a95eb
8 changed files with 60 additions and 198 deletions

View File

@ -1,5 +1,9 @@
Please see http://code.google.com/p/idapython/source/list for a detailed list of changes. Please see http://code.google.com/p/idapython/source/list for a detailed list of changes.
Changes from version 1.5.5 to 1.5.6
------------------------------------
- IDA Pro 6.4 support
Changes from version 1.5.4 to 1.5.5 Changes from version 1.5.4 to 1.5.5
------------------------------------ ------------------------------------
- IDA Pro 6.3 support - IDA Pro 6.3 support

View File

@ -24,7 +24,7 @@ from distutils import sysconfig
VERBOSE = True VERBOSE = True
IDA_MAJOR_VERSION = 6 IDA_MAJOR_VERSION = 6
IDA_MINOR_VERSION = 3 IDA_MINOR_VERSION = 4
if 'IDA' in os.environ: if 'IDA' in os.environ:
IDA_SDK = os.environ['IDA'] IDA_SDK = os.environ['IDA']
@ -36,7 +36,7 @@ else:
# IDAPython version # IDAPython version
VERSION_MAJOR = 1 VERSION_MAJOR = 1
VERSION_MINOR = 5 VERSION_MINOR = 5
VERSION_PATCH = 5 VERSION_PATCH = 6
# Determine Python version # Determine Python version
PYTHON_MAJOR_VERSION = int(platform.python_version()[0]) PYTHON_MAJOR_VERSION = int(platform.python_version()[0])

View File

@ -427,25 +427,25 @@ static int PyRunFile(const char *FileName)
} }
#endif #endif
PyObject *PyFileObject = PyFile_FromString((char*)FileName, "r"); PyObject *file_obj = PyFile_FromString((char*)FileName, "r"); //lint !e1776
PyObject *globals = GetMainGlobals(); PyObject *globals = GetMainGlobals();
if ( globals == NULL || PyFileObject == NULL ) if ( globals == NULL || file_obj == NULL )
{ {
Py_XDECREF(PyFileObject); Py_XDECREF(file_obj);
return 0; return 0;
} }
PyErr_Clear(); PyErr_Clear();
PYW_GIL_ENSURE; PYW_GIL_ENSURE;
PyObject *result = PyRun_File( PyObject *result = PyRun_File(
PyFile_AsFile(PyFileObject), PyFile_AsFile(file_obj),
FileName, FileName,
Py_file_input, Py_file_input,
globals, globals,
globals); globals);
PYW_GIL_RELEASE; PYW_GIL_RELEASE;
Py_XDECREF(PyFileObject); Py_XDECREF(file_obj);
Py_XDECREF(result); Py_XDECREF(result);
return result != NULL && !PyErr_Occurred(); return result != NULL && !PyErr_Occurred();

View File

@ -670,9 +670,6 @@ def MakeArray(ea, nitems):
""" """
flags = idaapi.getFlags(ea) flags = idaapi.getFlags(ea)
if idaapi.isCode(flags) or idaapi.isTail(flags) or idaapi.isAlign(flags):
return False
if idaapi.isCode(flags) or idaapi.isTail(flags) or idaapi.isAlign(flags): if idaapi.isCode(flags) or idaapi.isTail(flags) or idaapi.isAlign(flags):
return False return False
@ -790,17 +787,6 @@ def MakeYword(ea):
return idaapi.doYwrd(ea, 32) return idaapi.doYwrd(ea, 32)
def MakeYword(ea):
"""
Convert the current item to a ymm word (32 bytes/256 bits)
@param ea: linear address
@return: 1-ok, 0-failure
"""
return idaapi.doYwrd(ea, 32)
def MakeFloat(ea): def MakeFloat(ea):
""" """
Convert the current item to a floating point (4 bytes) Convert the current item to a floating point (4 bytes)
@ -2358,12 +2344,24 @@ def GetCommentEx(ea, repeatable):
@param ea: linear address @param ea: linear address
@param repeatable: 1 to get the repeatable comment, 0 to get the normal comment
@return: string or None if it fails @return: string or None if it fails
""" """
return idaapi.get_cmt(ea, repeatable) return idaapi.get_cmt(ea, repeatable)
def CommentEx(ea, repeatable): GetCommentEx(ea, repeatable) def CommentEx(ea, repeatable):
"""
Get regular indented comment
@param ea: linear address
@param repeatable: 1 to get the repeatable comment, 0 to get the normal comment
@return: string or None if it fails
"""
return GetCommentEx(ea, repeatable)
def AltOp(ea, n): def AltOp(ea, n):
@ -6983,159 +6981,6 @@ def DelHiddenArea(ea):
return idaapi.del_hidden_area(ea) return idaapi.del_hidden_area(ea)
def GetStepTraceOptions():
"""
Get step current tracing options
@return: a combination of ST_... constants
"""
return idaapi.get_step_trace_options()
def SetStepTraceOptions(options):
"""
Set step current tracing options.
@param options: combination of ST_... constants
"""
return idaapi.set_step_trace_options(options)
ST_OVER_DEBUG_SEG = 0x01 # step tracing will be disabled when IP is in a debugger segment
ST_OVER_LIB_FUNC = 0x02 # step tracing will be disabled when IP is in a library function
ST_ALREADY_LOGGED = 0x04 # step tracing will be disabled when IP is already logged
ST_SKIP_LOOPS = 0x08 # step tracing will try to skip loops already recorded
def LoadTraceFile(filename):
"""
Load a previously recorded binary trace file
@param filename: trace file
"""
return idaapi.load_trace_file(filename, None)
def SaveTraceFile(filename, description):
"""
Save current trace to a binary trace file
@param filename: trace file
"""
return idaapi.save_trace_file(filename, description)
def CheckTraceFile(filename):
"""
Check the given binary trace file
@param filename: trace file
"""
return idaapi.is_valid_trace_file(filename)
def ClearTraceFile(filename):
"""
Clear the current trace buffer
"""
return idaapi.clear_trace()
def GetTraceDesc(filename):
"""
Get the trace description of the given binary trace file
@param filename: trace file
"""
return idaapi.get_trace_file_desc(filename)
def SetTraceDesc(filename, description):
"""
Update the trace description of the given binary trace file
@param filename: trace file
@description: trace description
"""
return idaapi.set_trace_file_desc(filename, description)
def GetMaxTev():
"""
Return the total number of recorded events
"""
return idaapi.get_tev_qty()
def GetTevEa(tev):
"""
Return the address of the specified event
@param tev: event number
"""
return idaapi.get_tev_ea(tev)
TEV_NONE = 0 # no event
TEV_INSN = 1 # an instruction trace
TEV_CALL = 2 # a function call trace
TEV_RET = 3 # a function return trace
TEV_BPT = 4 # write, read/write, execution trace
TEV_MEM = 5 # memory layout changed
TEV_EVENT = 6 # debug event
def GetTevType(tev):
"""
Return the type of the specified event (TEV_... constants)
@param tev: event number
"""
return idaapi.get_tev_type(tev)
def GetTevTid(tev):
"""
Return the thread id of the specified event
@param tev: event number
"""
return idaapi.get_tev_tid(tev)
def GetTevRegVal(tev, reg):
"""
Return the register value for the specified event
@param tev: event number
@param reg: register name (like EAX, RBX, ...)
"""
return idaapi.get_tev_reg_val(tev, reg)
def GetTevRegMemQty(tev):
"""
Return the number of memory addresses recorded for the specified event
@param tev: event number
"""
return idaapi.get_tev_reg_mem_qty(tev)
def GetTevRegMem(tev, idx):
"""
Return the memory pointed by 'index' for the specified event
@param tev: event number
@param idx: memory address index
"""
return idaapi.get_tev_reg_mem(tev, idx)
def GetTevRegMemEa(tev, idx):
"""
Return the address pointed by 'index' for the specified event
@param tev: event number
@param idx: memory address index
"""
return idaapi.get_tev_reg_mem_ea(tev, idx)
def GetTevCallee(tev):
"""
Return the address of the callee for the specified event
@param tev: event number
"""
return idaapi.get_call_tev_callee(tev)
def GetTevReturn(tev):
"""
Return the return address for the specified event
@param tev: event number
"""
return idaapi.get_ret_tev_return(tev)
def GetBptTevEa(tev):
"""
Return the address of the specified TEV_BPT event
@param tev: event number
"""
return idaapi.get_bpt_tev_ea(tev)
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# D E B U G G E R I N T E R F A C E # D E B U G G E R I N T E R F A C E
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
@ -8040,7 +7885,7 @@ def SetBptCndEx(ea, cnd, is_lowcnd):
return False return False
bpt.condition = cnd bpt.condition = cnd
if not is_lowcnd: if is_lowcnd:
bpt.flags |= BPT_LOWCND bpt.flags |= BPT_LOWCND
else: else:
bpt.flags &= ~BPT_LOWCND bpt.flags &= ~BPT_LOWCND
@ -8542,9 +8387,10 @@ def SegDefReg(ea, reg, value): return SetSegDefReg(ea, reg, va
def Comment(ea): return GetCommentEx(ea, 0) def Comment(ea): return GetCommentEx(ea, 0)
"""Returns the non-repeatable comment or None""" """Returns the regular comment or None"""
def RptCmt(ea): return GetCommentEx(ea, 1) def RptCmt(ea): return GetCommentEx(ea, 1)
"""Returns the repeatable comment or None"""
def SetReg(ea, reg, value): return SetRegEx(ea, reg, value, SR_user) def SetReg(ea, reg, value): return SetRegEx(ea, reg, value, SR_user)

View File

@ -94,6 +94,8 @@ struct py_timer_ctx_t
}; };
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// check if we have a file which is known to be executed automatically
// by SWIG or Python runtime
bool pywraps_check_autoscripts(char *buf, size_t bufsize) bool pywraps_check_autoscripts(char *buf, size_t bufsize)
{ {
static const char *const exts[] = static const char *const exts[] =
@ -114,14 +116,18 @@ bool pywraps_check_autoscripts(char *buf, size_t bufsize)
for ( size_t ifn=0; ifn < qnumber(fns); ++ifn ) for ( size_t ifn=0; ifn < qnumber(fns); ++ifn )
{ {
// check for a script or module with several possible extensions
for ( size_t iext=0; iext < qnumber(exts); ++iext ) for ( size_t iext=0; iext < qnumber(exts); ++iext )
{ {
qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]); qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]);
if ( qfileexist(fns[ifn]) ) if ( qfileexist(buf) )
{
qstrncpy(buf, fns[ifn], bufsize);
return true; return true;
} }
// check for a subdirectory under current directory
if ( qfileexist(fns[ifn]) )
{
qstrncpy(buf, fns[ifn], bufsize);
return true;
} }
} }
return false; return false;

View File

@ -1285,6 +1285,8 @@ struct py_timer_ctx_t
}; };
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// check if we have a file which is known to be executed automatically
// by SWIG or Python runtime
bool pywraps_check_autoscripts(char *buf, size_t bufsize) bool pywraps_check_autoscripts(char *buf, size_t bufsize)
{ {
static const char *const exts[] = static const char *const exts[] =
@ -1305,14 +1307,18 @@ bool pywraps_check_autoscripts(char *buf, size_t bufsize)
for ( size_t ifn=0; ifn < qnumber(fns); ++ifn ) for ( size_t ifn=0; ifn < qnumber(fns); ++ifn )
{ {
// check for a script or module with several possible extensions
for ( size_t iext=0; iext < qnumber(exts); ++iext ) for ( size_t iext=0; iext < qnumber(exts); ++iext )
{ {
qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]); qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]);
if ( qfileexist(fns[ifn]) ) if ( qfileexist(buf) )
{
qstrncpy(buf, fns[ifn], bufsize);
return true; return true;
} }
// check for a subdirectory under current directory
if ( qfileexist(fns[ifn]) )
{
qstrncpy(buf, fns[ifn], bufsize);
return true;
} }
} }
return false; return false;

View File

@ -360,7 +360,7 @@ static PyObject *ph_get_instruc()
{ {
Py_ssize_t i = 0; Py_ssize_t i = 0;
PyObject *py_result = PyTuple_New(ph.instruc_end - ph.instruc_start); PyObject *py_result = PyTuple_New(ph.instruc_end - ph.instruc_start);
for ( instruc_t *p = ph.instruc + ph.instruc_start, *end = ph.instruc + ph.instruc_end; for ( const instruc_t *p = ph.instruc + ph.instruc_start, *end = ph.instruc + ph.instruc_end;
p != end; p != end;
++p ) ++p )
{ {