Exemple #1
0
        /// <summary>
        /// Reads a string. It is assumed that a MTF_MEDIA_ADDRESS structure is next in the stream.
        /// </summary>
        public string ReadString(long StartPosition, EStringType Type)
        {
            long oldpos = BaseStream.Position;

            ushort sz  = ReadUInt16();
            long   off = StartPosition + ReadUInt16();

            BaseStream.Seek(off, System.IO.SeekOrigin.Begin);
            string str;

            if (Type == EStringType.ANSI)
            {
                byte[] bytes = ReadBytes(sz);
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                str = encoding.GetString(bytes);
            }
            else if (Type == EStringType.Unicode)
            {
                byte[] bytes = ReadBytes(sz);
                System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();
                str = encoding.GetString(bytes);
            }
            else
            {
                str = "";
            }

            BaseStream.Seek(oldpos + 4, System.IO.SeekOrigin.Begin);

            return(str);
        }
        /// <summary>
        /// Reads a string. It is assumed that a MTF_MEDIA_ADDRESS structure is next in the stream.
        /// </summary>
        public string ReadString(long startPosition, EStringType type)
        {
            var oldpos = BaseStream.Position;

            var size         = ReadUInt16();
            var globalOffset = startPosition + ReadUInt16();

            BaseStream.Seek(globalOffset, System.IO.SeekOrigin.Begin);

            string result;

            if (type == EStringType.ANSI)
            {
                var bytes    = ReadBytes(size);
                var encoding = new ASCIIEncoding();
                result = encoding.GetString(bytes);
            }
            else if (type == EStringType.Unicode)
            {
                var bytes    = ReadBytes(size);
                var encoding = new UnicodeEncoding();
                result = encoding.GetString(bytes);
            }
            else
            {
                result = "";
            }

            BaseStream.Seek(oldpos + 4, System.IO.SeekOrigin.Begin);

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Reads a string. It is assumed that string bytes is next in the stream.
        /// </summary>
        public string ReadFixedSizeString(int Size, EStringType Type)
        {
            string str;

            if (Type == EStringType.ANSI)
            {
                byte[] bytes = ReadBytes(Size);
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                str = encoding.GetString(bytes);
            }
            else if (Type == EStringType.Unicode)
            {
                byte[] bytes = ReadBytes(Size);
                System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();
                str = encoding.GetString(bytes);
            }
            else
            {
                str = "";
            }

            return(str);
        }
Exemple #4
0
        /// <summary>
        /// Read block header.
        /// </summary>
        protected void ReadData(CBackupStream Reader)
        {
            StartPosition = Reader.BaseStream.Position;
            Streams       = new System.Collections.Generic.List <CDataStream>();

            BlockType          = (EBlockType)Reader.ReadUInt32();
            Attributes         = (EBlockAttributes)Reader.ReadUInt32();
            OffsetToFirstEvent = Reader.ReadUInt16();
            OSID                 = (EOSID)Reader.ReadByte();
            OSVersion            = Reader.ReadByte();
            DisplayableSize      = Reader.ReadUInt64();
            FormatLogicalAddress = Reader.ReadUInt64();
            ReservedMBC          = Reader.ReadUInt16();
            Reserved1            = Reader.ReadUInt16();
            Reserved2            = Reader.ReadUInt16();
            Reserved3            = Reader.ReadUInt16();
            ControlBlock         = Reader.ReadUInt32();
            Reserved4            = Reader.ReadUInt32();
            OsSpecificData       = Reader.ReadOsSpecificData(StartPosition, OSID, OSVersion, BlockType);
            StringType           = (EStringType)Reader.ReadByte();
            Reserved5            = Reader.ReadByte();
            HeaderChecksum       = Reader.ReadUInt16();
        }
        /// <summary>
        /// Read block header.
        /// </summary>
        protected void ReadData(CBackupStream Reader)
        {
            StartPosition = Reader.BaseStream.Position;
            Streams = new System.Collections.Generic.List<CDataStream>();

            BlockType = (EBlockType)Reader.ReadUInt32();
            Attributes = (EBlockAttributes)Reader.ReadUInt32();
            OffsetToFirstEvent = Reader.ReadUInt16();
            OSID = (EOSID)Reader.ReadByte();
            OSVersion = Reader.ReadByte();
            DisplayableSize = Reader.ReadUInt64();
            FormatLogicalAddress = Reader.ReadUInt64();
            ReservedMBC = Reader.ReadUInt16();
            Reserved1 = Reader.ReadUInt16();
            Reserved2 = Reader.ReadUInt16();
            Reserved3 = Reader.ReadUInt16();
            ControlBlock = Reader.ReadUInt32();
            Reserved4 = Reader.ReadUInt32();
            OsSpecificData = Reader.ReadOsSpecificData(StartPosition, OSID, OSVersion, BlockType);
            StringType = (EStringType)Reader.ReadByte();
            Reserved5 = Reader.ReadByte();
            HeaderChecksum = Reader.ReadUInt16();
        }
        /// <summary>
        /// Reads a string. It is assumed that a MTF_MEDIA_ADDRESS structure is next in the stream.
        /// </summary>
        public string ReadString(long StartPosition, EStringType Type)
        {
            long oldpos = BaseStream.Position;

            ushort sz = ReadUInt16();
            long off = StartPosition + ReadUInt16();
            BaseStream.Seek(off, System.IO.SeekOrigin.Begin);
            string str;
            if (Type == EStringType.ANSI)
            {
                byte[] bytes = ReadBytes(sz);
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                str = encoding.GetString(bytes);
            }
            else if (Type == EStringType.Unicode)
            {
                byte[] bytes = ReadBytes(sz);
                System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();
                str = encoding.GetString(bytes);
            }
            else
            {
                str = "";
            }

            BaseStream.Seek(oldpos + 4, System.IO.SeekOrigin.Begin);

            return str;
        }
        /// <summary>
        /// Reads a string. It is assumed that string bytes is next in the stream.
        /// </summary>
        public string ReadFixedSizeString(int Size, EStringType Type)
        {
            string str;
            if (Type == EStringType.ANSI)
            {
                byte[] bytes = ReadBytes(Size);
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                str = encoding.GetString(bytes);
            }
            else if (Type == EStringType.Unicode)
            {
                byte[] bytes = ReadBytes(Size);
                System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();
                str = encoding.GetString(bytes);
            }
            else
            {
                str = "";
            }

            return str;
        }