This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMisc.cpp
400 lines (347 loc) · 11.9 KB
/
Misc.cpp
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// taken from CheatEngine table by Cielos
// http://forum.cheatengine.org/viewtopic.php?p=5641841#5641841
#include "stdafx.h"
#include "Misc.h"
LPBYTE pCharCustomization, oCharCustomization;
void __declspec(naked) HCharCustomization()
{
__asm
{
cmp dword ptr[ebx + 284h], 10;
jne getBack;
mov dword ptr[ebx + 284h], 2;
getBack:
jmp oCharCustomization;
}
}
const float plus = 89.9f, minus = -89.9f;
LPBYTE pExtendVerticalCam1, pExtendVerticalCam2, pExtendVerticalBow1, pExtendVerticalBow2;
LPVOID oExtendVerticalCam1, oExtendVerticalCam2, oExtendVerticalBow1, oExtendVerticalBow2;
void __declspec(naked) HExtendVerticalCam1()
{
__asm movss xmm0, plus
__asm jmp oExtendVerticalCam1;
}
void __declspec(naked) HExtendVerticalCam2()
{
__asm movss xmm0, minus
__asm jmp oExtendVerticalCam2;
}
void __declspec(naked) HExtendVerticalBow1()
{
__asm movss xmm0, plus
__asm jmp oExtendVerticalBow1;
}
void __declspec(naked) HExtendVerticalBow2()
{
__asm movss xmm0, minus
__asm jmp oExtendVerticalBow2;
}
LPBYTE pAutoCamV, pAutoCamH, oAutoCamV, oAutoCamH;
void __declspec(naked) HAutoCamV()
{
__asm cmp esi, 0;
__asm jmp oAutoCamV;
}
void __declspec(naked) HAutoCamH()
{
__asm cmp edx, 0;
__asm jmp oAutoCamH;
}
LPVOID oWeather;
void __declspec(naked) HWeather()
{
__asm
{
cmp byte ptr[ecx + 0xB33A8], 0;
je flagZero;
cmp word ptr[ecx + 0x34], 0xDC;
jmp oWeather;
flagZero:
cmp word ptr[ecx + 0x34], 0xE6;
je unsetZero;
cmp ecx, ecx;
jmp oWeather;
unsetZero:
cmp ecx, 0;
jmp oWeather;
}
}
bool jumpMod;
float jumpMods[6] = { 0.0f, 19.00f, 13.95f, -2.00f, 0.30f, 4.25f };
float jumpModsRun[6] = { 0.0f, 15.25f, 22.90f, -1.25f, 0.30f, 4.25f };
LPBYTE pJumpMod1, pJumpMod2, oJumpMod1, oJumpMod2;
void __declspec(naked) HJumpMod1()
{
__asm mov edx, ecx;
__asm jmp oJumpMod1;
}
void __declspec(naked) HJumpMod2()
{
__asm
{
mov ecx, [edi + 0x3DEC];
mov ecx, [ecx + 8];
test ecx, ecx;
jnz getBack;
cmp edx, 9;
jl loadNormal;
cmp edx, 18;
jl loadRun;
jmp getBack;
loadNormal:
lea esi, jumpMods;
jmp getBack;
loadRun:
lea esi, jumpModsRun;
getBack:
jmp oJumpMod2;
}
}
float fallHeight;
LPBYTE pFallHeight, oFallHeight;
void __declspec(naked) HFallHeight()
{
__asm
{
mov ecx, [esi + 0x3DEC];
test ecx, ecx;
jz getBack;
mov ecx, [ecx + 8];
cmp ecx, -1;
je getBack;
fstp st(0);
fld fallHeight;
getBack:
jmp oFallHeight;
}
}
bool movementSpeedDebug = false;
void __stdcall HMovementSpeedDebug(LPVOID animId) { logFile << animId << std::endl; }
float movementSpeed;
LPBYTE pMovementSpeed, oMovementSpeed;
void __declspec(naked) HMovementSpeed()
{
__asm
{
mov esi, [edi + 0x3DEC];
mov esi, [esi + 8];
cmp esi, 0;
jl getBack;
mov esi, [edi + 0x2DD4];
cmp esi, 0;
jle getBack;
cmp movementSpeedDebug, 1;
jne skipDebug;
push esi;
mov esi, [edi + 0x3DEC];
mov esi, [esi + 8];
cmp esi, 0;
pop esi;
jne skipDebug;
pushad;
sub esp, 16 * 8;
movdqu xmmword ptr[esp + 16 * 0], xmm0;
movdqu xmmword ptr[esp + 16 * 1], xmm1;
movdqu xmmword ptr[esp + 16 * 2], xmm2;
movdqu xmmword ptr[esp + 16 * 3], xmm3;
movdqu xmmword ptr[esp + 16 * 4], xmm4;
movdqu xmmword ptr[esp + 16 * 5], xmm5;
movdqu xmmword ptr[esp + 16 * 6], xmm6;
movdqu xmmword ptr[esp + 16 * 7], xmm7;
push esi;
call HMovementSpeedDebug;
movdqu xmm7, xmmword ptr[esp + 16 * 7];
movdqu xmm6, xmmword ptr[esp + 16 * 6];
movdqu xmm5, xmmword ptr[esp + 16 * 5];
movdqu xmm4, xmmword ptr[esp + 16 * 4];
movdqu xmm3, xmmword ptr[esp + 16 * 3];
movdqu xmm2, xmmword ptr[esp + 16 * 2];
movdqu xmm1, xmmword ptr[esp + 16 * 1];
movdqu xmm0, xmmword ptr[esp + 16 * 0];
add esp, 16 * 8;
popad;
skipDebug:
cmp esi, 0x7D;//sprint
je modValue;
cmp esi, 0x05;//sprint
je modValue;
cmp esi, 0x02;//run
je modValue;
cmp esi, 0x01;//walk
je modValue;
jmp getBack;
modValue:
mulss xmm0, movementSpeed;
getBack:
jmp oMovementSpeed;
}
}
float gatheringSpeed;
bool charCustomization, extendVerticalCam, disableAutoCam;
void renderMiscUI()
{
if (ImGui::CollapsingHeader("Main"))
{
static bool borderlessFullscreen = config.getBool("main", "borderlessFullscreen", false);
if (ImGui::Checkbox("Borderless fullscreen", &borderlessFullscreen))
config.setBool("main", "borderlessFullscreen", borderlessFullscreen);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("requires game restart");
if (ImGui::Checkbox("Char customization", &charCustomization))
{
config.setBool("main", "charCustomization", charCustomization);
Hooks::SwitchHook("CharCustomization", pCharCustomization, charCustomization);
}
if (ImGui::Checkbox("Camera - extend vertical", &extendVerticalCam))
{
config.setBool("main", "extendVerticalCam", extendVerticalCam);
Hooks::SwitchHook("ExtendVerticalCam1", pExtendVerticalCam1, extendVerticalCam);
Hooks::SwitchHook("ExtendVerticalCam2", pExtendVerticalCam2, extendVerticalCam);
Hooks::SwitchHook("ExtendVerticalCamBow1", pExtendVerticalBow1, extendVerticalCam);
Hooks::SwitchHook("ExtendVerticalCamBow2", pExtendVerticalBow2, extendVerticalCam);
}
if (ImGui::Checkbox("Camera - disable autocorrection", &disableAutoCam))
{
config.setBool("main", "disableAutoCam", disableAutoCam);
Hooks::SwitchHook("DisableAutoCamV", pAutoCamV, disableAutoCam);
Hooks::SwitchHook("DisableAutoCamH", pAutoCamH, disableAutoCam);
}
std::pair<int, const char*> weather[]{ { 0, "Clear sky" }, { 1, "Cloudy" }, { 2, "Foggy" }, { 3, "Vulcanic" } };
ImGui::RadioButtons(GetBasePtr(0xB8780), weather);
ImGui::Checkbox("Weather - post game", GetBasePtr<bool>(0xB33A8));
ImGui::PushItemWidth(150.0f);
if (ImGui::InputFloatEx("Gathering/Mining speed", &gatheringSpeed, 0.1f, 1.0f, 100.0f, 1))
config.setFloat("main", "gatheringSpeed", gatheringSpeed);
bool prevState = fallHeight < 0;
if (ImGui::InputFloatEx("Fall height", &fallHeight, 10.0f, -FLT_MAX, 0.0f))
{
config.setFloat("main", "fallHeight", fallHeight);
if (prevState != fallHeight < 0)
Hooks::SwitchHook("FallHeight", pFallHeight, fallHeight < 0);
}
prevState = movementSpeed >= 0;
if (ImGui::InputFloatEx("Movement speed", &movementSpeed, 0.1f, -1.0f))
{
config.setFloat("main", "movementSpeed", movementSpeed);
if (prevState != movementSpeed >= 0)
Hooks::SwitchHook("MovementSpeed", pMovementSpeed, movementSpeed >= 0);
}
ImGui::PopItemWidth();
ImGui::SameLine();
ImGui::Checkbox("Log", &movementSpeedDebug);
if (ImGui::TreeNode("Jump mod"))
{
if (ImGui::Checkbox("Enabled", &jumpMod))
{
config.setBool("main", "jumpMod", jumpMod);
Hooks::SwitchHook("JumpMod", pJumpMod1, jumpMod);
Hooks::SwitchHook("JumpMod", pJumpMod2, jumpMod);
}
ImGui::TextUnformatted("Walking Jump");
ImGui::TextUnformatted("Running Jump", 190.0f);
ImGui::PushItemWidth(150.0f);
int i = 1;
for (auto str : { "Height", "Length", "Gravity", "Damping", "MoveSpeed" })
{
if (ImGui::InputFloatEx(string("##1").append(str).c_str(), jumpMods + i, 0.1f))
config.setFloats("main", "jumpMods", std::vector<float>(jumpMods + 1, jumpMods + 6));
ImGui::SameLine();
if (ImGui::InputFloatEx(str, jumpModsRun + i, 0.1f))
config.setFloats("main", "jumpModsRun", std::vector<float>(jumpModsRun + 1, jumpModsRun + 6));
i++;
}
ImGui::PopItemWidth();
ImGui::TreePop();
}
}
}
void Hooks::Misc()
{
BYTE sigChar[] = { 0x83, 0xBB, 0x84, 0x02, 0x00, 0x00, 0x0B }; //cmp dword ptr [ebx+284h], 0Bh
if (FindSignature("CharCustomization", sigChar, &pCharCustomization))
{
charCustomization = config.getBool("main", "charCustomization", false);
CreateHook("CharCustomization", pCharCustomization, &HCharCustomization, &oCharCustomization, charCustomization);
}
BYTE sigCam[] = { 0xF3, 0x0F, 0x10, 0x80, 0x8C, 0x00, 0x00, 0x00, //movss xmm0, dword ptr [eax+8Ch]
0xF3, 0x0F, 0x10, 0x0D, 0xCC, 0xCC, 0xCC, 0xCC, //movss xmm1
0xF3, 0x0F, 0x10, 0x11 }; //movss xmm2, dword ptr [ecx]
BYTE sigBow[] = { 0xF3, 0x0F, 0x10, 0x81, 0x8C, 0x00, 0x00, 0x00, //movss xmm0, dword ptr [ecx+8Ch]
0xF3, 0x0F, 0x10, 0x0D, 0xCC, 0xCC, 0xCC, 0xCC, //movss xmm1
0xF3, 0x0F, 0x10, 0x17 }; //movss xmm2, dword ptr [edi]
if (FindSignature("ExtendVerticalCam", sigCam, &pExtendVerticalCam1) &&
FindSignature("ExtendVerticalCamBow", sigBow, &pExtendVerticalBow1))
{
pExtendVerticalCam1 += 8;
pExtendVerticalCam2 = pExtendVerticalCam1 + 0x21;
pExtendVerticalBow1 += 8;
pExtendVerticalBow2 = pExtendVerticalBow1 + 0x27;
extendVerticalCam = config.getBool("main", "extendVerticalCam", false);
CreateHook("ExtendVerticalCam1", pExtendVerticalCam1, &HExtendVerticalCam1, &oExtendVerticalCam1, extendVerticalCam);
CreateHook("ExtendVerticalCam2", pExtendVerticalCam2, &HExtendVerticalCam2, &oExtendVerticalCam2, extendVerticalCam);
CreateHook("ExtendVerticalCamBow1", pExtendVerticalBow1, &HExtendVerticalBow1, &oExtendVerticalBow1, extendVerticalCam);
CreateHook("ExtendVerticalCamBow2", pExtendVerticalBow2, &HExtendVerticalBow2, &oExtendVerticalBow2, extendVerticalCam);
}
BYTE sigV[] = { 0x80, 0xBE, 0xF0, 0x02, 0x00, 0x00, 0x00, //cmp byte ptr [esi+2F0h], 0
0x0F, 0x85, 0xCC, 0xCC, 0x00, 0x00 }; //jnz
BYTE sigH[] = { 0x80, 0xBA, 0xF1, 0x02, 0x00, 0x00, 0x00, //cmp byte ptr [edx+2F1h], 0
0x0F, 0x85, 0xCC, 0xCC, 0x00, 0x00 }; //jnz
if (FindSignature("DisableAutoCamV", sigV, &pAutoCamV) &&
FindSignature("DisableAutoCamH", sigH, &pAutoCamH))
{
disableAutoCam = config.getBool("main", "disableAutoCam", false);
CreateHook("DisableAutoCamV", pAutoCamV, &HAutoCamV, nullptr, disableAutoCam);
CreateHook("DisableAutoCamH", pAutoCamH, &HAutoCamH, nullptr, disableAutoCam);
oAutoCamV = pAutoCamV + 7;
oAutoCamH = pAutoCamH + 7;
}
BYTE *pOffset;
BYTE sigWeather[] = { 0x80, 0xB9, 0xA8, 0x33, 0x0B, 0x00, 0x00, 0x74, 0x15 };
if (FindSignature("Weather", sigWeather, &pOffset))
{
CreateHook("Weather", pOffset, &HWeather, nullptr);
oWeather = pOffset + 7;
}
gatheringSpeed = config.getFloat("main", "gatheringSpeed", 1.0f);
BYTE sigGathering[] = { 0xBA, 0x68, 0x00, 0x00, 0x00, 0x8B, 0xCE, 0xE8, 0xCC, 0xCC, 0xCC, 0xCC, 0x84, 0xC0, 0x74 };
if (FindSignature("Gathering", sigGathering, &pOffset))
{
pOffset += pOffset[sizeof sigGathering] + sizeof sigGathering + 5;
Set<float*>((float**)pOffset, { &gatheringSpeed });
for (int i = 0; i < 3; i++)
{
if (!Find("Gathering", pOffset, pOffset + 0x10000, sigGathering, &pOffset))
break;
pOffset += pOffset[sizeof sigGathering] + sizeof sigGathering + 5;
Set<float*>((float**)pOffset, { &gatheringSpeed });
}
}
fallHeight = config.getFloat("main", "fallHeight", -1000.0f);
BYTE sigFall[] = { 0xD9, 0x5C, 0x24, 0x0C, 0x80, 0xBE, 0xD0, 0x1E, 0x00, 0x00, 0x00 };
if (FindSignature("FallHeight", sigFall, &pFallHeight))
CreateHook("FallHeight", pFallHeight, &HFallHeight, &oFallHeight, fallHeight < 0);
movementSpeed = config.getFloat("main", "movementSpeed", -1.0f);
BYTE sigMovement[] = { 0xF3, 0x0F, 0x11, 0x87, 0xE4, 0x0E, 0x00, 0x00, 0x5E, 0x0F, 0x28, 0xC1 };
if (FindSignature("MovementSpeed", sigMovement, &pMovementSpeed))
CreateHook("MovementSpeed", pMovementSpeed, &HMovementSpeed, &oMovementSpeed, movementSpeed >= 0);
BYTE sigJump[] = { 0x8B, 0x40, 0x70, 0x56, 0x8B, 0x34, 0x88, 0x8B, 0x16, 0x8B, 0x42, 0x10 };
if (FindSignature("JumpMod", sigJump, &pJumpMod1))
{
pJumpMod1 += sizeof sigJump;
BYTE sigJump2[] = { 0xD9, 0x46, 0x04, 0xD9, 0x9F, 0xD8, 0x38, 0x00, 0x00 };
if (Find("JumpMod", pJumpMod1, pJumpMod1 + 0x100, sigJump2, &pJumpMod2))
{
jumpMod = config.getBool("main", "jumpMod", false);
auto mods = config.getFloats("main", "jumpMods");
if (mods.size() == 5)
copy(mods.begin(), mods.end(), jumpMods + 1);
mods = config.getFloats("main", "jumpModsRun");
if (mods.size() == 5)
copy(mods.begin(), mods.end(), jumpModsRun + 1);
CreateHook("JumpMod", pJumpMod1, &HJumpMod1, &oJumpMod1, jumpMod);
CreateHook("JumpMod", pJumpMod2, &HJumpMod2, &oJumpMod2, jumpMod);
}
}
InGameUIAdd(renderMiscUI);
}