Пример #1
0
    def _loadSections(self, machO):
        segStruct = machO.makeStruct('16s4^2i2L')
        sectStruct = machO.makeStruct(Section.STRUCT_FORMAT)
        (segname, self.vmaddr, self._vmsize, self._fileoff, self._filesize,
         self.maxprot, self.initprot, nsects,
         _) = readStruct(machO.file, segStruct)

        self.segname = fromStringz(segname)

        machO_fileOrigin = machO._fileOrigin

        sectVals = peekStructs(machO.file, sectStruct,
                               count=nsects)  # get all section headers
        sectionsList = (Section.createSection(i) for i in sectVals
                        )  # convert all headers into Section objects
        sections = DataTable('className', 'sectname', 'ftype')
        for s in sectionsList:
            if s.offset < machO_fileOrigin:
                s.offset += machO_fileOrigin
            sections.append(s,
                            className=type(s).__name__,
                            sectname=s.sectname,
                            ftype=s.ftype)
        self.sections = sections
        self._hasAnalyzedSections = False
        self._shouldImportMappings = machO.mappings.mutable
Пример #2
0
	def createSection(cls, val):
		'''Creates a section given be section header. *val* should be a tuple
		ordered as the C ``section`` structure.'''
	
		(sectname, segname, addr, size,
			offset, align, reloff, nreloc, flags, rs1, rs2) = val
		
		sectname = fromStringz(sectname)
		segname = fromStringz(segname)
		reserved = (rs1, rs2)
		
		ftype = flags & 0xff
		attrib = flags >> 8
			
		# we pass ftype twice to ensure __init__ and createSectionType won't be
		# mixed (as they have different number of arguments.)
		return cls.createFType(ftype, sectname, segname, addr, size, offset, align, reloff, nreloc, ftype, attrib, reserved)
Пример #3
0
    def createSection(cls, val):
        '''Creates a section given be section header. *val* should be a tuple
		ordered as the C ``section`` structure.'''

        (sectname, segname, addr, size, offset, align, reloff, nreloc, flags,
         rs1, rs2) = val

        sectname = fromStringz(sectname)
        segname = fromStringz(segname)
        reserved = (rs1, rs2)

        ftype = flags & 0xff
        attrib = flags >> 8

        # we pass ftype twice to ensure __init__ and createSectionType won't be
        # mixed (as they have different number of arguments.)
        return cls.createFType(ftype, sectname, segname, addr, size, offset,
                               align, reloff, nreloc, ftype, attrib, reserved)
Пример #4
0
	def _loadSections(self, machO):
		segStruct = machO.makeStruct('16s4^2i2L')
		sectStruct = machO.makeStruct(Section.STRUCT_FORMAT)
		(segname, self.vmaddr, self._vmsize, self._fileoff, self._filesize, self.maxprot, self.initprot, nsects, _) = readStruct(machO.file, segStruct)
		
		self.segname = fromStringz(segname)
		
		machO_fileOrigin = machO._fileOrigin
			
		sectVals = peekStructs(machO.file, sectStruct, count=nsects)	# get all section headers
		sectionsList = (Section.createSection(i) for i in sectVals)	# convert all headers into Section objects
		sections = DataTable('className', 'sectname', 'ftype')
		for s in sectionsList:
			if s.offset < machO_fileOrigin:
				s.offset += machO_fileOrigin
			sections.append(s, className=type(s).__name__, sectname=s.sectname, ftype=s.ftype)
		self.sections = sections
		self._hasAnalyzedSections = False
		self._shouldImportMappings = machO.mappings.mutable