예제 #1
0
        private void WriteCFGData(SaveIO.SaveWriter writer)
        {
            // Get the CRC32 of the data
            byte[] cfgData = new byte[_cfgSize - CRC32Size];
            Encoding.ASCII.GetBytes(CFGText, 0, CFGText.Length, cfgData, 0);

            CRC32 crc32 = new CRC32();

            byte[] checksum = crc32.ComputeHash(cfgData);

            // Write it out
            writer.WriteBlock(checksum);
            writer.WriteBlock(cfgData);
        }
예제 #2
0
        private void WriteMainHeader(SaveIO.SaveWriter writer)
        {
            // Write the new header to a MemoryStream for resigning purposes
            MemoryStream tempStream = new MemoryStream(HeaderSize - CRC32Size);

            SaveIO.SaveWriter tempWriter = new SaveIO.SaveWriter(tempStream);
            tempWriter.WriteUInt32(_unknown);
            tempWriter.WriteInt32(_cfgSize);
            tempWriter.WriteInt32(_dataBlock1Size);
            tempWriter.WriteInt32(_dataBlock2Size);
            tempWriter.WriteInt32(_saveDataSize);

            // Grab its CRC32
            CRC32 crc32 = new CRC32();

            byte[] checksum = crc32.ComputeHash(tempStream.GetBuffer());

            // Now write it to the destination stream
            writer.WriteBlock(checksum);
            writer.WriteBlock(tempStream.GetBuffer());
            tempWriter.Close();
        }
예제 #3
0
        private void Resign(SaveIO.SaveWriter writer, Stream resignStream, long baseOffset)
        {
            long saveCrcOffset = baseOffset + HeaderSize + _cfgSize + _dataBlock1Size + _dataBlock2Size;

            // Resign the main save data
            resignStream.Seek(saveCrcOffset + CRC32Size, SeekOrigin.Begin);
            CRC32 crc32 = new CRC32();

            byte[] checksum = crc32.ComputeHash(resignStream);

            // Write it out
            writer.SeekTo(saveCrcOffset);
            writer.WriteBlock(checksum);
        }