diff --git a/build.py b/build.py index 267f8e8..b90635d 100644 --- a/build.py +++ b/build.py @@ -1,425 +1,425 @@ -#!/usr/bin/env python -#------------------------------------------------------------ -# IDAPython - Python plugin for Interactive Disassembler Pro -# -# Copyright (c) 2004-2008 Gergely Erdelyi -# -# All rights reserved. -# -# For detailed copyright information see the file COPYING in -# the root of the distribution archive. -#------------------------------------------------------------ -# build.py - Custom build script -#------------------------------------------------------------ -import os -import platform -import shutil -import sys -import types -import zipfile -from distutils import sysconfig - -# Start of user configurable options -VERBOSE = True -IDA_MAJOR_VERSION = 5 -IDA_MINOR_VERSION = 1 -IDA_SDK = ".." + os.sep + "swigsdk-versions" + os.sep + "%d.%d" % (IDA_MAJOR_VERSION, IDA_MINOR_VERSION) -# End of user configurable options - -# IDAPython version -VERSION_MAJOR = 1 -VERSION_MINOR = 0 -VERSION_PATCH = 0 - -# Determine Python version -PYTHON_MAJOR_VERSION = int(platform.python_version()[0]) -PYTHON_MINOR_VERSION = int(platform.python_version()[2]) - -# Find Python headers -PYTHON_INCLUDE_DIRECTORY = sysconfig.get_config_var('INCLUDEPY') - -# Swig command-line parameters -SWIG_OPTIONS = '-modern -python -c++ -w451 -shadow -D__GNUC__' - -# Common macros for all compilations -COMMON_MACROS = [ - ("VER_MAJOR", "%d" % VERSION_MAJOR), - ("VER_MINOR", "%d" % VERSION_MINOR), - ("VER_PATCH", "%d" % VERSION_PATCH), - "__IDP__", - ("MAXSTR", "1024"), - "USE_DANGEROUS_FUNCTIONS", - "USE_STANDARD_FILE_FUNCTIONS" ] - -# Common includes for all compilations -COMMON_INCLUDES = [ ".", "swig" ] - -# List files for the binary distribution -BINDIST_MANIFEST = [ - "README.txt", - "COPYING.txt", - "CHANGES.txt", - "STATUS.txt", - "python/init.py", - "python/idc.py", - "python/idautils.py", - ("idaapi.py", "python"), - "docs/notes.txt", - "examples/chooser.py", - "examples/colours.py", - "examples/debughook.py", - "examples/ex1.idc", - "examples/ex1_idaapi.py", - "examples/ex1_idautils.py", - "examples/hotkey.py", - "examples/structure.py", -] - -# List files for the source distribution (appended to binary list) -SRCDIST_MANIFEST = [ - "BUILDING.txt", - "python.cpp", - "basetsd.h", - "build.py", - "swig/allins.i", - "swig/auto.i", - "swig/bytes.i", - "swig/dbg.i", - "swig/diskio.i", - "swig/entry.i", - "swig/enum.i", - "swig/expr.i", - "swig/fixup.i", - "swig/frame.i", - "swig/funcs.i", - "swig/ida.i", - "swig/idaapi.i", - "swig/idp.i", - "swig/ints.i", - "swig/kernwin.i", - "swig/lines.i", - "swig/loader.i", - "swig/moves.i", - "swig/nalt.i", - "swig/name.i", - "swig/offset.i", - "swig/pro.i", - "swig/queue.i", - "swig/search.i", - "swig/segment.i", - "swig/srarea.i", - "swig/strlist.i", - "swig/struct.i", - "swig/typeconv.i", - "swig/typeinf.i", - "swig/ua.i", - "swig/xref.i", - "patches/ida51.patch", - "tools/gendocs.py", -] - -# Temporaty build files to remove -BUILD_TEMPFILES = [ - "idaapi.cpp", - "idaapi.obj", - "idaapi.o", - "idaapi.py", - "idapython.sln", - "idapython.ncb", - "python.exp", - "python.lib", - "python.obj" -] - -class BuilderBase: - """ Base class for builders """ - def __init__(self): - pass - - def compile(self, source, objectname=None, includes=[], macros=[]): - """ - Compile the source file - """ - allmacros = [] - allmacros.extend(COMMON_MACROS) - allmacros.extend(self.basemacros) - allmacros.extend(macros) - macrostring = self._build_command_string(allmacros, self.macro_delimiter) - - allincludes = [] - allincludes.extend(COMMON_INCLUDES) - allincludes.extend(includes) - includestring = self._build_command_string(allincludes, self.include_delimiter) - - if not objectname: - objectname = source + self.object_extension - - cmdstring = "%s %s %s %s %s %s" % (self.compiler, - self.compiler_parameters, - self.compiler_out_string(objectname), - self.compiler_in_string(source + self.source_extension), - includestring, - macrostring) - - if VERBOSE: print cmdstring - return os.system(cmdstring) - - - def link(self, objects, outfile, libpaths=[], libraries=[], extra_parameters=None): - """ Link the binary from objects and libraries """ - cmdstring = "%s %s %s" % (self.linker, - self.linker_parameters, - self.linker_out_string(outfile)) - - for objectfile in objects: - cmdstring = "%s %s" % (cmdstring, objectfile + self.object_extension) - - for libpath in libpaths: - cmdstring = "%s %s%s" % (cmdstring, self.libpath_delimiter, libpath) - - for library in libraries: - cmdstring = "%s %s" % (cmdstring, library) - - if extra_parameters: - cmdstring = "%s %s" % (cmdstring, extra_parameters) - - if VERBOSE: print cmdstring - return os.system(cmdstring) - - - def _build_command_string(self, macros, argument_delimiter): - macrostring = "" - - for item in macros: - if type(item) == types.TupleType: - macrostring += '%s%s="%s" ' % (argument_delimiter, item[0], item[1]) - else: - macrostring += '%s%s ' % (argument_delimiter, item) - - return macrostring - - -class GCCBuilder(BuilderBase): - """ Generic GCC compiler class """ - def __init__(self): - self.include_delimiter = "-I" - self.macro_delimiter = "-D" - self.libpath_delimiter = "-L" - self.compiler_parameters = "-fpermissive" - self.linker_parameters = "-shared" - self.basemacros = [ ] - self.compiler = "g++" - self.linker = "g++" - self.source_extension = ".cpp" - self.object_extension = ".o" - - def compiler_in_string(self, filename): - return "-c %s" % filename - - def compiler_out_string(self, filename): - return "-o %s" % filename - - def linker_out_string(self, filename): - return "-o %s" % filename - - -class MSVCBuilder(BuilderBase): - """ Generic GCC compiler class """ - def __init__(self): - self.include_delimiter = "/I" - self.macro_delimiter = "/D" - self.libpath_delimiter = "/LIBPATH:" - self.compiler_parameters = "/nologo /EHsc" - self.linker_parameters = "/nologo /dll /export:PLUGIN" - self.basemacros = [ "WIN32", - "_USRDLL", - "__NT__" ] - self.compiler = "cl" - self.linker = "link" - self.source_extension = ".cpp" - self.object_extension = ".obj" - - def compiler_in_string(self, filename): - return "/c %s" % filename - - def compiler_out_string(self, filename): - return "/Fo%s" % filename - - def linker_out_string(self, filename): - return "/out:%s" % filename - - -def build_distribution(manifest, distrootdir): - """ Create dist tree and copy files to it """ - - # Remove the previous distibution if exits - if os.path.exists(distrootdir): - shutil.rmtree(distrootdir) - - # Also make a ZIP archive of the build - zippath = distrootdir + ".zip" - zip = zipfile.ZipFile(zippath, "w", zipfile.ZIP_DEFLATED) - - # Create output directory - os.makedirs(distrootdir) - - # Copy files, one by one - for f in manifest: - if type(f) == types.TupleType: - srcfilepath = f[0] - srcfilename = os.path.basename(srcfilepath) - dstdir = distrootdir + os.sep + f[1] - dstfilepath = dstdir + os.sep + srcfilename - else: - srcfilepath = f - srcfilename = os.path.basename(f) - srcdir = os.path.dirname(f) - - if srcdir == "": - dstdir = distrootdir - else: - dstdir = distrootdir + os.sep + srcdir - - if not os.path.exists(dstdir): - os.makedirs(dstdir) - - dstfilepath = dstdir + os.sep + srcfilename - shutil.copyfile(srcfilepath, dstfilepath) - zip.write(dstfilepath) - - zip.close() - -def build_plugin(system, idasdkdir): - """ Build the plugin from the SWIG wrapper and plugin main source """ - - # Find IDA SDK headers - ida_include_directory = idasdkdir + os.sep + "include" - - # Platform-specific settings for the Linux build - if system == "Linux": - builder = GCCBuilder() - plugin_name = "python.plx" - platform_macros = [ "__LINUX__" ] - python_libpath = sysconfig.EXEC_PREFIX + os.sep + "lib" - python_library = "-lpython%d.%d" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) - ida_libpath = idasdkdir + os.sep + "libgcc32.lnx" - ida_lib = "" - extra_link_parameters = "/usr/lib/python%s.%s/lib-dynload/*.so" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) - - # Platform-specific settings for the Windows build - if system == "Windows": - builder = MSVCBuilder() - plugin_name = "python.plw" - platform_macros = [ "__NT__" ] - python_libpath = sysconfig.EXEC_PREFIX + os.sep + "libs" - python_library = "python%d%d.lib" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) - ida_libpath = idasdkdir + os.sep + "libvc.w32" - ida_lib = "ida.lib" - extra_link_parameters = None - - # Platform-specific settings for the Linux build - if system == "Darwin": - builder = GCCBuilder() - builder.linker_parameters = "-dynamiclib" - plugin_name = "python.pmc" - platform_macros = [ "__MAC__" ] - python_libpath = "." - python_library = "-framework Python" - ida_libpath = idasdkdir + os.sep + "libgcc32.mac" - ida_lib = "-lida" - extra_link_parameters = "" - - - # Build the wrapper from the interface files - swigcmd = "swig %s -Iswig -o idaapi.cpp -I%s idaapi.i" % (SWIG_OPTIONS, ida_include_directory) - if VERBOSE: print swigcmd - res = os.system(swigcmd) - - if res != 0: return False - - # Compile the wrapper - res = builder.compile("idaapi", - includes=[ PYTHON_INCLUDE_DIRECTORY, ida_include_directory ], - macros=platform_macros) - - if res != 0: return False - - # Compile the main plugin source - res = builder.compile("python", - includes=[ PYTHON_INCLUDE_DIRECTORY, ida_include_directory ], - macros=platform_macros) - - if res != 0: return False - - # Link the final binary - res = builder.link( ["idaapi", "python"], - plugin_name, - [ python_libpath, ida_libpath ], - [ python_library, ida_lib ], - extra_link_parameters) - - if res != 0: return False - - return True - - -def clean(manifest): - """ Clean the temporary files """ - - for i in manifest: - try: - os.unlink(i) - except: - pass - - -if __name__ == "__main__": - # Detect the platform - system = platform.system() - - if system == "Windows" or system == "Microsoft": - platform_string = "win32" - plugin_name = "python.plw" - - if system == "Linux": - platform_string = "linux" - plugin_name = "python.plx" - - if system == "Darwin": - platform_string = "macosx" - plugin_name = "python.pmc" - - BINDISTDIR = "idapython-%d.%d.%d_ida%d.%d_py%d.%d_%s" % (VERSION_MAJOR, - VERSION_MINOR, - VERSION_PATCH, - IDA_MAJOR_VERSION, - IDA_MINOR_VERSION, - PYTHON_MAJOR_VERSION, - PYTHON_MINOR_VERSION, - platform_string) - SRCDISTDIR = "idapython-%d.%d.%d" % (VERSION_MAJOR, - VERSION_MINOR, - VERSION_PATCH) - - # Build the plugin - res = build_plugin(system, IDA_SDK) - if not res: sys.exit(1) - - # Build the binary distribution - binmanifest = [] - binmanifest.extend(BINDIST_MANIFEST) - binmanifest.append((plugin_name, "plugins")) - build_distribution(binmanifest, BINDISTDIR) - - # Build the binary distribution - srcmanifest = [] - srcmanifest.extend(BINDIST_MANIFEST) - srcmanifest.extend(SRCDIST_MANIFEST) - build_distribution(srcmanifest, SRCDISTDIR) - - # Clean the temp files - cleanlist = [] - cleanlist.extend(BUILD_TEMPFILES) - cleanlist.append(plugin_name) -# clean(cleanlist) - +#!/usr/bin/env python +#------------------------------------------------------------ +# IDAPython - Python plugin for Interactive Disassembler Pro +# +# Copyright (c) 2004-2008 Gergely Erdelyi +# +# All rights reserved. +# +# For detailed copyright information see the file COPYING in +# the root of the distribution archive. +#------------------------------------------------------------ +# build.py - Custom build script +#------------------------------------------------------------ +import os +import platform +import shutil +import sys +import types +import zipfile +from distutils import sysconfig + +# Start of user configurable options +VERBOSE = True +IDA_MAJOR_VERSION = 5 +IDA_MINOR_VERSION = 1 +IDA_SDK = ".." + os.sep + "swigsdk-versions" + os.sep + "%d.%d" % (IDA_MAJOR_VERSION, IDA_MINOR_VERSION) +# End of user configurable options + +# IDAPython version +VERSION_MAJOR = 1 +VERSION_MINOR = 0 +VERSION_PATCH = 0 + +# Determine Python version +PYTHON_MAJOR_VERSION = int(platform.python_version()[0]) +PYTHON_MINOR_VERSION = int(platform.python_version()[2]) + +# Find Python headers +PYTHON_INCLUDE_DIRECTORY = sysconfig.get_config_var('INCLUDEPY') + +# Swig command-line parameters +SWIG_OPTIONS = '-modern -python -c++ -w451 -shadow -D__GNUC__' + +# Common macros for all compilations +COMMON_MACROS = [ + ("VER_MAJOR", "%d" % VERSION_MAJOR), + ("VER_MINOR", "%d" % VERSION_MINOR), + ("VER_PATCH", "%d" % VERSION_PATCH), + "__IDP__", + ("MAXSTR", "1024"), + "USE_DANGEROUS_FUNCTIONS", + "USE_STANDARD_FILE_FUNCTIONS" ] + +# Common includes for all compilations +COMMON_INCLUDES = [ ".", "swig" ] + +# List files for the binary distribution +BINDIST_MANIFEST = [ + "README.txt", + "COPYING.txt", + "CHANGES.txt", + "STATUS.txt", + "python/init.py", + "python/idc.py", + "python/idautils.py", + ("idaapi.py", "python"), + "docs/notes.txt", + "examples/chooser.py", + "examples/colours.py", + "examples/debughook.py", + "examples/ex1.idc", + "examples/ex1_idaapi.py", + "examples/ex1_idautils.py", + "examples/hotkey.py", + "examples/structure.py", +] + +# List files for the source distribution (appended to binary list) +SRCDIST_MANIFEST = [ + "BUILDING.txt", + "python.cpp", + "basetsd.h", + "build.py", + "swig/allins.i", + "swig/auto.i", + "swig/bytes.i", + "swig/dbg.i", + "swig/diskio.i", + "swig/entry.i", + "swig/enum.i", + "swig/expr.i", + "swig/fixup.i", + "swig/frame.i", + "swig/funcs.i", + "swig/ida.i", + "swig/idaapi.i", + "swig/idp.i", + "swig/ints.i", + "swig/kernwin.i", + "swig/lines.i", + "swig/loader.i", + "swig/moves.i", + "swig/nalt.i", + "swig/name.i", + "swig/offset.i", + "swig/pro.i", + "swig/queue.i", + "swig/search.i", + "swig/segment.i", + "swig/srarea.i", + "swig/strlist.i", + "swig/struct.i", + "swig/typeconv.i", + "swig/typeinf.i", + "swig/ua.i", + "swig/xref.i", + "patches/ida51.patch", + "tools/gendocs.py", +] + +# Temporaty build files to remove +BUILD_TEMPFILES = [ + "idaapi.cpp", + "idaapi.obj", + "idaapi.o", + "idaapi.py", + "idapython.sln", + "idapython.ncb", + "python.exp", + "python.lib", + "python.obj" +] + +class BuilderBase: + """ Base class for builders """ + def __init__(self): + pass + + def compile(self, source, objectname=None, includes=[], macros=[]): + """ + Compile the source file + """ + allmacros = [] + allmacros.extend(COMMON_MACROS) + allmacros.extend(self.basemacros) + allmacros.extend(macros) + macrostring = self._build_command_string(allmacros, self.macro_delimiter) + + allincludes = [] + allincludes.extend(COMMON_INCLUDES) + allincludes.extend(includes) + includestring = self._build_command_string(allincludes, self.include_delimiter) + + if not objectname: + objectname = source + self.object_extension + + cmdstring = "%s %s %s %s %s %s" % (self.compiler, + self.compiler_parameters, + self.compiler_out_string(objectname), + self.compiler_in_string(source + self.source_extension), + includestring, + macrostring) + + if VERBOSE: print cmdstring + return os.system(cmdstring) + + + def link(self, objects, outfile, libpaths=[], libraries=[], extra_parameters=None): + """ Link the binary from objects and libraries """ + cmdstring = "%s %s %s" % (self.linker, + self.linker_parameters, + self.linker_out_string(outfile)) + + for objectfile in objects: + cmdstring = "%s %s" % (cmdstring, objectfile + self.object_extension) + + for libpath in libpaths: + cmdstring = "%s %s%s" % (cmdstring, self.libpath_delimiter, libpath) + + for library in libraries: + cmdstring = "%s %s" % (cmdstring, library) + + if extra_parameters: + cmdstring = "%s %s" % (cmdstring, extra_parameters) + + if VERBOSE: print cmdstring + return os.system(cmdstring) + + + def _build_command_string(self, macros, argument_delimiter): + macrostring = "" + + for item in macros: + if type(item) == types.TupleType: + macrostring += '%s%s="%s" ' % (argument_delimiter, item[0], item[1]) + else: + macrostring += '%s%s ' % (argument_delimiter, item) + + return macrostring + + +class GCCBuilder(BuilderBase): + """ Generic GCC compiler class """ + def __init__(self): + self.include_delimiter = "-I" + self.macro_delimiter = "-D" + self.libpath_delimiter = "-L" + self.compiler_parameters = "-fpermissive" + self.linker_parameters = "-shared" + self.basemacros = [ ] + self.compiler = "g++" + self.linker = "g++" + self.source_extension = ".cpp" + self.object_extension = ".o" + + def compiler_in_string(self, filename): + return "-c %s" % filename + + def compiler_out_string(self, filename): + return "-o %s" % filename + + def linker_out_string(self, filename): + return "-o %s" % filename + + +class MSVCBuilder(BuilderBase): + """ Generic GCC compiler class """ + def __init__(self): + self.include_delimiter = "/I" + self.macro_delimiter = "/D" + self.libpath_delimiter = "/LIBPATH:" + self.compiler_parameters = "/nologo /EHsc" + self.linker_parameters = "/nologo /dll /export:PLUGIN" + self.basemacros = [ "WIN32", + "_USRDLL", + "__NT__" ] + self.compiler = "cl" + self.linker = "link" + self.source_extension = ".cpp" + self.object_extension = ".obj" + + def compiler_in_string(self, filename): + return "/c %s" % filename + + def compiler_out_string(self, filename): + return "/Fo%s" % filename + + def linker_out_string(self, filename): + return "/out:%s" % filename + + +def build_distribution(manifest, distrootdir): + """ Create dist tree and copy files to it """ + + # Remove the previous distibution if exits + if os.path.exists(distrootdir): + shutil.rmtree(distrootdir) + + # Also make a ZIP archive of the build + zippath = distrootdir + ".zip" + zip = zipfile.ZipFile(zippath, "w", zipfile.ZIP_DEFLATED) + + # Create output directory + os.makedirs(distrootdir) + + # Copy files, one by one + for f in manifest: + if type(f) == types.TupleType: + srcfilepath = f[0] + srcfilename = os.path.basename(srcfilepath) + dstdir = distrootdir + os.sep + f[1] + dstfilepath = dstdir + os.sep + srcfilename + else: + srcfilepath = f + srcfilename = os.path.basename(f) + srcdir = os.path.dirname(f) + + if srcdir == "": + dstdir = distrootdir + else: + dstdir = distrootdir + os.sep + srcdir + + if not os.path.exists(dstdir): + os.makedirs(dstdir) + + dstfilepath = dstdir + os.sep + srcfilename + shutil.copyfile(srcfilepath, dstfilepath) + zip.write(dstfilepath) + + zip.close() + +def build_plugin(system, idasdkdir): + """ Build the plugin from the SWIG wrapper and plugin main source """ + + # Find IDA SDK headers + ida_include_directory = idasdkdir + os.sep + "include" + + # Platform-specific settings for the Linux build + if system == "Linux": + builder = GCCBuilder() + plugin_name = "python.plx" + platform_macros = [ "__LINUX__" ] + python_libpath = sysconfig.EXEC_PREFIX + os.sep + "lib" + python_library = "-lpython%d.%d" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) + ida_libpath = idasdkdir + os.sep + "libgcc32.lnx" + ida_lib = "" + extra_link_parameters = "/usr/lib/python%s.%s/lib-dynload/*.so" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) + + # Platform-specific settings for the Windows build + if system == "Windows": + builder = MSVCBuilder() + plugin_name = "python.plw" + platform_macros = [ "__NT__" ] + python_libpath = sysconfig.EXEC_PREFIX + os.sep + "libs" + python_library = "python%d%d.lib" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) + ida_libpath = idasdkdir + os.sep + "libvc.w32" + ida_lib = "ida.lib" + extra_link_parameters = None + + # Platform-specific settings for the Linux build + if system == "Darwin": + builder = GCCBuilder() + builder.linker_parameters = "-dynamiclib" + plugin_name = "python.pmc" + platform_macros = [ "__MAC__" ] + python_libpath = "." + python_library = "-framework Python" + ida_libpath = idasdkdir + os.sep + "libgcc32.mac" + ida_lib = "-lida" + extra_link_parameters = "" + + + # Build the wrapper from the interface files + swigcmd = "swig %s -Iswig -o idaapi.cpp -I%s idaapi.i" % (SWIG_OPTIONS, ida_include_directory) + if VERBOSE: print swigcmd + res = os.system(swigcmd) + + if res != 0: return False + + # Compile the wrapper + res = builder.compile("idaapi", + includes=[ PYTHON_INCLUDE_DIRECTORY, ida_include_directory ], + macros=platform_macros) + + if res != 0: return False + + # Compile the main plugin source + res = builder.compile("python", + includes=[ PYTHON_INCLUDE_DIRECTORY, ida_include_directory ], + macros=platform_macros) + + if res != 0: return False + + # Link the final binary + res = builder.link( ["idaapi", "python"], + plugin_name, + [ python_libpath, ida_libpath ], + [ python_library, ida_lib ], + extra_link_parameters) + + if res != 0: return False + + return True + + +def clean(manifest): + """ Clean the temporary files """ + + for i in manifest: + try: + os.unlink(i) + except: + pass + + +if __name__ == "__main__": + # Detect the platform + system = platform.system() + + if system == "Windows" or system == "Microsoft": + platform_string = "win32" + plugin_name = "python.plw" + + if system == "Linux": + platform_string = "linux" + plugin_name = "python.plx" + + if system == "Darwin": + platform_string = "macosx" + plugin_name = "python.pmc" + + BINDISTDIR = "idapython-%d.%d.%d_ida%d.%d_py%d.%d_%s" % (VERSION_MAJOR, + VERSION_MINOR, + VERSION_PATCH, + IDA_MAJOR_VERSION, + IDA_MINOR_VERSION, + PYTHON_MAJOR_VERSION, + PYTHON_MINOR_VERSION, + platform_string) + SRCDISTDIR = "idapython-%d.%d.%d" % (VERSION_MAJOR, + VERSION_MINOR, + VERSION_PATCH) + + # Build the plugin + res = build_plugin(system, IDA_SDK) + if not res: sys.exit(1) + + # Build the binary distribution + binmanifest = [] + binmanifest.extend(BINDIST_MANIFEST) + binmanifest.append((plugin_name, "plugins")) + build_distribution(binmanifest, BINDISTDIR) + + # Build the binary distribution + srcmanifest = [] + srcmanifest.extend(BINDIST_MANIFEST) + srcmanifest.extend(SRCDIST_MANIFEST) + build_distribution(srcmanifest, SRCDISTDIR) + + # Clean the temp files + cleanlist = [] + cleanlist.extend(BUILD_TEMPFILES) + cleanlist.append(plugin_name) +# clean(cleanlist) + diff --git a/examples/ex1_idaapi.py b/examples/ex1_idaapi.py index 3fec86a..6de2092 100644 --- a/examples/ex1_idaapi.py +++ b/examples/ex1_idaapi.py @@ -1,29 +1,29 @@ -# -# Reference Lister -# -# List all functions and all references to them in the current section. -# -# Implemented using direct IDA Plugin API calls -# -from idaapi import * - -# Get current ea -ea = get_screen_ea() - -# Get segment class -seg = getseg(ea) - -# Loop from segment start to end -func = get_func(seg.startEA) - -while func != None and func.startEA < seg.endEA: - funcea = func.startEA - print "Function %s at 0x%x" % (GetFunctionName(funcea), funcea) - - ref = get_first_cref_to(funcea) - - while ref != BADADDR: - print " called from %s(0x%x)" % (get_func_name(ref), ref) - ref = get_next_cref_to(funcea, ref) - - func = get_next_func(funcea) +# +# Reference Lister +# +# List all functions and all references to them in the current section. +# +# Implemented using direct IDA Plugin API calls +# +from idaapi import * + +# Get current ea +ea = get_screen_ea() + +# Get segment class +seg = getseg(ea) + +# Loop from segment start to end +func = get_func(seg.startEA) + +while func != None and func.startEA < seg.endEA: + funcea = func.startEA + print "Function %s at 0x%x" % (GetFunctionName(funcea), funcea) + + ref = get_first_cref_to(funcea) + + while ref != BADADDR: + print " called from %s(0x%x)" % (get_func_name(ref), ref) + ref = get_next_cref_to(funcea, ref) + + func = get_next_func(funcea) diff --git a/examples/ex1_idautils.py b/examples/ex1_idautils.py index d0d76b7..b995f56 100644 --- a/examples/ex1_idautils.py +++ b/examples/ex1_idautils.py @@ -1,20 +1,20 @@ -# -# Reference Lister -# -# List all functions and all references to them in the current section. -# -# Implemented with the idautils module -# -from idautils import * - -# Get current ea -ea = ScreenEA() - -# Loop from start to end in the current segment -for funcea in Functions(SegStart(ea), SegEnd(ea)): - print "Function %s at 0x%x" % (GetFunctionName(funcea), funcea) - - # Find all code references to funcea - for ref in CodeRefsTo(funcea, 1): - print " called from %s(0x%x)" % (GetFunctionName(ref), ref) - +# +# Reference Lister +# +# List all functions and all references to them in the current section. +# +# Implemented with the idautils module +# +from idautils import * + +# Get current ea +ea = ScreenEA() + +# Loop from start to end in the current segment +for funcea in Functions(SegStart(ea), SegEnd(ea)): + print "Function %s at 0x%x" % (GetFunctionName(funcea), funcea) + + # Find all code references to funcea + for ref in CodeRefsTo(funcea, 1): + print " called from %s(0x%x)" % (GetFunctionName(ref), ref) + diff --git a/swig/allins.i b/swig/allins.i index 6c2fe8f..eda9e5a 100644 --- a/swig/allins.i +++ b/swig/allins.i @@ -1,7 +1,7 @@ -// Ignore the unnedded externals -%ignore Instructions; - -// This makes SWIG ignore the size def for the Intel enum -#define ENUM_SIZE(x) - -%include "allins.hpp" +// Ignore the unnedded externals +%ignore Instructions; + +// This makes SWIG ignore the size def for the Intel enum +#define ENUM_SIZE(x) + +%include "allins.hpp" diff --git a/swig/auto.i b/swig/auto.i index 8169599..e894b22 100644 --- a/swig/auto.i +++ b/swig/auto.i @@ -1,13 +1,13 @@ -%ignore auto_process_all; -%ignore autoPlanned; -%ignore nextPlanned; -%ignore autoDelCode; -%ignore autoPeek; -%ignore autoProcess; -%ignore auto_init; -%ignore auto_save; -%ignore auto_term; -%ignore ea_without_xrefs; - -%include "auto.hpp" - +%ignore auto_process_all; +%ignore autoPlanned; +%ignore nextPlanned; +%ignore autoDelCode; +%ignore autoPeek; +%ignore autoProcess; +%ignore auto_init; +%ignore auto_save; +%ignore auto_term; +%ignore ea_without_xrefs; + +%include "auto.hpp" + diff --git a/swig/dbg.i b/swig/dbg.i index b37a12a..163d8a2 100644 --- a/swig/dbg.i +++ b/swig/dbg.i @@ -1,233 +1,233 @@ -// SWIG chokes on the original declaration so it is replicated here -typedef struct -{ - ulonglong ival; // 8: integer value - ushort fval[6]; // 12: floating point value in the internal representation (see ieee.h) -} regval_t; - -%immutable dbg; -%include "dbg.hpp" - -%feature("director") DBG_Hooks; - -%inline %{ - -int idaapi DBG_Callback(void *ud, int notification_code, va_list va); -class DBG_Hooks -{ -public: - virtual ~DBG_Hooks() {}; - - bool hook() { return hook_to_notification_point(HT_DBG, DBG_Callback, this); }; - bool unhook() { return unhook_from_notification_point(HT_DBG, DBG_Callback, this); }; - /* Hook functions to be overridden in Python */ - virtual void dbg_process_start(process_id_t pid, - thread_id_t tid, - ea_t ea, - char *name, - ea_t base, - asize_t size) { }; - virtual void dbg_process_exit(process_id_t pid, - thread_id_t tid, - ea_t ea, - int exit_code) { }; - virtual void dbg_process_attach(process_id_t pid, - thread_id_t tid, - ea_t ea, - char *name, - ea_t base, - asize_t size) { }; - virtual void dbg_process_detach(process_id_t pid, - thread_id_t tid, - ea_t ea) { }; - virtual void dbg_thread_start(process_id_t pid, - thread_id_t tid, - ea_t ea) { }; - virtual void dbg_thread_exit(process_id_t pid, - thread_id_t tid, - ea_t ea, - int exit_code) { }; - virtual void dbg_library_load(process_id_t pid, - thread_id_t tid, - ea_t ea, - char *name, - ea_t base, - asize_t size) { }; - virtual void dbg_library_unload(process_id_t pid, - thread_id_t tid, - ea_t ea, - char *libname) { }; - virtual void dbg_information(process_id_t pid, - thread_id_t tid, - ea_t ea, - char *info) { }; - virtual int dbg_exception(process_id_t pid, - thread_id_t tid, - ea_t ea, - int code, - bool can_cont, - ea_t exc_ea, - char *info) { return 0; }; - virtual void dbg_suspend_process(void) { }; - virtual int dbg_bpt(thread_id_t tid, ea_t breakpoint_ea) { return 0; }; - virtual int dbg_trace(thread_id_t tid, ea_t ip) { return 0; }; - virtual void dbg_request_error(ui_notification_t failed_command, - dbg_notification_t failed_dbg_notification) { }; - virtual void dbg_step_into(void) { }; - virtual void dbg_step_over(void) { }; - virtual void dbg_run_to(thread_id_t tid) { }; - virtual void dbg_step_until_ret(void) { }; -}; - -int idaapi DBG_Callback(void *ud, int notification_code, va_list va) -{ - class DBG_Hooks *proxy = (class DBG_Hooks *)ud; - - debug_event_t *event; - thread_id_t tid; - int *warn; - ea_t ip; - ui_notification_t failed_command; - dbg_notification_t failed_dbg_notification; - ea_t breakpoint_ea; - - try { - switch (notification_code) - { - case dbg_process_start: - event = va_arg(va, debug_event_t *); - proxy->dbg_process_start(event->pid, - event->tid, - event->ea, - event->modinfo.name, - event->modinfo.base, - event->modinfo.size); - return 0; - case dbg_process_exit: - event = va_arg(va, debug_event_t *); - proxy->dbg_process_exit(event->pid, - event->tid, - event->ea, - event->exit_code); - return 0; - - case dbg_process_attach: - event = va_arg(va, debug_event_t *); - proxy->dbg_process_attach(event->pid, - event->tid, - event->ea, - event->modinfo.name, - event->modinfo.base, - event->modinfo.size); - return 0; - - case dbg_process_detach: - event = va_arg(va, debug_event_t *); - proxy->dbg_process_detach(event->pid, - event->tid, - event->ea); - return 0; - - case dbg_thread_start: - event = va_arg(va, debug_event_t *); - proxy->dbg_thread_start(event->pid, - event->tid, - event->ea); - return 0; - - case dbg_thread_exit: - event = va_arg(va, debug_event_t *); - proxy->dbg_thread_exit(event->pid, - event->tid, - event->ea, - event->exit_code); - return 0; - - case dbg_library_load: - event = va_arg(va, debug_event_t *); - proxy->dbg_library_load(event->pid, - event->tid, - event->ea, - event->modinfo.name, - event->modinfo.base, - event->modinfo.size); - return 0; - - case dbg_library_unload: - event = va_arg(va, debug_event_t *); - proxy->dbg_library_unload(event->pid, - event->tid, - event->ea, - event->info); - return 0; - - case dbg_information: - event = va_arg(va, debug_event_t *); - proxy->dbg_information(event->pid, - event->tid, - event->ea, - event->info); - return 0; - - case dbg_exception: - event = va_arg(va, debug_event_t *); - warn = va_arg(va, int *); - *warn = proxy->dbg_exception(event->pid, - event->tid, - event->ea, - event->exc.code, - event->exc.can_cont, - event->exc.ea, - event->exc.info); - return 0; - - case dbg_suspend_process: - proxy->dbg_suspend_process(); - return 0; - - case dbg_bpt: - tid = va_arg(va, thread_id_t); - breakpoint_ea = va_arg(va, ea_t); - warn = va_arg(va, int *); - *warn = proxy->dbg_bpt(tid, breakpoint_ea); - return 0; - - case dbg_trace: - tid = va_arg(va, thread_id_t); - ip = va_arg(va, ea_t); - return proxy->dbg_bpt(tid, ip); - - case dbg_request_error: - failed_command = (ui_notification_t)va_arg(va, int); - failed_dbg_notification = (dbg_notification_t)va_arg(va, int); - proxy->dbg_request_error(failed_command, failed_dbg_notification); - return 0; - - case dbg_step_into: - proxy->dbg_step_into(); - return 0; - - case dbg_step_over: - proxy->dbg_step_over(); - return 0; - - case dbg_run_to: - tid = va_arg(va, thread_id_t); - proxy->dbg_run_to(tid); - return 0; - - case dbg_step_until_ret: - proxy->dbg_step_until_ret(); - return 0; - } - } - catch (Swig::DirectorException &e) - { - msg("Exception in IDP Hook function:\n"); - if (PyErr_Occurred()) - { - PyErr_Print(); - } - } -} -%} +// SWIG chokes on the original declaration so it is replicated here +typedef struct +{ + ulonglong ival; // 8: integer value + ushort fval[6]; // 12: floating point value in the internal representation (see ieee.h) +} regval_t; + +%immutable dbg; +%include "dbg.hpp" + +%feature("director") DBG_Hooks; + +%inline %{ + +int idaapi DBG_Callback(void *ud, int notification_code, va_list va); +class DBG_Hooks +{ +public: + virtual ~DBG_Hooks() {}; + + bool hook() { return hook_to_notification_point(HT_DBG, DBG_Callback, this); }; + bool unhook() { return unhook_from_notification_point(HT_DBG, DBG_Callback, this); }; + /* Hook functions to be overridden in Python */ + virtual void dbg_process_start(process_id_t pid, + thread_id_t tid, + ea_t ea, + char *name, + ea_t base, + asize_t size) { }; + virtual void dbg_process_exit(process_id_t pid, + thread_id_t tid, + ea_t ea, + int exit_code) { }; + virtual void dbg_process_attach(process_id_t pid, + thread_id_t tid, + ea_t ea, + char *name, + ea_t base, + asize_t size) { }; + virtual void dbg_process_detach(process_id_t pid, + thread_id_t tid, + ea_t ea) { }; + virtual void dbg_thread_start(process_id_t pid, + thread_id_t tid, + ea_t ea) { }; + virtual void dbg_thread_exit(process_id_t pid, + thread_id_t tid, + ea_t ea, + int exit_code) { }; + virtual void dbg_library_load(process_id_t pid, + thread_id_t tid, + ea_t ea, + char *name, + ea_t base, + asize_t size) { }; + virtual void dbg_library_unload(process_id_t pid, + thread_id_t tid, + ea_t ea, + char *libname) { }; + virtual void dbg_information(process_id_t pid, + thread_id_t tid, + ea_t ea, + char *info) { }; + virtual int dbg_exception(process_id_t pid, + thread_id_t tid, + ea_t ea, + int code, + bool can_cont, + ea_t exc_ea, + char *info) { return 0; }; + virtual void dbg_suspend_process(void) { }; + virtual int dbg_bpt(thread_id_t tid, ea_t breakpoint_ea) { return 0; }; + virtual int dbg_trace(thread_id_t tid, ea_t ip) { return 0; }; + virtual void dbg_request_error(ui_notification_t failed_command, + dbg_notification_t failed_dbg_notification) { }; + virtual void dbg_step_into(void) { }; + virtual void dbg_step_over(void) { }; + virtual void dbg_run_to(thread_id_t tid) { }; + virtual void dbg_step_until_ret(void) { }; +}; + +int idaapi DBG_Callback(void *ud, int notification_code, va_list va) +{ + class DBG_Hooks *proxy = (class DBG_Hooks *)ud; + + debug_event_t *event; + thread_id_t tid; + int *warn; + ea_t ip; + ui_notification_t failed_command; + dbg_notification_t failed_dbg_notification; + ea_t breakpoint_ea; + + try { + switch (notification_code) + { + case dbg_process_start: + event = va_arg(va, debug_event_t *); + proxy->dbg_process_start(event->pid, + event->tid, + event->ea, + event->modinfo.name, + event->modinfo.base, + event->modinfo.size); + return 0; + case dbg_process_exit: + event = va_arg(va, debug_event_t *); + proxy->dbg_process_exit(event->pid, + event->tid, + event->ea, + event->exit_code); + return 0; + + case dbg_process_attach: + event = va_arg(va, debug_event_t *); + proxy->dbg_process_attach(event->pid, + event->tid, + event->ea, + event->modinfo.name, + event->modinfo.base, + event->modinfo.size); + return 0; + + case dbg_process_detach: + event = va_arg(va, debug_event_t *); + proxy->dbg_process_detach(event->pid, + event->tid, + event->ea); + return 0; + + case dbg_thread_start: + event = va_arg(va, debug_event_t *); + proxy->dbg_thread_start(event->pid, + event->tid, + event->ea); + return 0; + + case dbg_thread_exit: + event = va_arg(va, debug_event_t *); + proxy->dbg_thread_exit(event->pid, + event->tid, + event->ea, + event->exit_code); + return 0; + + case dbg_library_load: + event = va_arg(va, debug_event_t *); + proxy->dbg_library_load(event->pid, + event->tid, + event->ea, + event->modinfo.name, + event->modinfo.base, + event->modinfo.size); + return 0; + + case dbg_library_unload: + event = va_arg(va, debug_event_t *); + proxy->dbg_library_unload(event->pid, + event->tid, + event->ea, + event->info); + return 0; + + case dbg_information: + event = va_arg(va, debug_event_t *); + proxy->dbg_information(event->pid, + event->tid, + event->ea, + event->info); + return 0; + + case dbg_exception: + event = va_arg(va, debug_event_t *); + warn = va_arg(va, int *); + *warn = proxy->dbg_exception(event->pid, + event->tid, + event->ea, + event->exc.code, + event->exc.can_cont, + event->exc.ea, + event->exc.info); + return 0; + + case dbg_suspend_process: + proxy->dbg_suspend_process(); + return 0; + + case dbg_bpt: + tid = va_arg(va, thread_id_t); + breakpoint_ea = va_arg(va, ea_t); + warn = va_arg(va, int *); + *warn = proxy->dbg_bpt(tid, breakpoint_ea); + return 0; + + case dbg_trace: + tid = va_arg(va, thread_id_t); + ip = va_arg(va, ea_t); + return proxy->dbg_bpt(tid, ip); + + case dbg_request_error: + failed_command = (ui_notification_t)va_arg(va, int); + failed_dbg_notification = (dbg_notification_t)va_arg(va, int); + proxy->dbg_request_error(failed_command, failed_dbg_notification); + return 0; + + case dbg_step_into: + proxy->dbg_step_into(); + return 0; + + case dbg_step_over: + proxy->dbg_step_over(); + return 0; + + case dbg_run_to: + tid = va_arg(va, thread_id_t); + proxy->dbg_run_to(tid); + return 0; + + case dbg_step_until_ret: + proxy->dbg_step_until_ret(); + return 0; + } + } + catch (Swig::DirectorException &e) + { + msg("Exception in IDP Hook function:\n"); + if (PyErr_Occurred()) + { + PyErr_Print(); + } + } +} +%} diff --git a/swig/entry.i b/swig/entry.i index 4fb1cf9..ac72192 100644 --- a/swig/entry.i +++ b/swig/entry.i @@ -1,7 +1,7 @@ -%ignore init_entries; -%ignore term_entries; -%ignore move_entries; -%ignore set_entry_name; - -%include "entry.hpp" - +%ignore init_entries; +%ignore term_entries; +%ignore move_entries; +%ignore set_entry_name; + +%include "entry.hpp" + diff --git a/swig/expr.i b/swig/expr.i index 0360c0a..5592797 100644 --- a/swig/expr.i +++ b/swig/expr.i @@ -1,61 +1,61 @@ -%ignore extfun_t; -%ignore funcset_t; -%ignore IDCFuncs; -%ignore set_idc_func; -%ignore VarLong; -%ignore VarNum; -%ignore VarString; -%ignore VarFloat; -%ignore VarFree; -%ignore calcexpr_long; -%ignore Run; -%ignore ExecuteLine; -%ignore ExecuteFile; -%ignore set_idc_func_body; -%ignore get_idc_func_body; -%ignore idc_stacksize; -%ignore idc_calldepth; -%ignore expr_printf; -%ignore expr_sprintf; -%ignore expr_printfer; -%ignore idaapi init_idc; -%ignore idaapi term_idc; -%ignore del_idc_userfuncs; -%ignore find_builtin_idc_func; -%ignore idc_lx; - -%cstring_output_maxstr_none(char *errbuf, size_t errbufsize); - -/* Compile* functions return false when error so the return */ -/* value must be negated for the error string to be returned */ -%rename (CompileEx) CompileEx_wrap; -%inline %{ -bool CompileEx_wrap(const char *file, bool del_macros, - char *errbuf, size_t errbufsize) -{ - return !CompileEx(file, del_macros, errbuf, errbufsize); -} -%} - -%rename (Compile) Compile_wrap; -%inline %{ -bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize) -{ - return !Compile(file, errbuf, errbufsize); -} -%} - -//%feature("compactdefaultargs") CompileLine; - -%ignore CompileLine(const char *line, char *errbuf, size_t errbufsize, uval_t (idaapi*_getname)(const char *name)=NULL); - -%rename (CompileLine) CompileLine_wrap; -%inline %{ -bool CompileLine_wrap(const char *line, char *errbuf, size_t errbufsize) -{ - return !CompileLine(line, errbuf, errbufsize); -} -%} - -%include "expr.hpp" - +%ignore extfun_t; +%ignore funcset_t; +%ignore IDCFuncs; +%ignore set_idc_func; +%ignore VarLong; +%ignore VarNum; +%ignore VarString; +%ignore VarFloat; +%ignore VarFree; +%ignore calcexpr_long; +%ignore Run; +%ignore ExecuteLine; +%ignore ExecuteFile; +%ignore set_idc_func_body; +%ignore get_idc_func_body; +%ignore idc_stacksize; +%ignore idc_calldepth; +%ignore expr_printf; +%ignore expr_sprintf; +%ignore expr_printfer; +%ignore idaapi init_idc; +%ignore idaapi term_idc; +%ignore del_idc_userfuncs; +%ignore find_builtin_idc_func; +%ignore idc_lx; + +%cstring_output_maxstr_none(char *errbuf, size_t errbufsize); + +/* Compile* functions return false when error so the return */ +/* value must be negated for the error string to be returned */ +%rename (CompileEx) CompileEx_wrap; +%inline %{ +bool CompileEx_wrap(const char *file, bool del_macros, + char *errbuf, size_t errbufsize) +{ + return !CompileEx(file, del_macros, errbuf, errbufsize); +} +%} + +%rename (Compile) Compile_wrap; +%inline %{ +bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize) +{ + return !Compile(file, errbuf, errbufsize); +} +%} + +//%feature("compactdefaultargs") CompileLine; + +%ignore CompileLine(const char *line, char *errbuf, size_t errbufsize, uval_t (idaapi*_getname)(const char *name)=NULL); + +%rename (CompileLine) CompileLine_wrap; +%inline %{ +bool CompileLine_wrap(const char *line, char *errbuf, size_t errbufsize) +{ + return !CompileLine(line, errbuf, errbufsize); +} +%} + +%include "expr.hpp" + diff --git a/swig/fixup.i b/swig/fixup.i index d900cb3..17ce79c 100644 --- a/swig/fixup.i +++ b/swig/fixup.i @@ -1,6 +1,6 @@ -%ignore apply_fixup; -%ignore convert_fixups; -%ignore move_fixups; - -%include "fixup.hpp" - +%ignore apply_fixup; +%ignore convert_fixups; +%ignore move_fixups; + +%include "fixup.hpp" + diff --git a/swig/frame.i b/swig/frame.i index c5e7503..f27d766 100644 --- a/swig/frame.i +++ b/swig/frame.i @@ -1,20 +1,20 @@ -%ignore add_frame_spec_member; -%ignore del_stkvars; -%ignore calc_frame_offset; -%ignore read_regvars; -%ignore write_regvars; -%ignore del_regvars; -%ignore free_regvar; -%ignore gen_regvar_defs; -%ignore set_llabel; -%ignore get_llabel_ea; -%ignore get_llabel; -%ignore read_llabels; -%ignore write_llabels; -%ignore del_llabels; -%ignore free_llabel; -%ignore read_stkpnts; -%ignore write_stkpnts; -%ignore del_stkpnts; - -%include "frame.hpp" +%ignore add_frame_spec_member; +%ignore del_stkvars; +%ignore calc_frame_offset; +%ignore read_regvars; +%ignore write_regvars; +%ignore del_regvars; +%ignore free_regvar; +%ignore gen_regvar_defs; +%ignore set_llabel; +%ignore get_llabel_ea; +%ignore get_llabel; +%ignore read_llabels; +%ignore write_llabels; +%ignore del_llabels; +%ignore free_llabel; +%ignore read_stkpnts; +%ignore write_stkpnts; +%ignore del_stkpnts; + +%include "frame.hpp" diff --git a/swig/idaapi.i b/swig/idaapi.i index 431e558..f92d968 100644 --- a/swig/idaapi.i +++ b/swig/idaapi.i @@ -1,121 +1,121 @@ -%module(docstring="IDA Pro Plugin SDK API wrapper",directors="1") idaapi -// Suppress 'previous definition of XX' warnings -#pragma SWIG nowarn=302 -// Enable automatic docstring generation -%feature(autodoc); -%{ -#include -#define USE_DANGEROUS_FUNCTIONS 1 -#ifdef HAVE_SSIZE_T -#define _SSIZE_T_DEFINED 1 -#endif -#include "ida.hpp" -#include "idp.hpp" -#include "allins.hpp" -#include "auto.hpp" -#include "bytes.hpp" -#include "dbg.hpp" -#include "diskio.hpp" -#include "entry.hpp" -#include "enum.hpp" -#include "expr.hpp" -#include "frame.hpp" -#include "fixup.hpp" -#include "funcs.hpp" -#include "idd.hpp" -#include "ints.hpp" -#include "kernwin.hpp" -#include "lines.hpp" -#include "loader.hpp" -#include "moves.hpp" -#include "netnode.hpp" -#include "nalt.hpp" -#include "name.hpp" -#include "offset.hpp" -#include "queue.hpp" -#include "search.hpp" -#include "srarea.hpp" -#include "strlist.hpp" -#include "struct.hpp" -#include "typeinf.hpp" -#include "ua.hpp" -#include "xref.hpp" -%} - -%constant ea_t BADADDR = 0xFFFFFFFF; -%constant sel_t BADSEL = 0xFFFFFFFF; - -// Help SWIG to figure out the ulonglong type -#ifdef SWIGWIN -typedef unsigned __int64 ulonglong; -typedef __int64 longlong; -#else -typedef unsigned long long ulonglong; -typedef long long longlong; -#endif - -%include "typemaps.i" - -%include "cstring.i" -%include "carrays.i" -%include "cpointer.i" - -%include "typeconv.i" - -%include "pro.h" - -// Convert all of these -%cstring_output_maxstr_none(char *buf, size_t bufsize); - -%array_class(uchar, uchar_array); -%array_class(tid_t, tid_array); -%array_class(ea_t, ea_array); -%array_class(sel_t, sel_array); -%pointer_class(int, int_pointer); -%pointer_class(ea_t, ea_pointer); -%pointer_class(sval_t, sval_pointer); -%pointer_class(sel_t, sel_pointer); - -%include "ida.i" -%include "idd.hpp" -%include "idp.i" -%include "netnode.i" -%include "nalt.i" - -%include "allins.i" -%include "area.hpp" -%include "auto.i" -%include "bytes.i" -%include "dbg.i" -%include "diskio.i" -%include "entry.i" -%include "enum.i" -%include "expr.i" -%include "fixup.i" -%include "frame.i" -%include "funcs.i" - -%inline { -/* Small wrapper to get the inf structure */ -idainfo *get_inf_structure(void) -{ - return &inf; -} -} - -%include "ints.i" -%include "kernwin.i" -%include "lines.i" -%include "loader.i" -%include "moves.i" -%include "name.i" -%include "offset.i" -%include "queue.i" -%include "search.i" -%include "segment.i" -%include "srarea.i" -%include "strlist.i" -%include "struct.i" -%include "typeinf.i" -%include "ua.i" -%include "xref.i" +%module(docstring="IDA Pro Plugin SDK API wrapper",directors="1") idaapi +// Suppress 'previous definition of XX' warnings +#pragma SWIG nowarn=302 +// Enable automatic docstring generation +%feature(autodoc); +%{ +#include +#define USE_DANGEROUS_FUNCTIONS 1 +#ifdef HAVE_SSIZE_T +#define _SSIZE_T_DEFINED 1 +#endif +#include "ida.hpp" +#include "idp.hpp" +#include "allins.hpp" +#include "auto.hpp" +#include "bytes.hpp" +#include "dbg.hpp" +#include "diskio.hpp" +#include "entry.hpp" +#include "enum.hpp" +#include "expr.hpp" +#include "frame.hpp" +#include "fixup.hpp" +#include "funcs.hpp" +#include "idd.hpp" +#include "ints.hpp" +#include "kernwin.hpp" +#include "lines.hpp" +#include "loader.hpp" +#include "moves.hpp" +#include "netnode.hpp" +#include "nalt.hpp" +#include "name.hpp" +#include "offset.hpp" +#include "queue.hpp" +#include "search.hpp" +#include "srarea.hpp" +#include "strlist.hpp" +#include "struct.hpp" +#include "typeinf.hpp" +#include "ua.hpp" +#include "xref.hpp" +%} + +%constant ea_t BADADDR = 0xFFFFFFFF; +%constant sel_t BADSEL = 0xFFFFFFFF; + +// Help SWIG to figure out the ulonglong type +#ifdef SWIGWIN +typedef unsigned __int64 ulonglong; +typedef __int64 longlong; +#else +typedef unsigned long long ulonglong; +typedef long long longlong; +#endif + +%include "typemaps.i" + +%include "cstring.i" +%include "carrays.i" +%include "cpointer.i" + +%include "typeconv.i" + +%include "pro.h" + +// Convert all of these +%cstring_output_maxstr_none(char *buf, size_t bufsize); + +%array_class(uchar, uchar_array); +%array_class(tid_t, tid_array); +%array_class(ea_t, ea_array); +%array_class(sel_t, sel_array); +%pointer_class(int, int_pointer); +%pointer_class(ea_t, ea_pointer); +%pointer_class(sval_t, sval_pointer); +%pointer_class(sel_t, sel_pointer); + +%include "ida.i" +%include "idd.hpp" +%include "idp.i" +%include "netnode.i" +%include "nalt.i" + +%include "allins.i" +%include "area.hpp" +%include "auto.i" +%include "bytes.i" +%include "dbg.i" +%include "diskio.i" +%include "entry.i" +%include "enum.i" +%include "expr.i" +%include "fixup.i" +%include "frame.i" +%include "funcs.i" + +%inline { +/* Small wrapper to get the inf structure */ +idainfo *get_inf_structure(void) +{ + return &inf; +} +} + +%include "ints.i" +%include "kernwin.i" +%include "lines.i" +%include "loader.i" +%include "moves.i" +%include "name.i" +%include "offset.i" +%include "queue.i" +%include "search.i" +%include "segment.i" +%include "srarea.i" +%include "strlist.i" +%include "struct.i" +%include "typeinf.i" +%include "ua.i" +%include "xref.i" diff --git a/swig/idp.i b/swig/idp.i index 85c9b6e..7e54c98 100644 --- a/swig/idp.i +++ b/swig/idp.i @@ -1,253 +1,253 @@ -%ignore gen_idb_event; - -// Ignore the function pointers -%ignore asm_t::checkarg_dispatch; -%ignore asm_t::func_header; -%ignore asm_t::func_footer; -%ignore asm_t::get_type_name; -%ignore processor_t::notify; -%ignore processor_t::header; -%ignore processor_t::footer; -%ignore processor_t::segstart; -%ignore processor_t::segend; -%ignore processor_t::assumes; -%ignore processor_t::u_ana; -%ignore processor_t::u_emu; -%ignore processor_t::u_out; -%ignore processor_t::u_outop; -%ignore processor_t::d_out; -%ignore processor_t::cmp_opnd; -%ignore processor_t::can_have_type; -%ignore processor_t::getreg; -%ignore processor_t::is_far_jump; -%ignore processor_t::translate; -%ignore processor_t::realcvt; -%ignore processor_t::is_switch; -%ignore processor_t::gen_map_file; -%ignore processor_t::extract_address; -%ignore processor_t::is_sp_based; -%ignore processor_t::create_func_frame; -%ignore processor_t::get_frame_retsize; -%ignore processor_t::gen_stkvar_def; -%ignore processor_t::u_outspec; -%ignore processor_t::is_align_insn; - -%include "idp.hpp" - -%feature("director") IDB_Hooks; - -%inline %{ - -int idaapi IDB_Callback(void *ud, int notification_code, va_list va); -class IDB_Hooks -{ -public: - virtual ~IDB_Hooks() {}; - - bool hook() { return hook_to_notification_point(HT_IDB, IDB_Callback, this); } - bool unhook() { return unhook_from_notification_point(HT_IDB, IDB_Callback, this); } - /* Hook functions to override in Python */ - virtual int byte_patched(ea_t ea) { return 0; }; - virtual int cmt_changed(ea_t, bool repeatable_cmt) { return 0; }; - virtual int ti_changed(ea_t ea, const type_t *type, const p_list *fnames) { msg("ti_changed hook not supported yet\n"); return 0; }; - virtual int op_ti_changed(ea_t ea, int n, const type_t *type, const p_list *fnames) { msg("op_ti_changed hook not supported yet\n"); return 0; }; - virtual int op_type_changed(ea_t ea, int n) { return 0; }; - virtual int enum_created(enum_t id) { return 0; }; - virtual int enum_deleted(enum_t id) { return 0; }; - virtual int enum_bf_changed(enum_t id) { return 0; }; - virtual int enum_renamed(enum_t id) { return 0; }; - virtual int enum_cmt_changed(enum_t id) { return 0; }; - virtual int enum_const_created(enum_t id, const_t cid) { return 0; }; - virtual int enum_const_deleted(enum_t id, const_t cid) { return 0; }; - virtual int struc_created(tid_t struc_id) { return 0; }; - virtual int struc_deleted(tid_t struc_id) { return 0; }; - virtual int struc_renamed(struc_t *sptr) { return 0; }; - virtual int struc_expanded(struc_t *sptr) { return 0; }; - virtual int struc_cmt_changed(tid_t struc_id) { return 0; }; - virtual int struc_member_created(struc_t *sptr, member_t *mptr) { return 0; }; - virtual int struc_member_deleted(struc_t *sptr, tid_t member_id) { return 0; }; - virtual int struc_member_renamed(struc_t *sptr, member_t *mptr) { return 0; }; - virtual int struc_member_changed(struc_t *sptr, member_t *mptr) { return 0; }; - virtual int thunk_func_created(func_t *pfn) { return 0; }; - virtual int func_tail_appended(func_t *pfn, func_t *tail) { return 0; }; - virtual int func_tail_removed(func_t *pfn, ea_t tail_ea) { return 0; }; - virtual int tail_owner_changed(func_t *tail, ea_t owner_func) { return 0; }; - virtual int func_noret_changed(func_t *pfn) { return 0; }; - virtual int segm_added(segment_t *s) { return 0; }; - virtual int segm_deleted(ea_t startEA) { return 0; }; - virtual int segm_start_changed(segment_t *s) { return 0; }; - virtual int segm_end_changed(segment_t *s) { return 0; }; - virtual int segm_moved(ea_t from, ea_t to, asize_t size) { return 0; }; -}; - -int idaapi IDB_Callback(void *ud, int notification_code, va_list va) -{ - class IDB_Hooks *proxy = (class IDB_Hooks *)ud; - ea_t ea, ea2; - bool repeatable_cmt; - type_t *type; - /* p_list *fnames; */ - int n; - enum_t id; - const_t cid; - tid_t struc_id; - struc_t *sptr; - member_t *mptr; - tid_t member_id; - func_t *pfn; - func_t *tail; - segment_t *seg; - asize_t size; - - try { - switch (notification_code) - { - case idb_event::byte_patched: - ea = va_arg(va, ea_t); - return proxy->byte_patched(ea); - - case idb_event::cmt_changed: - ea = va_arg(va, ea_t); - repeatable_cmt = va_arg(va, int); - return proxy->cmt_changed(ea, repeatable_cmt); -#if 0 - case idb_event::ti_changed: - ea = va_arg(va, ea_t); - type = va_arg(va, type_t *); - fnames = va_arg(va, fnames); - return proxy->ti_changed(ea, type, fnames); - - case idb_event::op_ti_changed: - ea = va_arg(va, ea_t); - n = va_arg(va, int); - type = va_arg(va, type_t *); - fnames = va_arg(va, fnames); - return proxy->op_ti_changed(ea, n, type, fnames); -#endif - case idb_event::op_type_changed: - ea = va_arg(va, ea_t); - n = va_arg(va, int); - return proxy->op_type_changed(ea, n); - - case idb_event::enum_created: - id = va_arg(va, enum_t); - return proxy->enum_created(id); - - case idb_event::enum_deleted: - id = va_arg(va, enum_t); - return proxy->enum_deleted(id); - - case idb_event::enum_bf_changed: - id = va_arg(va, enum_t); - return proxy->enum_bf_changed(id); - - case idb_event::enum_cmt_changed: - id = va_arg(va, enum_t); - return proxy->enum_cmt_changed(id); - - case idb_event::enum_const_created: - id = va_arg(va, enum_t); - cid = va_arg(va, const_t); - return proxy->enum_const_created(id, cid); - - case idb_event::enum_const_deleted: - id = va_arg(va, enum_t); - cid = va_arg(va, const_t); - return proxy->enum_const_deleted(id, cid); - - case idb_event::struc_created: - struc_id = va_arg(va, tid_t); - return proxy->struc_created(struc_id); - - case idb_event::struc_deleted: - struc_id = va_arg(va, tid_t); - return proxy->struc_deleted(struc_id); - - case idb_event::struc_renamed: - sptr = va_arg(va, struc_t *); - return proxy->struc_renamed(sptr); - - case idb_event::struc_expanded: - sptr = va_arg(va, struc_t *); - return proxy->struc_expanded(sptr); - - case idb_event::struc_cmt_changed: - struc_id = va_arg(va, tid_t); - return proxy->struc_cmt_changed(struc_id); - - case idb_event::struc_member_created: - sptr = va_arg(va, struc_t *); - mptr = va_arg(va, member_t *); - return proxy->struc_member_created(sptr, mptr); - - case idb_event::struc_member_deleted: - sptr = va_arg(va, struc_t *); - member_id = va_arg(va, tid_t); - return proxy->struc_member_deleted(sptr, member_id); - - case idb_event::struc_member_renamed: - sptr = va_arg(va, struc_t *); - mptr = va_arg(va, member_t *); - return proxy->struc_member_renamed(sptr, mptr); - - case idb_event::struc_member_changed: - sptr = va_arg(va, struc_t *); - mptr = va_arg(va, member_t *); - return proxy->struc_member_changed(sptr, mptr); - - case idb_event::thunk_func_created: - pfn = va_arg(va, func_t *); - return proxy->thunk_func_created(pfn); - - case idb_event::func_tail_appended: - pfn = va_arg(va, func_t *); - tail = va_arg(va, func_t *); - return proxy->func_tail_appended(pfn, tail); - - case idb_event::func_tail_removed: - pfn = va_arg(va, func_t *); - ea = va_arg(va, ea_t); - return proxy->func_tail_removed(pfn, ea); - - case idb_event::tail_owner_changed: - tail = va_arg(va, func_t *); - ea = va_arg(va, ea_t); - return proxy->tail_owner_changed(tail, ea); - - case idb_event::func_noret_changed: - pfn = va_arg(va, func_t *); - return proxy->func_noret_changed(pfn); - - case idb_event::segm_added: - seg = va_arg(va, segment_t *); - return proxy->segm_added(seg); - - case idb_event::segm_deleted: - ea = va_arg(va, ea_t); - return proxy->segm_deleted(ea); - - case idb_event::segm_start_changed: - seg = va_arg(va, segment_t *); - return proxy->segm_start_changed(seg); - - case idb_event::segm_end_changed: - seg = va_arg(va, segment_t *); - return proxy->segm_end_changed(seg); - - case idb_event::segm_moved: - ea = va_arg(va, ea_t); - ea2 = va_arg(va, ea_t); - size = va_arg(va, asize_t); - return proxy->segm_moved(ea, ea2, size); - } - } - catch (Swig::DirectorException &e) - { - msg("Exception in IDP Hook function:\n"); - if (PyErr_Occurred()) - { - PyErr_Print(); - } - } -} -%} +%ignore gen_idb_event; + +// Ignore the function pointers +%ignore asm_t::checkarg_dispatch; +%ignore asm_t::func_header; +%ignore asm_t::func_footer; +%ignore asm_t::get_type_name; +%ignore processor_t::notify; +%ignore processor_t::header; +%ignore processor_t::footer; +%ignore processor_t::segstart; +%ignore processor_t::segend; +%ignore processor_t::assumes; +%ignore processor_t::u_ana; +%ignore processor_t::u_emu; +%ignore processor_t::u_out; +%ignore processor_t::u_outop; +%ignore processor_t::d_out; +%ignore processor_t::cmp_opnd; +%ignore processor_t::can_have_type; +%ignore processor_t::getreg; +%ignore processor_t::is_far_jump; +%ignore processor_t::translate; +%ignore processor_t::realcvt; +%ignore processor_t::is_switch; +%ignore processor_t::gen_map_file; +%ignore processor_t::extract_address; +%ignore processor_t::is_sp_based; +%ignore processor_t::create_func_frame; +%ignore processor_t::get_frame_retsize; +%ignore processor_t::gen_stkvar_def; +%ignore processor_t::u_outspec; +%ignore processor_t::is_align_insn; + +%include "idp.hpp" + +%feature("director") IDB_Hooks; + +%inline %{ + +int idaapi IDB_Callback(void *ud, int notification_code, va_list va); +class IDB_Hooks +{ +public: + virtual ~IDB_Hooks() {}; + + bool hook() { return hook_to_notification_point(HT_IDB, IDB_Callback, this); } + bool unhook() { return unhook_from_notification_point(HT_IDB, IDB_Callback, this); } + /* Hook functions to override in Python */ + virtual int byte_patched(ea_t ea) { return 0; }; + virtual int cmt_changed(ea_t, bool repeatable_cmt) { return 0; }; + virtual int ti_changed(ea_t ea, const type_t *type, const p_list *fnames) { msg("ti_changed hook not supported yet\n"); return 0; }; + virtual int op_ti_changed(ea_t ea, int n, const type_t *type, const p_list *fnames) { msg("op_ti_changed hook not supported yet\n"); return 0; }; + virtual int op_type_changed(ea_t ea, int n) { return 0; }; + virtual int enum_created(enum_t id) { return 0; }; + virtual int enum_deleted(enum_t id) { return 0; }; + virtual int enum_bf_changed(enum_t id) { return 0; }; + virtual int enum_renamed(enum_t id) { return 0; }; + virtual int enum_cmt_changed(enum_t id) { return 0; }; + virtual int enum_const_created(enum_t id, const_t cid) { return 0; }; + virtual int enum_const_deleted(enum_t id, const_t cid) { return 0; }; + virtual int struc_created(tid_t struc_id) { return 0; }; + virtual int struc_deleted(tid_t struc_id) { return 0; }; + virtual int struc_renamed(struc_t *sptr) { return 0; }; + virtual int struc_expanded(struc_t *sptr) { return 0; }; + virtual int struc_cmt_changed(tid_t struc_id) { return 0; }; + virtual int struc_member_created(struc_t *sptr, member_t *mptr) { return 0; }; + virtual int struc_member_deleted(struc_t *sptr, tid_t member_id) { return 0; }; + virtual int struc_member_renamed(struc_t *sptr, member_t *mptr) { return 0; }; + virtual int struc_member_changed(struc_t *sptr, member_t *mptr) { return 0; }; + virtual int thunk_func_created(func_t *pfn) { return 0; }; + virtual int func_tail_appended(func_t *pfn, func_t *tail) { return 0; }; + virtual int func_tail_removed(func_t *pfn, ea_t tail_ea) { return 0; }; + virtual int tail_owner_changed(func_t *tail, ea_t owner_func) { return 0; }; + virtual int func_noret_changed(func_t *pfn) { return 0; }; + virtual int segm_added(segment_t *s) { return 0; }; + virtual int segm_deleted(ea_t startEA) { return 0; }; + virtual int segm_start_changed(segment_t *s) { return 0; }; + virtual int segm_end_changed(segment_t *s) { return 0; }; + virtual int segm_moved(ea_t from, ea_t to, asize_t size) { return 0; }; +}; + +int idaapi IDB_Callback(void *ud, int notification_code, va_list va) +{ + class IDB_Hooks *proxy = (class IDB_Hooks *)ud; + ea_t ea, ea2; + bool repeatable_cmt; + type_t *type; + /* p_list *fnames; */ + int n; + enum_t id; + const_t cid; + tid_t struc_id; + struc_t *sptr; + member_t *mptr; + tid_t member_id; + func_t *pfn; + func_t *tail; + segment_t *seg; + asize_t size; + + try { + switch (notification_code) + { + case idb_event::byte_patched: + ea = va_arg(va, ea_t); + return proxy->byte_patched(ea); + + case idb_event::cmt_changed: + ea = va_arg(va, ea_t); + repeatable_cmt = va_arg(va, int); + return proxy->cmt_changed(ea, repeatable_cmt); +#if 0 + case idb_event::ti_changed: + ea = va_arg(va, ea_t); + type = va_arg(va, type_t *); + fnames = va_arg(va, fnames); + return proxy->ti_changed(ea, type, fnames); + + case idb_event::op_ti_changed: + ea = va_arg(va, ea_t); + n = va_arg(va, int); + type = va_arg(va, type_t *); + fnames = va_arg(va, fnames); + return proxy->op_ti_changed(ea, n, type, fnames); +#endif + case idb_event::op_type_changed: + ea = va_arg(va, ea_t); + n = va_arg(va, int); + return proxy->op_type_changed(ea, n); + + case idb_event::enum_created: + id = va_arg(va, enum_t); + return proxy->enum_created(id); + + case idb_event::enum_deleted: + id = va_arg(va, enum_t); + return proxy->enum_deleted(id); + + case idb_event::enum_bf_changed: + id = va_arg(va, enum_t); + return proxy->enum_bf_changed(id); + + case idb_event::enum_cmt_changed: + id = va_arg(va, enum_t); + return proxy->enum_cmt_changed(id); + + case idb_event::enum_const_created: + id = va_arg(va, enum_t); + cid = va_arg(va, const_t); + return proxy->enum_const_created(id, cid); + + case idb_event::enum_const_deleted: + id = va_arg(va, enum_t); + cid = va_arg(va, const_t); + return proxy->enum_const_deleted(id, cid); + + case idb_event::struc_created: + struc_id = va_arg(va, tid_t); + return proxy->struc_created(struc_id); + + case idb_event::struc_deleted: + struc_id = va_arg(va, tid_t); + return proxy->struc_deleted(struc_id); + + case idb_event::struc_renamed: + sptr = va_arg(va, struc_t *); + return proxy->struc_renamed(sptr); + + case idb_event::struc_expanded: + sptr = va_arg(va, struc_t *); + return proxy->struc_expanded(sptr); + + case idb_event::struc_cmt_changed: + struc_id = va_arg(va, tid_t); + return proxy->struc_cmt_changed(struc_id); + + case idb_event::struc_member_created: + sptr = va_arg(va, struc_t *); + mptr = va_arg(va, member_t *); + return proxy->struc_member_created(sptr, mptr); + + case idb_event::struc_member_deleted: + sptr = va_arg(va, struc_t *); + member_id = va_arg(va, tid_t); + return proxy->struc_member_deleted(sptr, member_id); + + case idb_event::struc_member_renamed: + sptr = va_arg(va, struc_t *); + mptr = va_arg(va, member_t *); + return proxy->struc_member_renamed(sptr, mptr); + + case idb_event::struc_member_changed: + sptr = va_arg(va, struc_t *); + mptr = va_arg(va, member_t *); + return proxy->struc_member_changed(sptr, mptr); + + case idb_event::thunk_func_created: + pfn = va_arg(va, func_t *); + return proxy->thunk_func_created(pfn); + + case idb_event::func_tail_appended: + pfn = va_arg(va, func_t *); + tail = va_arg(va, func_t *); + return proxy->func_tail_appended(pfn, tail); + + case idb_event::func_tail_removed: + pfn = va_arg(va, func_t *); + ea = va_arg(va, ea_t); + return proxy->func_tail_removed(pfn, ea); + + case idb_event::tail_owner_changed: + tail = va_arg(va, func_t *); + ea = va_arg(va, ea_t); + return proxy->tail_owner_changed(tail, ea); + + case idb_event::func_noret_changed: + pfn = va_arg(va, func_t *); + return proxy->func_noret_changed(pfn); + + case idb_event::segm_added: + seg = va_arg(va, segment_t *); + return proxy->segm_added(seg); + + case idb_event::segm_deleted: + ea = va_arg(va, ea_t); + return proxy->segm_deleted(ea); + + case idb_event::segm_start_changed: + seg = va_arg(va, segment_t *); + return proxy->segm_start_changed(seg); + + case idb_event::segm_end_changed: + seg = va_arg(va, segment_t *); + return proxy->segm_end_changed(seg); + + case idb_event::segm_moved: + ea = va_arg(va, ea_t); + ea2 = va_arg(va, ea_t); + size = va_arg(va, asize_t); + return proxy->segm_moved(ea, ea2, size); + } + } + catch (Swig::DirectorException &e) + { + msg("Exception in IDP Hook function:\n"); + if (PyErr_Occurred()) + { + PyErr_Print(); + } + } +} +%} diff --git a/swig/ints.i b/swig/ints.i index 5a57a31..46b5ef8 100644 --- a/swig/ints.i +++ b/swig/ints.i @@ -1,6 +1,6 @@ -// Kernel-only symbols -%ignore init_predefs; -%ignore term_predefs; - -%include "ints.i" - +// Kernel-only symbols +%ignore init_predefs; +%ignore term_predefs; + +%include "ints.i" + diff --git a/swig/lines.i b/swig/lines.i index 6643f82..2fa80c7 100644 --- a/swig/lines.i +++ b/swig/lines.i @@ -1,63 +1,63 @@ -// Convert this for ver 4.8 tag_remove() -%cstring_output_maxstr_none(char *buf, int bufsize); - -// FIXME: These should be fixed -%ignore tag_on; -%ignore tag_off; -%ignore tag_addchr; -%ignore tag_addstr; -%ignore tag_addr; -%ignore tag_advance; -%ignore tag_skipcodes; -%ignore tag_skipcode; -%ignore set_user_defined_prefix; -%ignore get_user_defined_prefix; -// Ignore va_list versions -%ignore printf_line_v; -%ignore gen_colored_cmt_line_v; -%ignore gen_cmt_line_v; -%ignore add_long_cmt_v; -%ignore describex; -// Kernel-only and unexported symbols -%ignore init_sourcefiles; -%ignore save_sourcefiles; -%ignore term_sourcefiles; -%ignore move_sourcefiles; -%ignore gen_xref_lines; -%ignore ml_getcmt_t; -%ignore ml_getnam_t; -%ignore ml_genxrf_t; -%ignore ml_saver_t; -%ignore setup_makeline; -%ignore MAKELINE_NONE; -%ignore MAKELINE_BINPREF; -%ignore MAKELINE_VOID; -%ignore MAKELINE_STACK; -%ignore save_line_in_array; -%ignore init_lines_array; -%ignore finish_makeline; -%ignore generate_disassembly; -%ignore gen_labeled_line; -%ignore gen_lname_line; -%ignore makeline_producer_t; -%ignore set_makeline_producer; -%ignore closing_comment; -%ignore close_comment; -%ignore copy_extra_lines; -%ignore ExtraLines; -%ignore ExtraKill; -%ignore ExtraFree; -%ignore Dumper; -%ignore init_lines; -%ignore save_lines; -%ignore term_lines; -%ignore gl_namedone; -%ignore data_as_stack; -%ignore calc_stack_alignment; -%ignore align_down_to_stack; -%ignore align_up_to_stack; -%ignore remove_spaces; - -%include "lines.hpp" - -%clear(char *buf, int bufsize); +// Convert this for ver 4.8 tag_remove() +%cstring_output_maxstr_none(char *buf, int bufsize); + +// FIXME: These should be fixed +%ignore tag_on; +%ignore tag_off; +%ignore tag_addchr; +%ignore tag_addstr; +%ignore tag_addr; +%ignore tag_advance; +%ignore tag_skipcodes; +%ignore tag_skipcode; +%ignore set_user_defined_prefix; +%ignore get_user_defined_prefix; +// Ignore va_list versions +%ignore printf_line_v; +%ignore gen_colored_cmt_line_v; +%ignore gen_cmt_line_v; +%ignore add_long_cmt_v; +%ignore describex; +// Kernel-only and unexported symbols +%ignore init_sourcefiles; +%ignore save_sourcefiles; +%ignore term_sourcefiles; +%ignore move_sourcefiles; +%ignore gen_xref_lines; +%ignore ml_getcmt_t; +%ignore ml_getnam_t; +%ignore ml_genxrf_t; +%ignore ml_saver_t; +%ignore setup_makeline; +%ignore MAKELINE_NONE; +%ignore MAKELINE_BINPREF; +%ignore MAKELINE_VOID; +%ignore MAKELINE_STACK; +%ignore save_line_in_array; +%ignore init_lines_array; +%ignore finish_makeline; +%ignore generate_disassembly; +%ignore gen_labeled_line; +%ignore gen_lname_line; +%ignore makeline_producer_t; +%ignore set_makeline_producer; +%ignore closing_comment; +%ignore close_comment; +%ignore copy_extra_lines; +%ignore ExtraLines; +%ignore ExtraKill; +%ignore ExtraFree; +%ignore Dumper; +%ignore init_lines; +%ignore save_lines; +%ignore term_lines; +%ignore gl_namedone; +%ignore data_as_stack; +%ignore calc_stack_alignment; +%ignore align_down_to_stack; +%ignore align_up_to_stack; +%ignore remove_spaces; + +%include "lines.hpp" + +%clear(char *buf, int bufsize); diff --git a/swig/moves.i b/swig/moves.i index b4154b7..fff9e2c 100644 --- a/swig/moves.i +++ b/swig/moves.i @@ -1,11 +1,11 @@ - -// Ignore kernel only symbols -%ignore init_marks; -%ignore term_marks; -%ignore change_jumps_stack_format; -%ignore move_marks; -%ignore loc_gtag; -%ignore DEFINE_CURLOC_HELPERS; -%ignore DEFINE_LOCATION_HELPERS; - + +// Ignore kernel only symbols +%ignore init_marks; +%ignore term_marks; +%ignore change_jumps_stack_format; +%ignore move_marks; +%ignore loc_gtag; +%ignore DEFINE_CURLOC_HELPERS; +%ignore DEFINE_LOCATION_HELPERS; + %include "moves.hpp" \ No newline at end of file diff --git a/swig/name.i b/swig/name.i index 1151ee9..60165b1 100644 --- a/swig/name.i +++ b/swig/name.i @@ -1,33 +1,33 @@ -%cstring_output_maxstr_none(char *buf, int bufsize); - -%cstring_bounded_output(char *dstname, MAXSTR); -%cstring_bounded_output(char *buf, MAXSTR); - -// This is for get_name_value's output value -%apply unsigned long *OUTPUT { uval_t *value }; - -// FIXME: These should be fixed -%ignore append_struct_fields; -%ignore get_struct_operand; -%ignore set_debug_names; -%ignore get_debug_name; -%ignore nameVa; - -// Unexported & kernel-only -%ignore get_short_name; -%ignore get_long_name; -%ignore get_colored_short_name; -%ignore get_colored_long_name; -%ignore addDummyName; -%ignore convert_debug_names_to_normal; -%ignore convert_name_formats; -%ignore showhide_name; -%ignore clear_lname_bit; -%ignore fix_new_name; -%ignore rename; -%ignore move_names; -%ignore is_exit_name; -%ignore dummy_name_ea; - -%include "name.hpp" - +%cstring_output_maxstr_none(char *buf, int bufsize); + +%cstring_bounded_output(char *dstname, MAXSTR); +%cstring_bounded_output(char *buf, MAXSTR); + +// This is for get_name_value's output value +%apply unsigned long *OUTPUT { uval_t *value }; + +// FIXME: These should be fixed +%ignore append_struct_fields; +%ignore get_struct_operand; +%ignore set_debug_names; +%ignore get_debug_name; +%ignore nameVa; + +// Unexported & kernel-only +%ignore get_short_name; +%ignore get_long_name; +%ignore get_colored_short_name; +%ignore get_colored_long_name; +%ignore addDummyName; +%ignore convert_debug_names_to_normal; +%ignore convert_name_formats; +%ignore showhide_name; +%ignore clear_lname_bit; +%ignore fix_new_name; +%ignore rename; +%ignore move_names; +%ignore is_exit_name; +%ignore dummy_name_ea; + +%include "name.hpp" + diff --git a/swig/netnode.i b/swig/netnode.i index 3b073c6..a8c7747 100644 --- a/swig/netnode.i +++ b/swig/netnode.i @@ -1,84 +1,84 @@ -// Ignore kernel only & unexported symbols -%ignore netlink; - -%ignore RootNode; -%ignore for_all_supvals; -%ignore netErrorHandler; -%ignore netnode_key_count; - -%ignore netnode_check; -%ignore netnode_kill; -%ignore netnode_start; -%ignore netnode_end; -%ignore netnode_next; -%ignore netnode_prev; -%ignore netnode_name; -%ignore netnode_rename; -%ignore netnode_valobj; -%ignore netnode_valstr; -%ignore netnode_set; -%ignore netnode_delvalue; -%ignore netnode_altval; -%ignore netnode_charval; -%ignore netnode_altval_idx8; -%ignore netnode_charval_idx8; -%ignore netnode_supval; -%ignore netnode_supstr; -%ignore netnode_supset; -%ignore netnode_supdel; -%ignore netnode_sup1st; -%ignore netnode_supnxt; -%ignore netnode_suplast; -%ignore netnode_supprev; -%ignore netnode_supval_idx8; -%ignore netnode_supstr_idx8; -%ignore netnode_supset_idx8; -%ignore netnode_supdel_idx8; -%ignore netnode_sup1st_idx8; -%ignore netnode_supnxt_idx8; -%ignore netnode_suplast_idx8; -%ignore netnode_supprev_idx8; -%ignore netnode_supdel_all; -%ignore netnode_hashval; -%ignore netnode_hashstr; -%ignore netnode_hashval_long; -%ignore netnode_hashset; -%ignore netnode_hashdel; -%ignore netnode_hash1st; -%ignore netnode_hashnxt; -%ignore netnode_hashlast; -%ignore netnode_hashprev; -%ignore netnode_blobsize; -%ignore netnode_getblob; -%ignore netnode_setblob; -%ignore netnode_delblob; -%ignore netnode_inited; -%ignore netnode_copy; -%ignore netnode_altshift; -%ignore netnode_charshift; -%ignore netnode_supshift; -%ignore netnode_altadjust; -%ignore netnode_exist; - -%ignore netnode::truncate_zero_pages; -%ignore netnode::append_zero_pages; -%ignore netnode::createbase; -%ignore netnode::checkbase; -%ignore netnode::set_close_flag; -%ignore netnode::reserve_nodes; -%ignore netnode::validate; -%ignore netnode::upgrade; -%ignore netnode::compress; -%ignore netnode::inited; -%ignore netnode::init; -%ignore netnode::flush; -%ignore netnode::term; -%ignore netnode::killbase; -%ignore netnode::getdrive; -%ignore netnode::getgraph; -%ignore netnode::registerbase; -%ignore netnode::setbase; - -%ignore netnode::altadjust; - +// Ignore kernel only & unexported symbols +%ignore netlink; + +%ignore RootNode; +%ignore for_all_supvals; +%ignore netErrorHandler; +%ignore netnode_key_count; + +%ignore netnode_check; +%ignore netnode_kill; +%ignore netnode_start; +%ignore netnode_end; +%ignore netnode_next; +%ignore netnode_prev; +%ignore netnode_name; +%ignore netnode_rename; +%ignore netnode_valobj; +%ignore netnode_valstr; +%ignore netnode_set; +%ignore netnode_delvalue; +%ignore netnode_altval; +%ignore netnode_charval; +%ignore netnode_altval_idx8; +%ignore netnode_charval_idx8; +%ignore netnode_supval; +%ignore netnode_supstr; +%ignore netnode_supset; +%ignore netnode_supdel; +%ignore netnode_sup1st; +%ignore netnode_supnxt; +%ignore netnode_suplast; +%ignore netnode_supprev; +%ignore netnode_supval_idx8; +%ignore netnode_supstr_idx8; +%ignore netnode_supset_idx8; +%ignore netnode_supdel_idx8; +%ignore netnode_sup1st_idx8; +%ignore netnode_supnxt_idx8; +%ignore netnode_suplast_idx8; +%ignore netnode_supprev_idx8; +%ignore netnode_supdel_all; +%ignore netnode_hashval; +%ignore netnode_hashstr; +%ignore netnode_hashval_long; +%ignore netnode_hashset; +%ignore netnode_hashdel; +%ignore netnode_hash1st; +%ignore netnode_hashnxt; +%ignore netnode_hashlast; +%ignore netnode_hashprev; +%ignore netnode_blobsize; +%ignore netnode_getblob; +%ignore netnode_setblob; +%ignore netnode_delblob; +%ignore netnode_inited; +%ignore netnode_copy; +%ignore netnode_altshift; +%ignore netnode_charshift; +%ignore netnode_supshift; +%ignore netnode_altadjust; +%ignore netnode_exist; + +%ignore netnode::truncate_zero_pages; +%ignore netnode::append_zero_pages; +%ignore netnode::createbase; +%ignore netnode::checkbase; +%ignore netnode::set_close_flag; +%ignore netnode::reserve_nodes; +%ignore netnode::validate; +%ignore netnode::upgrade; +%ignore netnode::compress; +%ignore netnode::inited; +%ignore netnode::init; +%ignore netnode::flush; +%ignore netnode::term; +%ignore netnode::killbase; +%ignore netnode::getdrive; +%ignore netnode::getgraph; +%ignore netnode::registerbase; +%ignore netnode::setbase; + +%ignore netnode::altadjust; + %include "netnode.hpp" \ No newline at end of file diff --git a/swig/offset.i b/swig/offset.i index fb277df..ca039de 100644 --- a/swig/offset.i +++ b/swig/offset.i @@ -1,3 +1,3 @@ -%ignore calc_probable_base; - -%include "offset.hpp" +%ignore calc_probable_base; + +%include "offset.hpp" diff --git a/swig/queue.i b/swig/queue.i index f7e4947..96efd23 100644 --- a/swig/queue.i +++ b/swig/queue.i @@ -1,12 +1,12 @@ -// TODO: This could be wrapped. -%ignore QueueGet; - -// Kernel-only & unexported symbols -%ignore QueueDel; -%ignore init_queue; -%ignore save_queue; -%ignore term_queue; -%ignore move_problems; -%ignore queue_del; - +// TODO: This could be wrapped. +%ignore QueueGet; + +// Kernel-only & unexported symbols +%ignore QueueDel; +%ignore init_queue; +%ignore save_queue; +%ignore term_queue; +%ignore move_problems; +%ignore queue_del; + %include "queue.hpp" \ No newline at end of file diff --git a/swig/search.i b/swig/search.i index c428ad1..e553e02 100644 --- a/swig/search.i +++ b/swig/search.i @@ -1,14 +1,14 @@ -%apply int * OUTPUT { int *opnum }; - -// Do not generate overloaded versions for default arguments -%feature("compactdefaultargs") find_error; -%feature("compactdefaultargs") find_notype; -%feature("compactdefaultargs") find_void; -%feature("compactdefaultargs") find_imm; - -// FIXME: search() should be checked and enabled -%ignore search; -%ignore user2bin; - -%include "search.hpp" -%clear int *opnum; +%apply int * OUTPUT { int *opnum }; + +// Do not generate overloaded versions for default arguments +%feature("compactdefaultargs") find_error; +%feature("compactdefaultargs") find_notype; +%feature("compactdefaultargs") find_void; +%feature("compactdefaultargs") find_imm; + +// FIXME: search() should be checked and enabled +%ignore search; +%ignore user2bin; + +%include "search.hpp" +%clear int *opnum; diff --git a/swig/segment.i b/swig/segment.i index f5df0d9..a1356aa 100644 --- a/swig/segment.i +++ b/swig/segment.i @@ -1,33 +1,33 @@ -// Ignore functions with callbacks -%ignore enumerate_selectors; -%ignore enumerate_segments_with_selector; - -// Kernel-only -%ignore init_groups; -%ignore save_groups; -%ignore term_groups; -%ignore vset_segm_name; -%ignore get_segm_expr; -%ignore get_based_segm_expr; -%ignore createSegmentation; -%ignore initSegment; -%ignore save_segments; -%ignore termSegment; -%ignore DeleteAllSegments; -%ignore delete_debug_segments; -%ignore is_debugger_segm; -%ignore is_ephemeral_segm; -%ignore correct_address; - -%include "segment.hpp" - -%inline %{ - sel_t get_defsr(segment_t *s, int reg) - { - return s->defsr[reg]; - } - void set_defsr(segment_t *s, int reg, sel_t value) - { - s->defsr[reg] = value; - } -%} +// Ignore functions with callbacks +%ignore enumerate_selectors; +%ignore enumerate_segments_with_selector; + +// Kernel-only +%ignore init_groups; +%ignore save_groups; +%ignore term_groups; +%ignore vset_segm_name; +%ignore get_segm_expr; +%ignore get_based_segm_expr; +%ignore createSegmentation; +%ignore initSegment; +%ignore save_segments; +%ignore termSegment; +%ignore DeleteAllSegments; +%ignore delete_debug_segments; +%ignore is_debugger_segm; +%ignore is_ephemeral_segm; +%ignore correct_address; + +%include "segment.hpp" + +%inline %{ + sel_t get_defsr(segment_t *s, int reg) + { + return s->defsr[reg]; + } + void set_defsr(segment_t *s, int reg, sel_t value) + { + s->defsr[reg] = value; + } +%} diff --git a/swig/srarea.i b/swig/srarea.i index 1465553..e747a31 100644 --- a/swig/srarea.i +++ b/swig/srarea.i @@ -1,21 +1,21 @@ -// Ignore kernel-only symbols -%ignore createSRarea; -%ignore killSRareas; -%ignore delSRarea; -%ignore SRareaStart; -%ignore SRareaEnd; -%ignore repairSRarea; -%ignore SRinit; -%ignore SRterm; -%ignore SRsave; - -#define R_es 29 -#define R_cs 30 -#define R_ss 31 -#define R_ds 32 -#define R_fs 33 -#define R_gs 34 - -%feature("compactdefaultargs") splitSRarea1; - -%include "srarea.hpp" +// Ignore kernel-only symbols +%ignore createSRarea; +%ignore killSRareas; +%ignore delSRarea; +%ignore SRareaStart; +%ignore SRareaEnd; +%ignore repairSRarea; +%ignore SRinit; +%ignore SRterm; +%ignore SRsave; + +#define R_es 29 +#define R_cs 30 +#define R_ss 31 +#define R_ds 32 +#define R_fs 33 +#define R_gs 34 + +%feature("compactdefaultargs") splitSRarea1; + +%include "srarea.hpp" diff --git a/swig/struct.i b/swig/struct.i index c375615..db26fc4 100644 --- a/swig/struct.i +++ b/swig/struct.i @@ -1,14 +1,14 @@ -// Kernel-only symbols -%ignore init_struc; -%ignore save_struc; -%ignore term_struc; - -%feature("compactdefaultargs") add_struc; - -%include "struct.hpp" -// Add a get_member() member function to struc_t. -// This helps to access the members array in the class. -%extend struc_t { - member_t * get_member(int index) { return &(self->members[index]); } -} - +// Kernel-only symbols +%ignore init_struc; +%ignore save_struc; +%ignore term_struc; + +%feature("compactdefaultargs") add_struc; + +%include "struct.hpp" +// Add a get_member() member function to struc_t. +// This helps to access the members array in the class. +%extend struc_t { + member_t * get_member(int index) { return &(self->members[index]); } +} + diff --git a/swig/typeconv.i b/swig/typeconv.i index f054895..5c22527 100644 --- a/swig/typeconv.i +++ b/swig/typeconv.i @@ -1,90 +1,90 @@ -// Convert an incoming Python list to a tid_t[] array -%typemap(in) tid_t[ANY](tid_t temp[$1_dim0]) { - int i, len; - - if (!PySequence_Check($input)) - { - PyErr_SetString(PyExc_TypeError,"Expecting a sequence"); - return NULL; - } - - /* Cap the number of elements to copy */ - len = PySequence_Length($input) < $1_dim0 ? PySequence_Length($input) : $1_dim0; - - for (i =0; i < len; i++) - { - PyObject *o = PySequence_GetItem($input,i); - if (!PyLong_Check(o)) - { - Py_XDECREF(o); - PyErr_SetString(PyExc_ValueError,"Expecting a sequence of long integers"); - return NULL; - } - - temp[i] = PyLong_AsUnsignedLong(o); - Py_DECREF(o); - } - $1 = &temp[0]; -} - -%define %cstring_output_maxstr_none(TYPEMAP, SIZE) -%typemap (default) SIZE { - $1 = MAXSTR; -} -%typemap(in,numinputs=0) (TYPEMAP, SIZE) { -#ifdef __cplusplus - $1 = ($1_ltype) new char[MAXSTR+1]; -#else - $1 = ($1_ltype) malloc(MAXSTR+1); -#endif -} -%typemap(out) ssize_t { - /* REMOVING ssize_t return value in $symname */ -} -%typemap(argout) (TYPEMAP,SIZE) { - if (result > 0) - { - resultobj = PyString_FromString($1); - } - else - { - Py_INCREF(Py_None); - resultobj = Py_None; - } -#ifdef __cplusplus - delete [] $1; -#else - free($1); -#endif -} -%enddef - -%define %cstring_bounded_output_none(TYPEMAP,MAX) -%typemap(in, numinputs=0) TYPEMAP(char temp[MAX+1]) { - $1 = ($1_ltype) temp; -} -%typemap(argout,fragment="t_output_helper") TYPEMAP { - PyObject *o; - $1[MAX] = 0; - - if ($1 > 0) - { - o = PyString_FromString($1); - } - else - { - o = Py_None; - Py_INCREF(Py_None); - } - $result = t_output_helper($result,o); -} -%enddef - -// Check that the argument is a callable Python object -%typemap(in) PyObject *pyfunc { - if (!PyCallable_Check($input)) { - PyErr_SetString(PyExc_TypeError, "Expecting a callable object"); - return NULL; - } - $1 = $input; -} +// Convert an incoming Python list to a tid_t[] array +%typemap(in) tid_t[ANY](tid_t temp[$1_dim0]) { + int i, len; + + if (!PySequence_Check($input)) + { + PyErr_SetString(PyExc_TypeError,"Expecting a sequence"); + return NULL; + } + + /* Cap the number of elements to copy */ + len = PySequence_Length($input) < $1_dim0 ? PySequence_Length($input) : $1_dim0; + + for (i =0; i < len; i++) + { + PyObject *o = PySequence_GetItem($input,i); + if (!PyLong_Check(o)) + { + Py_XDECREF(o); + PyErr_SetString(PyExc_ValueError,"Expecting a sequence of long integers"); + return NULL; + } + + temp[i] = PyLong_AsUnsignedLong(o); + Py_DECREF(o); + } + $1 = &temp[0]; +} + +%define %cstring_output_maxstr_none(TYPEMAP, SIZE) +%typemap (default) SIZE { + $1 = MAXSTR; +} +%typemap(in,numinputs=0) (TYPEMAP, SIZE) { +#ifdef __cplusplus + $1 = ($1_ltype) new char[MAXSTR+1]; +#else + $1 = ($1_ltype) malloc(MAXSTR+1); +#endif +} +%typemap(out) ssize_t { + /* REMOVING ssize_t return value in $symname */ +} +%typemap(argout) (TYPEMAP,SIZE) { + if (result > 0) + { + resultobj = PyString_FromString($1); + } + else + { + Py_INCREF(Py_None); + resultobj = Py_None; + } +#ifdef __cplusplus + delete [] $1; +#else + free($1); +#endif +} +%enddef + +%define %cstring_bounded_output_none(TYPEMAP,MAX) +%typemap(in, numinputs=0) TYPEMAP(char temp[MAX+1]) { + $1 = ($1_ltype) temp; +} +%typemap(argout,fragment="t_output_helper") TYPEMAP { + PyObject *o; + $1[MAX] = 0; + + if ($1 > 0) + { + o = PyString_FromString($1); + } + else + { + o = Py_None; + Py_INCREF(Py_None); + } + $result = t_output_helper($result,o); +} +%enddef + +// Check that the argument is a callable Python object +%typemap(in) PyObject *pyfunc { + if (!PyCallable_Check($input)) { + PyErr_SetString(PyExc_TypeError, "Expecting a callable object"); + return NULL; + } + $1 = $input; +} diff --git a/swig/xref.i b/swig/xref.i index e632091..039bbab 100644 --- a/swig/xref.i +++ b/swig/xref.i @@ -1,22 +1,22 @@ -// Ignore kernel-only functions and variables -%ignore create_xrefs_from; -%ignore create_xrefs_from_data; -%ignore delete_all_xrefs_from; -%ignore delete_data_xrefs_from; -%ignore delete_code_xrefs_from; -%ignore destroy_if_align; -%ignore lastXR; -%ignore has_jump_or_flow_xref; -%ignore has_call_xref; -%ignore destroy_switch_info; - -// These functions should not be called directly (according to docs) -%ignore xrefblk_t_first_from; -%ignore xrefblk_t_next_from; -%ignore xrefblk_t_first_to; -%ignore xrefblk_t_next_to; - -// 'from' is a reserved Python keyword -%rename (frm) from; - -%include "xref.hpp" +// Ignore kernel-only functions and variables +%ignore create_xrefs_from; +%ignore create_xrefs_from_data; +%ignore delete_all_xrefs_from; +%ignore delete_data_xrefs_from; +%ignore delete_code_xrefs_from; +%ignore destroy_if_align; +%ignore lastXR; +%ignore has_jump_or_flow_xref; +%ignore has_call_xref; +%ignore destroy_switch_info; + +// These functions should not be called directly (according to docs) +%ignore xrefblk_t_first_from; +%ignore xrefblk_t_next_from; +%ignore xrefblk_t_first_to; +%ignore xrefblk_t_next_to; + +// 'from' is a reserved Python keyword +%rename (frm) from; + +%include "xref.hpp" diff --git a/tools/gendocs.py b/tools/gendocs.py index 7d57601..48149d5 100644 --- a/tools/gendocs.py +++ b/tools/gendocs.py @@ -1,25 +1,25 @@ -#------------------------------------------------------------ -# gendoc.py: Generate an API cross-reference for IDAPython -#------------------------------------------------------------ -__author__ = "Gergely Erdelyi " - -import epydoc.cli - -# This is a small hack to prevent epydoc from exiting the whole -# IDA process in case something goes wrong. -def exit(eval): - print "not exiting" -epydoc.cli.sys.exit = exit - -# Fill in the command-line arguments -epydoc.cli.optparse.sys.argv = [ 'epydoc', - '--no-sourcecode', - '-u', 'http://www.d-dome.net/idapython/', - '--navlink', 'IDAPython Reference', - '--no-private', - '--simple-term', - '-o', 'idapython-reference-%d.%d.%d' % (IDAPYTHON_VERSION[:3]), - '--html', - 'idc', 'idautils', 'idaapi' ] -# Generate the documentation -epydoc.cli.cli() +#------------------------------------------------------------ +# gendoc.py: Generate an API cross-reference for IDAPython +#------------------------------------------------------------ +__author__ = "Gergely Erdelyi " + +import epydoc.cli + +# This is a small hack to prevent epydoc from exiting the whole +# IDA process in case something goes wrong. +def exit(eval): + print "not exiting" +epydoc.cli.sys.exit = exit + +# Fill in the command-line arguments +epydoc.cli.optparse.sys.argv = [ 'epydoc', + '--no-sourcecode', + '-u', 'http://www.d-dome.net/idapython/', + '--navlink', 'IDAPython Reference', + '--no-private', + '--simple-term', + '-o', 'idapython-reference-%d.%d.%d' % (IDAPYTHON_VERSION[:3]), + '--html', + 'idc', 'idautils', 'idaapi' ] +# Generate the documentation +epydoc.cli.cli()