Fandom

Magic Lantern Firmware Wiki

IDAPython/utils.py

< IDAPython

328pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

RegistersEdit

  • def getRegs03(op):
getRegs03("blah R1 blah R3 blah R2 blah R5") => [1, 3, 2]
  • def getRegsS(op):
getRegsS("blah R1 blah R3 blah R2 blah R5") => ["R1", "R3", "R2", "R5"]

Decoding instructionsEdit

ARM asm instructions are sometimes a big keyword made from mnemonics and some suffixes (conditional, mode, change flags, byte/word operation and maybe others.

  • Mode suffixes: (IA|IB|DA|DB|FD|FA|ED|EA)
  • Conditional suffixes: (AL|NV|EQ|NE|VS|VC|MI|PL|CS|CC|HI|LS|GE|LT|GT|LE)
  • Flag change suffix: S
  • Byte and Halfword: B and H
  • def GetModeSuffix(ea):
returns the mode suffix string or ""

e.g. if ea contains LDMIA blah blah, 
GetModeSuffix(ea) => "IA"
  • def GetCondSuffix(ea):
returns the conditional suffix string or ""

e.g. if ea contains ADDEQ blah blah, 
GetCondSuffix(ea) => "EQ"
  • def GetExtraSuffixes(ea):
get a string with all suffixes except mode and condition
  • def GetFlagSuffix(ea):
returns "S" or ""
  • def GetByteSuffix(ea):
returns "B" or ""
  • def GetHalfwordSuffix(ea):
returns "H" or ""
  • def OppositeSuffix(s):
OppositeSuffix("EQ") => NE
OppositeSuffix("MI") => PL
and so on...
  • def ChangesFlags(ea):
True if the instruction at "ea" changes flags, False otherwise.
  • isFuncStart(ea):
True if ea is the first instruction of a function, else False

Binary/Hex stuffEdit

  • def setBit01(old, offset, value):
def setBit01(old, offset, value):
    if value: setBit(old, offset)
    else: clearBit(old, offset)
  • def hex(x):
hex(10) => "A"
hex(-1) => "FFFFFFFF"

Also on Fandom

Random Wiki