Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions keypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@ def get_hardware_mode():
cpuname = info.procname.lower()
else:
cpuname = info.procName.lower()
#print("Keypatch MF = %s" %idaapi.cvar.inf.mf)

try:
# since IDA7 beta 3 (170724) renamed inf.mf -> is_be()/set_be()
is_be = idaapi.cvar.inf.is_be()
except:
# older IDA versions
is_be = idaapi.cvar.inf.mf
# print("Keypatch BIG_ENDIAN = %s" %is_be)

if cpuname == "metapc":
arch = KS_ARCH_X86
if info.is_64bit():
Expand All @@ -177,14 +185,14 @@ def get_hardware_mode():
# ARM or ARM64
if info.is_64bit():
arch = KS_ARCH_ARM64
if idaapi.cvar.inf.mf:
if is_be:
mode = KS_MODE_BIG_ENDIAN
else:
mode = KS_MODE_LITTLE_ENDIAN
else:
arch = KS_ARCH_ARM
# either big-endian or little-endian
if idaapi.cvar.inf.mf:
if is_be:
mode = KS_MODE_ARM | KS_MODE_BIG_ENDIAN
else:
mode = KS_MODE_ARM | KS_MODE_LITTLE_ENDIAN
Expand All @@ -194,7 +202,7 @@ def get_hardware_mode():
mode = KS_MODE_SPARC64
else:
mode = KS_MODE_SPARC32
if idaapi.cvar.inf.mf:
if is_be:
mode |= KS_MODE_BIG_ENDIAN
else:
mode |= KS_MODE_LITTLE_ENDIAN
Expand All @@ -213,7 +221,7 @@ def get_hardware_mode():
mode = KS_MODE_MIPS64
else:
mode = KS_MODE_MIPS32
if idaapi.cvar.inf.mf:
if is_be:
mode |= KS_MODE_BIG_ENDIAN
else:
mode |= KS_MODE_LITTLE_ENDIAN
Expand Down