void DecryptFileBytes(byte[] eraBytes) { using (var era_in_ms = new System.IO.MemoryStream(eraBytes, writable: false)) using (var era_out_ms = new System.IO.MemoryStream(eraBytes, writable: true)) using (var era_reader = new IO.EndianReader(era_in_ms, Shell.EndianFormat.Big)) using (var era_writer = new IO.EndianWriter(era_out_ms, Shell.EndianFormat.Big)) { // "Halo Wars Alpha 093106 Feb 21 2009" was released pre-decrypted, so try and detect if the file is already decrypted first if (!EraFileHeader.VerifyIsEraAndDecrypted(era_reader)) { CryptStream(era_reader, era_writer, Security.Cryptography.CryptographyTransformType.Decrypt); } } }
bool ReadEraFromStream() { bool result = true; result = EraFileHeader.VerifyIsEraAndDecrypted(mEraStream.Reader); if (!result) { if (VerboseOutput != null) { VerboseOutput.WriteLine("\tFailed: File is either not decrypted, corrupt, or not even an ERA"); } } else { mEraStream.VirtualAddressTranslationInitialize(Shell.ProcessorSize.x32); mEraFile = new EraFile(); mEraFile.FileName = mSourceFile; mEraFile.Serialize(mEraStream); mEraFile.ReadPostprocess(mEraStream); } return(result); }