2019-03-31 19:29:36 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Switch_Toolbox.Library.IO;
|
|
|
|
|
using Syroot.BinaryData;
|
2019-04-21 19:55:21 +00:00
|
|
|
|
using System.IO;
|
2019-03-31 19:29:36 +00:00
|
|
|
|
|
|
|
|
|
namespace FirstPlugin
|
|
|
|
|
{
|
|
|
|
|
public class SAHT
|
|
|
|
|
{
|
2019-04-21 19:55:21 +00:00
|
|
|
|
public string FileName { get; set; }
|
|
|
|
|
|
|
|
|
|
public SAHT(string fileName) {
|
|
|
|
|
FileName = fileName;
|
|
|
|
|
Read(new FileReader(fileName));
|
2019-03-31 19:29:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<HashEntry> HashEntries = new List<HashEntry>();
|
|
|
|
|
|
|
|
|
|
private void Read(FileReader reader)
|
|
|
|
|
{
|
|
|
|
|
reader.ReadSignature(4, "SAHT");
|
|
|
|
|
uint FileSize = reader.ReadUInt32();
|
|
|
|
|
uint Offset = reader.ReadUInt32();
|
|
|
|
|
uint EntryCount = reader.ReadUInt32();
|
|
|
|
|
|
|
|
|
|
reader.Seek(Offset, System.IO.SeekOrigin.Begin);
|
|
|
|
|
for (int i = 0; i <EntryCount; i++)
|
|
|
|
|
{
|
|
|
|
|
HashEntry entry = new HashEntry();
|
|
|
|
|
entry.Read(reader);
|
|
|
|
|
reader.Align(16);
|
|
|
|
|
HashEntries.Add(entry);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-21 19:55:21 +00:00
|
|
|
|
ToTextFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ToTextFile()
|
|
|
|
|
{
|
|
|
|
|
StringWriter writer = new StringWriter();
|
|
|
|
|
|
2019-03-31 19:29:36 +00:00
|
|
|
|
foreach (var entry in HashEntries)
|
|
|
|
|
{
|
2019-04-21 19:55:21 +00:00
|
|
|
|
writer.WriteLine($"{entry.Name}={entry.Hash.ToString("x")}");
|
2019-03-31 19:29:36 +00:00
|
|
|
|
}
|
2019-04-21 19:55:21 +00:00
|
|
|
|
|
|
|
|
|
File.WriteAllText(FileName + ".txt", writer.ToString());
|
2019-03-31 19:29:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class HashEntry
|
|
|
|
|
{
|
|
|
|
|
public uint Hash { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public void Read(FileReader reader)
|
|
|
|
|
{
|
|
|
|
|
Hash = reader.ReadUInt32();
|
|
|
|
|
Name = reader.ReadString(BinaryStringFormat.ZeroTerminated);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|