idapro 0.0.4.dev1__tar.gz → 0.0.6.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/PKG-INFO +1 -1
  2. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/__init__.py +28 -25
  3. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/config.py +15 -12
  4. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro.egg-info/PKG-INFO +1 -1
  5. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/setup.py +1 -1
  6. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/LICENSE +0 -0
  7. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/README.md +0 -0
  8. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/py.typed +0 -0
  9. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_allins.pyi +0 -0
  10. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_api.pyi +0 -0
  11. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_auto.pyi +0 -0
  12. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_bitrange.pyi +0 -0
  13. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_bytes.pyi +0 -0
  14. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_dbg.pyi +0 -0
  15. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_dirtree.pyi +0 -0
  16. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_diskio.pyi +0 -0
  17. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_entry.pyi +0 -0
  18. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_expr.pyi +0 -0
  19. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_fixup.pyi +0 -0
  20. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_fpro.pyi +0 -0
  21. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_frame.pyi +0 -0
  22. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_funcs.pyi +0 -0
  23. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_gdl.pyi +0 -0
  24. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_graph.pyi +0 -0
  25. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_hexrays.pyi +0 -0
  26. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_ida.pyi +0 -0
  27. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_idaapi.pyi +0 -0
  28. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_idc.pyi +0 -0
  29. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_idd.pyi +0 -0
  30. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_idp.pyi +0 -0
  31. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_ieee.pyi +0 -0
  32. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_kernwin.pyi +0 -0
  33. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_libfuncs.pyi +0 -0
  34. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_lines.pyi +0 -0
  35. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_loader.pyi +0 -0
  36. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_merge.pyi +0 -0
  37. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_mergemod.pyi +0 -0
  38. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_moves.pyi +0 -0
  39. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_nalt.pyi +0 -0
  40. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_name.pyi +0 -0
  41. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_netnode.pyi +0 -0
  42. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_offset.pyi +0 -0
  43. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_pro.pyi +0 -0
  44. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_problems.pyi +0 -0
  45. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_range.pyi +0 -0
  46. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_regfinder.pyi +0 -0
  47. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_registry.pyi +0 -0
  48. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_search.pyi +0 -0
  49. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_segment.pyi +0 -0
  50. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_segregs.pyi +0 -0
  51. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_srclang.pyi +0 -0
  52. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_strlist.pyi +0 -0
  53. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_tryblks.pyi +0 -0
  54. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_typeinf.pyi +0 -0
  55. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_ua.pyi +0 -0
  56. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_undo.pyi +0 -0
  57. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/ida_xref.pyi +0 -0
  58. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/idaapi.pyi +0 -0
  59. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/idadex.pyi +0 -0
  60. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/idautils.pyi +0 -0
  61. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro/stubs/idc.pyi +0 -0
  62. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro.egg-info/SOURCES.txt +0 -0
  63. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro.egg-info/dependency_links.txt +0 -0
  64. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro.egg-info/not-zip-safe +0 -0
  65. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/idapro.egg-info/top_level.txt +0 -0
  66. {idapro-0.0.4.dev1 → idapro-0.0.6.dev1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: idapro
3
- Version: 0.0.4.dev1
3
+ Version: 0.0.6.dev1
4
4
  Summary: IDA Library Python module
5
5
  Author: Hex-Rays SA
6
6
  Author-email: support@hex-rays.com
@@ -2,13 +2,14 @@ from __future__ import annotations
2
2
  import sys
3
3
  import platform
4
4
  from pathlib import Path
5
+ from typing import Optional
5
6
  import ctypes
6
7
  import os
7
8
  from .config import get_ida_install_dir
8
9
 
9
10
  def find_file(name, path):
10
11
  """Internal method used for recursively find a file in a folder"""
11
- for root, dirs, files in os.walk(path):
12
+ for root, _, files in os.walk(path):
12
13
  if name in files:
13
14
  return os.path.join(root, name)
14
15
  return None
@@ -27,30 +28,9 @@ else:
27
28
 
28
29
  # Get the ida-install-dir setting
29
30
  root_dir = get_ida_install_dir()
30
-
31
- if platform_str == "Windows":
32
- # IDA kernel and modules may need dependencies in its root dir (e.g. clp64.dll)
33
- # tell Windows loader where they can be found
34
- # NB: for AddDllDirectory() be effective for indirectly loaded DLLs,
35
- # SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS) has to be called first
36
- kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
37
- SetDefaultDllDirectories = getattr(kernel32, "SetDefaultDllDirectories")
38
- if SetDefaultDllDirectories:
39
- from ctypes.wintypes import DWORD, BOOL
40
- SetDefaultDllDirectories.argtypes = [DWORD]
41
- SetDefaultDllDirectories.restype = BOOL
42
- LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000
43
- LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400
44
- flags = LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_USER_DIRS
45
- if SetDefaultDllDirectories(flags):
46
- # finally, add IDA's directory for dependencies
47
- os.add_dll_directory(root_dir)
48
- else:
49
- os.environ['PATH'] = root_dir + os.pathsep + os.environ.get('PATH', '')
50
-
51
- idalib_path = find_file(name=name, path=root_dir)
31
+ idalib_path = find_file(name=name, path=root_dir) if root_dir else None
52
32
  if idalib_path is None:
53
- raise ImportError(f"Could not find {name} in {root_dir}. Please make sure you are using IDA version 9.0 or newer and the IDADIR environment variable is set and points to the active IDA installation.")
33
+ raise ImportError(f"Cannot load IDA library file {name}. Please make sure you are using IDA version 9.0 or newer and the IDADIR environment variable is set and points to the active IDA installation.")
54
34
 
55
35
  if "IDA_IS_INTERACTIVE" in os.environ:
56
36
  if os.environ["IDA_IS_INTERACTIVE"] == "1":
@@ -58,6 +38,26 @@ if "IDA_IS_INTERACTIVE" in os.environ:
58
38
 
59
39
  # load the library and initialize the kernel
60
40
  try:
41
+ if platform_str == "Windows":
42
+ # IDA kernel and modules may need dependencies in its root dir (e.g. clp64.dll)
43
+ # tell Windows loader where they can be found
44
+ # NB: for AddDllDirectory() be effective for indirectly loaded DLLs,
45
+ # SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS) has to be called first
46
+ kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
47
+ SetDefaultDllDirectories = getattr(kernel32, "SetDefaultDllDirectories")
48
+ if SetDefaultDllDirectories:
49
+ from ctypes.wintypes import DWORD, BOOL
50
+ SetDefaultDllDirectories.argtypes = [DWORD]
51
+ SetDefaultDllDirectories.restype = BOOL
52
+ LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000
53
+ LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400
54
+ flags = LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_USER_DIRS
55
+ if SetDefaultDllDirectories(flags):
56
+ # finally, add IDA's directory for dependencies
57
+ os.add_dll_directory(root_dir)
58
+ else:
59
+ os.environ['PATH'] = root_dir + os.pathsep + os.environ.get('PATH', '')
60
+
61
61
  libida = ctypes.cdll.LoadLibrary(idalib_path)
62
62
  except Exception as e:
63
63
  raise ImportError(f"Failed loading IDA library file {idalib_path}, exception {e}\n")
@@ -76,12 +76,15 @@ if error_description != None:
76
76
  sys.path.append(str(Path(idalib_path).parent / "python/lib-dynload"))
77
77
  sys.path.append(str(Path(idalib_path).parent / "python"))
78
78
 
79
- def open_database(file_name:str, run_auto_analysis: bool, args: str = None)->int:
79
+ def open_database(file_name:str, run_auto_analysis: bool, args: Optional[str] = None, enable_history: bool = False)->int:
80
80
  """Opens the database specified by the file_name argument.
81
81
  If run_auto_analysis is set to True, the auto-analysis will start and wait for its completion.
82
+ If enable_history is set to True, update the file history list; the default within idalib is not to update it.
82
83
  Optionally, additional arguments can be provided via args parameter, which follow the same format as IDA's command-line arguments.
83
84
  NOTE: All library functions must be called from the same thread that initialized the library.
84
85
  The library is single-threaded, and performing database operations from a different thread may result in undefined behavior."""
86
+ if enable_history:
87
+ args = (args or "") + " -Oidalib:enable_history"
85
88
  return libida.open_database(file_name.encode(), run_auto_analysis, args.encode() if args is not None else None)
86
89
 
87
90
  def close_database(save = True)->None:
@@ -7,12 +7,16 @@ def get_user_config_path():
7
7
  """Get the path to the user's config file based on platform following IDA's user directories."""
8
8
  system = platform.system()
9
9
 
10
- if system == "Windows":
11
- # On Windows, use the %APPDATA%\Hex-Rays\IDA Pro directory
12
- config_dir = Path(os.getenv('APPDATA')) / "Hex-Rays" / "IDA Pro"
10
+ idausr_env = os.getenv("IDAUSR")
11
+ if idausr_env:
12
+ config_dir = Path(idausr_env)
13
13
  else:
14
- # On macOS and Linux, use ~/.idapro
15
- config_dir = Path.home() / ".idapro"
14
+ if system == "Windows":
15
+ # On Windows, use the %APPDATA%\Hex-Rays\IDA Pro directory
16
+ config_dir = Path(os.getenv('APPDATA')) / "Hex-Rays" / "IDA Pro"
17
+ else:
18
+ # On macOS and Linux, use ~/.idapro
19
+ config_dir = Path.home() / ".idapro"
16
20
 
17
21
  # Return the full path to the config file (now in JSON format)
18
22
  user_config_path = config_dir / "ida-config.json"
@@ -71,12 +75,11 @@ def set_ida_install_dir(new_path):
71
75
  def get_ida_install_dir():
72
76
  """Retrieve the IDA installation directory."""
73
77
 
78
+ # $IDADIR overrides JSON config
79
+ idadir = os.environ.get('IDADIR')
80
+ if idadir:
81
+ return idadir
82
+
74
83
  # Read the configuration JSON file
75
84
  config = load_config()
76
- install_dir = config['Paths'].get('ida-install-dir', None)
77
-
78
- # Fallback to IDADIR env var if the JSON value is not set
79
- if install_dir is None or len(install_dir) == 0:
80
- install_dir = os.environ.get('IDADIR', '')
81
-
82
- return install_dir
85
+ return config['Paths'].get('ida-install-dir', None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: idapro
3
- Version: 0.0.4.dev1
3
+ Version: 0.0.6.dev1
4
4
  Summary: IDA Library Python module
5
5
  Author: Hex-Rays SA
6
6
  Author-email: support@hex-rays.com
@@ -74,7 +74,7 @@ example_code = "#!/usr/bin/env python3\n\"\"\"\nIDA Pro Python Library Usage Exa
74
74
 
75
75
  setup(
76
76
  name="idapro",
77
- version="0.0.4.dev1",
77
+ version="0.0.6.dev1",
78
78
  author="Hex-Rays SA",
79
79
  author_email="support@hex-rays.com",
80
80
  description="IDA Library Python module",
File without changes
File without changes
File without changes
File without changes