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

Commit 1258fab

Browse files
author
skochinsky@gmail.com
committed
IDAPython 1.5.3
- IDA Pro 6.2 support - added set_idc_func_ex(): it is now possible to add new IDC functions using Python - added visit_patched_bytes() (see ex_patch.py) - added support for the multiline text input control in the Form class - added support for the editable/readonly dropdown list control in the Form class - added execute_sync() to register a function call into the UI message queue - added execute_ui_requests() / check ex_uirequests.py - added add_hotkey() / del_hotkey() to bind Python methods to hotkeys - added register_timer()/unregister_timer(). Check ex_timer.py - added the IDC (Arrays) netnode manipulation layer into idc.py - added idautils.Structs() and StructMembers() generator functions - removed the "Run Python Statement" menu item. IDA now has a unified dialog. Use RunPlugin("python", 0) to invoke it manually. - better error messages for script plugins, loaders and processor modules - bugfix: Dbg_Hooks.dbg_run_to() was receiving wrong input - bugfix: A few Enum related functions were not properly working in idc.py - bugfix: GetIdaDirectory() and GetProcessName() were broken in idc.py - bugfix: idaapi.get_item_head() / idc.ItemHead() were not working
1 parent 96cd02d commit 1258fab

36 files changed

Lines changed: 3445 additions & 648 deletions

AUTHORS.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The IDAPython Team:
77

88
* Hex-Rays - http://www.hex-rays.com/ - <support@hex-rays.com>
99

10-
Hex-Rays joined the project in September 2009 and started contributing.
10+
Hex-Rays joined the IDAPython project in September 2009 and started contributing.
1111
It is primarily maintained by Elias Bachaalany.
1212

1313

@@ -21,3 +21,4 @@ The IDAPython Team:
2121
Igor Skochinsky
2222
Sebastian Muniz
2323
cbwhiz
24+
Arnaud Diederen

BUILDING.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
----------------------------------------------------------
2-
IDAPython - Python plugin for Interactive Disassembler Pro
3-
----------------------------------------------------------
1+
------------------------------------------------------
2+
IDAPython - Python plugin for Interactive Disassembler
3+
------------------------------------------------------
44
Building From Source
55
--------------------
66

@@ -36,10 +36,10 @@ BUILDING
3636

3737
Make sure all the needed tools (compiler, swig) are on the PATH.
3838

39-
1. Unpack the IDAPython source and IDA Pro SDK into the following
39+
1. Unpack the IDAPython source and IDA SDK into the following
4040
directory structure:
4141

42-
swigsdk-versions/x.y/ - A supported version of the IDA Pro SDK
42+
swigsdk-versions/x.y/ - A supported version of the IDA SDK
4343
idapython/ - IDAPython source code
4444

4545
2. On Mac OS X copy libida.dylib from the IDA install directory to

CHANGES.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
Please see http://code.google.com/p/idapython/source/list for a detailed list of changes.
22

33

4+
Changes from version 1.5.2 to 1.5.3
5+
------------------------------------
6+
- added set_idc_func_ex(): it is now possible to add new IDC functions using Python
7+
- added visit_patched_bytes() (see ex_patch.py)
8+
- added support for the multiline text input control in the Form class
9+
- added support for the editable/readonly dropdown list control in the Form class
10+
- added execute_sync() to register a function call into the UI message queue
11+
- added execute_ui_requests() / check ex_uirequests.py
12+
- added add_hotkey() / del_hotkey() to bind Python methods to hotkeys
13+
- added register_timer()/unregister_timer(). Check ex_timer.py
14+
- added the IDC (Arrays) netnode manipulation layer into idc.py
15+
- added idautils.Structs() and StructMembers() generator functions
16+
- removed the "Run Python Statment" menu item. IDA now has a unified dialog.
17+
Use RunPlugin("python", 0) to invoke it manually.
18+
- better error messages for script plugins, loaders and processor modules
19+
- bugfix: Dbg_Hooks.dbg_run_to() was receiving wrong input
20+
- bugfix: A few Enum related functions were not properly working in idc.py
21+
- bugfix: GetIdaDirectory() and GetProcessName() were broken in idc.py
22+
- bugfix: idaapi.get_item_head() / idc.ItemHead() were not working
23+
424
Changes from version 1.5.1 to 1.5.2
525
------------------------------------
626
- added ui_term/ui_save/ui_saved/ui_get_ea_hint UI notifications
727
- added ph_get_operand_info() to retrieve operand information while debugging
828
- added PteDump.py script
9-
- some code refactoring
29+
- bugfix: read/write_dbg_memory() and dbg_get_thread_sreg_base() were not working with all debugger modules
1030
- bugfix: idaapi.netnode.getblob() was limited to MAXSPECSIZE
1131
- bugfix: idc.GetString()/idaapi.get_ascii_contents()/idautils.Strings() were limited to MAXSTR string length
1232
- bugfix: idaapi.del_menu_item() was failing to delete some menu items

README.txt

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
----------------------------------------------------------
2-
IDAPython - Python plugin for Interactive Disassembler Pro
3-
----------------------------------------------------------
1+
------------------------------------------------------
2+
IDAPython - Python plugin for Interactive Disassembler
3+
------------------------------------------------------
44

5-
WHAT IS IDAPTYHON?
5+
What is IDAPython?
66
------------------
77

88
IDAPython is an IDA plugin which makes it possible to write scripts
@@ -12,7 +12,7 @@ access to both the IDA API and any installed Python module.
1212
Check the scripts in the examples directory to get an quick glimpse.
1313

1414

15-
AVAILABILITY
15+
Availability
1616
------------
1717

1818
Latest stable versions of IDAPython are available from
@@ -22,7 +22,7 @@ Development builds are available from
2222
http://code.google.com/p/idapython/
2323

2424

25-
RESOURCES
25+
Resources
2626
---------
2727

2828
The full function cross-reference is readable online at
@@ -35,22 +35,23 @@ Mailing list for the project is hosted by Google Groups at
3535
http://groups.google.com/group/idapython
3636

3737

38-
INSTALLATION FROM BINARIES
38+
Installation from binaries
3939
--------------------------
4040

4141
1. Install 2.6 or 2.7 from http://www.python.org/
42-
2. Copy "python" directory to %IDADIR%
43-
3. Copy "plugins" directory to the %IDADIR%\plugins\
42+
2. Copy the whole "python" directory to %IDADIR%
43+
3. Copy the contents of the "plugins" directory to the %IDADIR%\plugins\
4444
4. Copy "python.cfg" to %IDADIR%\cfg
4545

46-
USAGE
46+
Usage
4747
-----
4848

4949
- Run script: File / Script file (Alt-F7)
5050
- Execute Python statement(s) (Ctrl-F3)
5151
- Run previously executed script again: View / Recent Scripts (Alt+F9)
5252

53-
Batch mode execution:
53+
54+
* Batch mode execution:
5455

5556
Start IDA with the following command line options:
5657

@@ -75,7 +76,7 @@ Where N can be:
7576
1: run script when UI is ready
7677
2: run script immediately on plugin load (shortly after IDA starts and before processor modules and loaders)
7778

78-
User init file:
79+
* User init file
7980

8081
You can place your custom settings to a file called 'idapythonrc.py'
8182
that should be placed to
@@ -89,3 +90,25 @@ or
8990
The user init file is read and executed at the end of the init process.
9091

9192
Please note that IDAPython can be configured with "python.cfg" file.
93+
94+
* Invoking Python from IDC
95+
96+
The IDAPython plugin exposes a new IDC function "RunPythonStatement(string idc_code)" that allows execution
97+
of Python code from IDC
98+
99+
* Invoking IDC from Python
100+
101+
It is possible to use the idc.Eval() to evaluate IDC expressions from Python
102+
103+
* Making Python the default language
104+
105+
By default, IDA will use IDC to evaluate expressions. It is possible to change the default language to use
106+
Python instead of IDC.
107+
108+
In order to do that, please use the following IDC code:
109+
110+
RunPlugin("python", 3)
111+
112+
To disable Python language and revert back to IDC:
113+
RunPlugin("python", 4)
114+

Scripts/VirusTotal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# -----------------------------------------------------------------------
2222
# Configuration file
23-
VT_CFGFILE = idaapi.get_user_idadir() + os.sep + "virustotal.cfg"
23+
VT_CFGFILE = os.path.join(idaapi.get_user_idadir(), "virustotal.cfg")
2424

2525
# -----------------------------------------------------------------------
2626
# VirusTotal Icon in PNG format

build.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22
#---------------------------------------------------------------------
3-
# IDAPython - Python plugin for Interactive Disassembler Pro
3+
# IDAPython - Python plugin for Interactive Disassembler
44
#
5-
# Copyright (c) 2004-2010 Gergely Erdelyi <gergely.erdelyi@d-dome.net>
5+
# (c) The IDAPython Team <idapython@googlegroups.com>
66
#
77
# All rights reserved.
88
#
@@ -24,19 +24,19 @@
2424
VERBOSE = True
2525

2626
IDA_MAJOR_VERSION = 6
27-
IDA_MINOR_VERSION = 1
27+
IDA_MINOR_VERSION = 2
2828

2929
if 'IDA' in os.environ:
3030
IDA_SDK = os.environ['IDA']
3131
else:
32-
IDA_SDK = ".." + os.sep + "swigsdk-versions" + os.sep + "%d.%d" % (IDA_MAJOR_VERSION, IDA_MINOR_VERSION)
32+
IDA_SDK = os.path.join("..", "swigsdk-versions", ("%d.%d" % (IDA_MAJOR_VERSION, IDA_MINOR_VERSION)))
3333

3434
# End of user configurable options
3535

3636
# IDAPython version
3737
VERSION_MAJOR = 1
3838
VERSION_MINOR = 5
39-
VERSION_PATCH = 2
39+
VERSION_PATCH = 3
4040

4141
# Determine Python version
4242
PYTHON_MAJOR_VERSION = int(platform.python_version()[0])
@@ -72,6 +72,8 @@
7272
"docs/notes.txt",
7373
"examples/chooser.py",
7474
"examples/colours.py",
75+
"examples/ex_idphook_asm.py",
76+
"examples/ex_uirequests.py",
7577
"examples/debughook.py",
7678
"examples/ex_cli.py",
7779
"examples/ex1.idc",
@@ -87,13 +89,18 @@
8789
"examples/ex_choose2.py",
8890
"examples/ex_debug_names.py",
8991
"examples/ex_graph.py",
92+
"examples/ex_hotkey.py",
93+
"examples/ex_patch.py",
94+
"examples/ex_expr.py",
95+
"examples/ex_timer.py",
9096
"examples/ex_dbg.py",
9197
"examples/ex_custview.py",
9298
"examples/ex_prefix_plugin.py",
9399
"examples/ex_pyside.py",
94100
"examples/ex_pyqt.py",
95101
"examples/ex_askusingform.py",
96102
"examples/ex_uihook.py",
103+
"examples/ex_idphook_asm.py",
97104
"examples/ex_imports.py"
98105
]
99106

@@ -216,7 +223,7 @@ def __init__(self):
216223
self.include_delimiter = "-I"
217224
self.macro_delimiter = "-D"
218225
self.libpath_delimiter = "-L"
219-
self.compiler_parameters = "-fpermissive"
226+
self.compiler_parameters = "-fpermissive -Wno-write-strings"
220227
self.linker_parameters = "-shared"
221228
self.basemacros = [ ]
222229
self.compiler = "g++ -m32"
@@ -279,21 +286,21 @@ def build_distribution(manifest, distrootdir, ea64, nukeold):
279286
if type(f) == types.TupleType:
280287
srcfilepath = f[0]
281288
srcfilename = os.path.basename(srcfilepath)
282-
dstdir = distrootdir + os.sep + f[1]
283-
dstfilepath = dstdir + os.sep + srcfilename
289+
dstdir = os.path.join(distrootdir, f[1])
290+
dstfilepath = os.path.join(dstdir, srcfilename)
284291
else:
285292
srcfilepath = f
286293
srcfilename = os.path.basename(f)
287294
srcdir = os.path.dirname(f)
288295
if srcdir == "":
289296
dstdir = distrootdir
290297
else:
291-
dstdir = distrootdir + os.sep + srcdir
298+
dstdir = os.path.join(distrootdir, srcdir)
292299

293300
if not os.path.exists(dstdir):
294301
os.makedirs(dstdir)
295302

296-
dstfilepath = dstdir + os.sep + srcfilename
303+
dstfilepath = os.path.join(dstdir, srcfilename)
297304
shutil.copyfile(srcfilepath, dstfilepath)
298305
zip.write(dstfilepath)
299306

@@ -304,14 +311,14 @@ def build_plugin(platform, idasdkdir, plugin_name, ea64):
304311
global SWIG_OPTIONS
305312
""" Build the plugin from the SWIG wrapper and plugin main source """
306313
# Path to the IDA SDK headers
307-
ida_include_directory = idasdkdir + os.sep + "include"
314+
ida_include_directory = os.path.join(idasdkdir, "include")
308315

309316
builder = None
310317
# Platform-specific settings for the Linux build
311318
if platform == "linux":
312319
builder = GCCBuilder()
313320
platform_macros = [ "__LINUX__" ]
314-
python_libpath = sysconfig.EXEC_PREFIX + os.sep + "lib"
321+
python_libpath = os.path.join(sysconfig.EXEC_PREFIX, "lib")
315322
python_library = "-lpython%d.%d" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION)
316323
ida_libpath = os.path.join(idasdkdir, "lib", ea64 and "x86_linux_gcc_64" or "x86_linux_gcc_32")
317324
ida_lib = ""
@@ -320,7 +327,7 @@ def build_plugin(platform, idasdkdir, plugin_name, ea64):
320327
elif platform == "win32":
321328
builder = MSVCBuilder()
322329
platform_macros = [ "__NT__" ]
323-
python_libpath = sysconfig.EXEC_PREFIX + os.sep + "libs"
330+
python_libpath = os.path.join(sysconfig.EXEC_PREFIX, "libs")
324331
python_library = "python%d%d.lib" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION)
325332
ida_libpath = os.path.join(idasdkdir, "lib", ea64 and "x86_win_vc_64" or "x86_win_vc_32")
326333
ida_lib = "ida.lib"

examples/chooser.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#
1111
# Modal chooser
12-
#
12+
#
1313

1414
# Get a modal Choose instance
1515
chooser = Choose([], "MyChooser", 1)
@@ -21,28 +21,30 @@
2121
ch = chooser.choose()
2222
# Print the results
2323
if ch > 0:
24-
print "You chose %d which is %s" % (ch, chooser.list[ch-1])
24+
print "You chose %d which is %s" % (ch, chooser.list[ch-1])
2525
else:
26-
print "Escape from chooser"
26+
print "Escape from chooser"
2727

2828
#
2929
# Normal chooser
3030
#
3131
class MyChoose(Choose):
32-
"""
33-
You have to subclass Chooser to override the enter() method
34-
"""
35-
def __init__(self, list=[], name="Choose"):
36-
Choose.__init__(self, list, name)
37-
# Set the width
38-
self.width = 50
32+
"""
33+
You have to subclass Chooser to override the enter() method
34+
"""
35+
def __init__(self, list=[], name="Choose"):
36+
Choose.__init__(self, list, name)
37+
# Set the width
38+
self.width = 50
39+
self.deflt = 1
3940

40-
def enter(self, n):
41-
print "Enter called. Do some stuff here."
42-
print "The chosen item is %d = %s" % (n, self.list[n-1])
43-
print "Now press ESC to leave."
41+
def enter(self, n):
42+
print "Enter called. Do some stuff here."
43+
print "The chosen item is %d = %s" % (n, self.list[n-1])
44+
print "Now press ESC to leave."
4445

4546
# Get a Choose instance
4647
chooser = MyChoose([ "First", "Second", "Third" ], "MyChoose")
48+
4749
# Run the chooser
4850
ch = chooser.choose()

0 commit comments

Comments
 (0)