Repository navigation
Expand file tree
/
Copy pathDecompiler.cs
More file actions
57 lines (45 loc) · 1.75 KB
/
Copy pathDecompiler.cs
File metadata and controls
57 lines (45 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UndertaleModLib;
using xdelta3.net;
namespace Watercooler
{
public class Decompiler
{
readonly string _gamePath, _patchPath, _outPath;
readonly UndertaleData _originalGameData, _modifiedGameData;
public Decompiler(string gamePath, string patchPath, string outPath)
{
_gamePath = gamePath;
_patchPath = patchPath;
_outPath = outPath;
Console.WriteLine("Reading game data...");
FileStream fs = File.OpenRead(_gamePath);
_originalGameData = UndertaleIO.Read(fs);
byte[] patchBytes = File.ReadAllBytes(_patchPath);
MemoryStream modStream = new();
fs.Seek(0, SeekOrigin.Begin);
fs.CopyTo(modStream);
fs.Close();
Console.WriteLine("Reading patched game data...");
byte[] patchedDataBytes = Xdelta3Lib.Decode(modStream.ToArray(), patchBytes).ToArray();
modStream.Close();
MemoryStream patchedDataStream = new(patchedDataBytes);
_modifiedGameData = UndertaleIO.Read(patchedDataStream);
patchedDataStream.Close();
Console.WriteLine("Read successful!");
Console.WriteLine("-----------------------------------------------");
}
public void Analyze()
{
Console.WriteLine($"Comparing {Math.Max(_originalGameData.Code.Count, _modifiedGameData.Code.Count)} code entry hashes... (This may take a while)");
foreach (var moddedCode in _modifiedGameData.Code)
{
Console.WriteLine(moddedCode.Name);
}
}
}
}