Using the minsc plugin at https://github.com/arizvisa/ida-minsc, you can access database information using database.information
. To get the detected architecture, you can access it via instruction.arch
(currently only Intel, Mips, and Arm are implemented for this particular method).
Python>db.info.processor(), db.info.bits(), db.info.byteorder(), ins.arch
('metapc', 0x20, 'little', <pc.Intel object at 0x7fdf2c145e90>)
Disclaimer: I maintain the ida-minsc plugin.
Register information can be accessed via instruction.architecture.register
(or instruction.register
).
Python>ins.arch.reg
<class 'internal.architecture.map_t'>
%bnd0 : <class 'register_t' index=97 dtype=dt_byte16 name='bnd0' position=0+128>
%bnd1 : <class 'register_t' index=98 dtype=dt_byte16 name='bnd1' position=0+128>
%bnd2 : <class 'register_t' index=99 dtype=dt_byte16 name='bnd2' position=0+128>
%bnd3 : <class 'register_t' index=100 dtype=dt_byte16 name='bnd3' position=0+128>
...
%zmm31 : <class 'register_t' index=164 dtype=dt_byte64 name='zmm31' position=0+512>
%ymm31 : \_<class 'register_t' index=132 dtype=dt_byte32 name='ymm31' position=0+256>
%xmm31 : \_<class 'register_t' index=116 dtype=dt_byte16 name='xmm31' position=0+128>
If you want to access the processor information as soon as the disassembler figures it out, you can add a hook. First we define some function that corresponds to IDP_Hooks.ev_newprc
. Then we can use the idp hooks in the ui
module from minsc accessed as ui.hooks.idp
.
import database as db, ui
def choose_processor(*dunno):
print('got', db.info.processor())
Python>ui.hook.idp.add('ev_newprc', choose_processor)
IDP Hook is now added (Note: edited a bit to highlight the function we've attached).
Python>ui.hook.idp
Events currently connected to IDP_Hooks:
...
IDP_Hooks.ev_newprc : __main__.choose_processor(*dunno)[+0]
...
IDP_Hooks.ev_rename : internal.hooks.changing(*parameters)[+0]
Now upon opening up or creating a database we'll see the following output.
Loading processor module procs/arm.so for ARM...
...
OK
WARNING:root:Detected processor module : AArch32 (13)
got ARM
Assuming __fastcall calling convention by default
...