Exemplo n.º 1
0
    def parse_list(self, fileptr, identifier):
        size_field = fileptr.read(4)
        list_identifier = fileptr.read(4)

        size = get_chunk_size(size_field)
        offset = fileptr.tell()

        if list_identifier == 'cmpr':
            fileptr.seek(offset)
            chunk = fileptr.read(size - 4)
            return self.parse_cmpr_list(identifier + size_field + \
                                        list_identifier + chunk)

        obj = model.RiffList(identifier + size_field + list_identifier)

        while fileptr.tell() <= offset + size - 8:
            ret = self.parse_stream(fileptr)
            if ret is None:
                fileptr.seek(offset)
                chunk = fileptr.read(size - 4)
                return model.RiffUnparsedList(identifier + size_field + \
                                              list_identifier + chunk)
            else:
                obj.childs.append(ret)

        return obj
Exemplo n.º 2
0
    def parse_compressed_list(self, stream, identifier, blocksizes):
        rawsize = dword2py_int(stream.read(4))
        list_identifier = stream.read(4)
        print list_identifier

        size = blocksizes[rawsize]

        size_field = py_int2dword(size)
        if size & 1: size += 1

        offset = stream.tell()

        obj = model.RiffList(identifier + size_field + list_identifier)

        while stream.tell() <= offset + size - 8:
            ret = self.parse_comressed_stream(stream, blocksizes)
            if ret is None:
                stream.seek(offset)
                chunk = stream.read(size - 4)
                return model.RiffUnparsedList(identifier + size_field + \
                                              list_identifier + chunk)
            else:
                obj.childs.append(ret)

        return obj