forked from Aragon12UC/IL2CPPUniversalSpeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
59 lines (43 loc) · 1.32 KB
/
main.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
#include "il2cpp.hpp"
#include "main.hpp"
MethodInfo* setTime;
bool bSpeed;
const float speedMultiplier = 3.f;
void SetTimeScale(float f) {
void* args[1] = { &f };
Il2CppException* exc;
il2cpp_runtime_invoke(setTime, nullptr, args, &exc);
}
void keyHandler() {
for (;;) {
/*
* If you want to use Unity's native input handling for this then feel free,
* but I don't see the point unless you're planning on using this on a game with a real anti-cheat.
*
* UnityEngine.InputLegacyModule.dll.Input.GetKeyDown(KeyCode);
*
* I've included an enum for KeyCode inside main.hpp
*/
if (GetAsyncKeyState(VK_F1) & 1) {
bSpeed = !bSpeed;
float timeScale = bSpeed ? speedMultiplier : 1.f;
SetTimeScale(timeScale);
}
Sleep(1);
}
}
void main() {
IL2CPP::Init();
Sleep(1500);
Il2CppDomain* domain = il2cpp_domain_get();
if (!domain) {
cout << "domain = null\n" << endl;
return;
}
il2cpp_thread_attach(domain);
cout << "IL2CPP Initialised." << endl;
Il2CppImage* unityCore = il2cpp_domain_assembly_open(domain, "UnityEngine.CoreModule")->image;
Il2CppClass* timeClass = il2cpp_class_from_name(unityCore, "UnityEngine", "Time");
setTime = (MethodInfo*)il2cpp_class_get_method_from_name(timeClass, "set_timeScale", 1);
keyHandler();
}