Indent API stuff
@@ -131,9 +131,33 @@ class BaseApi(object):
:rtype: bool
"""
+ @abstractmethod
+ def get_comment(self, ea):
+ """
+ Get the comment at an address
+ :param ea: Effective address
+ :type ea: int
+ :return: Comment
+ :rtype: str
+ """
+
+ @abstractmethod
+ def set_comment(self, ea, comment):
+ """
+ Add a comment to an address
+ :param ea: Effective address
+ :type ea: int
+ :param comment: Comment
+ :type comment: str
+ :return: None
+ """
+
api = None
+
# region IDA Api
+
+if api is None:
try:
import idaapi # noqa
import idc # noqa
@@ -192,12 +216,21 @@ try:
result = idc.create_struct(ea, -1, struct_name)
return bool(result)
+ def get_comment(self, ea):
+ idc.get_cmt(ea, False)
+
+ def set_comment(self, ea, comment):
+ idc.set_cmt(ea, comment, False)
+
api = IdaApi()
except ImportError:
print("Warning: Unable to load IDA")
+
# endregion
# region Ghidra Api
+
+if api is None:
try:
import ghidra
@@ -233,10 +266,20 @@ try:
def clear_struct(self, sid):
raise NotImplementedError
+ def convert_to_struct(self, ea, sid):
+ raise NotImplementedError
+
+ def get_comment(self, ea):
+ raise NotImplementedError
+
+ def set_comment(self, ea, comment):
+ raise NotImplementedError
+
api = GhidraApi()
except ImportError:
print("Warning: Unable to load Ghidra")
+
# endregion
if api is None:
