Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Author: fastman92
- Description:
- in MIPS executable you may often see instructions like this:
- li $at, 0x40555555
- 0x40555555 is really a float 32-bit value.
- However since IDA Pro sees a non-float register ($at) it will not show a float, but an integer.
- This script will put a comment like this:
- # float: 3.33333
- '''
- import struct
- APPLICATION_NAME = "MIPS li $at, float comment inserter"
- def f2b(f):
- return struct.unpack('I',struct.pack('f',f))[0]
- def b2f(b):
- return struct.unpack('f',struct.pack('I',b))[0]
- def isWhole(x):
- if(x%1 == 0):
- return True
- else:
- return False
- def floatToStr(num):
- if(isWhole(num)):
- return "%g.0" % (num)
- else:
- return "%g" % (num)
- def main():
- Message("---- Start of MIPS li $at, float comment inserter 1.1 by fastman92 ----\n")
- seg = FirstSeg()
- while seg != BADADDR:
- loc = SegStart(seg)
- while loc != BADADDR and loc < SegEnd(seg):
- if GetMnem(loc) == 'li':
- firstOp = GetOpnd(loc, 0)
- secondType = GetOpType(loc, 1)
- if firstOp == "$at" and secondType == o_imm:
- comment = GetCommentEx(loc, False)
- if comment == None or comment.startswith( 'float:'):
- value = GetOperandValue(loc, 1)
- value = b2f(value)
- MakeComm(loc, "float: " + floatToStr(value))
- print "0x%X - comment with float value %g inserted" % (loc, value)
- loc = NextHead(loc, BADADDR)
- seg = NextSeg(seg)
- Message("---- End of MIPS li $at, float comment inserter 1.1 by fastman92 ----\n")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement