1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-20 19:59:30 +08:00

add: global speedup for hook

This commit is contained in:
0O0o0oOoO00
2025-05-11 15:19:14 +08:00
parent 724e89fd0f
commit 604da2aaeb
15 changed files with 487 additions and 355 deletions

View File

@@ -6,6 +6,35 @@
#include <sol/sol.hpp>
#include "utils.hpp"
#include "il2cpp.hpp"
using fnset_TimeScaleT = void(*)(float);
static fnset_TimeScaleT get_Time_set_timeScale() {
Il2CppDomain* domain = il2cpp_domain_get();
size_t assembly_count = 0;
Il2CppAssembly** assemblies = il2cpp_domain_get_assemblies(domain, &assembly_count);
Il2CppClass* cls = nullptr;
for (size_t i = 0; i < assembly_count; ++i) {
Il2CppImage* image = il2cpp_assembly_get_image(assemblies[i]);
Il2CppClass* klass = il2cpp_class_from_name(image, "UnityEngine", "Time");
if (klass != nullptr) {
cls = klass;
break;
}
}
if (cls != nullptr) {
MethodInfo* method_info = il2cpp_class_get_method_from_name(cls, "set_timeScale", 1);
if (method_info != nullptr) {
auto method = reinterpret_cast<fnset_TimeScaleT>(method_info->methodPointer);
SPDLOG_INFO("Found Time.set_timeScale at {}", (void*)method_info->methodPointer);
return method;
}
}
SPDLOG_ERROR("Failed to get Time.set_timeScale");
throw std::runtime_error("Failed to get Time.set_timeScale");
}
#define IS_ENABLED(n) \
if (is_enabled(n)) { \
@@ -211,6 +240,19 @@ void Cracker::disable_all() {
disable_no_emotion_warning();
disable_opsi_fast_move();
disable_gg_factor();
disable_global_speedup();
}
void Cracker::enable_global_speedup(float rate) {
// IS_ENABLED(GLOBAL_SPEEDUP)
get_Time_set_timeScale()(rate);
ENABLE(GLOBAL_SPEEDUP)
}
void Cracker::disable_global_speedup() {
// IS_DISABLED(GLOBAL_SPEEDUP)
get_Time_set_timeScale()(1.0);
DISABLE(GLOBAL_SPEEDUP)
}
void Cracker::enable_gg_factor() {