Skip to content

Instantly share code, notes, and snippets.

@0xc010d
Created March 5, 2013 23:58
Show Gist options
  • Save 0xc010d/5095544 to your computer and use it in GitHub Desktop.
Save 0xc010d/5095544 to your computer and use it in GitHub Desktop.
Insert call
doc = Document.getCurrentDocument()
seg = doc.getCurrentSegment()
adr = doc.getCurrentAddress()
dstStr = Document.ask("Enter destination address:")
if dstStr != None:
dst = int(dstStr, 16)
offset = dst - (adr + 6)
after = adr + 6
while seg.getTypeAtAddress(after) == Segment.TYPE_NEXT:
after = after + 1
seg.writeByte(adr + 0, 0xFF)
seg.writeByte(adr + 1, 0x15)
seg.writeByte(adr + 2, ((offset >> 0) & 255))
seg.writeByte(adr + 3, ((offset >> 8) & 255))
seg.writeByte(adr + 4, ((offset >> 16) & 255))
seg.writeByte(adr + 5, ((offset >> 24) & 255))
seg.markAsCode(adr)
adr = adr + 6
while adr < after:
seg.writeByte(adr, 0x90)
seg.markAsCode(adr)
adr = adr + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment