예제 #1
0
    def load_binary(self, filename=None, offset=None, filemap=None):
        """ Loads the ELF file into a memory mapped file """

        if filename == None:
            filename = self.prop.filename

        self.prop.file_src = open(filename, 'r+')
        self.prop.map_src = mmap(self.prop.file_src.fileno(),
                                 0, access=self.prop.mode)

        Chunk.load(self, offset, filemap)
예제 #2
0
    def load_binary(self, filename=None, offset=None, filemap=None):
        """ Loads the ELF file into a memory mapped file """

        if filename == None:
            filename = self.prop.filename

        self.prop.file_src = open(filename, 'r+')
        self.prop.map_src = mmap(self.prop.file_src.fileno(),
                                 0,
                                 access=self.prop.mode)

        Chunk.load(self, offset, filemap)
예제 #3
0
파일: header.py 프로젝트: sybtjp/python-elf
    def load(self, offset=None, filemap=None):
        """ Loads header fields according to descriptions/format """

        Chunk.load(self, offset, filemap)

        fields = list(unpack_from(''.join([self.prop.endian]+self.format),
                                  self.data))
        idx = 0
        for fmt in self.format:
            if fmt[len(fmt)-1] not in [ 's', 'p' ] and (
                        fmt[:len(fmt)-1].isdigit() == True):
                v = idx
                self.fields += [()]
                for n in range (0, int(fmt[:len(fmt)-1])):
                    self.fields[v] += (fields[idx],)
                    idx += 1
            else:
                self.fields += [fields[idx]]
                idx += 1
예제 #4
0
    def load(self, offset=None, filemap=None):
        """ Loads header fields according to descriptions/format """

        Chunk.load(self, offset, filemap)

        fields = list(
            unpack_from(''.join([self.prop.endian] + self.format), self.data))
        idx = 0
        for fmt in self.format:
            if fmt[len(fmt) - 1] not in [
                    's', 'p'
            ] and (fmt[:len(fmt) - 1].isdigit() == True):
                v = idx
                self.fields += [()]
                for n in range(0, int(fmt[:len(fmt) - 1])):
                    self.fields[v] += (fields[idx], )
                    idx += 1
            else:
                self.fields += [fields[idx]]
                idx += 1