Though not as popular as functions and lines, IDA segments include both. In Sark,
objects allow access to underlying
>>> # >>> # Reference Lister >>> # >>> # List all functions and all references to them in the current section. >>> # >>> # Implemented with Sark >>> # >>> # See reference implementation here: https://code.google.com/p/idapython/wiki/ExampleScripts >>> # >>> for function in sark.Segment().functions: >>> print "Function %s at 0x%x" % (function.name, function.ea) >>> for ref in function.crefs_to: >>> print " called from %s(0x%x)" % (sark.Function(ref).name, ref)
sark.Line objects, they encapsulate relevant API into a
single object. Some useful members are:
|lines||all the lines in the segment (a generator)|
|functions||all the functions in the segment (a generator)|
|size||the size of the segment|
|permissions||the segments permissions (r/w/x). Can be modified.|
|next||the next segment.|
|bitness||the bitness of the segment (16, 32 or 64.)|
All similarly named members between
work similarly as well to avoid confusion.
There are 2 ways to get segments:
- Using the
sark.Segmentobject, using an address in a segment, a segment name, or the index of a segment.
sark.segmentsto iterate over segments.