Exemple #1
0
 public void GetByteArrayMultipleTimes()
 {
     byte[] a = new byte[]{0x01, 0x02};
     Bytes bytes = new Bytes(a);
     bytes.Append(new byte[] {0x03, 0x04, 0x05, 0x06});
     bytes.Append(new byte[] {0x07});
     Assert.AreEqual(7, bytes.ByteArray.Length);
     Assert.AreEqual(7, bytes.ByteArray.Length);
 }
        private void Get(int offset, int getLength, Bytes intoBytes)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(string.Format("offset {0} must be >= 0", offset));
            }

            if (getLength < 0)
            {
                throw new ArgumentOutOfRangeException(string.Format("getLength {0} must be >= 0", getLength));
            }

            if (offset >= Length)
            {
                throw new ArgumentOutOfRangeException(string.Format("offset {0} must be < Length {1}", offset, Length));
            }

            if ((getLength + offset) > Length)
            {
                throw new ArgumentOutOfRangeException(
                          string.Format("offset {0} + getLength {1} = {2} must be < Length {3}", offset, getLength, offset + getLength,
                                        Length));
            }

            if (IsArray)
            {
                if (offset == 0 && getLength == Length)
                {
                    intoBytes.Append(_byteArray);
                    return;
                }

                intoBytes.Append(MidByteArray(_byteArray, offset, getLength));
                return;
            }

            foreach (Bytes bytes in _bytesList)
            {
                if (bytes.Length <= offset)
                {
                    offset -= bytes.Length;
                    continue;
                }

                if (bytes.Length >= (offset + getLength))
                {
                    bytes.Get(offset, getLength, intoBytes);
                    return;
                }

                int lengthToGet = bytes.Length - offset;
                bytes.Get(offset, lengthToGet, intoBytes);
                getLength -= lengthToGet;
                offset     = 0;
            }
        }
Exemple #3
0
 // Token: 0x0600001C RID: 28 RVA: 0x000026E0 File Offset: 0x000016E0
 private void Get(int offset, int getLength, Bytes intoBytes)
 {
     if (offset < 0)
     {
         throw new ArgumentOutOfRangeException(string.Format("offset {0} must be >= 0", offset));
     }
     if (getLength < 0)
     {
         throw new ArgumentOutOfRangeException(string.Format("getLength {0} must be >= 0", getLength));
     }
     if (offset >= this.Length)
     {
         throw new ArgumentOutOfRangeException(string.Format("offset {0} must be < Length {1}", offset, this.Length));
     }
     if (getLength + offset > this.Length)
     {
         throw new ArgumentOutOfRangeException(string.Format("offset {0} + getLength {1} = {2} must be < Length {3}", new object[]
         {
             offset,
             getLength,
             offset + getLength,
             this.Length
         }));
     }
     if (!this.IsArray)
     {
         foreach (Bytes bytes in this._bytesList)
         {
             if (bytes.Length <= offset)
             {
                 offset -= bytes.Length;
             }
             else
             {
                 if (bytes.Length >= offset + getLength)
                 {
                     bytes.Get(offset, getLength, intoBytes);
                     break;
                 }
                 int num = bytes.Length - offset;
                 bytes.Get(offset, num, intoBytes);
                 getLength -= num;
                 offset     = 0;
             }
         }
         return;
     }
     if (offset == 0 && getLength == this.Length)
     {
         intoBytes.Append(this._byteArray);
         return;
     }
     intoBytes.Append(Bytes.MidByteArray(this._byteArray, offset, getLength));
 }
Exemple #4
0
 public void ConvertArrayToList()
 {
     Bytes bytes = new Bytes(new byte[] { sixteenBytes[0], sixteenBytes[1] });
     Assert.IsTrue(bytes.IsArray);
     bytes.Append(new byte[] { sixteenBytes[2], sixteenBytes[3] });
     Assert.IsFalse(bytes.IsArray);
 }
Exemple #5
0
 public void AppendBytesObject()
 {
     Bytes bytes = new Bytes(new byte[] { sixteenBytes[0], sixteenBytes[1] });
     bytes.Append(new Bytes(new byte[] { sixteenBytes[2], sixteenBytes[3] }));
     Assert.AreEqual(4, bytes.Length);
     Assert.IsFalse(bytes.IsArray);
 }
Exemple #6
0
 public void LittleEndian0xFE()
 {
     byte b = 0xFE;
     Bytes bytes = new Bytes();
     bytes.Append(b);
     bool[] bits = bytes.GetBits().Values;
     Assert.AreEqual(8, bits.Length, "Bits length");
     Assert.IsFalse(bits[0], "Bit 0 value");
     for (int i = 1; i < 8; i++)
         Assert.IsTrue(bits[i], string.Format("Bit {0} value", i));
 }
Exemple #7
0
 public void LittleEndian0x0101()
 {
     byte[] bs = new byte[] { 0x01, 0x01 };
     Bytes bytes = new Bytes();
     bytes.Append(bs);
     bool[] bits = bytes.GetBits().Values;
     Assert.AreEqual(16, bits.Length, "Bits length");
     Assert.IsTrue(bits[0], "Bit 0 value");
     Assert.IsTrue(bits[8], "Bit 8 value");
     for (int i = 1; i < 8; i++)
         Assert.IsFalse(bits[i], string.Format("Bit {0} value", i));
     for (int i = 9; i < 16; i++)
         Assert.IsFalse(bits[i], string.Format("Bit {0} value", i));
 }
Exemple #8
0
        public void Test_Get()
        {
            Bytes bytes = new Bytes();

            Bytes newBytes = new Bytes();
            newBytes.Append(new byte[] { sixteenBytes[0], sixteenBytes[1] });
            newBytes.Append(new byte[] { sixteenBytes[2], sixteenBytes[3] });
            bytes.Append(newBytes);

            bytes.Append(new Bytes(new byte[] { sixteenBytes[4], sixteenBytes[5] }));

            newBytes = new Bytes();
            newBytes.Append(new byte[] { sixteenBytes[6], sixteenBytes[7], sixteenBytes[8] });
            newBytes.Append(new byte[] { sixteenBytes[9] });
            bytes.Append(newBytes);

            newBytes = new Bytes();
            newBytes.Append(new Bytes(new byte[] { sixteenBytes[10] }));
            newBytes.Append(new Bytes(new byte[] { sixteenBytes[11] }));
            bytes.Append(newBytes);

            newBytes = new Bytes();
            newBytes.Append(new Bytes(new byte[] { sixteenBytes[12] }));
            newBytes.Append(new Bytes(new byte[] { sixteenBytes[13], sixteenBytes[14] }));
            newBytes.Append(new Bytes(new byte[] { sixteenBytes[15] }));
            bytes.Append(newBytes);

            AssertArraysAreEqual(bytes.ByteArray, sixteenBytes);

            for (int offset = 0; offset < 16; offset++)
            {
                for (int length = 0; length <= (16 - offset); length++)
                {
                    AssertArraysAreEqual(Bytes.MidByteArray(sixteenBytes, offset, length), bytes.Get(offset, length).ByteArray);
                }
            }
        }
Exemple #9
0
 internal Bytes GetStandardOLE2Stream(Bytes bytes)
 {
     uint standardLength = _ole2Doc.StandardStreamMinBytes;
     uint padLength = standardLength = ((uint)bytes.Length % standardLength);
     if (padLength < standardLength)
         bytes.Append(new byte[padLength]);
     return bytes;
 }
Exemple #10
0
        private static Bytes ROW(Row row)
        {
            Bytes bytes = new Bytes();

            //Index of this row
            bytes.Append(BitConverter.GetBytes((ushort)(row.RowIndex - 1)));

            //Index to column of the first cell which is described by a cell record
            bytes.Append(BitConverter.GetBytes((ushort)(row.MinCellCol - 1)));

            //Index to column of the last cell which is described by a cell record, + 1
            bytes.Append(BitConverter.GetBytes(row.MaxCellCol));

            //Height of row in twips, custom row height indicator
            //TODO: Implement Row height and custom height indicators (excelfileformat.pdf p.190)
            bytes.Append(new byte[] {0x08, 0x01});

            //Not used
            bytes.Append(new byte[] {0x00, 0x00});

            //Not used anymore in BIFF8 (DBCELL instead)
            bytes.Append(new byte[] {0x00, 0x00});

            //Option flags and default row formatting
            //TODO: Implement Row option flags and default row formatting (excelfileformat.pdf p.190)
            bytes.Append(new byte[] {0x00, 0x01, 0x0F, 0x00});

            return Record.GetBytes(RID.ROW, bytes);
        }
Exemple #11
0
        private static Bytes GetBytesLPSTR(object value)
        {
            Bytes lpstr = new Bytes();

            string theString = value as string;
            Encoder encoder = Encoding.UTF8.GetEncoder();
            char[] theChars = theString.ToCharArray();
            int paddedLength = theChars.Length + 1; //add one for terminating null
            paddedLength += (paddedLength % 4); //must be multiple of 4
            byte[] bytes = new byte[paddedLength];
            encoder.GetBytes(theChars, 0, theChars.Length, bytes, 0, true);
            lpstr.Append(BitConverter.GetBytes((uint) paddedLength));
            lpstr.Append(bytes);

            return lpstr;
        }
Exemple #12
0
        private Bytes MERGEDCELLS()
        {
            Bytes mergedcells = new Bytes();

            int areaIndex = 0;
            int mergeAreaCount = _mergeAreas.Count;
            long areasPerRecord = 1027;
            int recordsRequired = (int)Math.Ceiling(_mergeAreas.Count/(double)areasPerRecord);
            for (int recordIndex = 0; recordIndex < recordsRequired; recordIndex++)
            {
                ushort blockAreaIndex = 0;
                Bytes rangeAddresses = new Bytes();
                while (areaIndex < mergeAreaCount && blockAreaIndex < areasPerRecord)
                {
                    rangeAddresses.Append(CellRangeAddress(_mergeAreas[areaIndex]));

                    blockAreaIndex++;
                    areaIndex++;
                }
                rangeAddresses.Prepend(BitConverter.GetBytes(blockAreaIndex));
                mergedcells.Append(Record.GetBytes(RID.MERGEDCELLS, rangeAddresses));
            }

            return mergedcells;
        }
Exemple #13
0
        private Bytes COLINFOS()
        {
            Bytes colinfos = new Bytes();

            for (int i = 0; i < _columnInfos.Count; i++)
                colinfos.Append(_columnInfos[i].Bytes);

            return colinfos;
        }
Exemple #14
0
        private static Bytes BOUNDSHEET(Worksheet sheet, int basePosition)
        {
            Bytes bytes = new Bytes();

            Bytes sheetName = XlsDocument.GetUnicodeString(sheet.Name, 8);
            bytes.Append(WorksheetVisibility.GetBytes(sheet.Visibility));
            bytes.Append(WorksheetType.GetBytes(sheet.SheetType));
            bytes.Append(sheetName);
            bytes.Prepend(BitConverter.GetBytes((int) basePosition)); //TODO: this should probably be unsigned 32 instead

            bytes.Prepend(BitConverter.GetBytes((ushort) bytes.Length));
            bytes.Prepend(RID.BOUNDSHEET);

            return bytes;
        }
Exemple #15
0
        private Bytes GetFormatRecord(ushort id, string format)
        {
            Bytes bytes = new Bytes();

            bytes.Append(BitConverter.GetBytes(id));
            bytes.Append(XlsDocument.GetUnicodeString(format, 16));

            return Record.GetBytes(RID.FORMAT, bytes);
        }
Exemple #16
0
        //NOTE: Don't want to pass recordBytes by ref or when we set it to a new Bytes
        //instance, it will wipe out what was appended to bytes
        private Bytes Continue(Bytes sst, Bytes bytes, out int remainingRecordBytes, ref bool isFirstContinue)
        {
            sst.Append(Record.GetBytes(isFirstContinue ? RID.SST : RID.CONTINUE, bytes));

            remainingRecordBytes = BIFF8.MaxDataBytesPerRecord;
            isFirstContinue = false;
            return new Bytes();
        }
Exemple #17
0
 private Bytes CellRangeAddress(ushort minRow, ushort maxRow, ushort minCol, ushort maxCol)
 {
     minRow--;
     maxRow--;
     minCol--;
     maxCol--;
     Bytes rangeAddress = new Bytes();
     rangeAddress.Append(BitConverter.GetBytes(minRow));
     rangeAddress.Append(BitConverter.GetBytes(maxRow));
     rangeAddress.Append(BitConverter.GetBytes(minCol));
     rangeAddress.Append(BitConverter.GetBytes(maxCol));
     return rangeAddress;
 }
Exemple #18
0
        private Bytes BLANK()
        {
            Bytes blank = new Bytes();

            //Index to row
            blank.Append(BitConverter.GetBytes((ushort)(Row - 1)));

            //Index to column
            blank.Append(BitConverter.GetBytes((ushort)(Column - 1)));

            //Index to XF record
            blank.Append(BitConverter.GetBytes((ushort) _xfIdx));

            return Record.GetBytes(RID.BLANK, blank);
        }
Exemple #19
0
        private Bytes INDEX(int baseLength)
        {
            Bytes index = new Bytes();

            //Not used
            index.Append(new byte[] { 0x00, 0x00, 0x00, 0x00 });

            //Index to first used row (0-based)
            index.Append(BitConverter.GetBytes(_rows.MinRow - 1));

            //Index to first row of unused tail of sheet(last row + 1, 0-based)
            index.Append(BitConverter.GetBytes(_rows.MaxRow));

            //Absolute stream position of the DEFCOLWIDTH record
            //TODO: Implement Worksheet.INDEX Absolute stream position of the DEFCOLWIDTH record (not necessary)
            index.Append(BitConverter.GetBytes((uint)0));

            for (int i = 1; i < _dbCellOffsets.Length; i++)
                index.Append(BitConverter.GetBytes((uint)(baseLength + _dbCellOffsets[i])));

            return Record.GetBytes(RID.INDEX, index);
        }
Exemple #20
0
        private Bytes LABEL()
        {
            Bytes label = new Bytes();

            label.Append(LABELBase());

            //Unicode string, 16-bit string length
            label.Append(XlsDocument.GetUnicodeString((string)Value ?? string.Empty, 16));

            return Record.GetBytes(RID.LABEL, label);
        }
Exemple #21
0
        private Bytes WINDOW2()
        {
            Bytes window2 = new Bytes();

            //TODO: Implement options - excelfileformat.pdf pp.210-211
            if (_doc.Workbook.Worksheets.GetIndex(Name) == 0) //NOTE: This was == 1, but the base of the worksheets collection must have changed
                window2.Append(new byte[] { 0xB6, 0x06 });
            else
                window2.Append(new byte[] { 0xB6, 0x04 });
            window2.Append(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });

            return Record.GetBytes(RID.WINDOW2, window2);
        }
Exemple #22
0
        private Bytes LABELBase()
        {
            Bytes labelBase = new Bytes();

            //Index to row
            labelBase.Append(BitConverter.GetBytes((ushort)(Row - 1)));

            //Index to column
            labelBase.Append(BitConverter.GetBytes((ushort)(Column - 1)));

            //Index to XF record
            labelBase.Append(BitConverter.GetBytes((ushort)_xfIdx));

            return labelBase;
        }
Exemple #23
0
        private Bytes SectorBinData(int sectorIndex)
        {
            if (0 > sectorIndex || sectorIndex > SectorCount)
                throw new ArgumentOutOfRangeException(string.Format("sectorIndex must be >= 0 and <= SectorCount {0}", SectorCount));

            int satSectors, satSid0, startSector, stopSector;

            Bytes bytes = new Bytes();

            satSectors = _doc.SAT.SectorCount;
            satSid0 = _doc.SAT.SID0;

            if (sectorIndex == 0)
            {
                startSector = 1;
                stopSector = 109;
            }
            else
            {
                startSector = 110 + ((sectorIndex - 1)*127);
                stopSector = startSector + 126;
            }

            for (int i = startSector; i <= stopSector; i++)
            {
                if (i < (satSectors + 1))
                    bytes.Append(BitConverter.GetBytes((int) (satSid0 + (i - 1))));
                else
                    bytes.Append(BitConverter.GetBytes((int) -1));
            }

            if (sectorIndex > 0)
            {
                if (stopSector >= satSectors)
                    bytes.Append(BitConverter.GetBytes((int) -2));
                else
                    bytes.Append(BitConverter.GetBytes((int) (SID0 + sectorIndex)));
            }

            return bytes;
        }
Exemple #24
0
        private Bytes LABELSST()
        {
            Bytes labelsst = new Bytes();

            labelsst.Append(LABELBase());

            //Index of string value in Shared String Table
            labelsst.Append(BitConverter.GetBytes((uint) _value));

            return Record.GetBytes(RID.LABELSST, labelsst);
        }
Exemple #25
0
        private static Bytes DBCELL(ushort[] cOff)
        {
            Bytes dbcell = new Bytes();

            for (int i = 0; i < cOff.Length; i++)
            {
                if (i == 0)
                    dbcell.Append(BitConverter.GetBytes((uint) cOff[i]));
                else
                    dbcell.Append(BitConverter.GetBytes(cOff[i]));
            }

            return Record.GetBytes(RID.DBCELL, dbcell);
        }
Exemple #26
0
        private Bytes NUMBER()
        {
            double value = Convert.ToDouble(Value);

            Bytes number = new Bytes();

            //Index to row
            number.Append(BitConverter.GetBytes((ushort) (Row - 1)));

            //Index to column
            number.Append(BitConverter.GetBytes((ushort) (Column - 1)));

            //Index to XF record
            number.Append(BitConverter.GetBytes((ushort) _xfIdx));

            //NUMBER Value
            number.Append(NUMBERVal(value));

            return Record.GetBytes(RID.NUMBER, number);
        }
Exemple #27
0
        private Bytes GetStream(System.IO.Stream fromDocumentStream, int did, Dictionary<int, byte[]> dir, ushort sectorSize, int[] sat, ushort shortSectorSize, int[] ssat, uint minStandardStreamSize)
        {
            Bytes stream = new Bytes();
            Bytes fromBytes;
            int[] fromSAT;
            ushort fromSectorSize;
            int sidNext;
            string shortness;

            int streamLength = BitConverter.ToInt32(MidByteArray(dir[did], 120, 4), 0);

            Bytes streamBytes = null;

            if (did == 0 || (streamLength >= minStandardStreamSize))
            {
                byte[] streamByteArray;
                streamByteArray = new byte[fromDocumentStream.Length];
                fromDocumentStream.Position = 0;
                fromDocumentStream.Read(streamByteArray, 0, streamByteArray.Length);
                streamBytes = new Bytes(streamByteArray);
            }

            if (did == 0)
            {
                fromSectorSize = sectorSize;
                fromSAT = sat;
                shortness = string.Empty;
                fromBytes = streamBytes;
            }
            else if (streamLength < minStandardStreamSize)
            {
                fromSectorSize = shortSectorSize;
                fromSAT = ssat;
                shortness = "Short ";
                fromBytes = GetStream(fromDocumentStream, 0, dir, sectorSize, sat, shortSectorSize, ssat, minStandardStreamSize);
            }
            else
            {
                fromSectorSize = sectorSize;
                fromSAT = sat;
                shortness = string.Empty;
                fromBytes = streamBytes;
            }

            sidNext = BitConverter.ToInt32(MidByteArray(dir[did], 116, 4), 0);
            while (sidNext > -2)
            {
                Bytes sector;
                if (did > 0 && streamLength < minStandardStreamSize)
                    sector = GetShortSectorBytes(fromBytes, fromSectorSize, sidNext);
                else
                    sector = GetSectorBytes(fromBytes, fromSectorSize, sidNext);

                if (sector.Length == 0)
                    throw new Exception(string.Format("{0}Sector not found [SID{1}]", shortness, sidNext));

                stream.Append(sector);

                sidNext = fromSAT[sidNext];
            }

            return stream.Get(streamLength);
        }
Exemple #28
0
        private Bytes RK(bool trueFalse)
        {
            Bytes rk = new Bytes();

            //Index to row
            rk.Append(BitConverter.GetBytes((ushort) (Row - 1)));

            //Index to column
            rk.Append(BitConverter.GetBytes((ushort) (Column - 1)));

            //Index to XF record
            rk.Append(BitConverter.GetBytes((ushort) _xfIdx));

            //RK Value
            if (Type == CellTypes.Integer)
                rk.Append(RKIntegerValue(Value, trueFalse));
            else if (Type == CellTypes.Float)
                rk.Append(RKDecimalValue(Value, trueFalse));

            return Record.GetBytes(RID.RK, rk);
        }
Exemple #29
0
        internal static Bytes GetUnicodeString(string text, int lengthBits)
        {
            int textLength;
            int limit = lengthBits == 8 ? byte.MaxValue : ushort.MaxValue;
            byte[] binaryLength = new byte[0];
            byte[] compression;
            byte[] compressedText = new byte[0];

            textLength = text.Length;
            if (textLength > limit)
                text = text.Substring(0, limit); //NOTE: Should throw Exception here?

            if (limit == 255)
                binaryLength = new byte[1] { (byte)text.Length };
            else if (limit == 65535)
                binaryLength = BitConverter.GetBytes((ushort)text.Length);

            if (IsCompressible(text))
            {
                compression = new byte[1];
                char[] chars = text.ToCharArray();
                compressedText = new byte[chars.Length];
                for (int i = 0; i < chars.Length; i++)
                    compressedText[i] = (byte)chars[i];
            }
            else
            {
                compression = new byte[1] { 1 };
            }

            Bytes bytes = new Bytes();
            bytes.Append(binaryLength);
            bytes.Append(compression);
            if (compressedText.Length > 0)
                bytes.Append(compressedText);
            else
                bytes.Append(Encoding.Unicode.GetBytes(text));
            return bytes;
        }
Exemple #30
0
        private void Get(int offset, int getLength, Bytes intoBytes)
        {
            if (offset < 0)
                throw new ArgumentOutOfRangeException(string.Format("offset {0} must be >= 0", offset));

            if (getLength < 0)
                throw new ArgumentOutOfRangeException(string.Format("getLength {0} must be >= 0", getLength));

            if (offset >= Length)
                throw new ArgumentOutOfRangeException(string.Format("offset {0} must be < Length {1}", offset, Length));

            if ((getLength + offset) > Length)
                throw new ArgumentOutOfRangeException(
                    string.Format("offset {0} + getLength {1} = {2} must be < Length {3}", offset, getLength, offset + getLength,
                                  Length));

            if (IsArray)
            {
                if (offset == 0 && getLength == Length)
                {
                    intoBytes.Append(_byteArray);
                    return;
                }

                intoBytes.Append(MidByteArray(_byteArray, offset, getLength));
                return;
            }

            foreach (Bytes bytes in _bytesList)
            {
                if (bytes.Length <= offset)
                {
                    offset -= bytes.Length;
                    continue;
                }

                if (bytes.Length >= (offset + getLength))
                {
                    bytes.Get(offset, getLength, intoBytes);
                    return;
                }

                int lengthToGet = bytes.Length - offset;
                bytes.Get(offset, lengthToGet, intoBytes);
                getLength -= lengthToGet;
                offset = 0;
            }
        }
Exemple #31
0
        internal static Bytes GetBytes(byte[] rid, Bytes data)
        {
            if (rid.Length != 2)
                throw new ArgumentException("must be 2 bytes", "rid");

            Bytes record = new Bytes();

            ushort offset = 0;
            ushort totalLength = (ushort)data.Length;
            do
            {
                ushort length = Math.Min((ushort) (totalLength - offset), BIFF8.MaxDataBytesPerRecord);

                if (offset == 0)
                {
                    record.Append(rid);
                    record.Append(BitConverter.GetBytes(length));
                    record.Append(data.Get(offset, length));
                }
                else
                {
                    record.Append(MyXls.RID.CONTINUE);
                    record.Append(BitConverter.GetBytes(length));
                    record.Append(data.Get(offset, length));
                }

                offset += length;
            } while (offset < totalLength);

            return record;
        }
Exemple #32
0
        private Bytes StreamDirectoryBytes(Stream stream)
        {
            Bytes bytes = new Bytes();

            //Stream Name
            bytes.Append(stream.Name);

            //Stream Name buffer fill
            bytes.Append(new byte[64 - bytes.Length]);

            //Stream Name length (including ending 0x00)
            bytes.Append(BitConverter.GetBytes((ushort)stream.Name.Length));

            //Type of entry {&H00 -> Empty, &H01 -> User Storage,
            //		&H02 -> User Stream, &H03 -> LockBytes (unknown),
            //		&H04 -> Property (unknown), &H05 -> Root storage}
            //TODO: UnHack this
            bytes.Append(HackDirectoryType(stream.Name));

            //TODO: Implement Red-Black Tree Node color {&H00 -> Red, &H01 -> Black} (Doesn't matter)
            bytes.Append(0x01);

            //TODO: UnHack Red-Black Tree Left-Child Node DID (-1 if no left child)
            bytes.Append(BitConverter.GetBytes(HackDirectoryDID(stream.Name, "LeftDID")));

            //TODO: UnHack Red-Black Tree Right-Child Node DID (-1 if no right child)
            bytes.Append(BitConverter.GetBytes(HackDirectoryDID(stream.Name, "RightDID")));

            //TODO: UnHack Storage Member Red-Black Tree Root Node DID (-1 if not storage)
            bytes.Append(BitConverter.GetBytes(HackDirectoryDID(stream.Name, "RootDID")));

            //Unique identifier for storage (Doesn't matter)
            bytes.Append(new byte[16]);

            //User flags (Doesn't matter)
            bytes.Append(new byte[4]);

            //Entry Creation Timestamp (Can be all 0's)
            bytes.Append(new byte[8]);

            //Entry Modification Timestamp (Can be all 0's)
            bytes.Append(new byte[8]);

            //SID of Stream's First Sector (for Short or Standard Streams)
            bytes.Append(BitConverter.GetBytes(stream.SID0));

            //Stream Size in Bytes (0 if storage, but not Root Storage entry)
            bytes.Append(BitConverter.GetBytes(stream.ByteCount));

            //Not used
            bytes.Append(new byte[4]);

            return bytes;
        }