From b37b34c7c8f1eeadb70e00810ef58810fda5bb6b Mon Sep 17 00:00:00 2001 From: LouisLiu <8723614@gmail.com> Date: Sat, 4 Jun 2022 16:33:28 +0800 Subject: [PATCH 1/4] add faketime --- cheat-library/FakeTime.h | 19 +++++++ cheat-library/cheat-library.vcxproj | 2 + cheat-library/cheat-library.vcxproj.filters | 6 ++ cheat-library/src/appdata/il2cpp-functions.h | 3 + cheat-library/src/user/cheat/cheat.cpp | 2 + .../src/user/cheat/world/FakeTime.cpp | 56 +++++++++++++++++++ cheat-library/src/user/cheat/world/FakeTime.h | 19 +++++++ 7 files changed, 107 insertions(+) create mode 100644 cheat-library/FakeTime.h create mode 100644 cheat-library/src/user/cheat/world/FakeTime.cpp create mode 100644 cheat-library/src/user/cheat/world/FakeTime.h diff --git a/cheat-library/FakeTime.h b/cheat-library/FakeTime.h new file mode 100644 index 0000000..d255681 --- /dev/null +++ b/cheat-library/FakeTime.h @@ -0,0 +1,19 @@ +#pragma once +namespace cheat::feature +{ + + class FakeTime : public Feature + { + public: + config::Field> f_Enabled; + static FakeTime& GetInstance(); + const FeatureGUIInfo& GetGUIInfo() const override; + void DrawMain() override; + virtual bool NeedStatusDraw() const override; + void DrawStatus() override; + void OnGameUpdate(); + private: + static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method); + FakeTime(); + }; +} \ No newline at end of file diff --git a/cheat-library/cheat-library.vcxproj b/cheat-library/cheat-library.vcxproj index 2e06492..4e5dd82 100644 --- a/cheat-library/cheat-library.vcxproj +++ b/cheat-library/cheat-library.vcxproj @@ -15,6 +15,7 @@ + false false @@ -125,6 +126,7 @@ + false false diff --git a/cheat-library/cheat-library.vcxproj.filters b/cheat-library/cheat-library.vcxproj.filters index e63930a..54eb76c 100644 --- a/cheat-library/cheat-library.vcxproj.filters +++ b/cheat-library/cheat-library.vcxproj.filters @@ -225,6 +225,9 @@ Header Files + + Header Files + @@ -408,6 +411,9 @@ Source Files + + Source Files + diff --git a/cheat-library/src/appdata/il2cpp-functions.h b/cheat-library/src/appdata/il2cpp-functions.h index c05d4a3..b813b49 100644 --- a/cheat-library/src/appdata/il2cpp-functions.h +++ b/cheat-library/src/appdata/il2cpp-functions.h @@ -279,6 +279,9 @@ DO_APP_FUNC(0x06552F50, Rect, RectTransform_get_rect, (RectTransform* __this, Me DO_APP_FUNC(0x06677BD0, float, Canvas_get_scaleFactor, (/*Canvas**/void* __this, MethodInfo* method)); +DO_APP_FUNC(0x00935700, void, LevelTimeManager_SetInternalTimeOfDay, (/*LevelTimeManager**/void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method)); + + // Singletons DO_APP_FUNC(0x05189A90, void*, Singleton_GetInstance, (MethodInfo* method)); DO_APP_FUNC_METHODINFO(0x096EA3B0, Singleton_1_MoleMole_MapModule__get_Instance__MethodInfo); diff --git a/cheat-library/src/user/cheat/cheat.cpp b/cheat-library/src/user/cheat/cheat.cpp index 85afd9e..a22ef97 100644 --- a/cheat-library/src/user/cheat/cheat.cpp +++ b/cheat-library/src/user/cheat/cheat.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -80,6 +81,7 @@ namespace cheat FEAT_INST(ElementalSight), FEAT_INST(KillAura), FEAT_INST(MobVacuum), + FEAT_INST(FakeTime), FEAT_INST(ChestTeleport), FEAT_INST(OculiTeleport), diff --git a/cheat-library/src/user/cheat/world/FakeTime.cpp b/cheat-library/src/user/cheat/world/FakeTime.cpp new file mode 100644 index 0000000..a72d17e --- /dev/null +++ b/cheat-library/src/user/cheat/world/FakeTime.cpp @@ -0,0 +1,56 @@ +#include "pch-il2cpp.h" +#include "FakeTime.h" +#include + + +namespace cheat::feature +{ + //CNLouisLiu + void* LevelTimeManager = NULL; + FakeTime::FakeTime() : Feature(), + NF(f_Enabled, "FakeTime", "Enabled", false) + { + HookManager::install(app::LevelTimeManager_SetInternalTimeOfDay, LevelTimeManager_SetInternalTimeOfDay_Hook); + + events::GameUpdateEvent += MY_METHOD_HANDLER(FakeTime::OnGameUpdate); + } + FakeTime& FakeTime::GetInstance() + { + static FakeTime instance; + return instance; + } + const FeatureGUIInfo& FakeTime::GetGUIInfo() const + { + static const FeatureGUIInfo info{ "FakeTime", "World", true }; + return info; + } + void FakeTime::DrawMain() + { + ConfigWidget("Enabled", f_Enabled, "Keep the game in daylight (12 noon)"); + } + bool FakeTime::NeedStatusDraw() const + { + return f_Enabled; + } + void FakeTime::DrawStatus() + { + ImGui::Text("FakeTime"); + } + void FakeTime::OnGameUpdate() + { + if (LevelTimeManager != NULL&& f_Enabled) { + CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, LevelTimeManager, 12.00f, false, false, (MethodInfo*)0); + } + } + void FakeTime::LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method) { + float Hours = inHours; + + if (GetInstance().f_Enabled) + { + Hours = 12.00f; + } + CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, __this, Hours, force, refreshEnviroTime, method); + + } + +} \ No newline at end of file diff --git a/cheat-library/src/user/cheat/world/FakeTime.h b/cheat-library/src/user/cheat/world/FakeTime.h new file mode 100644 index 0000000..947faad --- /dev/null +++ b/cheat-library/src/user/cheat/world/FakeTime.h @@ -0,0 +1,19 @@ +#pragma once +namespace cheat::feature +{ + + class FakeTime : public Feature + { + public: + config::Field> f_Enabled; + static FakeTime& GetInstance(); + void OnGameUpdate(); + const FeatureGUIInfo& GetGUIInfo() const override; + void DrawMain() override; + virtual bool NeedStatusDraw() const override; + void DrawStatus() override; + private: + static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method); + FakeTime(); + }; +} \ No newline at end of file From db2057e355e0211a62b115656c2dca0ade95fac8 Mon Sep 17 00:00:00 2001 From: LouisLiu <8723614@gmail.com> Date: Thu, 16 Jun 2022 00:46:43 +0800 Subject: [PATCH 2/4] Support custom time --- .../src/user/cheat/world/FakeTime.cpp | 29 +++++++++++++------ cheat-library/src/user/cheat/world/FakeTime.h | 4 +++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cheat-library/src/user/cheat/world/FakeTime.cpp b/cheat-library/src/user/cheat/world/FakeTime.cpp index a72d17e..3009c0f 100644 --- a/cheat-library/src/user/cheat/world/FakeTime.cpp +++ b/cheat-library/src/user/cheat/world/FakeTime.cpp @@ -8,7 +8,9 @@ namespace cheat::feature //CNLouisLiu void* LevelTimeManager = NULL; FakeTime::FakeTime() : Feature(), - NF(f_Enabled, "FakeTime", "Enabled", false) + NF(f_Enabled, "FakeTime", "Enabled", false), + NF(f_TimeHour, "FakeTime", "TimeHour", 12), + NF(f_TimeMinute, "FakeTime", "TimeMinute", 0) { HookManager::install(app::LevelTimeManager_SetInternalTimeOfDay, LevelTimeManager_SetInternalTimeOfDay_Hook); @@ -26,7 +28,9 @@ namespace cheat::feature } void FakeTime::DrawMain() { - ConfigWidget("Enabled", f_Enabled, "Keep the game in daylight (12 noon)"); + ConfigWidget("Enabled", f_Enabled, "Keep game time the same"); + ConfigWidget("TimeHour", f_TimeHour, 1, 0, 24); + ConfigWidget("TimeMinute", f_TimeMinute, 1, 0, 60); } bool FakeTime::NeedStatusDraw() const { @@ -34,23 +38,30 @@ namespace cheat::feature } void FakeTime::DrawStatus() { - ImGui::Text("FakeTime"); + ImGui::Text("FakeTime|%d:%d", f_TimeHour.value(), f_TimeMinute.value()); + } + float FakeTime::ConversionTime() { + + float time = float(f_TimeHour); + float timemin = f_TimeMinute / 60; + return time + timemin; } void FakeTime::OnGameUpdate() { - if (LevelTimeManager != NULL&& f_Enabled) { - CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, LevelTimeManager, 12.00f, false, false, (MethodInfo*)0); + if (LevelTimeManager != NULL && f_Enabled) { + auto& faketime = GetInstance(); + CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, LevelTimeManager, faketime.ConversionTime(), false, false, (MethodInfo*)0); } } void FakeTime::LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method) { float Hours = inHours; - - if (GetInstance().f_Enabled) + auto& faketime = GetInstance(); + if (faketime.f_Enabled) { - Hours = 12.00f; + Hours = faketime.ConversionTime(); } CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, __this, Hours, force, refreshEnviroTime, method); - + } } \ No newline at end of file diff --git a/cheat-library/src/user/cheat/world/FakeTime.h b/cheat-library/src/user/cheat/world/FakeTime.h index 947faad..8f0a31a 100644 --- a/cheat-library/src/user/cheat/world/FakeTime.h +++ b/cheat-library/src/user/cheat/world/FakeTime.h @@ -6,6 +6,9 @@ namespace cheat::feature { public: config::Field> f_Enabled; + config::Field f_TimeHour; + config::Field f_TimeMinute; + static FakeTime& GetInstance(); void OnGameUpdate(); const FeatureGUIInfo& GetGUIInfo() const override; @@ -14,6 +17,7 @@ namespace cheat::feature void DrawStatus() override; private: static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method); + float ConversionTime(); FakeTime(); }; } \ No newline at end of file From 18a9c82196dfb77f0635393fd4779b65c3b0d1e9 Mon Sep 17 00:00:00 2001 From: LouisLiu <35774374+CNLouisLiu@users.noreply.github.com> Date: Thu, 16 Jun 2022 00:49:13 +0800 Subject: [PATCH 3/4] Delete FakeTime.h --- cheat-library/FakeTime.h | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 cheat-library/FakeTime.h diff --git a/cheat-library/FakeTime.h b/cheat-library/FakeTime.h deleted file mode 100644 index d255681..0000000 --- a/cheat-library/FakeTime.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -namespace cheat::feature -{ - - class FakeTime : public Feature - { - public: - config::Field> f_Enabled; - static FakeTime& GetInstance(); - const FeatureGUIInfo& GetGUIInfo() const override; - void DrawMain() override; - virtual bool NeedStatusDraw() const override; - void DrawStatus() override; - void OnGameUpdate(); - private: - static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method); - FakeTime(); - }; -} \ No newline at end of file From 43691b29bb073bdebfcfb12b157ec0715d217813 Mon Sep 17 00:00:00 2001 From: LouisLiu <8723614@gmail.com> Date: Thu, 16 Jun 2022 00:46:43 +0800 Subject: [PATCH 4/4] Support custom time --- cheat-library/FakeTime.h | 19 ------------ .../src/user/cheat/world/FakeTime.cpp | 29 +++++++++++++------ cheat-library/src/user/cheat/world/FakeTime.h | 4 +++ 3 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 cheat-library/FakeTime.h diff --git a/cheat-library/FakeTime.h b/cheat-library/FakeTime.h deleted file mode 100644 index d255681..0000000 --- a/cheat-library/FakeTime.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -namespace cheat::feature -{ - - class FakeTime : public Feature - { - public: - config::Field> f_Enabled; - static FakeTime& GetInstance(); - const FeatureGUIInfo& GetGUIInfo() const override; - void DrawMain() override; - virtual bool NeedStatusDraw() const override; - void DrawStatus() override; - void OnGameUpdate(); - private: - static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method); - FakeTime(); - }; -} \ No newline at end of file diff --git a/cheat-library/src/user/cheat/world/FakeTime.cpp b/cheat-library/src/user/cheat/world/FakeTime.cpp index a72d17e..3009c0f 100644 --- a/cheat-library/src/user/cheat/world/FakeTime.cpp +++ b/cheat-library/src/user/cheat/world/FakeTime.cpp @@ -8,7 +8,9 @@ namespace cheat::feature //CNLouisLiu void* LevelTimeManager = NULL; FakeTime::FakeTime() : Feature(), - NF(f_Enabled, "FakeTime", "Enabled", false) + NF(f_Enabled, "FakeTime", "Enabled", false), + NF(f_TimeHour, "FakeTime", "TimeHour", 12), + NF(f_TimeMinute, "FakeTime", "TimeMinute", 0) { HookManager::install(app::LevelTimeManager_SetInternalTimeOfDay, LevelTimeManager_SetInternalTimeOfDay_Hook); @@ -26,7 +28,9 @@ namespace cheat::feature } void FakeTime::DrawMain() { - ConfigWidget("Enabled", f_Enabled, "Keep the game in daylight (12 noon)"); + ConfigWidget("Enabled", f_Enabled, "Keep game time the same"); + ConfigWidget("TimeHour", f_TimeHour, 1, 0, 24); + ConfigWidget("TimeMinute", f_TimeMinute, 1, 0, 60); } bool FakeTime::NeedStatusDraw() const { @@ -34,23 +38,30 @@ namespace cheat::feature } void FakeTime::DrawStatus() { - ImGui::Text("FakeTime"); + ImGui::Text("FakeTime|%d:%d", f_TimeHour.value(), f_TimeMinute.value()); + } + float FakeTime::ConversionTime() { + + float time = float(f_TimeHour); + float timemin = f_TimeMinute / 60; + return time + timemin; } void FakeTime::OnGameUpdate() { - if (LevelTimeManager != NULL&& f_Enabled) { - CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, LevelTimeManager, 12.00f, false, false, (MethodInfo*)0); + if (LevelTimeManager != NULL && f_Enabled) { + auto& faketime = GetInstance(); + CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, LevelTimeManager, faketime.ConversionTime(), false, false, (MethodInfo*)0); } } void FakeTime::LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method) { float Hours = inHours; - - if (GetInstance().f_Enabled) + auto& faketime = GetInstance(); + if (faketime.f_Enabled) { - Hours = 12.00f; + Hours = faketime.ConversionTime(); } CALL_ORIGIN(LevelTimeManager_SetInternalTimeOfDay_Hook, __this, Hours, force, refreshEnviroTime, method); - + } } \ No newline at end of file diff --git a/cheat-library/src/user/cheat/world/FakeTime.h b/cheat-library/src/user/cheat/world/FakeTime.h index 947faad..8f0a31a 100644 --- a/cheat-library/src/user/cheat/world/FakeTime.h +++ b/cheat-library/src/user/cheat/world/FakeTime.h @@ -6,6 +6,9 @@ namespace cheat::feature { public: config::Field> f_Enabled; + config::Field f_TimeHour; + config::Field f_TimeMinute; + static FakeTime& GetInstance(); void OnGameUpdate(); const FeatureGUIInfo& GetGUIInfo() const override; @@ -14,6 +17,7 @@ namespace cheat::feature void DrawStatus() override; private: static void LevelTimeManager_SetInternalTimeOfDay_Hook(void* __this, float inHours, bool force, bool refreshEnviroTime, MethodInfo* method); + float ConversionTime(); FakeTime(); }; } \ No newline at end of file