1515from json import load
1616
1717# IDA Python SDK
18+ IDA_VERSION = IDAPYTHON_VERSION [0 ]
19+
1820from idaapi import *
1921from idc import *
2022from idautils import *
3840import ida_hexrays
3941import ida_range
4042# PyQt
41- from PySide6 import QtCore , QtWidgets
42- from PySide6 .QtWidgets import (QPushButton , QHBoxLayout )
43+ if IDA_VERSION >= 9 :
44+ from PySide6 import QtCore , QtWidgets
45+ from PySide6 .QtWidgets import (QPushButton , QHBoxLayout )
46+ else :
47+ from PyQt5 import QtCore , QtWidgets
48+ from PyQt5 .QtWidgets import (QPushButton , QHBoxLayout )
4349
4450# Qiling
4551from qiling import Qiling
@@ -293,29 +299,33 @@ def get_xrefsfrom(addr, flags=ida_xref.XREF_ALL):
293299 def get_input_file_path ():
294300 return ida_nalt .get_input_file_path ()
295301
302+ @staticmethod
303+ def get_info_structure ():
304+ return ida_idaapi .get_inf_structure ()
305+
296306 @staticmethod
297307 def get_main_address ():
298- return ida_ida .inf_get_main ()
308+ return ida_ida .inf_get_main () if IDA_VERSION >= 9 else IDA . get_info_structure (). main
299309
300310 @staticmethod
301311 def get_max_address ():
302- return ida_ida .inf_get_max_ea ()
312+ return ida_ida .inf_get_max_ea () if IDA_VERSION >= 9 else IDA . get_info_structure (). max_ea
303313
304314 @staticmethod
305315 def get_min_address ():
306- return ida_ida .inf_get_min_ea ()
316+ return ida_ida .inf_get_min_ea () if IDA_VERSION >= 9 else IDA . get_info_structure (). min_ea
307317
308318 @staticmethod
309319 def is_big_endian ():
310- return ida_ida .inf_is_be ()
320+ return ida_ida .inf_is_be () if IDA_VERSION >= 9 else IDA . get_info_structure (). is_be
311321
312322 @staticmethod
313323 def is_little_endian ():
314324 return not IDA .is_big_endian ()
315325
316326 @staticmethod
317327 def get_filetype ():
318- ftype = ida_ida .inf_get_filetype ()
328+ ftype = ida_ida .inf_get_filetype () if IDA_VERSION >= 9 else IDA . get_info_structure (). filetype
319329 if ftype == ida_ida .f_MACHO :
320330 return "macho"
321331 elif ftype == ida_ida .f_PE or ftype == ida_ida .f_EXE or ftype == ida_ida .f_EXE_old : # is this correct?
@@ -327,17 +337,18 @@ def get_filetype():
327337
328338 @staticmethod
329339 def get_ql_arch_string ():
330- proc = ida_ida .inf_get_procname ().lower ()
340+ proc = ( ida_ida .inf_get_procname () if IDA_VERSION >= 9 else IDA . get_info_structure (). procname ).lower ()
331341 result = None
342+ is_64_bit = ida_ida .inf_is_64bit () if IDA_VERSION >= 9 else IDA .get_info_structure ().is_64bit ()
332343 if proc == "metapc" :
333344 result = "x86"
334- if ida_ida . inf_is_64bit () :
345+ if is_64_bit :
335346 result = "x8664"
336347 elif "mips" in proc :
337348 result = "mips"
338349 elif "arm" in proc :
339350 result = "arm32"
340- if ida_ida . inf_is_64bit () :
351+ if is_64_bit :
341352 result = "arm64"
342353 # That's all we support :(
343354 return result
0 commit comments