mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(XP3): threat non-'File' index records as hashed names.
added NoCryptTitles to Xp3Scheme.
This commit is contained in:
parent
e0fa7430f2
commit
b02b95cbf1
@ -71,7 +71,8 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class Xp3Scheme : ResourceScheme
|
public class Xp3Scheme : ResourceScheme
|
||||||
{
|
{
|
||||||
public Dictionary<string, ICrypt> KnownSchemes;
|
public IDictionary<string, ICrypt> KnownSchemes;
|
||||||
|
public ISet<string> NoCryptTitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Archive version 1: encrypt file first, then calculate checksum
|
// Archive version 1: encrypt file first, then calculate checksum
|
||||||
@ -153,20 +154,7 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
if (entry_size < 0)
|
if (entry_size < 0)
|
||||||
return null;
|
return null;
|
||||||
dir_offset += 12 + entry_size;
|
dir_offset += 12 + entry_size;
|
||||||
if (0x6E666E68 == entry_signature // "hnfn"
|
if (0x656C6946 == entry_signature) // "File"
|
||||||
|| 0x6C696D73 == entry_signature // "smil"
|
|
||||||
|| 0x46696C65 == entry_signature) // "eliF"
|
|
||||||
{
|
|
||||||
uint hash = header.ReadUInt32();
|
|
||||||
int name_size = header.ReadInt16();
|
|
||||||
entry_size -= 6;
|
|
||||||
if (name_size * 2 <= entry_size)
|
|
||||||
{
|
|
||||||
var filename = new string (header.ReadChars (name_size));
|
|
||||||
filename_map.Add (hash, filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (0x656C6946 == entry_signature) // "File"
|
|
||||||
{
|
{
|
||||||
var entry = new Xp3Entry();
|
var entry = new Xp3Entry();
|
||||||
while (entry_size > 0)
|
while (entry_size > 0)
|
||||||
@ -262,6 +250,24 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
dir.Add (entry);
|
dir.Add (entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (entry_size > 7)
|
||||||
|
{
|
||||||
|
// 0x6E666E68 == entry_signature // "hnfn"
|
||||||
|
// 0x6C696D73 == entry_signature // "smil"
|
||||||
|
// 0x46696C65 == entry_signature // "eliF"
|
||||||
|
// 0x757A7559 == entry_signature // "Yuzu"
|
||||||
|
uint hash = header.ReadUInt32();
|
||||||
|
int name_size = header.ReadInt16();
|
||||||
|
if (name_size > 0)
|
||||||
|
{
|
||||||
|
entry_size -= 6;
|
||||||
|
if (name_size * 2 <= entry_size)
|
||||||
|
{
|
||||||
|
var filename = new string (header.ReadChars (name_size));
|
||||||
|
filename_map.Add (hash, filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
NextEntry:
|
NextEntry:
|
||||||
header.BaseStream.Position = dir_offset;
|
header.BaseStream.Position = dir_offset;
|
||||||
}
|
}
|
||||||
@ -740,12 +746,16 @@ NextEntry:
|
|||||||
var title = FormatCatalog.Instance.LookupGame (file.Name);
|
var title = FormatCatalog.Instance.LookupGame (file.Name);
|
||||||
if (string.IsNullOrEmpty (title))
|
if (string.IsNullOrEmpty (title))
|
||||||
return null;
|
return null;
|
||||||
return GetScheme (title);
|
ICrypt algorithm;
|
||||||
|
if (!KnownSchemes.TryGetValue (title, out algorithm) && NoCryptTitles.Contains (title))
|
||||||
|
algorithm = NoCryptAlgorithm;
|
||||||
|
return algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Xp3Scheme KiriKiriScheme = new Xp3Scheme
|
static Xp3Scheme KiriKiriScheme = new Xp3Scheme
|
||||||
{
|
{
|
||||||
KnownSchemes = new Dictionary<string, ICrypt>(),
|
KnownSchemes = new Dictionary<string, ICrypt>(),
|
||||||
|
NoCryptTitles = new HashSet<string>()
|
||||||
};
|
};
|
||||||
|
|
||||||
public static IDictionary<string, ICrypt> KnownSchemes
|
public static IDictionary<string, ICrypt> KnownSchemes
|
||||||
@ -753,6 +763,11 @@ NextEntry:
|
|||||||
get { return KiriKiriScheme.KnownSchemes; }
|
get { return KiriKiriScheme.KnownSchemes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ISet<string> NoCryptTitles
|
||||||
|
{
|
||||||
|
get { return KiriKiriScheme.NoCryptTitles; }
|
||||||
|
}
|
||||||
|
|
||||||
public override ResourceScheme Scheme
|
public override ResourceScheme Scheme
|
||||||
{
|
{
|
||||||
get { return KiriKiriScheme; }
|
get { return KiriKiriScheme; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user