├── README.md
├── YPF Manager
├── packages.config
├── App.config
├── Checksum
│ ├── Checksum.cs
│ ├── MurmurHash2.cs
│ ├── Crc32.cs
│ └── Adler32.cs
├── YPF
│ ├── YPFEntry.cs
│ ├── YPFHeader.cs
│ └── YPFArchive.cs
├── Log.cs
├── Properties
│ └── AssemblyInfo.cs
├── Util.cs
├── YPF Manager.csproj
├── Program.cs
└── Config.cs
├── YPF Manager.sln
└── .gitignore
/README.md:
--------------------------------------------------------------------------------
1 | # YPF-Manager
--------------------------------------------------------------------------------
/YPF Manager/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/YPF Manager/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/YPF Manager/Checksum/Checksum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace Ypf_Manager
5 | {
6 | abstract class Checksum
7 | {
8 |
9 | //
10 | // Variable(s)
11 | //
12 |
13 | public abstract String Name { get; }
14 |
15 |
16 | //
17 | // Function(s)
18 | //
19 |
20 | // Compute byte array hash with implemented algorithm
21 | public abstract UInt32 ComputeHash(Byte[] inputBytes);
22 |
23 |
24 | // Compute stream hash with implemented algorithm
25 | public UInt32 ComputeHash(Stream inputStream, int length)
26 | {
27 | Byte[] buffer = new Byte[length];
28 |
29 | inputStream.Read(buffer, 0, length);
30 |
31 | return ComputeHash(buffer);
32 | }
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/YPF Manager/YPF/YPFEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Ypf_Manager
4 | {
5 | class YPFEntry
6 | {
7 |
8 | //
9 | // Enum(s)
10 | //
11 |
12 | public enum FileType
13 | {
14 | text = 0,
15 | bmp = 1,
16 | png = 2,
17 | jpg = 3,
18 | gif = 4,
19 | wav = 5,
20 | ogg = 6,
21 | psd = 7,
22 | ycg = 8, //masked as .png
23 | psb = 9
24 | }
25 |
26 |
27 | //
28 | // Variable(s)
29 | //
30 |
31 | public String FileName { get; set; }
32 |
33 | public UInt32 NameChecksum { get; set; }
34 |
35 | public UInt32 DataChecksum { get; set; }
36 |
37 | public Int32 CompressedFileSize { get; set; }
38 |
39 | public Int32 RawFileSize { get; set; }
40 |
41 | public Boolean IsCompressed { get; set; }
42 |
43 | public FileType Type { get; set; }
44 |
45 | public Int64 Offset { get; set; }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/YPF Manager/Log.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace Ypf_Manager
6 | {
7 | class Log
8 | {
9 |
10 | //
11 | // Variable(s)
12 | //
13 |
14 | private readonly StringBuilder sb;
15 |
16 |
17 | //
18 | // Constructor(s)
19 | //
20 |
21 | public Log()
22 | {
23 | sb = new StringBuilder();
24 | }
25 |
26 |
27 | //
28 | // Function(s)
29 | //
30 |
31 | // Add a new message to the log
32 | public void Add(String message)
33 | {
34 | sb.Append(DateTime.Now.ToString("[yyyy/MM/dd HH:mm:ss] "));
35 | sb.Append(message);
36 | sb.Append('\n');
37 | }
38 |
39 |
40 | // Save the log into a file
41 | public void Save()
42 | {
43 | String outputFile = $@"{Config.ExecutableLocation()}\log.txt";
44 |
45 | File.AppendAllText(outputFile, sb.ToString(), new UTF8Encoding(false));
46 | }
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/YPF Manager.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30804.86
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YPF Manager", "YPF Manager\YPF Manager.csproj", "{A4127DE7-0837-4139-BFE2-A6C2DC7B3C29}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {A4127DE7-0837-4139-BFE2-A6C2DC7B3C29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {A4127DE7-0837-4139-BFE2-A6C2DC7B3C29}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {A4127DE7-0837-4139-BFE2-A6C2DC7B3C29}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {A4127DE7-0837-4139-BFE2-A6C2DC7B3C29}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {27B4C83D-3D23-40B9-8435-D86BC249F786}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/YPF Manager/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("YPF Manager")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("YPF Manager")]
14 | [assembly: AssemblyCopyright("Copyright © 2020")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("a4127de7-0837-4139-bfe2-a6c2dc7b3c29")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("0.1.0.0")]
37 | [assembly: AssemblyFileVersion("0.1.0.0")]
38 | [assembly: NeutralResourcesLanguage("en")]
39 |
--------------------------------------------------------------------------------
/YPF Manager/Util.cs:
--------------------------------------------------------------------------------
1 | using Ionic.Zlib;
2 | using System;
3 | using System.IO;
4 |
5 | namespace Ypf_Manager
6 | {
7 | public static class Util
8 | {
9 |
10 | //
11 | // Function(s)
12 | //
13 |
14 | // Returns the one complement of a given byte
15 | public static Byte OneComplement(Byte i)
16 | {
17 | return (Byte)~i;
18 | }
19 |
20 |
21 | // Copy data from input stream to ouput stream
22 | public static void CopyStream(Stream inputStream, Stream outputStream, Int64 length)
23 | {
24 | Int32 bufferSize = 4096;
25 |
26 | Byte[] buffer = new Byte[bufferSize];
27 |
28 | Int64 bytesToRead = length;
29 |
30 | while (bytesToRead > 0)
31 | {
32 | Int32 bytesRead = inputStream.Read(buffer, 0, (Int32)Math.Min(bufferSize, bytesToRead));
33 |
34 | outputStream.Write(buffer, 0, bytesRead);
35 |
36 | bytesToRead -= bytesRead;
37 | }
38 | }
39 |
40 |
41 | // Decompress zlib stream to memory stream
42 | public static MemoryStream DecompressZlibStream(Stream inputStream, int decompressedSize)
43 | {
44 | MemoryStream decompressedFileStream = new MemoryStream(decompressedSize);
45 |
46 | using (ZlibStream decompressionStream = new ZlibStream(inputStream, CompressionMode.Decompress, true))
47 | {
48 | decompressionStream.CopyTo(decompressedFileStream);
49 | }
50 |
51 | decompressedFileStream.Position = 0;
52 |
53 | if (decompressedFileStream.Length != decompressedSize)
54 | {
55 | throw new Exception("Invalid Decompressed File Size");
56 | }
57 |
58 | return decompressedFileStream;
59 | }
60 |
61 |
62 | // Compress stream to zlib memory stream
63 | public static MemoryStream CompressZlibStream(Stream inputStream)
64 | {
65 | MemoryStream compressedFileStream = new MemoryStream();
66 |
67 | using (ZlibStream compressionStream = new ZlibStream(compressedFileStream, CompressionMode.Compress, CompressionLevel.Level9, true))
68 | {
69 | CopyStream(inputStream, compressionStream, inputStream.Length);
70 | }
71 |
72 | return compressedFileStream;
73 | }
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/YPF Manager/Checksum/MurmurHash2.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Source: https://github.com/abrandoned/murmur2/blob/master/MurmurHash2.c
3 | *
4 | * MurmurHash2, by Austin Appleby
5 | * Note - This code makes a few assumptions about how your machine behaves -
6 | * 1. We can read a 4-byte value from any address without crashing
7 | * 2. sizeof(int) == 4
8 | *
9 | * And it has a few limitations -
10 | *
11 | * 1. It will not work incrementally.
12 | * 2. It will not produce the same results on little-endian and big-endian
13 | * machines.
14 | */
15 |
16 | using System;
17 |
18 | namespace Ypf_Manager
19 | {
20 | class MurmurHash2 : Checksum
21 | {
22 |
23 | //
24 | // Variable(s)
25 | //
26 |
27 | public override string Name => "MurmurHash2";
28 |
29 |
30 | //
31 | // Function(s)
32 | //
33 |
34 | // Compute byte array hash with MurmurHash2 algorithm
35 | public override UInt32 ComputeHash(byte[] data)
36 | {
37 | //
38 | // Original function parameters
39 | //
40 |
41 | UInt32 seed = 0;
42 | Int32 len = data.Length;
43 |
44 |
45 | //
46 | // MurmurHash2 compute hash
47 | //
48 |
49 | // 'm' and 'r' are mixing constants generated offline
50 | // They're not really 'magic', they just happen to work well
51 | const UInt32 m = 0x5bd1e995;
52 | const Int32 r = 24;
53 |
54 | // Initialize the hash to a 'random' value
55 | UInt32 h = seed ^ (UInt32)len;
56 |
57 | // Mix 4 bytes at a time into the hash
58 | Int32 dataIndex = 0;
59 |
60 | while (len >= 4)
61 | {
62 | UInt32 k = BitConverter.ToUInt32(data, dataIndex);
63 |
64 | k *= m;
65 | k ^= k >> r;
66 | k *= m;
67 |
68 | h *= m;
69 | h ^= k;
70 |
71 | dataIndex += 4;
72 | len -= 4;
73 | }
74 |
75 | // Handle the last few bytes of the input array
76 | if (len == 3)
77 | {
78 | h ^= (UInt32)(data[dataIndex + 2] << 16);
79 | len--;
80 | }
81 |
82 | if (len == 2)
83 | {
84 | h ^= (UInt32)(data[dataIndex + 1] << 8);
85 | len--;
86 | }
87 |
88 | if (len == 1)
89 | {
90 | h ^= data[dataIndex];
91 |
92 | h *= m;
93 | }
94 |
95 | // Do a few final mixes of the hash to ensure the last few bytes are well-incorporated
96 | h ^= h >> 13;
97 | h *= m;
98 | h ^= h >> 15;
99 |
100 | return h;
101 | }
102 |
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/YPF Manager/YPF Manager.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A4127DE7-0837-4139-BFE2-A6C2DC7B3C29}
8 | Exe
9 | Ypf_Manager
10 | YPF Manager
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 |
39 | ..\packages\DotNetZip.1.15.0\lib\net40\DotNetZip.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/YPF Manager/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace Ypf_Manager
5 | {
6 | class Program
7 | {
8 |
9 | //
10 | // Function(s)
11 | //
12 |
13 | static void Main(string[] args)
14 | {
15 | // Set variables
16 | Log log = new Log();
17 | Config config = new Config();
18 |
19 | // Header
20 | Console.WriteLine("YPF Manager v0.1");
21 | Console.WriteLine();
22 | Console.WriteLine();
23 |
24 | try
25 | {
26 | // Scan args
27 | config.Set(args);
28 |
29 | // Process current operation mode
30 | switch (config.Mode)
31 | {
32 | case Config.OperationMode.CreateArchive:
33 |
34 | foreach (String f in config.FoldersToProcess)
35 | {
36 | YPFArchive.Create(f, $"{f}.ypf", config.EngineVersion);
37 | }
38 | break;
39 |
40 | case Config.OperationMode.ExtractArchive:
41 |
42 | foreach (String f in config.FilesToProcess)
43 | {
44 | YPFArchive.Extract(f, $@"{Path.GetDirectoryName(f)}\{Path.GetFileNameWithoutExtension(f)}");
45 | }
46 | break;
47 |
48 | case Config.OperationMode.PrintArchiveInfo:
49 |
50 | foreach (String f in config.FilesToProcess)
51 | {
52 | YPFArchive.PrintInfo(f, config.SkipDataIntegrityValidationOnPrintInfo);
53 | }
54 | break;
55 |
56 | case Config.OperationMode.Help:
57 |
58 | Console.WriteLine("[DESCRIPTION]");
59 | Console.WriteLine("Manage your YPF archives with this tool.");
60 | Console.WriteLine();
61 |
62 | Console.WriteLine("[USAGE]");
63 | Console.WriteLine("Create archive:\t\t-c -v [options]");
64 | Console.WriteLine("Extract archive:\t-e [options]");
65 | Console.WriteLine("Print info:\t\t-p [options]");
66 | Console.WriteLine();
67 |
68 | Console.WriteLine("[OPTIONS]");
69 | Console.WriteLine("\t-c \tSet create archive mode");
70 | Console.WriteLine("\t-e \t\tSet extract archive mode");
71 | Console.WriteLine("\t-p \t\tSet print archive info mode");
72 | Console.WriteLine("\t-v \t\tSet the YU-RIS engine target version of the archive file");
73 | Console.WriteLine("\t-w\t\t\tWait for user input before exit");
74 | Console.WriteLine("\t-sdc\t\t\tSkip data integrity validation (Print info only)");
75 |
76 | break;
77 | }
78 | }
79 | catch (Exception ex)
80 | {
81 | // Save error to log
82 | log.Add(ex.Message);
83 | log.Save();
84 |
85 | // Print error to console
86 | Console.WriteLine(ex.Message);
87 | }
88 |
89 | // Wait for user input if -w argument is provided
90 | if (config.WaitForUserInputBeforeExit)
91 | {
92 | Console.WriteLine();
93 | Console.WriteLine("Press enter to exit");
94 | Console.ReadLine();
95 | }
96 | }
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/YPF Manager/Checksum/Crc32.cs:
--------------------------------------------------------------------------------
1 | // Source: https://en.wikipedia.org/wiki/Cyclic_redundancy_check
2 |
3 | using System;
4 |
5 | namespace Ypf_Manager
6 | {
7 |
8 | class Crc32 : Checksum
9 | {
10 |
11 | //
12 | // Variable(s)
13 | //
14 |
15 | public override string Name => "CRC32";
16 |
17 | private readonly UInt32[] Crc32Table =
18 | {
19 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
20 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
21 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
22 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
23 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
24 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
25 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
26 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
27 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
28 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
29 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
30 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
31 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
32 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
33 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
34 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
35 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
36 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
37 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
38 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
39 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
40 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
41 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
42 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
43 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
44 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
45 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
46 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
47 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
48 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
49 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
50 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
51 | };
52 |
53 |
54 | //
55 | // Function(s)
56 | //
57 |
58 | // Compute byte array hash with CRC-32 algorithm
59 | public override UInt32 ComputeHash(byte[] data)
60 | {
61 | // Initialize CRC-32 to starting value
62 | UInt32 crc32 = 0xffffffff;
63 |
64 | for (int i = 0; i < data.Length; i++)
65 | {
66 | // Crc32Table is an array of 256 32-bit constants
67 | crc32 = (crc32 >> 8) ^ Crc32Table[(byte)((crc32 ^ data[i]) & 0xFF)];
68 | }
69 |
70 | // Finalize the CRC-32 value by inverting all the bits
71 | return ~crc32;
72 | }
73 |
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/YPF Manager/Config.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 |
5 | namespace Ypf_Manager
6 | {
7 | class Config
8 | {
9 |
10 | //
11 | // Enum(s)
12 | //
13 |
14 | public enum OperationMode
15 | {
16 | CreateArchive = 0,
17 | ExtractArchive = 1,
18 | PrintArchiveInfo = 2,
19 | Help = 3
20 | }
21 |
22 |
23 | //
24 | // Variable(s)
25 | //
26 |
27 | public static String ExecutableLocation()
28 | {
29 | return Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
30 | }
31 | public OperationMode Mode { get; set; }
32 |
33 | public Boolean WaitForUserInputBeforeExit { get; set; }
34 |
35 | public Boolean SkipDataIntegrityValidationOnPrintInfo { get; set; }
36 |
37 | public Int32 EngineVersion { get; set; }
38 |
39 | public List FilesToProcess { get; set; }
40 |
41 | public List FoldersToProcess { get; set; }
42 |
43 |
44 | //
45 | // Constructor(s)
46 | //
47 |
48 | public Config()
49 | {
50 | //
51 | // Set initial values
52 | //
53 |
54 | Mode = OperationMode.Help;
55 |
56 | WaitForUserInputBeforeExit = false;
57 |
58 | SkipDataIntegrityValidationOnPrintInfo = false;
59 |
60 | EngineVersion = 0;
61 |
62 | FilesToProcess = new List();
63 | FoldersToProcess = new List();
64 | }
65 |
66 |
67 | //
68 | // Function(s)
69 | //
70 |
71 | // Scan args to set options
72 | public void Set(String[] args)
73 | {
74 | //
75 | // Scan arguments
76 | //
77 |
78 | for (int i = 0; i < args.Length; i++)
79 | {
80 | String currentArg = args[i];
81 |
82 | if (currentArg == "-c")
83 | {
84 | // Create archive
85 | Mode = OperationMode.CreateArchive;
86 | }
87 | else if (currentArg == "-e")
88 | {
89 | // Extract archive
90 | Mode = OperationMode.ExtractArchive;
91 | }
92 | else if (currentArg == "-p")
93 | {
94 | // Print archive info
95 | Mode = OperationMode.PrintArchiveInfo;
96 | }
97 | else if (currentArg == "-v")
98 | {
99 | //
100 | // Set engine version
101 | //
102 |
103 | // When -v is provided, the next argument is the engine version
104 | i++;
105 |
106 | if (i == args.Length)
107 | {
108 | // -v is the last argument and no version is provided
109 | throw new Exception("Can't find engine version");
110 | }
111 |
112 | // Try parsing the provided engine version
113 | if (Int32.TryParse(args[i], out int engine))
114 | {
115 | EngineVersion = engine;
116 | }
117 | else
118 | {
119 | throw new Exception("Failed parsing engine version");
120 | }
121 | }
122 | else if (currentArg == "-w")
123 | {
124 | // Wait for user input before exit
125 | WaitForUserInputBeforeExit = true;
126 | }
127 | else if (currentArg == "-sdc")
128 | {
129 | // Skip data check
130 | SkipDataIntegrityValidationOnPrintInfo = true;
131 | }
132 | else if (currentArg.EndsWith(".ypf") && File.Exists(currentArg))
133 | {
134 | // Detected file
135 | FilesToProcess.Add(Path.GetFullPath(currentArg));
136 | }
137 | else if (Directory.Exists(currentArg))
138 | {
139 | // Detected folder
140 | FoldersToProcess.Add(Path.GetFullPath(currentArg));
141 | }
142 | }
143 |
144 |
145 | //
146 | // Detect edge cases
147 | //
148 |
149 | if ((Mode == OperationMode.ExtractArchive || Mode == OperationMode.PrintArchiveInfo) && FilesToProcess.Count == 0)
150 | {
151 | throw new Exception("Can't find files to process");
152 | }
153 | else if (Mode == OperationMode.CreateArchive && FoldersToProcess.Count == 0)
154 | {
155 | throw new Exception("Can't find folders to process");
156 | }
157 | }
158 |
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/YPF Manager/Checksum/Adler32.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Source: https://github.com/madler/zlib/blob/master/adler32.c
3 | *
4 | * adler32.c -- compute the Adler-32 checksum of a data stream
5 | *
6 | * Copyright (C) 1995-2011, 2016 Mark Adler
7 | *
8 | * This software is provided 'as-is', without any express or implied
9 | * warranty. In no event will the authors be held liable for any damages
10 | * arising from the use of this software.
11 | *
12 | * Permission is granted to anyone to use this software for any purpose,
13 | * including commercial applications, and to alter it and redistribute it
14 | * freely, subject to the following restrictions:
15 | *
16 | * 1. The origin of this software must not be misrepresented; you must not
17 | * claim that you wrote the original software. If you use this software
18 | * in a product, an acknowledgment in the product documentation would be
19 | * appreciated but is not required.
20 | * 2. Altered source versions must be plainly marked as such, and must not be
21 | * misrepresented as being the original software.
22 | * 3. This notice may not be removed or altered from any source distribution.
23 | *
24 | * Jean-loup Gailly Mark Adler
25 | * jloup@gzip.org madler@alumni.caltech.edu
26 | *
27 | * The data format used by the zlib library is described by RFCs (Request for
28 | * Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
29 | * (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
30 | */
31 |
32 | using System;
33 |
34 | namespace Ypf_Manager
35 | {
36 |
37 | class Adler32 : Checksum
38 | {
39 |
40 | //
41 | // Variable(s)
42 | //
43 |
44 | public override string Name => "Adler32";
45 |
46 | // Largest prime smaller than 65536
47 | const UInt32 BASE = 65521;
48 |
49 | const Int32 NMAX = 5552;
50 |
51 |
52 | //
53 | // Function(s)
54 | //
55 |
56 | // Compute byte array hash with Adler32 algorithm
57 | public override UInt32 ComputeHash(byte[] data)
58 | {
59 | //
60 | // Original function parameters
61 | //
62 |
63 | UInt32 adler = 1;
64 | Int32 dataIndex = 0;
65 | Int32 len = data.Length;
66 |
67 |
68 | //
69 | // Adler32 compute hash
70 | //
71 |
72 | // Split Adler-32 into component sums
73 | UInt32 sum2 = (adler >> 16) & 0xffff;
74 | adler &= 0xffff;
75 |
76 | // In case user likes doing a byte at a time, keep it fast
77 | if (len == 1)
78 | {
79 | adler += data[0];
80 | if (adler >= BASE)
81 | adler -= BASE;
82 | sum2 += adler;
83 | if (sum2 >= BASE)
84 | sum2 -= BASE;
85 | return adler | (sum2 << 16);
86 | }
87 |
88 | // Initial Adler-32 value (deferred check for len == 1 speed)
89 | if (len == 0)
90 | return 1;
91 |
92 | // In case short lengths are provided, keep it somewhat fast
93 | if (len < 16)
94 | {
95 | while (0 != len--)
96 | {
97 | adler += data[dataIndex++];
98 | sum2 += adler;
99 | }
100 | if (adler >= BASE)
101 | adler -= BASE;
102 |
103 | // Only added so many BASE's
104 | sum2 %= BASE;
105 |
106 | return adler | (sum2 << 16);
107 | }
108 |
109 | // Do length NMAX blocks -- requires just one modulo operation
110 | while (len >= NMAX)
111 | {
112 | len -= NMAX;
113 |
114 | // NMAX is divisible by 16
115 | Int32 n = NMAX / 16;
116 |
117 | do
118 | {
119 | // 16 sums unrolled
120 |
121 | // DO16(buf);
122 | for (int i = 0; i < 16; i++)
123 | {
124 | adler += data[dataIndex++]; sum2 += adler;
125 | }
126 | } while (0 != --n);
127 | adler %= BASE;
128 | sum2 %= BASE;
129 | }
130 |
131 | // Do remaining bytes (less than NMAX, still just one modulo)
132 | if (0 != len)
133 | {
134 | // Avoid modulos if none remaining
135 | while (len >= 16)
136 | {
137 | len -= 16;
138 |
139 | // DO16(buf);
140 | for (int i = 0; i < 16; i++)
141 | {
142 | adler += data[dataIndex++]; sum2 += adler;
143 | }
144 | }
145 | while (0 != len--)
146 | {
147 | adler += data[dataIndex++];
148 | sum2 += adler;
149 | }
150 | adler %= BASE;
151 | sum2 %= BASE;
152 | }
153 |
154 | // Return recombined sums
155 | return adler | (sum2 << 16);
156 | }
157 |
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.vspscc
94 | *.vssscc
95 | .builds
96 | *.pidb
97 | *.svclog
98 | *.scc
99 |
100 | # Chutzpah Test files
101 | _Chutzpah*
102 |
103 | # Visual C++ cache files
104 | ipch/
105 | *.aps
106 | *.ncb
107 | *.opendb
108 | *.opensdf
109 | *.sdf
110 | *.cachefile
111 | *.VC.db
112 | *.VC.VC.opendb
113 |
114 | # Visual Studio profiler
115 | *.psess
116 | *.vsp
117 | *.vspx
118 | *.sap
119 |
120 | # Visual Studio Trace Files
121 | *.e2e
122 |
123 | # TFS 2012 Local Workspace
124 | $tf/
125 |
126 | # Guidance Automation Toolkit
127 | *.gpState
128 |
129 | # ReSharper is a .NET coding add-in
130 | _ReSharper*/
131 | *.[Rr]e[Ss]harper
132 | *.DotSettings.user
133 |
134 | # TeamCity is a build add-in
135 | _TeamCity*
136 |
137 | # DotCover is a Code Coverage Tool
138 | *.dotCover
139 |
140 | # AxoCover is a Code Coverage Tool
141 | .axoCover/*
142 | !.axoCover/settings.json
143 |
144 | # Coverlet is a free, cross platform Code Coverage Tool
145 | coverage*.json
146 | coverage*.xml
147 | coverage*.info
148 |
149 | # Visual Studio code coverage results
150 | *.coverage
151 | *.coveragexml
152 |
153 | # NCrunch
154 | _NCrunch_*
155 | .*crunch*.local.xml
156 | nCrunchTemp_*
157 |
158 | # MightyMoose
159 | *.mm.*
160 | AutoTest.Net/
161 |
162 | # Web workbench (sass)
163 | .sass-cache/
164 |
165 | # Installshield output folder
166 | [Ee]xpress/
167 |
168 | # DocProject is a documentation generator add-in
169 | DocProject/buildhelp/
170 | DocProject/Help/*.HxT
171 | DocProject/Help/*.HxC
172 | DocProject/Help/*.hhc
173 | DocProject/Help/*.hhk
174 | DocProject/Help/*.hhp
175 | DocProject/Help/Html2
176 | DocProject/Help/html
177 |
178 | # Click-Once directory
179 | publish/
180 |
181 | # Publish Web Output
182 | *.[Pp]ublish.xml
183 | *.azurePubxml
184 | # Note: Comment the next line if you want to checkin your web deploy settings,
185 | # but database connection strings (with potential passwords) will be unencrypted
186 | *.pubxml
187 | *.publishproj
188 |
189 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
190 | # checkin your Azure Web App publish settings, but sensitive information contained
191 | # in these scripts will be unencrypted
192 | PublishScripts/
193 |
194 | # NuGet Packages
195 | *.nupkg
196 | # NuGet Symbol Packages
197 | *.snupkg
198 | # The packages folder can be ignored because of Package Restore
199 | **/[Pp]ackages/*
200 | # except build/, which is used as an MSBuild target.
201 | !**/[Pp]ackages/build/
202 | # Uncomment if necessary however generally it will be regenerated when needed
203 | #!**/[Pp]ackages/repositories.config
204 | # NuGet v3's project.json files produces more ignorable files
205 | *.nuget.props
206 | *.nuget.targets
207 |
208 | # Microsoft Azure Build Output
209 | csx/
210 | *.build.csdef
211 |
212 | # Microsoft Azure Emulator
213 | ecf/
214 | rcf/
215 |
216 | # Windows Store app package directories and files
217 | AppPackages/
218 | BundleArtifacts/
219 | Package.StoreAssociation.xml
220 | _pkginfo.txt
221 | *.appx
222 | *.appxbundle
223 | *.appxupload
224 |
225 | # Visual Studio cache files
226 | # files ending in .cache can be ignored
227 | *.[Cc]ache
228 | # but keep track of directories ending in .cache
229 | !?*.[Cc]ache/
230 |
231 | # Others
232 | ClientBin/
233 | ~$*
234 | *~
235 | *.dbmdl
236 | *.dbproj.schemaview
237 | *.jfm
238 | *.pfx
239 | *.publishsettings
240 | orleans.codegen.cs
241 |
242 | # Including strong name files can present a security risk
243 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
244 | #*.snk
245 |
246 | # Since there are multiple workflows, uncomment next line to ignore bower_components
247 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
248 | #bower_components/
249 |
250 | # RIA/Silverlight projects
251 | Generated_Code/
252 |
253 | # Backup & report files from converting an old project file
254 | # to a newer Visual Studio version. Backup files are not needed,
255 | # because we have git ;-)
256 | _UpgradeReport_Files/
257 | Backup*/
258 | UpgradeLog*.XML
259 | UpgradeLog*.htm
260 | ServiceFabricBackup/
261 | *.rptproj.bak
262 |
263 | # SQL Server files
264 | *.mdf
265 | *.ldf
266 | *.ndf
267 |
268 | # Business Intelligence projects
269 | *.rdl.data
270 | *.bim.layout
271 | *.bim_*.settings
272 | *.rptproj.rsuser
273 | *- [Bb]ackup.rdl
274 | *- [Bb]ackup ([0-9]).rdl
275 | *- [Bb]ackup ([0-9][0-9]).rdl
276 |
277 | # Microsoft Fakes
278 | FakesAssemblies/
279 |
280 | # GhostDoc plugin setting file
281 | *.GhostDoc.xml
282 |
283 | # Node.js Tools for Visual Studio
284 | .ntvs_analysis.dat
285 | node_modules/
286 |
287 | # Visual Studio 6 build log
288 | *.plg
289 |
290 | # Visual Studio 6 workspace options file
291 | *.opt
292 |
293 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
294 | *.vbw
295 |
296 | # Visual Studio LightSwitch build output
297 | **/*.HTMLClient/GeneratedArtifacts
298 | **/*.DesktopClient/GeneratedArtifacts
299 | **/*.DesktopClient/ModelManifest.xml
300 | **/*.Server/GeneratedArtifacts
301 | **/*.Server/ModelManifest.xml
302 | _Pvt_Extensions
303 |
304 | # Paket dependency manager
305 | .paket/paket.exe
306 | paket-files/
307 |
308 | # FAKE - F# Make
309 | .fake/
310 |
311 | # CodeRush personal settings
312 | .cr/personal
313 |
314 | # Python Tools for Visual Studio (PTVS)
315 | __pycache__/
316 | *.pyc
317 |
318 | # Cake - Uncomment if you are using it
319 | # tools/**
320 | # !tools/packages.config
321 |
322 | # Tabs Studio
323 | *.tss
324 |
325 | # Telerik's JustMock configuration file
326 | *.jmconfig
327 |
328 | # BizTalk build output
329 | *.btp.cs
330 | *.btm.cs
331 | *.odx.cs
332 | *.xsd.cs
333 |
334 | # OpenCover UI analysis results
335 | OpenCover/
336 |
337 | # Azure Stream Analytics local run output
338 | ASALocalRun/
339 |
340 | # MSBuild Binary and Structured Log
341 | *.binlog
342 |
343 | # NVidia Nsight GPU debugger configuration file
344 | *.nvuser
345 |
346 | # MFractors (Xamarin productivity tool) working folder
347 | .mfractor/
348 |
349 | # Local History for Visual Studio
350 | .localhistory/
351 |
352 | # BeatPulse healthcheck temp database
353 | healthchecksdb
354 |
355 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
356 | MigrationBackup/
357 |
358 | # Ionide (cross platform F# VS Code tools) working folder
359 | .ionide/
360 |
361 | # Fody - auto-generated XML schema
362 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/YPF Manager/YPF/YPFHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Ypf_Manager
8 | {
9 | class YPFHeader
10 | {
11 |
12 | //
13 | // Variable(s)
14 | //
15 |
16 | // YPF\0
17 | public byte[] Signature { get { return new byte[] { 0x59, 0x50, 0x46, 0x00 }; } }
18 |
19 | private Int32 _version;
20 |
21 | public Int32 Version
22 | {
23 | get => _version;
24 | set
25 | {
26 | if (value < 234 || value > 500)
27 | {
28 | throw new Exception($"Version {value} not supported");
29 | }
30 |
31 | _version = value;
32 |
33 | SetLengthSwappingTable();
34 | SetChecksum();
35 | AssumeFileNameEncryptionKey();
36 | }
37 | }
38 |
39 | public Int32 ArchivedFilesHeaderSize { get; set; }
40 |
41 | //Shift-JIS
42 | public Encoding Encoding { get { return Encoding.GetEncoding(932); } }
43 |
44 | public List ArchivedFiles { get; set; }
45 |
46 | public Checksum NameChecksum { get; private set; }
47 |
48 | public Checksum DataChecksum { get; private set; }
49 |
50 | public Byte FileNameEncryptionKey { get; set; }
51 |
52 | public Byte[] LengthSwappingTable { get; private set; }
53 |
54 |
55 | //
56 | // Constructor(s)
57 | //
58 |
59 | public YPFHeader()
60 | {
61 | ArchivedFiles = new List();
62 | }
63 |
64 |
65 | public YPFHeader(int version)
66 | {
67 | ArchivedFiles = new List();
68 |
69 | Version = version;
70 | }
71 |
72 |
73 | public YPFHeader(Stream inputStream)
74 | {
75 | BinaryReader inputBinaryReader = new BinaryReader(inputStream);
76 |
77 | ArchivedFiles = new List();
78 |
79 | if (!Enumerable.SequenceEqual(Signature, inputBinaryReader.ReadBytes(4)))
80 | {
81 | throw new Exception("Invalid Archive Signature");
82 | }
83 |
84 | Version = inputBinaryReader.ReadInt32();
85 | int filesCount = inputBinaryReader.ReadInt32();
86 | ArchivedFilesHeaderSize = inputBinaryReader.ReadInt32();
87 |
88 | inputBinaryReader.BaseStream.Position += 16;
89 |
90 | if (filesCount <= 0)
91 | {
92 | throw new Exception("Invalid Files Count");
93 | }
94 |
95 | if (ArchivedFilesHeaderSize <= 0)
96 | {
97 | throw new Exception("Invalid Archived Files Header Size");
98 | }
99 |
100 | ArchivedFiles.Capacity = filesCount;
101 |
102 | for (int i = 0; i < filesCount; i++)
103 | {
104 | ArchivedFiles.Add(ReadNextEntry(inputBinaryReader));
105 | }
106 | }
107 |
108 |
109 | //
110 | // Function(s)
111 | //
112 |
113 | // Set length swapping table
114 | public void SetLengthSwappingTable()
115 | {
116 | if (Version >= 500)
117 | {
118 | LengthSwappingTable = new byte[] { 0x00, 0x01, 0x02, 0x0A, 0x04, 0x05, 0x35, 0x07, 0x08, 0x0B, 0x03, 0x09, 0x10, 0x13, 0x0E, 0x0F, 0x0C, 0x18, 0x12, 0x0D, 0x2E, 0x1B, 0x16, 0x17, 0x11, 0x19, 0x1A, 0x15, 0x1E, 0x1D, 0x1C, 0x1F, 0x23, 0x21, 0x22, 0x20, 0x24, 0x25, 0x29, 0x27, 0x28, 0x26, 0x2A, 0x2B, 0x2F, 0x2D, 0x14, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x06, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF };
119 | }
120 | else
121 | {
122 | LengthSwappingTable = new byte[] { 0x00, 0x01, 0x02, 0x48, 0x04, 0x05, 0x35, 0x07, 0x08, 0x0B, 0x0A, 0x09, 0x10, 0x13, 0x0E, 0x0F, 0x0C, 0x19, 0x12, 0x0D, 0x14, 0x1B, 0x16, 0x17, 0x18, 0x11, 0x1A, 0x15, 0x1E, 0x1D, 0x1C, 0x1F, 0x23, 0x21, 0x22, 0x20, 0x24, 0x25, 0x29, 0x27, 0x28, 0x26, 0x2A, 0x2B, 0x2F, 0x2D, 0x32, 0x2C, 0x30, 0x31, 0x2E, 0x33, 0x34, 0x06, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x03, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF };
123 | }
124 | }
125 |
126 |
127 | // Set the checksum algorithms
128 | public void SetChecksum()
129 | {
130 | if (Version < 479)
131 | {
132 | DataChecksum = new Adler32();
133 | NameChecksum = new Crc32();
134 | }
135 | else
136 | {
137 | DataChecksum = new MurmurHash2();
138 | NameChecksum = new MurmurHash2();
139 | }
140 | }
141 |
142 |
143 | // Assume filename xor encryption key (may not work because some versions have multiple keys)
144 | public void AssumeFileNameEncryptionKey()
145 | {
146 | if (Version == 290)
147 | {
148 | FileNameEncryptionKey = 0x40;
149 | }
150 | else if (Version >= 500)
151 | {
152 | FileNameEncryptionKey = 0x36;
153 | }
154 | else
155 | {
156 | FileNameEncryptionKey = 0x00;
157 | }
158 | }
159 |
160 |
161 | // Validate data integrity by checking if data checksum matches providen checksum
162 | public void ValidateDataIntegrity(Stream inputStream, Int64 position, Int32 length, UInt32 checksum)
163 | {
164 | inputStream.Position = position;
165 |
166 | UInt32 calculatedDataChecksum = DataChecksum.ComputeHash(inputStream, length);
167 |
168 | if (checksum != calculatedDataChecksum)
169 | {
170 | throw new Exception("Invalid Data Checksum / Corrupted Data");
171 | }
172 | }
173 |
174 |
175 | // Validate name integrity by checking if name checksum matches providen checksum
176 | public void ValidateNameIntegrity(Byte[] inputArray, UInt32 checksum)
177 | {
178 | UInt32 calculatedNameChecksum = NameChecksum.ComputeHash(inputArray);
179 |
180 | if (calculatedNameChecksum != checksum)
181 | {
182 | throw new Exception("Invalid Name Checksum / Corrupted Name");
183 | }
184 | }
185 |
186 |
187 | // Read the next entry from the provided file
188 | public YPFEntry ReadNextEntry(BinaryReader inputBinaryReader)
189 | {
190 | YPFEntry entry = new YPFEntry();
191 |
192 | entry.NameChecksum = inputBinaryReader.ReadUInt32();
193 |
194 | Byte fileNameLengthEncoded = Util.OneComplement(inputBinaryReader.ReadByte());
195 | Byte fileNameLengthDecoded = LengthSwappingTable[fileNameLengthEncoded];
196 |
197 | Byte[] fileNameEncoded = inputBinaryReader.ReadBytes(fileNameLengthDecoded);
198 |
199 | for (int i = 0; i < fileNameLengthDecoded; i++)
200 | {
201 | fileNameEncoded[i] = (byte)(Util.OneComplement(fileNameEncoded[i]) ^ FileNameEncryptionKey);
202 | }
203 |
204 | entry.FileName = Encoding.GetString(fileNameEncoded);
205 | entry.Type = (YPFEntry.FileType)inputBinaryReader.ReadByte();
206 | entry.IsCompressed = (inputBinaryReader.ReadByte() == 1);
207 | entry.RawFileSize = inputBinaryReader.ReadInt32();
208 | entry.CompressedFileSize = inputBinaryReader.ReadInt32();
209 |
210 | if (Version < 479)
211 | {
212 | entry.Offset = inputBinaryReader.ReadInt32();
213 | }
214 | else
215 | {
216 | entry.Offset = inputBinaryReader.ReadInt64();
217 | }
218 |
219 | entry.DataChecksum = inputBinaryReader.ReadUInt32();
220 |
221 | ValidateNameIntegrity(fileNameEncoded, entry.NameChecksum);
222 |
223 | if (!Enum.IsDefined(typeof(YPFEntry.FileType), entry.Type))
224 | {
225 | throw new Exception("Unexpected File Type");
226 | }
227 |
228 | return entry;
229 | }
230 |
231 |
232 | // Find a duplicate file entry with the same checksum and size
233 | public YPFEntry FindDuplicateEntry(UInt32 fileChecksum, Int32 fileSize)
234 | {
235 | return ArchivedFiles.FirstOrDefault(x => x.DataChecksum == fileChecksum && x.RawFileSize == fileSize);
236 | }
237 |
238 | }
239 | }
240 |
--------------------------------------------------------------------------------
/YPF Manager/YPF/YPFArchive.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 |
5 | namespace Ypf_Manager
6 | {
7 | static class YPFArchive
8 | {
9 |
10 | //
11 | // Function(s)
12 | //
13 |
14 | // Create a new archive from a given folder
15 | public static void Create(String inputFolder, String outputFile, Int32 version)
16 | {
17 | Console.WriteLine("[*COMPRESS*]");
18 | Console.WriteLine($"Folder: {inputFolder}");
19 | Console.WriteLine($"File: {outputFile}");
20 | Console.WriteLine($"Version: {version}");
21 | Console.WriteLine();
22 |
23 | Console.WriteLine("Initializing header");
24 |
25 | YPFHeader header = new YPFHeader(version);
26 |
27 | String[] filesToProcess = Directory.GetFiles(inputFolder, "*.*", SearchOption.AllDirectories);
28 |
29 | // Set list capacity to improve performance
30 | header.ArchivedFiles.Capacity = filesToProcess.Length;
31 |
32 | // Skip the constant header section
33 | header.ArchivedFilesHeaderSize = 32;
34 |
35 | // Process files to get their data and accurately calculate the header size
36 | foreach (String file in filesToProcess)
37 | {
38 | YPFEntry entry = new YPFEntry();
39 |
40 | String fileName = file.Substring(inputFolder.Length + 1);
41 | String fileExtension = Path.GetExtension(fileName).Substring(1);
42 |
43 | // Remove YCG extension from the filename
44 | if (fileExtension == "ycg")
45 | {
46 | fileName = fileName.Substring(0, fileName.Length - 4);
47 | }
48 |
49 | // Detect null filename
50 | // This can happen when using YCG files
51 | // e.g. fileName = ".ycg"
52 | if (!(fileName.Length > 0))
53 | {
54 | throw new Exception("Filename can't be null");
55 | }
56 |
57 | // Detect duplicated filenames (O(n^2))
58 | // This can happen when using YCG and PNG files together
59 | // e.g. fileName1 = "test1.png"
60 | // fileName2 = "test1.png.ycg"
61 | //
62 | // since ".ycg" will be trimmed from the end, the two files will have the same name:
63 | //
64 | // fileName1 = "test1.png" (PNG)
65 | // fileName2 = "test1.png" (YCG)
66 | if (header.ArchivedFiles.FirstOrDefault(x => x.FileName == fileName) != null)
67 | {
68 | throw new Exception("Filenames must be unique");
69 | }
70 |
71 | Byte[] encodedName = header.Encoding.GetBytes(fileName);
72 |
73 | entry.FileName = fileName;
74 | entry.NameChecksum = header.NameChecksum.ComputeHash(encodedName);
75 | entry.Type = Enum.IsDefined(typeof(YPFEntry.FileType), fileExtension) ? (YPFEntry.FileType)Enum.Parse(typeof(YPFEntry.FileType), fileExtension, true) : YPFEntry.FileType.text;
76 |
77 | // Accurately calculate the entry header size
78 | header.ArchivedFilesHeaderSize += 23 + encodedName.Length + (header.Version >= 479 ? 4 : 0);
79 |
80 | header.ArchivedFiles.Add(entry);
81 | }
82 |
83 | // Order list by Name Checksum as expected by the archive format
84 | header.ArchivedFiles = header.ArchivedFiles.OrderBy(x => x.NameChecksum).ToList();
85 |
86 | using (FileStream outputFileStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write, FileShare.None, 4096, FileOptions.SequentialScan))
87 | using (BinaryWriter outputBinaryWriter = new BinaryWriter(outputFileStream))
88 | {
89 | // Skip header to directly write the files
90 | outputFileStream.Position = header.ArchivedFilesHeaderSize;
91 |
92 | // Read the files and write them to the archive
93 | for (int i = 0; i < header.ArchivedFiles.Count; i++)
94 | {
95 | YPFEntry entry = header.ArchivedFiles[i];
96 |
97 | Console.WriteLine($"Adding {entry.FileName}");
98 |
99 | using (MemoryStream rawMemoryStream = new MemoryStream())
100 | {
101 | String filePath = $@"{inputFolder}\{entry.FileName}{(entry.Type == YPFEntry.FileType.ycg ? ".ycg" : "")}";
102 |
103 | // Copy the FileStream to a MemoryStream to improve performance
104 | using (FileStream inputFileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.SequentialScan))
105 | {
106 | // Check if the current file saturated the 32 filesize bits
107 | if (inputFileStream.Length > Int32.MaxValue)
108 | {
109 | throw new Exception("Max filesize reached for the current YPF version");
110 | }
111 |
112 | // Check if the current file is empty
113 | if (inputFileStream.Length == 0)
114 | {
115 | throw new Exception("Empty files (0 Byte) are not supported");
116 | }
117 |
118 | rawMemoryStream.Capacity = (Int32)inputFileStream.Length;
119 | Util.CopyStream(inputFileStream, rawMemoryStream, inputFileStream.Length);
120 | }
121 |
122 | rawMemoryStream.Position = 0;
123 |
124 | header.ArchivedFiles[i].Offset = outputFileStream.Position;
125 | header.ArchivedFiles[i].RawFileSize = (Int32)rawMemoryStream.Length;
126 |
127 | using (MemoryStream compressedFileStream = Util.CompressZlibStream(rawMemoryStream))
128 | {
129 | // Check if the compressed file is smaller than the original one
130 | if (compressedFileStream.Length < rawMemoryStream.Length)
131 | {
132 | compressedFileStream.Position = 0;
133 |
134 | UInt32 calculatedDataChecksum = header.DataChecksum.ComputeHash(compressedFileStream, (Int32)compressedFileStream.Length);
135 |
136 | YPFEntry duplicatedEntry = header.FindDuplicateEntry(calculatedDataChecksum, (Int32)rawMemoryStream.Length);
137 |
138 | if (duplicatedEntry != null)
139 | {
140 | header.ArchivedFiles[i].Offset = duplicatedEntry.Offset;
141 | }
142 | else
143 | {
144 | compressedFileStream.Position = 0;
145 |
146 | Util.CopyStream(compressedFileStream, outputFileStream, compressedFileStream.Length);
147 | }
148 |
149 | header.ArchivedFiles[i].CompressedFileSize = (Int32)compressedFileStream.Length;
150 | header.ArchivedFiles[i].IsCompressed = true;
151 | header.ArchivedFiles[i].DataChecksum = calculatedDataChecksum;
152 | }
153 | else
154 | {
155 | rawMemoryStream.Position = 0;
156 |
157 | UInt32 calculatedDataChecksum = header.DataChecksum.ComputeHash(rawMemoryStream, (Int32)rawMemoryStream.Length);
158 |
159 | YPFEntry duplicatedEntry = header.FindDuplicateEntry(calculatedDataChecksum, (Int32)rawMemoryStream.Length);
160 |
161 | if (duplicatedEntry != null)
162 | {
163 | header.ArchivedFiles[i].Offset = duplicatedEntry.Offset;
164 | }
165 | else
166 | {
167 | rawMemoryStream.Position = 0;
168 |
169 | Util.CopyStream(rawMemoryStream, outputFileStream, rawMemoryStream.Length);
170 | }
171 |
172 | header.ArchivedFiles[i].CompressedFileSize = (Int32)rawMemoryStream.Length;
173 | header.ArchivedFiles[i].IsCompressed = false;
174 | header.ArchivedFiles[i].DataChecksum = calculatedDataChecksum;
175 | }
176 | }
177 |
178 | // Check if the current file saturated the 32 offset bits
179 | if (header.Version < 479 && outputFileStream.Position > Int32.MaxValue)
180 | {
181 | throw new Exception("Max offset reached for the current YPF version");
182 | }
183 | }
184 | }
185 |
186 |
187 | //
188 | // Write the header since all the entry data is now known
189 | //
190 |
191 | Console.WriteLine($"Finalizing header");
192 |
193 | outputFileStream.Position = 0;
194 |
195 | outputBinaryWriter.Write(header.Signature);
196 | outputBinaryWriter.Write(header.Version);
197 | outputBinaryWriter.Write(header.ArchivedFiles.Count);
198 | outputBinaryWriter.Write(header.ArchivedFilesHeaderSize);
199 |
200 | outputFileStream.Position += 16;
201 |
202 | foreach (YPFEntry entry in header.ArchivedFiles)
203 | {
204 | outputBinaryWriter.Write(entry.NameChecksum);
205 |
206 | Byte[] encodedName = header.Encoding.GetBytes(entry.FileName);
207 |
208 | if (encodedName.Length > 0xFF)
209 | {
210 | throw new Exception("File name length can't be longer than 255 bytes (Shift-JIS)");
211 | }
212 |
213 | byte lengthEncoded = Util.OneComplement((byte)header.LengthSwappingTable.ToList().IndexOf((byte)encodedName.Length));
214 |
215 | outputBinaryWriter.Write(lengthEncoded);
216 |
217 | for (int i = 0; i < encodedName.Length; i++)
218 | {
219 | encodedName[i] = Util.OneComplement((byte)(encodedName[i] ^ header.FileNameEncryptionKey));
220 | }
221 |
222 | outputBinaryWriter.Write(encodedName);
223 | outputBinaryWriter.Write((byte)entry.Type);
224 | outputBinaryWriter.Write(entry.IsCompressed);
225 | outputBinaryWriter.Write(entry.RawFileSize);
226 | outputBinaryWriter.Write(entry.CompressedFileSize);
227 |
228 | if (header.Version < 479)
229 | {
230 | outputBinaryWriter.Write((Int32)entry.Offset);
231 | }
232 | else
233 | {
234 | outputBinaryWriter.Write(entry.Offset);
235 | }
236 |
237 | outputBinaryWriter.Write(entry.DataChecksum);
238 | }
239 |
240 | if (outputFileStream.Position != header.ArchivedFilesHeaderSize)
241 | {
242 | throw new Exception("Unexpected Header Size");
243 | }
244 | }
245 | }
246 |
247 |
248 | // Extract an archive to the specified folder
249 | public static void Extract(String inputFile, String outputFolder)
250 | {
251 | Console.WriteLine("[*EXTRACT*]");
252 | Console.WriteLine($"File: {inputFile}");
253 | Console.WriteLine($"Folder: {outputFolder}");
254 | Console.WriteLine();
255 |
256 | using (FileStream inputFileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.SequentialScan))
257 | {
258 | // Header data
259 | YPFHeader header = new YPFHeader(inputFileStream);
260 |
261 | // Order by offset to improve sequential read performance
262 | header.ArchivedFiles = header.ArchivedFiles.OrderBy(x => x.Offset).ToList();
263 |
264 | for (int i = 0; i < header.ArchivedFiles.Count; i++)
265 | {
266 | // Entry data
267 | YPFEntry entry = header.ArchivedFiles[i];
268 |
269 | Console.WriteLine($"[{i + 1}/{header.ArchivedFiles.Count}] Extracting {entry.FileName}");
270 |
271 | // Copy file to MemoryStream to improve performance
272 | MemoryStream entryMemoryStream = new MemoryStream(entry.CompressedFileSize);
273 | inputFileStream.Position = entry.Offset;
274 | Util.CopyStream(inputFileStream, entryMemoryStream, entry.CompressedFileSize);
275 |
276 | // Validate file checksum
277 | header.ValidateDataIntegrity(entryMemoryStream, 0, entry.CompressedFileSize, entry.DataChecksum);
278 | entryMemoryStream.Position = 0;
279 |
280 | // Decompress file if needed
281 | if (entry.IsCompressed)
282 | {
283 | entryMemoryStream = Util.DecompressZlibStream(entryMemoryStream, entry.RawFileSize);
284 | }
285 |
286 | String customExtension = (entry.Type == YPFEntry.FileType.ycg ? ".ycg" : "");
287 | String outputFileName = $@"{outputFolder}\{entry.FileName}{customExtension}";
288 |
289 | // Create file directory tree
290 | Directory.CreateDirectory(Path.GetDirectoryName(outputFileName));
291 |
292 | // Write the file
293 | using (FileStream outputFileStream = new FileStream(outputFileName, FileMode.Create, FileAccess.Write, FileShare.None, 4096, FileOptions.None))
294 | {
295 | Util.CopyStream(entryMemoryStream, outputFileStream, entry.RawFileSize);
296 | }
297 |
298 | entryMemoryStream.Dispose();
299 | }
300 | }
301 | }
302 |
303 |
304 | // Print the info of a specified archive
305 | public static void PrintInfo(String inputFile, Boolean skipDataIntegrityValidation)
306 | {
307 | Console.WriteLine("[*PRINT INFO*]");
308 | Console.WriteLine($"File: {inputFile}");
309 | Console.WriteLine();
310 |
311 | using (FileStream inputFileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.SequentialScan))
312 | {
313 | // Header data
314 | YPFHeader header = new YPFHeader(inputFileStream);
315 |
316 | // Print header info
317 | Console.WriteLine("[HEADER]");
318 | Console.WriteLine($"Version: {header.Version}");
319 | Console.WriteLine($"Files Count: {header.ArchivedFiles.Count}");
320 | Console.WriteLine($"Header Size: {header.ArchivedFilesHeaderSize}");
321 | Console.WriteLine($"Name Checksum Algorithm: {header.NameChecksum.Name}");
322 | Console.WriteLine($"Data Checksum Algorithm: {header.DataChecksum.Name}");
323 | Console.WriteLine($"Filename Encryption Key: {header.FileNameEncryptionKey:x2}");
324 | Console.WriteLine();
325 |
326 | Console.WriteLine("[FILES]");
327 |
328 | for (int i = 0; i < header.ArchivedFiles.Count; i++)
329 | {
330 | // Entry data
331 | YPFEntry entry = header.ArchivedFiles[i];
332 |
333 | // Print entry info
334 | Console.WriteLine($"[{i + 1}/{header.ArchivedFiles.Count}]");
335 | Console.WriteLine($"\tFilename: {entry.FileName}");
336 | Console.WriteLine($"\tCompressed: {entry.IsCompressed}");
337 | Console.WriteLine($"\tSize: {entry.RawFileSize}");
338 | Console.WriteLine($"\tCompressed Size: {entry.CompressedFileSize}");
339 | Console.WriteLine($"\tOffset: {entry.Offset}");
340 | Console.WriteLine($"\tType: {entry.Type}");
341 | Console.WriteLine($"\tName Checksum: {entry.NameChecksum:x8}");
342 | Console.WriteLine($"\tData Checksum: {entry.DataChecksum:x8}");
343 | Console.WriteLine();
344 | }
345 |
346 | // Skip data integrity validation if requested by the user
347 | if (!skipDataIntegrityValidation)
348 | {
349 | // Order by offset to improve sequential read performance
350 | header.ArchivedFiles = header.ArchivedFiles.OrderBy(x => x.Offset).ToList();
351 |
352 | Console.WriteLine();
353 | Console.WriteLine("[DATA]");
354 | Console.Write("Validating data integrity...");
355 |
356 | // Validate each entry
357 | foreach (YPFEntry entry in header.ArchivedFiles)
358 | {
359 | header.ValidateDataIntegrity(inputFileStream, entry.Offset, entry.CompressedFileSize, entry.DataChecksum);
360 | }
361 |
362 | Console.WriteLine(" Complete");
363 | }
364 | }
365 | }
366 |
367 | }
368 | }
369 |
--------------------------------------------------------------------------------