| 6 | from struct import unpack |
| 7 | |
| 8 | class Segment: |
| 9 | |
| 10 | def __init__(self, lc, data): |
| 11 | self.name = lc.segment_name |
| 12 | self.section_num = lc.number_of_sections |
| 13 | self.vm_address = lc.vm_address |
| 14 | self.vm_size = lc.vm_size |
| 15 | self.file_offset = lc.file_offset |
| 16 | self.file_size = lc.file_size |
| 17 | self.max_vm_protection = lc.maximum_vm_protection |
| 18 | self.init_vm_protection = lc.initial_vm_protection |
| 19 | self.flags = lc.flags |
| 20 | self.content = data[self.file_offset : self.file_offset + self.file_size] |
| 21 | self.sections = [] |
| 22 | self.sections_index = [] |
| 23 | for i in range(self.section_num): |
| 24 | self.sections.append(Section(lc.sections[i], data)) |
| 25 | |
| 26 | # def __str__(self): |
| 27 | # return (" Segment {}: content {}".format(self.name, self.content)) |
| 28 | |
| 29 | |
| 30 | class Section: |