From 9c7ea4c65904a71eb7bf28630bdc77950efe23c7 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 30 Dec 2016 20:52:59 +0400 Subject: [PATCH] implemented ACV1 archives. --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/NonColor/ArcACV.cs | 93 +++++++++++++++++++++++++++++++++++ supported.html | 7 ++- 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 ArcFormats/NonColor/ArcACV.cs diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 8712275b..e8cb6cb4 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -221,6 +221,7 @@ WidgetNPK.xaml + diff --git a/ArcFormats/NonColor/ArcACV.cs b/ArcFormats/NonColor/ArcACV.cs new file mode 100644 index 00000000..a782ebc3 --- /dev/null +++ b/ArcFormats/NonColor/ArcACV.cs @@ -0,0 +1,93 @@ +//! \file ArcACV.cs +//! \date Wed Dec 28 09:49:14 2016 +//! \brief Mirai resource archive. +// +// Copyright (C) 2016 by morkt +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.IO; +using GameRes.Compression; +using GameRes.Utility; + +namespace GameRes.Formats.NonColor +{ + [Export(typeof(ArchiveFormat))] + public class AcvOpener : DatOpener + { + public override string Tag { get { return "ACV"; } } + public override string Description { get { return "Mirai resource archive"; } } + public override uint Signature { get { return 0x31564341; } } // 'ACV1' + public override bool IsHierarchic { get { return true; } } + public override bool CanWrite { get { return false; } } + + public AcvOpener () + { + Extensions = new string[] { "dat" }; + } + + public override ArcFile TryOpen (ArcView file) + { + uint key = 0x8B6A4E5F; + int count = file.View.ReadInt32 (4) ^ (int)key; + if (!IsSaneCount (count)) + return null; + + var scheme = QueryScheme (file.Name); + if (null == scheme) + return null; + + bool is_script = VFS.IsPathEqualsToFileName (file.Name, "script.dat"); + + var dir = new List (count); + using (var input = file.CreateStream (8, (uint)count * 0x15)) + { + foreach (var entry in ReadIndex (input, count, scheme, key)) + { + if (!entry.CheckPlacement (file.MaxOffset)) + return null; + if (is_script) + entry.Hash ^= scheme.Hash; + dir.Add (entry); + } + } + return new ArcFile (file, this, dir); + } + + public override Stream OpenEntry (ArcFile arc, Entry entry) + { + var dent = entry as ArcDatEntry; + if (null == dent || 0 == dent.Size) + return arc.File.CreateStream (entry.Offset, entry.Size); + var data = arc.File.View.ReadBytes (entry.Offset, entry.Size); + if (dent.IsPacked) + { + DecryptData (data, (uint)dent.Hash); + return new ZLibStream (new MemoryStream (data), CompressionMode.Decompress); + } + if (dent.RawName != null && 0 != dent.Flags) + DecryptWithName (data, dent.RawName); + return new BinMemoryStream (data, entry.Name); + } + } +} diff --git a/supported.html b/supported.html index 53bf0ec5..0875ffdb 100644 --- a/supported.html +++ b/supported.html @@ -906,6 +906,7 @@ Otto no Mae de Okasarete...
*.gec-No *.arc-NoAI6WIN Gakuen Saimin Reido
+Shinsou Noise
*.akbAKBNo *.cpzCPZ2
CPZ5
CPZ6NoCMVS
CVNS @@ -1061,8 +1062,9 @@ Shin Genre Esudere!!
Valkyrie Complex
*.cps-No -arc*.dat
script.dat-Nonon color +arc*.dat
script.dat-
ACV1Nonon color
mirai Doubly na Kanojo
+Hana Hime * Absolute!
Nora to Oujo to Noraneko Heart
Tsujidou-san no Jun'ai Road
Tsujidou-san no Virgin Road
@@ -1289,6 +1291,9 @@ Maou no Ingu
Doreijou
*.kgfKGFNo +*.pfspf8NoArtemis Engine +Boku no Elf Onee-san
+

1 Non-encrypted only