Skip to content

Instantly share code, notes, and snippets.

@lallousx86
Last active April 20, 2017 17:51
Show Gist options
  • Save lallousx86/129b27f18e9fc1b941171facc6b1d1a2 to your computer and use it in GitHub Desktop.
Save lallousx86/129b27f18e9fc1b941171facc6b1d1a2 to your computer and use it in GitHub Desktop.
Export marked locations in IDA Pro with IDAPython
#
# Export marked location sorted by their address
#
# Get marked locations
Locs = []
idx = 0
while True:
s = idc.GetMarkComment(idx)
if s is None:
break
ea = idc.GetMarkedPos(idx)
Locs.append((ea, s))
idx += 1
# Sort them by address
Locs.sort(lambda x, y: -1 if x[0] - y[0] < 0 else 1)
# Emit insertion code
idx = 0
for ea, s in Locs:
print 'idc.MarkPosition(0x%x, 0, 0, 0, %d, "%s")' % (ea, idx, s)
idx += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment