/// <summary> /// Parsing header data from encrypted file. /// <param name="data">Raw data.</param> /// <param name="offset">Offset from the start of the raw data <see cref="byte"/>[].</param> /// </summary> public void ParseStandardInformation(byte[] data, int offset) { if (data.Length < offset) { throw new Exception("File is corrupted."); } // position Type = (AttributeType)BitConverter.ToUInt32(data, offset); // 0 if (Type != AttributeType.STANDARD_INFORMATION) { throw new Exception("File is corrupted."); } TotalLength = BitConverter.ToUInt32(data, offset + 4); // 4 CreationTime = EnigmaEfsUtility.ConverteToWinTime(data, offset + 8); // 8 OwnerId = BitConverter.ToUInt32(data, offset + 16); // 16 AlteredTime = EnigmaEfsUtility.ConverteToWinTime(data, offset + 20); // 20 ATimeUserId = BitConverter.ToUInt32(data, offset + 28); // 28 ReadTime = EnigmaEfsUtility.ConverteToWinTime(data, offset + 32); // 32 RTimeUserId = BitConverter.ToUInt32(data, offset + 40); // 40 }
/// <summary> /// Writting Standard Information header to <see cref="byte"/>[]. /// </summary> public byte[] UnparseStandardInformation() { var standInformationHeader = new byte[GetSaveLength()]; // position Buffer.BlockCopy(BitConverter.GetBytes((uint)Type), 0, standInformationHeader, 0, 4); // 0 Buffer.BlockCopy(BitConverter.GetBytes(TotalLength), 0, standInformationHeader, 4, 4); // 4 EnigmaEfsUtility.ConverterFomWinTime(standInformationHeader, 8, CreationTime); // 8 Buffer.BlockCopy(BitConverter.GetBytes(OwnerId), 0, standInformationHeader, 16, 4); // 16 EnigmaEfsUtility.ConverterFomWinTime(standInformationHeader, 20, AlteredTime); // 20 Buffer.BlockCopy(BitConverter.GetBytes(ATimeUserId), 0, standInformationHeader, 28, 4); // 28 EnigmaEfsUtility.ConverterFomWinTime(standInformationHeader, 32, ReadTime); // 32 Buffer.BlockCopy(BitConverter.GetBytes(RTimeUserId), 0, standInformationHeader, 40, 4); // 40 return(standInformationHeader); }