Esempio n. 1
0
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override String ToString()
        {
            String nl = Environment.NewLine;

            String extraData = string.Empty;

            using (MemoryStream b = new MemoryStream())
            {
                try
                {
                    HexDump.Dump(this.field_12_data, 0, b, 0);
                    //extraData = b.ToString();
                    extraData = Encoding.UTF8.GetString(b.ToArray());
                }
                catch (Exception e)
                {
                    extraData = e.ToString();
                }
                return(GetType().Name + ":" + nl +
                       "  RecordId: 0x" + HexDump.ToHex(RecordId) + nl +
                       "  Version: 0x" + HexDump.ToHex(Version) + nl +
                       "  Instance: 0x" + HexDump.ToHex(Instance) + nl +
                       "  Secondary UID: " + HexDump.ToHex(field_1_secondaryUID) + nl +
                       "  CacheOfSize: " + field_2_cacheOfSize + nl +
                       "  BoundaryTop: " + field_3_boundaryTop + nl +
                       "  BoundaryLeft: " + field_4_boundaryLeft + nl +
                       "  BoundaryWidth: " + field_5_boundaryWidth + nl +
                       "  BoundaryHeight: " + field_6_boundaryHeight + nl +
                       "  X: " + field_7_width + nl +
                       "  Y: " + field_8_height + nl +
                       "  CacheOfSavedSize: " + field_9_cacheOfSavedSize + nl +
                       "  CompressionFlag: " + field_10_compressionFlag + nl +
                       "  Filter: " + field_11_filter + nl +
                       "  Data:" + nl + extraData);
            }
        }
Esempio n. 2
0
        /**
         * Returns the string representation of this record.
         */
        public override String ToString()
        {
            String nl = Environment.NewLine;

            String extraData;

            using (MemoryStream b = new MemoryStream())
            {
                try
                {
                    HexDump.Dump(this.remainingData, 0, b, 0);
                    extraData = b.ToString();
                }
                catch (Exception)
                {
                    extraData = "error\n";
                }
                return(GetType().Name + ":" + nl +
                       "  RecordId: 0x" + HexDump.ToHex(RECORD_ID) + nl +
                       "  Options: 0x" + HexDump.ToHex(Options) + nl);
                //"  Extra Data:" + nl +
                //extraData;
            }
        }
Esempio n. 3
0
        public void TestDumpToStringOutOfIndex()
        {
            byte[] testArray = new byte[0];

            try
            {
                HexDump.Dump(testArray, 0, -1);
                Assert.Fail("Should throw an exception with invalid input");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            try
            {
                HexDump.Dump(testArray, 0, 1);
                Assert.Fail("Should throw an exception with invalid input");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }
        }
Esempio n. 4
0
        public void TestDump()
        {
            byte[] testArray = new byte[256];

            for (int j = 0; j < 256; j++)
            {
                testArray[j] = (byte)j;
            }
            MemoryStream stream = new MemoryStream();

            HexDump.Dump(testArray, 0, stream, 0);
            byte[] outputArray = new byte[16 * (73 + HexDump.EOL.Length)];

            for (int j = 0; j < 16; j++)
            {
                int offset = (73 + HexDump.EOL.Length) * j;

                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)ToHex(j);
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)' ';
                for (int k = 0; k < 16; k++)
                {
                    outputArray[offset++] = (byte)ToHex(j);
                    outputArray[offset++] = (byte)ToHex(k);
                    outputArray[offset++] = (byte)' ';
                }
                for (int k = 0; k < 16; k++)
                {
                    outputArray[offset++] = (byte)toAscii((j * 16) + k);
                }
                System.Array.Copy(Encoding.UTF8.GetBytes(HexDump.EOL), 0, outputArray, offset,
                                  Encoding.UTF8.GetBytes(HexDump.EOL).Length);
            }
            byte[] actualOutput = stream.ToArray();

            Assert.AreEqual(outputArray.Length,
                            actualOutput.Length, "array size mismatch");

            for (int j = 0; j < outputArray.Length; j++)
            {
                Assert.AreEqual(outputArray[j],
                                actualOutput[j], "array[ " + j + "] mismatch");
            }

            // verify proper behavior with non-zero offset
            stream = new MemoryStream();
            HexDump.Dump(testArray, 0x10000000, stream, 0);
            outputArray = new byte[16 * (73 + HexDump.EOL.Length)];
            for (int j = 0; j < 16; j++)
            {
                int offset = (73 + HexDump.EOL.Length) * j;

                outputArray[offset++] = (byte)'1';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)ToHex(j);
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)' ';
                for (int k = 0; k < 16; k++)
                {
                    outputArray[offset++] = (byte)ToHex(j);
                    outputArray[offset++] = (byte)ToHex(k);
                    outputArray[offset++] = (byte)' ';
                }
                for (int k = 0; k < 16; k++)
                {
                    outputArray[offset++] = (byte)toAscii((j * 16) + k);
                }
                System.Array.Copy(Encoding.UTF8.GetBytes(HexDump.EOL), 0, outputArray, offset,
                                  Encoding.UTF8.GetBytes(HexDump.EOL).Length);
            }
            actualOutput = stream.ToArray();
            Assert.AreEqual(outputArray.Length,
                            actualOutput.Length, "array size mismatch");
            for (int j = 0; j < outputArray.Length; j++)
            {
                Assert.AreEqual(outputArray[j], actualOutput[j], "array[ " + j + "] mismatch");
            }

            // verify proper behavior with negative offset
            stream = new MemoryStream();
            HexDump.Dump(testArray, 0xFF000000, stream, 0);
            outputArray = new byte[16 * (73 + HexDump.EOL.Length)];
            for (int j = 0; j < 16; j++)
            {
                int offset = (73 + HexDump.EOL.Length) * j;

                outputArray[offset++] = (byte)'F';
                outputArray[offset++] = (byte)'F';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)ToHex(j);
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)' ';
                for (int k = 0; k < 16; k++)
                {
                    outputArray[offset++] = (byte)ToHex(j);
                    outputArray[offset++] = (byte)ToHex(k);
                    outputArray[offset++] = (byte)' ';
                }
                for (int k = 0; k < 16; k++)
                {
                    outputArray[offset++] = (byte)toAscii((j * 16) + k);
                }
                System.Array.Copy(Encoding.UTF8.GetBytes(HexDump.EOL), 0, outputArray, offset,
                                  Encoding.UTF8.GetBytes(HexDump.EOL).Length);
            }
            actualOutput = stream.ToArray();
            Assert.AreEqual(outputArray.Length, actualOutput.Length, "array size mismatch");
            for (int j = 0; j < outputArray.Length; j++)
            {
                Assert.AreEqual(outputArray[j],
                                actualOutput[j], "array[ " + j + "] mismatch");
            }

            // verify proper behavior with non-zero index
            stream = new MemoryStream();
            HexDump.Dump(testArray, 0x10000000, stream, 0x81);
            outputArray = new byte[(8 * (73 + HexDump.EOL.Length)) - 1];
            for (int j = 0; j < 8; j++)
            {
                int offset = (73 + HexDump.EOL.Length) * j;

                outputArray[offset++] = (byte)'1';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)'0';
                outputArray[offset++] = (byte)ToHex(j + 8);
                outputArray[offset++] = (byte)'1';
                outputArray[offset++] = (byte)' ';
                for (int k = 0; k < 16; k++)
                {
                    int index = 0x81 + (j * 16) + k;

                    if (index < 0x100)
                    {
                        outputArray[offset++] = (byte)ToHex(index / 16);
                        outputArray[offset++] = (byte)ToHex(index);
                    }
                    else
                    {
                        outputArray[offset++] = (byte)' ';
                        outputArray[offset++] = (byte)' ';
                    }
                    outputArray[offset++] = (byte)' ';
                }
                for (int k = 0; k < 16; k++)
                {
                    int index = 0x81 + (j * 16) + k;

                    if (index < 0x100)
                    {
                        outputArray[offset++] = (byte)toAscii(index);
                    }
                }
                System.Array.Copy(Encoding.UTF8.GetBytes(HexDump.EOL), 0, outputArray, offset,
                                  Encoding.UTF8.GetBytes(HexDump.EOL).Length);
            }
            actualOutput = stream.ToArray();
            Assert.AreEqual(outputArray.Length,
                            actualOutput.Length, "array size mismatch");
            for (int j = 0; j < outputArray.Length; j++)
            {
                Assert.AreEqual(outputArray[j],
                                actualOutput[j], "array[ " + j + "] mismatch");
            }

            // verify proper behavior with negative index
            try
            {
                HexDump.Dump(testArray, 0x10000000, new MemoryStream(),
                             -1);
                Assert.Fail("should have caught ArrayIndexOutOfBoundsException on negative index");
            }
            catch (IndexOutOfRangeException)
            {
                // as expected
            }

            // verify proper behavior with index that is too large
            try
            {
                HexDump.Dump(testArray, 0x10000000, new MemoryStream(),
                             testArray.Length);
                Assert.Fail("should have caught ArrayIndexOutOfBoundsException on large index");
            }
            catch (IndexOutOfRangeException)
            {
                // as expected
            }

            // verify proper behaviour with empty byte array
            MemoryStream os = new MemoryStream();

            HexDump.Dump(new byte[0], 0, os, 0);
            Assert.AreEqual("No Data" + Environment.NewLine, Encoding.UTF8.GetString(os.ToArray()));
        }
Esempio n. 5
0
        public void TestDumpToPrintStream()
        {
            byte[] testArray = new byte[256];

            for (int j = 0; j < 256; j++)
            {
                testArray[j] = (byte)j;
            }

            MemoryStream in1 = new MemoryStream(testArray);

            try
            {
                MemoryStream   byteOut = new MemoryStream();
                BufferedStream out1    = new BufferedStream(byteOut);
                try
                {
                    HexDump.Dump(in1, out1, 0, 256);
                }
                finally
                {
                    out1.Close();
                }

                String str = Encoding.UTF8.GetString(byteOut.ToArray());
                Assert.IsTrue(str.Contains("0123456789:;<=>?"), "Had: \n" + str);
            }
            finally
            {
                in1.Close();
            }

            in1 = new MemoryStream(testArray);
            try
            {
                MemoryStream   byteOut = new MemoryStream();
                BufferedStream out1    = new BufferedStream(byteOut);
                try
                {
                    // test with more than we have
                    HexDump.Dump(in1, out1, 0, 1000);
                }
                finally
                {
                    out1.Close();
                }

                String str = Encoding.UTF8.GetString(byteOut.ToArray());
                Assert.IsTrue(str.Contains("0123456789:;<=>?"), "Had: \n" + str);
            }
            finally
            {
                in1.Close();
            }

            in1 = new MemoryStream(testArray);
            try
            {
                MemoryStream   byteOut = new MemoryStream();
                BufferedStream out1    = new BufferedStream(byteOut);
                try
                {
                    // test with -1
                    HexDump.Dump(in1, out1, 0, -1);
                }
                finally
                {
                    out1.Close();
                }

                String str = Encoding.UTF8.GetString(byteOut.ToArray());
                Assert.IsTrue(str.Contains("0123456789:;<=>?"), "Had: \n" + str);
            }
            finally
            {
                in1.Close();
            }

            in1 = new MemoryStream(testArray);
            try
            {
                MemoryStream   byteOut = new MemoryStream();
                BufferedStream out1    = new BufferedStream(byteOut);
                try
                {
                    HexDump.Dump(in1, out1, 1, 235);
                }
                finally
                {
                    out1.Close();
                }

                String str = Encoding.UTF8.GetString(byteOut.ToArray());
                Assert.IsTrue(str.Contains("123456789:;<=>?@"),
                              "Line contents should be Moved by one now, but Had: \n" + str);
            }
            finally
            {
                in1.Close();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// This version of dump is a translation from the open office escher dump routine.
        /// </summary>
        /// <param name="maxLength">The number of bytes to Read</param>
        /// <param name="in1">An input stream to Read from.</param>
        public void DumpOld(long maxLength, Stream in1)
        {
            long          remainingBytes = maxLength;
            short         options;              // 4 bits for the version and 12 bits for the instance
            short         recordId;
            int           recordBytesRemaining; // including enclosing records
            StringBuilder stringBuf = new StringBuilder();
            short         nDumpSize;
            String        recordName;

            bool atEOF = false;

            while (!atEOF && (remainingBytes > 0))
            {
                stringBuf            = new StringBuilder();
                options              = LittleEndian.ReadShort(in1);
                recordId             = LittleEndian.ReadShort(in1);
                recordBytesRemaining = LittleEndian.ReadInt(in1);

                remainingBytes -= 2 + 2 + 4;

                switch (recordId)
                {
                case unchecked ((short)0xF000):
                    recordName = "MsofbtDggContainer";
                    break;

                case unchecked ((short)0xF006):
                    recordName = "MsofbtDgg";
                    break;

                case unchecked ((short)0xF016):
                    recordName = "MsofbtCLSID";
                    break;

                case unchecked ((short)0xF00B):
                    recordName = "MsofbtOPT";
                    break;

                case unchecked ((short)0xF11A):
                    recordName = "MsofbtColorMRU";
                    break;

                case unchecked ((short)0xF11E):
                    recordName = "MsofbtSplitMenuColors";
                    break;

                case unchecked ((short)0xF001):
                    recordName = "MsofbtBstoreContainer";
                    break;

                case unchecked ((short)0xF007):
                    recordName = "MsofbtBSE";
                    break;

                case unchecked ((short)0xF002):
                    recordName = "MsofbtDgContainer";
                    break;

                case unchecked ((short)0xF008):
                    recordName = "MsofbtDg";
                    break;

                case unchecked ((short)0xF118):
                    recordName = "MsofbtRegroupItem";
                    break;

                case unchecked ((short)0xF120):
                    recordName = "MsofbtColorScheme";
                    break;

                case unchecked ((short)0xF003):
                    recordName = "MsofbtSpgrContainer";
                    break;

                case unchecked ((short)0xF004):
                    recordName = "MsofbtSpContainer";
                    break;

                case unchecked ((short)0xF009):
                    recordName = "MsofbtSpgr";
                    break;

                case unchecked ((short)0xF00A):
                    recordName = "MsofbtSp";
                    break;

                case unchecked ((short)0xF00C):
                    recordName = "MsofbtTextbox";
                    break;

                case unchecked ((short)0xF00D):
                    recordName = "MsofbtClientTextbox";
                    break;

                case unchecked ((short)0xF00E):
                    recordName = "MsofbtAnchor";
                    break;

                case unchecked ((short)0xF00F):
                    recordName = "MsofbtChildAnchor";
                    break;

                case unchecked ((short)0xF010):
                    recordName = "MsofbtClientAnchor";
                    break;

                case unchecked ((short)0xF011):
                    recordName = "MsofbtClientData";
                    break;

                case unchecked ((short)0xF11F):
                    recordName = "MsofbtOleObject";
                    break;

                case unchecked ((short)0xF11D):
                    recordName = "MsofbtDeletedPspl";
                    break;

                case unchecked ((short)0xF005):
                    recordName = "MsofbtSolverContainer";
                    break;

                case unchecked ((short)0xF012):
                    recordName = "MsofbtConnectorRule";
                    break;

                case unchecked ((short)0xF013):
                    recordName = "MsofbtAlignRule";
                    break;

                case unchecked ((short)0xF014):
                    recordName = "MsofbtArcRule";
                    break;

                case unchecked ((short)0xF015):
                    recordName = "MsofbtClientRule";
                    break;

                case unchecked ((short)0xF017):
                    recordName = "MsofbtCalloutRule";
                    break;

                case unchecked ((short)0xF119):
                    recordName = "MsofbtSelection";
                    break;

                case unchecked ((short)0xF122):
                    recordName = "MsofbtUDefProp";
                    break;

                default:
                    if (recordId >= unchecked ((short)0xF018) && recordId <= unchecked ((short)0xF117))
                    {
                        recordName = "MsofbtBLIP";
                    }
                    else if ((options & (short)0x000F) == (short)0x000F)
                    {
                        recordName = "UNKNOWN container";
                    }
                    else
                    {
                        recordName = "UNKNOWN ID";
                    }
                    break;
                }

                stringBuf.Append("  ");
                stringBuf.Append(HexDump.ToHex(recordId));
                stringBuf.Append("  ").Append(recordName).Append(" [");
                stringBuf.Append(HexDump.ToHex(options));
                stringBuf.Append(',');
                stringBuf.Append(HexDump.ToHex(recordBytesRemaining));
                stringBuf.Append("]  instance: ");
                stringBuf.Append(HexDump.ToHex(((short)(options >> 4))));
                Console.WriteLine(stringBuf.ToString());


                if (recordId == (unchecked ((short)0xF007)) && 36 <= remainingBytes && 36 <= recordBytesRemaining)
                {       // BSE, FBSE
                    //                ULONG nP = pIn->GetRecPos();

                    byte n8;
                    //                short n16;
                    //                int n32;

                    stringBuf = new StringBuilder("    btWin32: ");
                    n8        = (byte)in1.ReadByte();
                    stringBuf.Append(HexDump.ToHex(n8));
                    stringBuf.Append(GetBlipType(n8));
                    stringBuf.Append("  btMacOS: ");
                    n8 = (byte)in1.ReadByte();
                    stringBuf.Append(HexDump.ToHex(n8));
                    stringBuf.Append(GetBlipType(n8));
                    Console.WriteLine(stringBuf.ToString());

                    Console.WriteLine("    rgbUid:");
                    HexDump.Dump(in1, 0, 16);

                    Console.Write("    tag: ");
                    OutHex(2, in1);
                    Console.WriteLine();
                    Console.Write("    size: ");
                    OutHex(4, in1);
                    Console.WriteLine();
                    Console.Write("    cRef: ");
                    OutHex(4, in1);
                    Console.WriteLine();
                    Console.Write("    offs: ");
                    OutHex(4, in1);
                    Console.WriteLine();
                    Console.Write("    usage: ");
                    OutHex(4, in1);
                    Console.WriteLine();
                    Console.Write("    cbName: ");
                    OutHex(4, in1);
                    Console.WriteLine();
                    Console.Write("    unused2: ");
                    OutHex(4, in1);
                    Console.WriteLine();
                    Console.Write("    unused3: ");
                    OutHex(4, in1);
                    Console.WriteLine();

                    // subtract the number of bytes we've Read
                    remainingBytes -= 36;
                    //n -= pIn->GetRecPos() - nP;
                    recordBytesRemaining = 0;           // loop to MsofbtBLIP
                }
                else if (recordId == unchecked ((short)0xF010) && 0x12 <= remainingBytes && 0x12 <= recordBytesRemaining)
                {       // ClientAnchor
                    //ULONG nP = pIn->GetRecPos();
                    //                short n16;

                    Console.Write("    Flag: ");
                    OutHex(2, in1);
                    Console.WriteLine();
                    Console.Write("    Col1: ");
                    OutHex(2, in1);
                    Console.Write("    dX1: ");
                    OutHex(2, in1);
                    Console.Write("    Row1: ");
                    OutHex(2, in1);
                    Console.Write("    dY1: ");
                    OutHex(2, in1);
                    Console.WriteLine();
                    Console.Write("    Col2: ");
                    OutHex(2, in1);
                    Console.Write("    dX2: ");
                    OutHex(2, in1);
                    Console.Write("    Row2: ");
                    OutHex(2, in1);
                    Console.Write("    dY2: ");
                    OutHex(2, in1);
                    Console.WriteLine();

                    remainingBytes       -= 18;
                    recordBytesRemaining -= 18;
                }
                else if (recordId == unchecked ((short)0xF00B) || recordId == unchecked ((short)0xF122))
                {       // OPT
                    int nComplex = 0;
                    Console.WriteLine("    PROPID        VALUE");
                    while (recordBytesRemaining >= 6 + nComplex && remainingBytes >= 6 + nComplex)
                    {
                        short n16;
                        int   n32;
                        n16 = LittleEndian.ReadShort(in1);
                        n32 = LittleEndian.ReadInt(in1);

                        recordBytesRemaining -= 6;
                        remainingBytes       -= 6;
                        Console.Write("    ");
                        Console.Write(HexDump.ToHex(n16));
                        Console.Write(" (");
                        int propertyId = n16 & (short)0x3FFF;
                        Console.Write(" " + propertyId);
                        if ((n16 & unchecked ((short)0x8000)) == 0)
                        {
                            if ((n16 & (short)0x4000) != 0)
                            {
                                Console.Write(", fBlipID");
                            }
                            Console.Write(")  ");

                            Console.Write(HexDump.ToHex(n32));

                            if ((n16 & (short)0x4000) == 0)
                            {
                                Console.Write(" (");
                                Console.Write(Dec1616(n32));
                                Console.Write(')');
                                Console.Write(" {" + PropertyName((short)propertyId) + "}");
                            }
                            Console.WriteLine();
                        }
                        else
                        {
                            Console.Write(", fComplex)  ");
                            Console.Write(HexDump.ToHex(n32));
                            Console.Write(" - Complex prop len");
                            Console.WriteLine(" {" + PropertyName((short)propertyId) + "}");

                            nComplex += n32;
                        }
                    }
                    // complex property data
                    while ((nComplex & remainingBytes) > 0)
                    {
                        nDumpSize = (nComplex > (int)remainingBytes) ? (short)remainingBytes : (short)nComplex;
                        HexDump.Dump(in1, 0, nDumpSize);
                        nComplex             -= nDumpSize;
                        recordBytesRemaining -= nDumpSize;
                        remainingBytes       -= nDumpSize;
                    }
                }
                else if (recordId == (unchecked ((short)0xF012)))
                {
                    Console.Write("    Connector rule: ");
                    Console.Write(LittleEndian.ReadInt(in1));
                    Console.Write("    ShapeID A: ");
                    Console.Write(LittleEndian.ReadInt(in1));
                    Console.Write("   ShapeID B: ");
                    Console.Write(LittleEndian.ReadInt(in1));
                    Console.Write("    ShapeID connector: ");
                    Console.Write(LittleEndian.ReadInt(in1));
                    Console.Write("   Connect pt A: ");
                    Console.Write(LittleEndian.ReadInt(in1));
                    Console.Write("   Connect pt B: ");
                    Console.WriteLine(LittleEndian.ReadInt(in1));

                    recordBytesRemaining -= 24;
                    remainingBytes       -= 24;
                }
                else if (recordId >= unchecked ((short)0xF018) && recordId < unchecked ((short)0xF117))
                {
                    Console.WriteLine("    Secondary UID: ");
                    HexDump.Dump(in1, 0, 16);
                    Console.WriteLine("    Cache of size: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Boundary top: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Boundary left: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Boundary width: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Boundary height: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    X: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Y: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Cache of saved size: " + HexDump.ToHex(LittleEndian.ReadInt(in1)));
                    Console.WriteLine("    Compression Flag: " + HexDump.ToHex((byte)in1.ReadByte()));
                    Console.WriteLine("    Filter: " + HexDump.ToHex((byte)in1.ReadByte()));
                    Console.WriteLine("    Data (after decompression): ");

                    recordBytesRemaining -= 34 + 16;
                    remainingBytes       -= 34 + 16;

                    nDumpSize = (recordBytesRemaining > (int)remainingBytes) ? (short)remainingBytes : (short)recordBytesRemaining;


                    byte[] buf  = new byte[nDumpSize];
                    int    Read = in1.Read(buf, 0, buf.Length);
                    while (Read != -1 && Read < nDumpSize)
                    {
                        Read += in1.Read(buf, Read, buf.Length);
                    }

                    using (MemoryStream bin = new MemoryStream(buf))
                    {
                        using (ZlibStream in2 = new ZlibStream(bin, CompressionMode.Decompress, false))
                        {
                            int bytesToDump = -1;
                            HexDump.Dump(in2, 0, bytesToDump);

                            recordBytesRemaining -= nDumpSize;
                            remainingBytes       -= nDumpSize;
                        }
                    }
                }

                bool isContainer = (options & (short)0x000F) == (short)0x000F;
                if (isContainer && remainingBytes >= 0)
                {       // Container
                    if (recordBytesRemaining <= (int)remainingBytes)
                    {
                        Console.WriteLine("            completed within");
                    }
                    else
                    {
                        Console.WriteLine("            continued elsewhere");
                    }
                }
                else if (remainingBytes >= 0)     // -> 0x0000 ... 0x0FFF
                {
                    nDumpSize = (recordBytesRemaining > (int)remainingBytes) ? (short)remainingBytes : (short)recordBytesRemaining;

                    if (nDumpSize != 0)
                    {
                        HexDump.Dump(in1, 0, nDumpSize);
                        remainingBytes -= nDumpSize;
                    }
                }
                else
                {
                    Console.WriteLine(" >> OVERRUN <<");
                }
            }
        }