public static WUDInfo createAndLoad(WUDDiscReader discReader, byte[] titleKey) { WUDInfo result = new WUDInfo(titleKey, discReader); byte[] PartitionTocBlock = discReader.readDecryptedToByteArray(Settings.WIIU_DECRYPTED_AREA_OFFSET, 0, 0x8000, titleKey, null); // verify DiscKey before proceeding byte[] copy = new byte[4]; Array.ConstrainedCopy(PartitionTocBlock, 0, copy, 0, 4); if (!ArraysEqual(copy, DECRYPTED_AREA_SIGNATURE)) { //MessageBox.Show("Decryption of PartitionTocBlock failed"); return(null); } Dictionary <string, WUDPartition> partitions = readPartitions(result, PartitionTocBlock); result.partitions.Clear(); foreach (var v in partitions) { result.partitions.Add(v.Key, v.Value); } return(result); }
private static byte[] getFSTEntryAsByte(String filename, WUDPartition partition, FST fst, WUDDiscReader discReader, byte[] key) { FSTEntry entry = getEntryByName(fst.root, filename); ContentFSTInfo info = fst.contentFSTInfos[((int)entry.contentFSTID)]; // Calculating the IV ByteBuffer byteBuffer = ByteBuffer.allocate(0x10); byteBuffer.position(0x08); long l = entry.fileOffset >> 16; byte[] ar = BitConverter.GetBytes(l); byte[] IV = new byte[0x10];//= copybyteBuffer.putLong(entry.fileOffset >> 16).ToArray(); Array.ConstrainedCopy(ar, 0, IV, 0x08, 0x08); return(discReader.readDecryptedToByteArray(Settings.WIIU_DECRYPTED_AREA_OFFSET + (long)partition.partitionOffset + (long)info.getOffset(), entry.fileOffset, (int)entry.fileSize, key, IV)); }