-
Notifications
You must be signed in to change notification settings - Fork 1
/
heave_ho.asl
179 lines (158 loc) · 6.01 KB
/
heave_ho.asl
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
state("HeaveHo") {}
startup
{
vars.PAGE_EXECUTE_ANY = MemPageProtect.PAGE_EXECUTE | MemPageProtect.PAGE_EXECUTE_READ | MemPageProtect.PAGE_EXECUTE_READWRITE | MemPageProtect.PAGE_EXECUTE_WRITECOPY;
vars.JustStarted = false;
vars.offset = 0.0;
vars.TotalRunTime = 0.0f;
vars.CurrentRunTime = 0.0f;
vars.OnStart = (EventHandler) (
(object sender, EventArgs e) => {
vars.JustStarted = true;
vars.offset = 0.0;
vars.TotalRunTime = 0.0;
}
);
timer.OnStart += vars.OnStart;
}
shutdown
{
timer.OnStart -= vars.OnStart;
}
init
{
// Version checking using hash
vars.gamePath = modules.First().FileName + "\\..\\HeaveHo_Data\\Managed\\Assembly-CSharp.dll";
print("[ASL] Reading bytes");
byte[] dllBytes = File.ReadAllBytes(vars.gamePath);
print("[ASL] Hashing bytes");
System.Security.Cryptography.SHA256 hasher = System.Security.Cryptography.SHA256.Create();
byte[] hashed = hasher.ComputeHash(dllBytes);
string s = "";
foreach (byte b in hashed) s += b;
if (s == "2336514740711751125296795513677151228992114533192051056830181341724411522967") version = "1.0";
else if (s == "36112821086181635956130462322119323419631435315621402321061141758778815141202") version = "1.1";
else version = "NA";
print("[ASL] Hash: " + s);
print("[ASL] Version: " + version);
// Version specific setup
var GMAwakeSigTarget = new SigScanTarget();
int gmOffset = 0x00;
if (version == "1.0") {
GMAwakeSigTarget = new SigScanTarget(0,
"55",
"48 8B EC",
"48 81 EC ?? ?? ?? ??",
"48 89 75 ??",
"48 8B F1",
"48 B8 ?? ?? ?? ?? ?? ?? ?? ??",
"48 8B 08",
"33 D2",
"48 8D 64 24 ??",
"49 BB ?? ?? ?? ?? ?? ?? ?? ??"
);
gmOffset = 0x14;
} else if (version == "1.1" || version == "NA") {
GMAwakeSigTarget = new SigScanTarget(0,
"55",
"48 8B EC",
"48 81 EC ?? ?? ?? ??",
"48 89 75 F8",
"48 8B F1",
"48 C7 45 C8 ?? ?? ?? ??",
"48 C7 45 D0 ?? ?? ?? ??",
"48 C7 45 D8 ?? ?? ?? ??",
"48 B8 ?? ?? ?? ?? ?? ?? ?? ??",
"48 8B 08"
);
gmOffset = 0x2c;
}
// Crashes if incorrect signature provided
var pages = game.MemoryPages();
SignatureScanner scanner = new SignatureScanner(game, modules.First().BaseAddress, modules.First().ModuleMemorySize);
IntPtr address = IntPtr.Zero;
bool found = false;
uint count = 0;
foreach (MemoryBasicInformation page in pages)
{
if ((uint)(page.Protect & vars.PAGE_EXECUTE_ANY) > 0)
{
print("[ASL] scanning page " + count.ToString());
scanner.Address = page.BaseAddress;
scanner.Size = (int)page.RegionSize.ToUInt32();
address = scanner.Scan(GMAwakeSigTarget, 16);
if (address != IntPtr.Zero) {
found = true;
break;
}
}
count++;
}
if (!found)
{
print("[ASL] Could not find GameManager::Awake");
return;
}
print("[ASL] GameManager::Awake found at: 0x" + address.ToString("X16"));
// Get game manager instance
IntPtr mGameManager = new IntPtr(memory.ReadValue<long>(address + gmOffset));
vars.GameManager = memory.ReadPointer(mGameManager);
print("[ASL] GameManager::Instance found at: 0x" + vars.GameManager.ToString("X16"));
}
update
{
//GameManager.levelSelectorInstance: [0x78]
//IntPtr levelSelectorInstance = memory.ReadPointer((IntPtr)vars.GameManager+0x78);
//print("[ASL] found LevelSelector at " + levelSelectorInstance.ToString("X16"));
//LevelSelector.currentLevelIndex: 0x58
//current.LevelIndex = memory.ReadValue<int>(levelSelectorInstance+0x98);
//print(String.Format("[ASL] level {0} loaded", current.LevelIndex));
//IntPtr LevelProperties = memory.ReadPointer(levelSelectorInstance+0x58);
//IntPtr LevelName = memory.ReadPointer(LevelProperties+0x10);
//int LevelNameLength = memory.ReadValue<int>(LevelName+0x10);
//print(String.Format("[ASL] level name is {0} chars long.", LevelNameLength));
//current.LevelName = memory.ReadString(LevelName+0x14, LevelNameLength * 2);
//print(String.Format("[ASL] current level: {0}", current.LevelName));
//IntPtr scoreManager = memory.ReadPointer((IntPtr)vars.GameManager+0xA8);
//IntPtr players = memory.ReadPointer(((IntPtr)vars.GameManager)+0xf0);
//IntPtr _items = memory.ReadPointer(players+0x10);
//IntPtr player = memory.ReadPointer(_items+0x20); //don't ask me why this works.
//IntPtr currentCharacter = memory.ReadPointer(player+0x170);
//IntPtr levelManager = memory.ReadPointer(currentCharacter+0x100);
//IntPtr levelRules = memory.ReadPointer(levelManager+0x20);
//IntPtr victoryTrigger = memory.ReadPointer(levelManager+0x30);
//current.IsVictory = memory.ReadValue<bool>(victoryTrigger+0x88);
//print(player.ToString());
// Get necessary variables with offsets from game manager
IntPtr metricsManager = memory.ReadPointer(((IntPtr)vars.GameManager)+0xB8);
IntPtr currentWorldMetrics = memory.ReadPointer(metricsManager+0x10);
IntPtr levelTimesArray = memory.ReadPointer(currentWorldMetrics+0x10);
current.levelTimesLength = memory.ReadValue<int>(levelTimesArray+0x18);
vars.levelTimes = memory.ReadPointer(levelTimesArray+0x10);
}
gameTime
{
if (current.levelTimesLength < old.levelTimesLength)
vars.TotalRunTime += vars.CurrentRunTime;
vars.CurrentRunTime = 0.0f;
for (int i = 0; i < current.levelTimesLength; i++)
vars.CurrentRunTime += memory.ReadValue<float>( ((IntPtr)vars.levelTimes) + 0x20 + (4 * i));
if (vars.JustStarted)
{
vars.JustStarted = false;
vars.offset = vars.CurrentRunTime;
}
return TimeSpan.FromSeconds((double)(vars.TotalRunTime + vars.CurrentRunTime) - vars.offset);
}
exit
{
current.levelTimesLength = 0;
}
split
{
return current.levelTimesLength > old.levelTimesLength;
}
isLoading
{
return true;
}