Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit 866e631

Browse files
author
elias.bachaalany@gmail.com
committed
Added IDA Pro 6.1 SP1 changes (thanks to Arnaud from Hex-Rays)
1 parent 78c79f8 commit 866e631

12 files changed

Lines changed: 94 additions & 31 deletions

File tree

python.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,8 @@ bool idaapi IDAPython_extlang_calcexpr(
10221022
begin_execution();
10231023
result = newref_t(PyRun_String(expr, Py_eval_input, globals, globals));
10241024
end_execution();
1025-
}
1026-
if ( ok && result != NULL )
10271025
ok = return_python_result(rv, result, errbuf, errbufsize);
1026+
}
10281027
return ok;
10291028
}
10301029

python/idautils.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,22 +330,25 @@ def Structs():
330330

331331
def StructMembers(sid):
332332
"""
333-
Get a list of structure members information.
333+
Get a list of structure members information (or stack vars if given a frame).
334334
335335
@param sid: ID of the structure.
336336
337337
@return: List of tuples (offset, name, size)
338338
339339
@note: If 'sid' does not refer to a valid structure,
340340
an exception will be raised.
341+
@note: This will not return 'holes' in structures/stack frames;
342+
it only returns defined structure members.
341343
"""
342-
off = idc.GetFirstMember(sid)
343-
if off == idaapi.BADNODE:
344+
m = idc.GetFirstMember(sid)
345+
if m == -1:
344346
raise Exception("No structure with ID: 0x%x" % sid)
345-
members = idc.GetMemberQty(sid)
346-
for idx in range(0, members):
347-
yield (off, idc.GetMemberName(sid, off), idc.GetMemberSize(sid, off))
348-
off = idc.GetStrucNextOff(sid, off)
347+
while (m != idaapi.BADADDR):
348+
name = idc.GetMemberName(sid, m)
349+
if name:
350+
yield (m, name, idc.GetMemberSize(sid, m))
351+
m = idc.GetStrucNextOff(sid, m)
349352

350353

351354
def DecodePrecedingInstruction(ea):

python/idc.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4943,7 +4943,7 @@ def GetStrucName(sid):
49434943
49444944
@param sid: structure type ID
49454945
4946-
@return: -1 if bad structure type ID is passed
4946+
@return: None if bad structure type ID is passed
49474947
otherwise returns structure type name.
49484948
"""
49494949
return idaapi.get_struc_name(sid)
@@ -5023,8 +5023,8 @@ def GetStrucPrevOff(sid, offset):
50235023
@param sid: structure type ID
50245024
@param offset: current offset
50255025
5026-
@return: -1 if bad structure type ID is passed
5027-
or no (more) offsets in the structure
5026+
@return: -1 if bad structure type ID is passed,
5027+
idaapi.BADADDR if no (more) offsets in the structure,
50285028
otherwise returns previous offset in a structure.
50295029
50305030
@note: IDA allows 'holes' between members of a
@@ -5052,8 +5052,8 @@ def GetStrucNextOff(sid, offset):
50525052
@param sid: structure type ID
50535053
@param offset: current offset
50545054
5055-
@return: -1 if bad structure type ID is passed
5056-
or no (more) offsets in the structure
5055+
@return: -1 if bad structure type ID is passed,
5056+
idaapi.BADADDR if no (more) offsets in the structure,
50575057
otherwise returns next offset in a structure.
50585058
50595059
@note: IDA allows 'holes' between members of a
@@ -5077,8 +5077,8 @@ def GetFirstMember(sid):
50775077
50785078
@param sid: structure type ID
50795079
5080-
@return: -1 if bad structure type ID is passed
5081-
or structure has no members
5080+
@return: -1 if bad structure type ID is passed,
5081+
idaapi.BADADDR if structure has no members,
50825082
otherwise returns offset of the first member.
50835083
50845084
@note: IDA allows 'holes' between members of a
@@ -5102,8 +5102,8 @@ def GetLastMember(sid):
51025102
51035103
@param sid: structure type ID
51045104
5105-
@return: -1 if bad structure type ID is passed
5106-
or structure has no members
5105+
@return: -1 if bad structure type ID is passed,
5106+
idaapi.BADADDR if structure has no members,
51075107
otherwise returns offset of the last member.
51085108
51095109
@note: IDA allows 'holes' between members of a
@@ -5212,7 +5212,7 @@ def GetMemberSize(sid, member_offset):
52125212
at offset 2, then 2,3,4,5 denote
52135213
the same structure member.
52145214
5215-
@return: -1 if bad structure type ID is passed
5215+
@return: None if bad structure type ID is passed,
52165216
or no such member in the structure
52175217
otherwise returns size of the specified
52185218
member in bytes.

python/init.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ def print_banner():
7272
_orig_stderr = sys.stderr;
7373
sys.stdout = sys.stderr = IDAPythonStdOut()
7474

75+
# -----------------------------------------------------------------------
76+
# Initialize the help, with our own stdin wrapper, that'll query the user
77+
# -----------------------------------------------------------------------
78+
import pydoc
79+
class IDAPythonHelpPrompter:
80+
def readline(self):
81+
return idaapi.askstr(0, '', 'Help topic?')
82+
help = pydoc.Helper(input = IDAPythonHelpPrompter(), output = sys.stdout)
83+
7584
# Assign a default sys.argv
7685
sys.argv = [""]
7786

pywraps.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,8 @@ class gil_lock_t
111111
// Declare a variable to acquire/release the GIL
112112
#define PYW_GIL_GET gil_lock_t lock;
113113

114-
#ifdef _DEBUG
115-
#define GIL_CHKCONDFAIL (PyGILState_GetThisThreadState() != _PyThreadState_Current)
116-
#else
117114
#define GIL_CHKCONDFAIL (((debug & IDA_DEBUG_PLUGIN) == IDA_DEBUG_PLUGIN) \
118115
&& PyGILState_GetThisThreadState() != _PyThreadState_Current)
119-
#endif
120116

121117
#define PYW_GIL_CHECK_LOCKED_SCOPE() \
122118
do \

pywraps/py_idaapi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static error_t idaapi idc_py_invoke0(
167167
idc_value_t *argv,
168168
idc_value_t *res)
169169
{
170-
PYW_GIL_CHECK_LOCKED_SCOPE();
170+
PYW_GIL_GET;
171171
PyObject *pyfunc = (PyObject *) argv[0].pvoid;
172172
newref_t py_result(PyObject_CallFunctionObjArgs(pyfunc, NULL));
173173

pywraps/py_idaapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import __builtin__
2121
import imp
2222

23-
def require(modulename):
23+
def require(modulename, package=None):
2424
"""
2525
Load, or reload a module.
2626
@@ -41,7 +41,7 @@ def require(modulename):
4141
else:
4242
import importlib
4343
import inspect
44-
m = importlib.import_module(modulename)
44+
m = importlib.import_module(modulename, package)
4545
frame_obj, filename, line_number, function_name, lines, index = inspect.stack()[1]
4646
importer_module = inspect.getmodule(frame_obj)
4747
if importer_module is None: # No importer module; called from command line

swig/bytes.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
// For get_enum_id()
55
%apply unsigned char *OUTPUT { uchar *serial };
66

7+
// get_[first|last]_serial_enum_member() won't take serials as input; it'll be present as output
8+
%apply unsigned char *OUTPUT { uchar *out_serial };
9+
// get_[next|prev]_serial_enum_member() take serials as input, and have the result present as output
10+
%apply unsigned char *INOUT { uchar *in_out_serial };
11+
712
// Unexported and kernel-only declarations
813
%ignore FlagsEnable;
914
%ignore FlagsDisable;

swig/idaapi.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ static error_t idaapi idc_py_invoke0(
13471347
idc_value_t *argv,
13481348
idc_value_t *res)
13491349
{
1350-
PYW_GIL_CHECK_LOCKED_SCOPE();
1350+
PYW_GIL_GET;
13511351
PyObject *pyfunc = (PyObject *) argv[0].pvoid;
13521352
newref_t py_result(PyObject_CallFunctionObjArgs(pyfunc, NULL));
13531353

@@ -2115,7 +2115,7 @@ import bisect
21152115
import __builtin__
21162116
import imp
21172117

2118-
def require(modulename):
2118+
def require(modulename, package=None):
21192119
"""
21202120
Load, or reload a module.
21212121

@@ -2136,7 +2136,7 @@ def require(modulename):
21362136
else:
21372137
import importlib
21382138
import inspect
2139-
m = importlib.import_module(modulename)
2139+
m = importlib.import_module(modulename, package)
21402140
frame_obj, filename, line_number, function_name, lines, index = inspect.stack()[1]
21412141
importer_module = inspect.getmodule(frame_obj)
21422142
if importer_module is None: # No importer module; called from command line

swig/lines.i

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
%ignore close_comment;
3838
%ignore copy_extra_cmts;
3939
%ignore gen_extra_cmts;
40-
%ignore get_first_free_extra_cmtidx;
4140
%ignore Dumper;
4241
%ignore init_lines;
4342
%ignore save_lines;

0 commit comments

Comments
 (0)