} // Offset: 0x1410, Size: 0xF0 public override byte[] ToByteArray() { var buffer = new byte[0x1500]; base.ToByteArray().CopyTo(buffer, 0); ExheaderHash.CopyTo(buffer, 0x160); BitConverter.GetBytes(AdditionalHeaderSize).CopyTo(buffer, 0x180); BitConverter.GetBytes(SectorZeroOffset).CopyTo(buffer, 0x184); BitConverter.GetBytes(PartitionFlags).CopyTo(buffer, 0x188); PartitionIdTable.CopyTo(buffer, 0x190); Reserved1.CopyTo(buffer, 0x1D0); Reserved2.CopyTo(buffer, 0x1F0); BitConverter.GetBytes(Card2SaveAddress).CopyTo(buffer, 0x200); BitConverter.GetBytes(CardInfoBitmask).CopyTo(buffer, 0x204); Reserved3.CopyTo(buffer, 0x208); BitConverter.GetBytes(TitleVersion).CopyTo(buffer, 0x310); BitConverter.GetBytes(CardRevision).CopyTo(buffer, 0x312); Reserved4.CopyTo(buffer, 0x314); CardSeedY.CopyTo(buffer, 0x1000); EncryptedCardSeed.CopyTo(buffer, 0x1010); CardSeedAESMAC.CopyTo(buffer, 0x1020); CardSeedNonce.CopyTo(buffer, 0x1030); Reserved5.CopyTo(buffer, 0x103C); FirstNcchHeader.CopyTo(buffer, 0x1100); CardDeviceReserved1.CopyTo(buffer, 0x1200); TitleKey.CopyTo(buffer, 0x1400); CardDeviceReserved2.CopyTo(buffer, 0x1410); return(buffer); }
public override void Log(TextWriter writer) { base.Log(writer); writer.Write($"Reserved1({Reserved1.ToHex()}) "); writer.Write($"RfpIv({RfpIv.ToHex()}) "); writer.Write($"Reserved2({Reserved2.ToHex()}) "); writer.Write($"OmmIv({OmmIv.ToHex()})"); }
public override void Log(TextWriter writer) { base.Log(writer); writer.Write($" Connections 01-03({BmcConnections01_03}) Connections 04-06({BmcConnections04_06}) Connections 07-09({BmcConnections07_09}) Connections 10-12({BmcConnections10_12})"); writer.Write($" DSP Chan used 01-02({BmcDspChans01_02}) DSP Chan used 03-04({BmcDspChans03_04}) DSP Chan used 05-06({BmcDspChans05_06}) DSP Chan used 07-08({BmcDspChans07_08})"); writer.Write($" Lost Connections({LostConnections})"); if (!Reserved1.Span.IsEmpty()) { writer.Write($" Reserved1({Reserved1.ToHex()})"); } writer.Write($" MAC Reset({MacReset}) Reject Dummy({RejectDummy}) Ho Timer > 150ms({HoTimer})"); if (!Reserved2.Span.IsEmpty()) { writer.Write($" Reserved2({Reserved2.ToHex()})"); } writer.Write($" Bad Frames({BadFrames}) Good Frames({GoodFrames})"); }
/// <summary> /// Validates the header and throws an exception if it's invalid /// </summary> public void Validate() { var E = Encoding.Default; if (Cookie == null || E.GetBytes(Cookie).Length != 8) { throw new ValidationException(nameof(Cookie), "Must be an 8 byte (ANSI) string"); } if (DataOffset != DEFAULT_DATA_OFFSET) { throw new ValidationException(nameof(DataOffset), $"Is currently unused and must be set to {DEFAULT_DATA_OFFSET}"); } if (TableOffset < HEADER_LENGTH + Footer.HEADER_LENGTH) { throw new ValidationException(nameof(TableOffset), $"Can't be less than the footer size plus the dynamic header size"); } if (HeaderVersion == null) { throw new ValidationException(nameof(HeaderVersion), "Must be defined"); } if (HeaderVersion.Major < ushort.MinValue || HeaderVersion.Minor < ushort.MinValue || HeaderVersion.Major > ushort.MaxValue || HeaderVersion.Minor > ushort.MaxValue) { throw new ValidationException(nameof(HeaderVersion), $"Major and minor must range from {ushort.MinValue}-{ushort.MaxValue}"); } if (MaxTableEntries == 0) { throw new ValidationException(nameof(MaxTableEntries), "Can't be zero. It should be equal to the number of blocks in the disk"); } if (BlockSize == 0) { throw new ValidationException(nameof(BlockSize), "Can't be zero."); } if (BlockSize % 512 != 0) { throw new ValidationException(nameof(BlockSize), "Must be a multiple of 512"); } if (VHD.ToDiskTimestamp(ParentTimeStamp) < int.MinValue || VHD.ToDiskTimestamp(ParentTimeStamp) > int.MaxValue) { throw new ValidationException(nameof(ParentTimeStamp), $"Must be at most {int.MinValue} - {int.MaxValue} seconds away from 2000-01-01 00:00:00 UTC"); } if (Reserved1 == null || Reserved1.Length != RESERVED1_FIELD_SIZE || Reserved1.Any(m => m > 0)) { throw new ValidationException(nameof(Reserved1), $"Must be {RESERVED1_FIELD_SIZE} nullbytes"); } if (Checksum != ComputeChecksum()) { throw new ValidationException(nameof(Checksum), $"Wrong checksum. Expected: {ComputeChecksum()}"); } if (ParentUnicodeName == null || Encoding.Unicode.GetBytes(ParentUnicodeName).Length != UNICODE_PARENT_LENGTH) { throw new ValidationException(nameof(ParentUnicodeName), $"Must be a {UNICODE_PARENT_LENGTH} byte UTF-16 string. Pad with nullbytes as needed"); } if (ParentLocatorEntries == null || ParentLocatorEntries.Length != LOCATOR_ENTRY_COUNT) { throw new ValidationException(nameof(ParentLocatorEntries), $"Must contain {LOCATOR_ENTRY_COUNT} entries"); } for (var i = 0; i < LOCATOR_ENTRY_COUNT; i++) { try { ParentLocatorEntries[i].Validate(); } catch (Exception ex) { throw new ValidationException(nameof(ParentLocatorEntries), $"Element at index {i} failed to validate. See inner exception for details.", ex); } } if (Reserved2 == null || Reserved2.Length != RESERVED2_FIELD_SIZE || Reserved2.Any(m => m > 0)) { throw new ValidationException(nameof(Reserved2), $"Must be {RESERVED2_FIELD_SIZE} nullbytes"); } }