@staticmethod
def
get_hardware_mode():
(arch, mode)
=
(
None
,
None
)
cpuname
=
ida_ida.inf_get_procname().lower()
is_be
=
ida_ida.inf_is_be()
if
cpuname
=
=
"metapc"
:
arch
=
KS_ARCH_X86
if
ida_ida.inf_is_64bit():
mode
=
KS_MODE_64
elif
ida_ida.inf_is_16bit():
mode
=
KS_MODE_16
else
:
mode
=
KS_MODE_32
elif
cpuname.startswith(
"arm"
):
if
ida_ida.inf_is_64bit():
arch
=
KS_ARCH_ARM64
if
is_be:
mode
=
KS_MODE_BIG_ENDIAN
else
:
mode
=
KS_MODE_LITTLE_ENDIAN
else
:
arch
=
KS_ARCH_ARM
if
is_be:
mode
=
KS_MODE_ARM | KS_MODE_BIG_ENDIAN
else
:
mode
=
KS_MODE_ARM | KS_MODE_LITTLE_ENDIAN
elif
cpuname.startswith(
"sparc"
):
arch
=
KS_ARCH_SPARC
if
ida_ida.inf_is_64bit():
mode
=
KS_MODE_SPARC64
else
:
mode
=
KS_MODE_SPARC32
if
is_be:
mode |
=
KS_MODE_BIG_ENDIAN
else
:
mode |
=
KS_MODE_LITTLE_ENDIAN
elif
cpuname.startswith(
"ppc"
):
arch
=
KS_ARCH_PPC
if
ida_ida.inf_is_64bit():
mode
=
KS_MODE_PPC64
else
:
mode
=
KS_MODE_PPC32
if
cpuname
=
=
"ppc"
:
mode
+
=
KS_MODE_BIG_ENDIAN
elif
cpuname.startswith(
"mips"
):
arch
=
KS_ARCH_MIPS
if
ida_ida.inf_is_64bit():
mode
=
KS_MODE_MIPS64
else
:
mode
=
KS_MODE_MIPS32
if
is_be:
mode |
=
KS_MODE_BIG_ENDIAN
else
:
mode |
=
KS_MODE_LITTLE_ENDIAN
elif
cpuname.startswith(
"systemz"
)
or
cpuname.startswith(
"s390x"
):
arch
=
KS_ARCH_SYSTEMZ
mode
=
KS_MODE_BIG_ENDIAN
return
(arch, mode)