diff --git a/CHANGES.txt b/CHANGES.txt index bc42779..74381e7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,9 @@ 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 ------------------------------------ - IDA Pro 6.3 support diff --git a/build.py b/build.py index a543f94..d3b45a0 100644 --- a/build.py +++ b/build.py @@ -24,7 +24,7 @@ from distutils import sysconfig VERBOSE = True IDA_MAJOR_VERSION = 6 -IDA_MINOR_VERSION = 3 +IDA_MINOR_VERSION = 4 if 'IDA' in os.environ: IDA_SDK = os.environ['IDA'] @@ -36,7 +36,7 @@ else: # IDAPython version VERSION_MAJOR = 1 VERSION_MINOR = 5 -VERSION_PATCH = 5 +VERSION_PATCH = 6 # Determine Python version PYTHON_MAJOR_VERSION = int(platform.python_version()[0]) @@ -516,4 +516,4 @@ def main(): build_source_package() if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/python.cpp b/python.cpp index 0b8add5..ae53f12 100644 --- a/python.cpp +++ b/python.cpp @@ -427,25 +427,25 @@ static int PyRunFile(const char *FileName) } #endif - PyObject *PyFileObject = PyFile_FromString((char*)FileName, "r"); + PyObject *file_obj = PyFile_FromString((char*)FileName, "r"); //lint !e1776 PyObject *globals = GetMainGlobals(); - if ( globals == NULL || PyFileObject == NULL ) + if ( globals == NULL || file_obj == NULL ) { - Py_XDECREF(PyFileObject); + Py_XDECREF(file_obj); return 0; } PyErr_Clear(); PYW_GIL_ENSURE; PyObject *result = PyRun_File( - PyFile_AsFile(PyFileObject), + PyFile_AsFile(file_obj), FileName, Py_file_input, globals, globals); PYW_GIL_RELEASE; - Py_XDECREF(PyFileObject); + Py_XDECREF(file_obj); Py_XDECREF(result); return result != NULL && !PyErr_Occurred(); diff --git a/python/idc.py b/python/idc.py index ef1af2c..a2a2bfc 100644 --- a/python/idc.py +++ b/python/idc.py @@ -670,9 +670,6 @@ def MakeArray(ea, nitems): """ 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): return False @@ -790,17 +787,6 @@ def MakeYword(ea): 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): """ Convert the current item to a floating point (4 bytes) @@ -2358,12 +2344,24 @@ def GetCommentEx(ea, repeatable): @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 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): @@ -6983,159 +6981,6 @@ def DelHiddenArea(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 #-------------------------------------------------------------------------- @@ -8040,7 +7885,7 @@ def SetBptCndEx(ea, cnd, is_lowcnd): return False bpt.condition = cnd - if not is_lowcnd: + if is_lowcnd: bpt.flags |= BPT_LOWCND else: 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) -"""Returns the non-repeatable comment or None""" +"""Returns the regular comment or None""" 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) diff --git a/pywraps/py_idaapi.hpp b/pywraps/py_idaapi.hpp index 0c97fb9..ecbd516 100644 --- a/pywraps/py_idaapi.hpp +++ b/pywraps/py_idaapi.hpp @@ -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) { 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 ) { + // check for a script or module with several possible extensions for ( size_t iext=0; iext < qnumber(exts); ++iext ) { qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]); - if ( qfileexist(fns[ifn]) ) - { - qstrncpy(buf, fns[ifn], bufsize); + if ( qfileexist(buf) ) return true; - } + } + // check for a subdirectory under current directory + if ( qfileexist(fns[ifn]) ) + { + qstrncpy(buf, fns[ifn], bufsize); + return true; } } return false; diff --git a/swig/idaapi.i b/swig/idaapi.i index a22ba06..829c61f 100644 --- a/swig/idaapi.i +++ b/swig/idaapi.i @@ -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) { 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 ) { + // check for a script or module with several possible extensions for ( size_t iext=0; iext < qnumber(exts); ++iext ) { qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]); - if ( qfileexist(fns[ifn]) ) - { - qstrncpy(buf, fns[ifn], bufsize); + if ( qfileexist(buf) ) return true; - } + } + // check for a subdirectory under current directory + if ( qfileexist(fns[ifn]) ) + { + qstrncpy(buf, fns[ifn], bufsize); + return true; } } return false; diff --git a/swig/idp.i b/swig/idp.i index ccc10ce..18dc86a 100644 --- a/swig/idp.i +++ b/swig/idp.i @@ -360,7 +360,7 @@ static PyObject *ph_get_instruc() { Py_ssize_t i = 0; 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 ) { diff --git a/swig/nalt.i b/swig/nalt.i index cf1c3ac..edbbaeb 100644 --- a/swig/nalt.i +++ b/swig/nalt.i @@ -50,10 +50,10 @@ static int idaapi py_import_enum_cb( PyObject *py_ea = Py_BuildValue(PY_FMT64, pyul_t(ea)); PYW_GIL_ENSURE; PyObject *py_result = PyObject_CallFunctionObjArgs( - (PyObject *)param, - py_ea, - py_name, - py_ord, + (PyObject *)param, + py_ea, + py_name, + py_ord, NULL); PYW_GIL_RELEASE; @@ -79,7 +79,7 @@ switch_info_ex_t *switch_info_ex_t_get_clink(PyObject *self) r = (switch_info_ex_t *) PyCObject_AsVoidPtr(attr); else r = NULL; - + Py_DECREF(attr); return r; } @@ -111,7 +111,7 @@ static PyObject *py_get_import_module_name(int mod_index) char buf[MAXSTR]; if ( !get_import_module_name(mod_index, buf, sizeof(buf)) ) Py_RETURN_NONE; - + return PyString_FromString(buf); } @@ -131,7 +131,7 @@ PyObject *py_get_switch_info_ex(ea_t ea) { switch_info_ex_t *ex = new switch_info_ex_t(); PyObject *py_obj; - if ( ::get_switch_info_ex(ea, ex, sizeof(switch_info_ex_t)) <= 0 + if ( ::get_switch_info_ex(ea, ex, sizeof(switch_info_ex_t)) <= 0 || (py_obj = create_idaapi_linked_class_instance(S_PY_SWIEX_CLSNAME, ex)) == NULL ) { delete ex; @@ -151,7 +151,7 @@ def create_switch_xrefs(insn_ea, si): will call it for switch tables Note: Custom switch information are not supported yet. - + @param insn_ea: address of the 'indirect jump' instruction @param si: switch information @@ -179,7 +179,7 @@ idaman bool ida_export py_create_switch_xrefs( def create_switch_table(insn_ea, si): """ Create switch table from the switch information - + @param insn_ea: address of the 'indirect jump' instruction @param si: switch information @@ -195,7 +195,7 @@ idaman bool ida_export py_create_switch_table( switch_info_ex_t *swi = switch_info_ex_t_get_clink(py_swi); if ( swi == NULL ) return false; - + create_switch_table(insn_ea, swi); return true; } @@ -256,7 +256,7 @@ static int py_enum_import_names(int mod_index, PyObject *py_cb) { if ( !PyCallable_Check(py_cb) ) return -1; - + return enum_import_names(mod_index, py_import_enum_cb, py_cb); }