From 958b5c2344cf2baea8f839b206df675ed67f6b38 Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 15 Feb 2019 09:27:40 -0500 Subject: [PATCH 1/3] fixed bug in loader for IDA-7 compatibility --- plugins/bap/utils/ida.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/bap/utils/ida.py b/plugins/bap/utils/ida.py index bb57fa3..74d94b2 100644 --- a/plugins/bap/utils/ida.py +++ b/plugins/bap/utils/ida.py @@ -1,6 +1,8 @@ """Utilities that interact with IDA.""" import idaapi import idc +from idaapi import * +from idc import * import idautils from ._service import Service @@ -30,7 +32,7 @@ def output_segments(out): out.writelines(('(', info.get_proc_name()[1], ' ', size, ' (')) for seg in idautils.Segments(): out.write("\n({} {} {:d} ({:#x} {:d}))".format( - idaapi.get_segm_name(seg), + get_segm_name(seg), "code" if idaapi.segtype(seg) == idaapi.SEG_CODE else "data", idaapi.get_fileregion_offset(seg), seg, idaapi.getseg(seg).size())) From e08185b381851f71232389a8541d1f6e6ada826e Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 15 Feb 2019 13:47:40 -0500 Subject: [PATCH 2/3] refactoring --- plugins/bap/utils/ida.py | 6 ++++-- tests/mockidaapi.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/bap/utils/ida.py b/plugins/bap/utils/ida.py index 74d94b2..e0613e7 100644 --- a/plugins/bap/utils/ida.py +++ b/plugins/bap/utils/ida.py @@ -1,14 +1,16 @@ """Utilities that interact with IDA.""" import idaapi import idc -from idaapi import * -from idc import * import idautils from ._service import Service from ._comment_handler import CommentHandlers from ._ctyperewriter import Rewriter +try: + from idc import get_segm_name +except ImportError: + from idaapi import get_segm_name service = Service() comment = CommentHandlers() diff --git a/tests/mockidaapi.py b/tests/mockidaapi.py index 2492e18..b8315a4 100644 --- a/tests/mockidaapi.py +++ b/tests/mockidaapi.py @@ -14,3 +14,4 @@ def get_cmt(ea, off): NotImplemented def set_cmt(ea, off): NotImplemented def askyn_c(dflt, title): NotImplemented def get_input_file_path() : NotImplemented +def get_segm_name(ea): NotImplemented From 5ead27ef6534ece27e050dd6463659b3465bfacd Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 28 Feb 2019 15:24:06 -0500 Subject: [PATCH 3/3] minor fix in tests --- tests/mockidaapi.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/mockidaapi.py b/tests/mockidaapi.py index b8315a4..4629cc9 100644 --- a/tests/mockidaapi.py +++ b/tests/mockidaapi.py @@ -6,12 +6,12 @@ PLUGIN_DRAW = NotImplemented PLUGIN_HIDE = NotImplemented PLUGIN_KEEP = NotImplemented -class plugin_t(object): NotImplemented -class text_sink_t(object): NotImplemented -class Choose2(object): NotImplemented -def idadir(sub): NotImplemented -def get_cmt(ea, off): NotImplemented -def set_cmt(ea, off): NotImplemented -def askyn_c(dflt, title): NotImplemented -def get_input_file_path() : NotImplemented -def get_segm_name(ea): NotImplemented +class plugin_t(object): pass +class text_sink_t(object): pass +class Choose2(object): pass +def idadir(sub): return NotImplemented +def get_cmt(ea, off): return NotImplemented +def set_cmt(ea, off): return NotImplemented +def askyn_c(dflt, title): return NotImplemented +def get_input_file_path() : return NotImplemented +def get_segm_name(ea): return NotImplemented