Пример #1
0
    def __init__(self, stream, offset=None):
        """
        Initializes a Fib object.

        :parameters:
            stream
                A stream that contains the FIB.

            offset
                The byte offset in the stream of the start of the FIB.
        """

        extractor = Extractor(datatypes.FibHeader)

        if offset is not None:
            stream.seek(offset, SEEK_SET)
        else:
            offset = stream.tell()
        # end if

        self.header = extractor.extract(stream.read(32))
        offset += 32

        # Get the size of the shorts array
        size = uint16_le.extract(stream.read(2))[0] * 2
        offset += 2

        # Get the shorts array
        self.shorts = extract_fib_array(datatypes.FibShorts, size, stream,
                                        offset)
        offset += size

        # Get the size of the longs array
        size = uint16_le.extract(stream.read(2))[0] * 4
        offset += 2

        # Get the longs array
        self.longs = extract_fib_array(datatypes.FibLongs, size, stream,
                                       offset)
        offset += size

        # Get the size of the fc_lcb array
        size = uint16_le.extract(stream.read(2))[0] * 8
        offset += 2

        # Figure out which data structure we need...
        if size <= 744:  # Size of FibFcLcb97
            record = datatypes.FibFcLcb97
        elif size <= 864:  # Size of FibFcLcb2000
            record = datatypes.FibFcLcb2000
        elif size <= 1088:  # Size of FibFcLcb2002
            record = datatypes.FibFcLcb2002
        elif size <= 1312:  # Size of FibFcLcb2003
            record = datatypes.FibFcLcb2003
        else:
            record = datatypes.FibFcLcb2007
        # end if

        # Get the fc_lcb array
        self.fc_lcb = extract_fib_array(record, size, stream, offset)
Пример #2
0
    def __init__(self, stream, offset=None):
        """
        Initializes an SttbLong object.

        :parameters:
            stream
                A stream that contains the Sttb.

            offset
                The byte offset of the start of the Sttb.
        """

        if offset is None:
            offset = stream.tell()
        # end if

        super(SttbLong, self).__init__(stream, offset)
        extended = self.extended

        if extended:
            offset += 2
        # end if

        stream.seek(offset, SEEK_SET)
        count = uint32_le.extract(stream.read(4))[0]

        extra_size = uint16_le.extract(stream.read(2))[0]

        data = list()
        extra_data = list()

        for index in range(count):
            if extended:
                char_count = uint16_le.extract(stream.read(2))[0] * 2
            else:
                char_count = uint8.extract(stream.read(1))[0]
            # end if

            data.append(stream.read(char_count))
            if extra_size:
                extra_data.append(stream.read(extra_size))
            # end if
        # end for

        self.extra_size = extra_size
        self.data = data
        self.extra_data = extra_data
Пример #3
0
    def __init__(self, stream, offset=None):
        """
        Initializes an SttbLong object.

        :parameters:
            stream
                A stream that contains the Sttb.

            offset
                The byte offset of the start of the Sttb.
        """

        if offset is None:
            offset = stream.tell()
        # end if

        super(SttbLong, self).__init__(stream, offset)
        extended = self.extended

        if extended:
            offset += 2
        # end if

        stream.seek(offset, SEEK_SET)
        count = uint32_le.extract(stream.read(4))[0]

        extra_size = uint16_le.extract(stream.read(2))[0]

        data = list()
        extra_data = list()

        for index in range(count):
            if extended:
                char_count = uint16_le.extract(stream.read(2))[0] * 2
            else:
                char_count = uint8.extract(stream.read(1))[0]
            # end if

            data.append(stream.read(char_count))
            if extra_size:
                extra_data.append(stream.read(extra_size))
            # end if
        # end for

        self.extra_size = extra_size
        self.data = data
        self.extra_data = extra_data
Пример #4
0
    def __init__(self, stream, offset=None):
        """
        Initializes a Fib object.

        :parameters:
            stream
                A stream that contains the FIB.

            offset
                The byte offset in the stream of the start of the FIB.
        """

        extractor = Extractor(datatypes.FibHeader)

        if offset is not None:
            stream.seek(offset, SEEK_SET)
        else:
            offset = stream.tell()
        # end if

        self.header = extractor.extract(stream.read(32))
        offset += 32

        # Get the size of the shorts array
        size = uint16_le.extract(stream.read(2))[0] * 2
        offset += 2

        # Get the shorts array
        self.shorts = extract_fib_array(
            datatypes.FibShorts, size, stream, offset
        )
        offset += size

        # Get the size of the longs array
        size = uint16_le.extract(stream.read(2))[0] * 4
        offset += 2

        # Get the longs array
        self.longs = extract_fib_array(
            datatypes.FibLongs, size, stream, offset
        )
        offset += size

        # Get the size of the fc_lcb array
        size = uint16_le.extract(stream.read(2))[0] * 8
        offset += 2

        # Figure out which data structure we need...
        if size <= 744: # Size of FibFcLcb97
            record = datatypes.FibFcLcb97
        elif size <= 864: # Size of FibFcLcb2000
            record = datatypes.FibFcLcb2000
        elif size <= 1088: # Size of FibFcLcb2002
            record = datatypes.FibFcLcb2002
        elif size <= 1312: # Size of FibFcLcb2003
            record = datatypes.FibFcLcb2003
        else:
            record = datatypes.FibFcLcb2007
        # end if

        # Get the fc_lcb array
        self.fc_lcb = extract_fib_array(record, size, stream, offset)