diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-11 20:52:11 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-11 21:02:23 +0200 |
commit | 1cbdcc1458c0864e08f558a18e6d5c4fbb79da6e (patch) | |
tree | 05e907c197931fb635a450e88e0baba54ed772b5 | |
download | ida-plugins-master.tar.xz ida-plugins-master.zip |
-rw-r--r-- | linux_und.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/linux_und.py b/linux_und.py new file mode 100644 index 0000000..3405808 --- /dev/null +++ b/linux_und.py @@ -0,0 +1,51 @@ +import idaapi +import idc + +class linux_und(idaapi.IDP_Hooks): + def __init__(self): + idaapi.IDP_Hooks.__init__(self) + self.n = idaapi.netnode("$ X86 Linux Undefined Instructions", 0, 1) + + def ev_ana_insn(self, ins): + if idaapi.get_byte(ins.ea) != 0x0f: + return False + next_byte = idaapi.get_byte(ins.ea + 1) + if next_byte == 0xff: + name = "ud0" + elif next_byte == 0xb9: + name = "ud1" + elif next_byte == 0x0b: + name = "ud2" + else: + return False + ins.itype = idaapi.CUSTOM_CMD_ITYPE + next_byte + ins.size = 2 + idaapi.set_manual_insn(ins.ea, name) + return True + +class linux_und_t(idaapi.plugin_t): + flags = idaapi.PLUGIN_PROC | idaapi.PLUGIN_HIDE + comment = "Instruction Decoder" + wanted_hotkey = "" + help = "Runs transparently" + wanted_name = "linux_und" + hook = None + + def init(self): + self.hook = None + if idaapi.ph_get_id() != idaapi.PLFM_386: + return idaapi.PLUGIN_SKIP + + self.hook = linux_und() + self.hook.hook() + return idaapi.PLUGIN_KEEP + + def run(self, arg): + pass + + def term(self): + if self.hook: + self.hook.unhook() + +def PLUGIN_ENTRY(): + return linux_und_t() |