示例#1
0
        public byte[] GetBytes(WriterCompatibilityMode writerCompatibilityMode)
        {
            byte[] buffer = new byte[HeaderLength];
            ByteWriter.WriteAnsiString(buffer, 0, dwMagic, 4);
            // update CRCPartial later
            ByteWriter.WriteAnsiString(buffer, 8, wMagicClient, 2);
            LittleEndianWriter.WriteUInt16(buffer, 10, wVer);
            LittleEndianWriter.WriteUInt16(buffer, 12, wVerClient);
            buffer[14] = bPlatformCreate;
            buffer[15] = bPlatformAccess;

            LittleEndianWriter.WriteUInt32(buffer, 16, dwReserved1);
            LittleEndianWriter.WriteUInt32(buffer, 20, dwReserved2);

            bidUnused.WriteBytes(buffer, 24);
            bidNextP.WriteBytes(buffer, 32);

            LittleEndianWriter.WriteUInt32(buffer, 40, dwUnique);

            int position = 44;

            for (int index = 0; index < 32; index++)
            {
                LittleEndianWriter.WriteUInt32(buffer, position, rgnid[index]);
                position += 4;
            }

            root.WriteBytes(buffer, 180, writerCompatibilityMode);

            LittleEndianWriter.WriteUInt32(buffer, 252, dwAlign);
            Array.Copy(rgbFM, 0, buffer, 256, 128);
            Array.Copy(rgbFP, 0, buffer, 384, 128);
            buffer[512] = bSentinel;
            buffer[513] = (byte)bCryptMethod;

            bidNextB.WriteBytes(buffer, 516);

            // update dwCRCFull later
            // ullReserved
            // dwReserved
            Array.Copy(rgbReserved2, 0, buffer, 528, 3);
            buffer[531] = bReserved;
            Array.Copy(rgbReserved3, 0, buffer, 532, 32);

            CRCPartial = PSTCRCCalculation.ComputeCRC(buffer, 8, 471);
            dwCRCFull  = PSTCRCCalculation.ComputeCRC(buffer, 8, 516);
            LittleEndianWriter.WriteUInt32(buffer, 4, CRCPartial);
            LittleEndianWriter.WriteUInt32(buffer, 524, dwCRCFull);

            return(buffer);
        }
示例#2
0
 public void WriteBytes(byte[] buffer, int offset)
 {
     bid.WriteBytes(buffer, offset + 0);
     LittleEndianWriter.WriteUInt64(buffer, offset + 8, ib);
 }