Applied all fixes to IDAPython 6.95, to this date (2016 Sept 26th.)

This commit is contained in:
Arnaud Diederen
2016-09-26 11:16:26 +02:00
parent 62ddab8db6
commit e22e859a41
76 changed files with 330 additions and 88 deletions
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
+3
View File
@@ -3939,6 +3939,7 @@
'intvec_t_truncate',
'invalidate_dbgmem_config',
'invalidate_dbgmem_contents',
'invalidate_visea_cache',
'is3byte',
'isASCII',
'isAlign',
@@ -6274,6 +6275,7 @@
'set_entry_forwarder',
'set_enum_bf',
'set_enum_cmt',
'set_enum_flag',
'set_enum_fromtil',
'set_enum_ghost',
'set_enum_hidden',
@@ -7078,6 +7080,7 @@
'update_extra_cmt',
'update_fpd',
'update_func',
'update_hidden_area',
'update_segm',
'user_cmts_begin',
'user_cmts_clear',
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Binary file not shown.
+1 -1
View File
@@ -163,8 +163,8 @@ fix_fun: found info for free_custom_icon
fix_fun: found info for is_idaq
fix_fun: found info for readsel2
### Processing lines.i
fix_fun: found info for set_user_defined_prefix
fix_fun: found info for tag_remove
fix_fun: found info for set_user_defined_prefix
fix_fun: found info for generate_disassembly
### Processing loader.i
fix_fun: found info for mem2base
Executable → Regular
+2
View File
@@ -23,10 +23,12 @@ import ida_kernwin
import ida_loader
import ida_nalt
import ida_name
import ida_netnode
import ida_segment
import ida_strlist
import ida_ua
import ida_xref
import idc
import types
import os
Executable → Regular
+1 -37
View File
@@ -47,6 +47,7 @@ import ida_idp
import ida_kernwin
import ida_lines
import ida_loader
import ida_moves
import ida_nalt
import ida_name
import ida_netnode
@@ -8422,43 +8423,6 @@ def SetColor(ea, what, color):
return False
#--------------------------------------------------------------------------
# X M L
#--------------------------------------------------------------------------
def SetXML(path, name, value):
"""
Set or update one or more XML values.
@param path: XPath expression of elements where to create value(s)
@param name: name of the element/attribute
(use @XXX for an attribute) to create.
If 'name' is empty, the elements or
attributes returned by XPath are directly
updated to contain the new 'value'.
@param value: value of the element/attribute
@return: success (True or False)
"""
return idaapi.set_xml(path, name, value)
def GetXML(path):
"""
Get one XML value.
@param path: XPath expression to an element
or attribute whose value is requested
@return: the value, None if failed
"""
v = idaapi.value_t()
if idaapi.get_xml(path):
return v.str
else:
return None
#----------------------------------------------------------------------------
# A R M S P E C I F I C
#----------------------------------------------------------------------------
Executable → Regular
View File
+8
View File
@@ -0,0 +1,8 @@
#<pycode(py_bytes)>
def doExtra(ea):
setFlags(ea, get_flags_novalue(ea) | FF_LINE)
def noExtra(ea):
setFlags(ea, get_flags_novalue(ea) & ~(FF_LINE))
#</pycode(py_bytes)>
Executable → Regular
View File
Executable → Regular
View File
+2
View File
@@ -15,6 +15,8 @@ def get_fchunk_referer(ea, idx):
static ea_t get_fchunk_referer(ea_t ea, size_t idx)
{
func_t *pfn = get_fchunk(ea);
if ( pfn == NULL )
return BADADDR;
func_parent_iterator_t dummy(pfn); // read referer info
if ( idx >= pfn->refqty || pfn->referers == NULL )
return BADADDR;
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
+13 -6
View File
@@ -34,20 +34,27 @@ def require(modulename, package=None):
module doesn't exist, it 'import's it, and if it does exist,
'reload()'s it.
The importing module (i.e., the module calling require()) will have
the loaded module bound to its globals(), under the name 'modulename'.
(If require() is called from the command line, the importing module
will be '__main__'.)
For more information, see: <http://www.hexblog.com/?p=749>.
"""
import inspect
frame_obj, filename, line_number, function_name, lines, index = inspect.stack()[1]
importer_module = inspect.getmodule(frame_obj)
if importer_module is None: # No importer module; called from command line
importer_module = sys.modules['__main__']
if modulename in sys.modules.keys():
reload(sys.modules[modulename])
m = sys.modules[modulename]
else:
import importlib
import inspect
m = importlib.import_module(modulename, package)
frame_obj, filename, line_number, function_name, lines, index = inspect.stack()[1]
importer_module = inspect.getmodule(frame_obj)
if importer_module is None: # No importer module; called from command line
importer_module = sys.modules['__main__']
setattr(importer_module, modulename, m)
sys.modules[modulename] = m
setattr(importer_module, modulename, m)
# -----------------------------------------------------------------------
Executable → Regular
View File
+63 -23
View File
@@ -231,6 +231,9 @@ class Form(object):
self.id = 0
"""Automatically assigned control ID"""
self.input_field_index = None
"""If this control is an input field, once Compile() returns this will hold its index. This is used only to compute the possible STARTITEM index"""
self.arg = None
"""Control argument value. This could be one element or a list/tuple (for multiple args per control)"""
@@ -259,6 +262,11 @@ class Form(object):
# Release the parent form reference
self.form = None
def is_input_field(self):
"""
Return True if this field acts as an input
"""
return False
#
# Label controls
@@ -327,6 +335,9 @@ class Form(object):
def get_tag(self):
return "%s%d" % (self.tag, self.id)
def is_input_field(self):
return True
class ChkGroupItemControl(GroupItemControl):
"""
@@ -465,6 +476,9 @@ class Form(object):
self.switdh,
":" if self.hlp is None else self.hlp)
def is_input_field(self):
return True
class NumericInput(InputControl, NumericArgument):
"""
@@ -585,6 +599,9 @@ class Form(object):
hlp)
self.arg = _FORMCB_T(lambda view, code, h=handler: h(code))
def is_input_field(self):
return False
class FormChangeCb(Control):
"""
@@ -981,8 +998,10 @@ class Form(object):
The form controls are wrapped inside curly braces: {ControlName}.
A special operator can be used to return the ID of a given control by its name: {id:ControlName}.
A special operator can be used to return the index of a given control by its name: {id:ControlName}.
This is useful when you use the STARTITEM form keyword to set the initially focused control.
(note that, technically, the index is not the same as the ID; that's because STARTITEM
uses raw, 0-based indexes rather than control IDs to determine the focused widget.)
@param form: Compiles the form and returns the arguments needed to be passed to AskUsingForm()
"""
@@ -1000,32 +1019,53 @@ class Form(object):
if isinstance(ctrl, Form.GroupControl):
ctrl._reset()
p = 0
while True:
def next_control(form, p, first_pass):
i1 = form.find("{", p)
# No more items?
if i1 == -1:
break
# Check if escaped
if (i1 != 0) and form[i1-1] == "\\":
# Remove escape sequence and restart search
form = form[:i1-1] + form[i1:]
# Skip current marker
p = i1
# Continue search
continue
if i1 < 0:
return form, None, None, None
if form[i1 - 1] == '\\' and i1 > 0:
if first_pass:
return next_control(form, i1 + 1, first_pass)
else:
# Remove escape sequence and restart search
form = form[:i1 - 1] + form[i1:]
return next_control(form, i1, first_pass)
i2 = form.find("}", i1)
if i2 == -1:
if i2 < 0:
raise SyntaxError("No matching closing brace '}'")
# Parse control name
ctrlname = form[i1+1:i2]
ctrlname = form[i1 + 1:i2]
if not ctrlname:
raise ValueError("Control %d has an invalid name!" % ctrlcnt)
return form, i1, i2, ctrlname
last_input_field_index = 0
# First pass: assign input_field_index values to controls
p = 0
while True:
form, i1, i2, ctrlname = next_control(form, p, first_pass=True)
if ctrlname is None:
break
p = i2
if ctrlname.startswith("id:"):
continue
ctrl = self.__controls.get(ctrlname, None)
if ctrl is None:
raise ValueError("No matching control '%s'" % ctrlname)
# If this control is an input, assign its index
if ctrl.is_input_field():
ctrl.input_field_index = last_input_field_index
last_input_field_index += 1
p = 0
while True:
form, i1, i2, ctrlname = next_control(form, p, first_pass=False)
if ctrlname is None:
break
# Is it the IDOF operator?
if ctrlname.startswith("id:"):
@@ -1042,7 +1082,7 @@ class Form(object):
# Replace control name by tag
if idfunc:
tag = str(ctrl.id)
tag = str(ctrl.input_field_index if ctrl.input_field_index is not None else ctrl.id)
else:
tag = ctrl.get_tag()
taglen = len(tag)
Executable → Regular
View File
Executable → Regular
View File
+1 -6
View File
@@ -362,12 +362,7 @@ public:
//--------------------------------------------------------------------------
bool refresh_current()
{
int x, y;
place_t *pl = get_place(false, &x, &y);
if ( pl == NULL )
return false;
return jumpto(pl, x, y);
return refresh();
}
//--------------------------------------------------------------------------
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
+11 -1
View File
@@ -52,12 +52,22 @@
%ignore internal_get_sreg_base;
%rename (internal_get_sreg_base) py_internal_get_sreg_base;
%thread;
%nonnul_argument_prototype(
inline bool idaapi load_debugger(const char *nonnul_dbgname, bool use_remote),
const char *nonnul_dbgname);
%nonnul_argument_prototype(
inline void idaapi set_debugger_event_cond(const char *nonnul_cond),
const char *nonnul_cond);
%nonnul_argument_prototype(
inline bool idaapi diff_trace_file(const char *nonnul_filename),
const char *nonnul_filename);
// We want ALL wrappers around what is declared in dbg.hpp
// to release the GIL when calling into the IDA api: those
// might be very long operations, that even require some
// network traffic.
%thread;
%include "dbg.hpp"
%nothread;
%ignore DBG_Callback;
+1 -1
View File
@@ -6,7 +6,7 @@
%ignore init_enums;
%ignore save_enums;
%ignore term_enums;
%ignore set_enum_flag;
%ignore set_enum_flag(enum_t, uint32, bool);
%ignore get_enum_name(tid_t);
%ignore get_selected_enum;
%ignore add_selected_enum;
+4
View File
@@ -52,6 +52,10 @@
%ignore CompileLineEx;
%ignore CompileLine;
%rename (CompileLine) CompileLine_wrap;
%nonnul_argument_prototype(
bool CompileLine_wrap(const char *nonnul_line, char *errbuf, size_t errbufsize),
const char *nonnul_line);
%{
//<code(py_expr)>
//</code(py_expr)>
+4 -1
View File
@@ -9,5 +9,8 @@
%ignore unregister_custom_fixup;
%ignore set_custom_fixup;
%include "fixup.hpp"
%nonnul_argument_prototype(
idaman void ida_export set_fixup(ea_t source, const fixup_data_t *nonnul_fp),
const fixup_data_t *nonnul_fp);
%include "fixup.hpp"
+4
View File
@@ -46,6 +46,10 @@
%ignore IDP_Callback;
%ignore _py_getreg;
%nonnul_argument_prototype(
static PyObject *AssembleLine(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *nonnul_line),
const char *nonnul_line);
%include "idp.hpp"
%inline %{
+4
View File
@@ -62,6 +62,10 @@
//</code(py_lines)>
%}
%nonnul_argument_prototype(
PyObject *py_tag_remove(const char *nonnul_instr),
const char *nonnul_instr);
%inline %{
//<inline(py_lines)>
//</inline(py_lines)>
+4
View File
@@ -48,6 +48,10 @@
}
}
%nonnul_argument_prototype(
asize_t get_member_size(const member_t *nonnul_mptr),
const member_t *nonnul_mptr);
//-------------------------------------------------------------------------
%include "struct.hpp"
// Add a get_member() member function to struc_t.
-10
View File
@@ -298,16 +298,6 @@
%apply qstring { _qstring<char> }
%apply qstring* { _qstring<char>* }
//---------------------------------------------------------------------
// varargs (mostly kernwin.hpp)
//---------------------------------------------------------------------
// This is used for functions like warning(), info() and so on
%typemap(in) (const char *format, ...)
{
$1 = "%s"; /* Fix format string to %s */
$2 = (void *) PyString_AsString($input); /* Get string argument */
};
#ifdef __EA64__
%apply longlong *INOUT { sval_t *value };
%apply longlong *INOUT { adiff_t *disp };
+32
View File
@@ -144,6 +144,34 @@ def check_cpp(opts):
"nostring" : " --size;",
},
"_wrap_warning__varargs__" : {
"nullptrcheck" : 1, # 1st arg
"mustcall" : "PyString_AsString",
},
"_wrap_error__varargs__" : {
"nullptrcheck" : 1,
"mustcall" : "PyString_AsString",
},
"_wrap_tag_remove" : {
"nullptrcheck" : 1,
},
"_wrap_CompileLine" : {
"nullptrcheck" : 1,
},
"_wrap_set_fixup" : {
"nullptrcheck" : 2,
},
"_wrap_get_member_size" : {
"nullptrcheck" : 1,
},
"_wrap_load_debugger" : {
"nullptrcheck" : 1,
"string" : ["SWIG_PYTHON_THREAD_BEGIN_ALLOW", "SWIG_PYTHON_THREAD_END_ALLOW"],
},
"_wrap_AssembleLine" : {
"nullptrcheck" : 5,
},
# no autoEnabled present
"SWIG_init" : {
"nostring" : "autoEnabled",
@@ -297,6 +325,10 @@ def check_cpp(opts):
look_for_stuff(chk["string"], False)
if "nostring" in chk:
look_for_stuff(chk["nostring"], False, lookForPresence=False)
if "nullptrcheck" in chk:
look_for_stuff('"invalid null pointer " "in method \'" "%s" "\', argument " "%d""' % (
fname.replace("_wrap_", "").replace("__varargs__", ""),
chk["nullptrcheck"]), False)
# Ensure all functions were spotted.
for fname in functions_coherence.keys():
+25
View File
@@ -626,6 +626,12 @@ static PyObject *type##_get_clink_ptr(PyObject *self)
{
$1 = "%s"; /* Fix format string to %s */
$2 = (void *) PyString_AsString($input); /* Get string argument */
/* Note: we cannot rely on 'nonnul_argument_prototype' for */
/* these, since we fiddle with the arguments number */
if ( $2 == NULL )
SWIG_exception_fail(
SWIG_ValueError,
"invalid null pointer " "in method '" "$symname" "', argument " "$argnum"" of type '" "$1_type""'");
};
// Help SWIG to figure out the ulonglong type
@@ -821,6 +827,25 @@ using Forms::TForm;
// get_[next|prev]_serial_enum_member() take serials as input, and have the result present as output
%apply unsigned char *INOUT { uchar *in_out_serial };
%define %nonnul_argument_prototype(PROTO, ARGSIG)
/* first, define the typemap */
%typemap(check) (ARGSIG)
{
if ( $1 == NULL )
SWIG_exception_fail(SWIG_ValueError, "invalid null pointer " "in method '" "$symname" "', argument " "$argnum"" of type '" "$1_type""'");
}
/* Then, redeclare prototype. Note that we want this prototype _only_ seen */
/* by SWiG, but not by the later compile phase: because of the defines */
/* in pro.h, 'idaapi', 'ida_export', etc... will disappear, causing */
/* VisualStudio to exit with a "same prototype, different modifiers" error. */
%inline %{
#ifndef _MSC_VER
PROTO;
#endif
%}
%enddef
%{
#include <expr.hpp>
#include <ieee.h>
+147
View File
@@ -0,0 +1,147 @@
[epydoc]
# The list of objects to document. Objects can be named using
# dotted names, module filenames, or package directory names.
# Aliases for this option include "objects" and "values".
modules: idc, idautils, idaapi, ida_allins ida_area ida_auto ida_bytes ida_dbg ida_diskio ida_entry ida_enum ida_expr ida_fixup ida_fpro ida_frame ida_funcs ida_gdl ida_graph ida_hexrays ida_ida ida_idaapi ida_idd ida_idp ida_ints ida_kernwin ida_lines ida_loader ida_moves ida_nalt ida_name ida_netnode ida_offset ida_pro ida_queue ida_registry ida_search ida_segment ida_srarea ida_strlist ida_struct ida_typeinf ida_ua ida_xref
# The type of output that should be generated. Should be one
# of: html, text, latex, dvi, ps, pdf.
output: html
# The path to the output directory. May be relative or absolute.
target: hr-html/
# An integer indicating how verbose epydoc should be. The default
# value is 0; negative values will supress warnings and errors;
# positive values will give more verbose output.
verbosity: 0
# A boolean value indicating that Epydoc should show a tracaback
# in case of unexpected error. By default don't show tracebacks
debug: 0
# If True, don't try to use colors or cursor control when doing
# textual output. The default False assumes a rich text prompt
simple-term: 0
### Generation options
# The default markup language for docstrings, for modules that do
# not define __docformat__. Defaults to epytext.
docformat: epytext
# Whether or not parsing should be used to examine objects.
parse: yes
# Whether or not introspection should be used to examine objects.
introspect: yes
# Don't examine in any way the modules whose dotted name match this
# regular expression pattern.
#exclude
# Don't perform introspection on the modules whose dotted name match this
# regular expression pattern.
#exclude-introspect
# Don't perform parsing on the modules whose dotted name match this
# regular expression pattern.
#exclude-parse
# The format for showing inheritance objects.
# It should be one of: 'grouped', 'listed', 'included'.
inheritance: listed
# Whether or not to inclue private variables. (Even if included,
# private variables will be hidden by default.)
private: no
# Whether or not to list each module's imports.
imports: no
# Whether or not to include syntax highlighted source code in
# the output (HTML only).
sourcecode: no
# Whether or not to includea a page with Epydoc log, containing
# effective option at the time of generation and the reported logs.
include-log: no
### Output options
# The documented project's name.
name: IDAPython
# The CSS stylesheet for HTML output. Can be the name of a builtin
# stylesheet, or the name of a file.
css: white
# The documented project's URL.
url: http://code.google.com/p/idapython/
# HTML code for the project link in the navigation bar. If left
# unspecified, the project link will be generated based on the
# project's name and URL.
link: <a href="http://www.hex-rays.com/">Hex-Rays</a>
# The "top" page for the documentation. Can be a URL, the name
# of a module or class, or one of the special names "trees.html",
# "indices.html", or "help.html"
#top: os.path
# An alternative help file. The named file should contain the
# body of an HTML file; navigation bars will be added to it.
#help: my_helpfile.html
# Whether or not to include a frames-based table of contents.
frames: yes
# Whether each class should be listed in its own section when
# generating LaTeX or PDF output.
separate-classes: no
### API linking options
# Define a new API document. A new interpreted text role
# will be created
#external-api: epydoc
# Use the records in this file to resolve objects in the API named NAME.
#external-api-file: epydoc:api-objects.txt
# Use this URL prefix to configure the string returned for external API.
#external-api-root: epydoc:http://epydoc.sourceforge.net/api
### Graph options
# The list of graph types that should be automatically included
# in the output. Graphs are generated using the Graphviz "dot"
# executable. Graph types include: "classtree", "callgraph",
# "umlclass". Use "all" to include all graph types
#graph: classtree
# The path to the Graphviz "dot" executable, used to generate
# graphs.
#dotpath: /usr/local/bin/dot
# The name of one or more pstat files (generated by the profile
# or hotshot module). These are used to generate call graphs.
#pstat: profile.out
# Specify the font used to generate Graphviz graphs.
# (e.g., helvetica or times).
graph-font: Helvetica
# Specify the font size used to generate Graphviz graphs.
#graph-font-size: 10
### Return value options
# The condition upon which Epydoc should exit with a non-zero
# exit status. Possible values are error, warning, docstring_warning
#fail-on: error
Executable → Regular
View File
-2
View File
@@ -1,5 +1,3 @@
#!/usr/bin/python
# TODO:
# * auto_queue_empty must return 1 by default. How should
# that be specified? In idp.hpp, or in a specific, 'recipe' file?
Executable → Regular
View File