From 01cd7d76752d32e9bb795b946972c550d901f0f3 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 3 Mar 2017 17:42:51 +0400 Subject: [PATCH] (MPK): check if *.msc entries are actually encrypted. --- ArcFormats/Propeller/ArcMPK.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ArcFormats/Propeller/ArcMPK.cs b/ArcFormats/Propeller/ArcMPK.cs index 39c23ffe..458da5ba 100644 --- a/ArcFormats/Propeller/ArcMPK.cs +++ b/ArcFormats/Propeller/ArcMPK.cs @@ -76,12 +76,11 @@ namespace GameRes.Formats.Propeller public override Stream OpenEntry (ArcFile arc, Entry entry) { - if (!entry.Name.EndsWith (".msc", StringComparison.InvariantCultureIgnoreCase)) - return base.OpenEntry (arc, entry); - var data = arc.File.View.ReadBytes (entry.Offset, entry.Size); - for (int i = 0; i < data.Length; ++i) - data[i] ^= 0x88; - return new BinMemoryStream (data, entry.Name); + var input = arc.File.CreateStream (entry.Offset, entry.Size); + if (!entry.Name.EndsWith (".msc", StringComparison.InvariantCultureIgnoreCase) + || 0x88 != input.PeekByte()) + return input; + return new XoredStream (input, 0x88); } } }