From 895afed4887cb27ed64e375b799f5e3f3fac2666 Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sat, 13 Apr 2024 18:32:45 +0200 Subject: [PATCH] add: unlimited uv --- user/hooks/hooks.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/user/hooks/hooks.cpp b/user/hooks/hooks.cpp index 298564f..6dba3a1 100644 --- a/user/hooks/hooks.cpp +++ b/user/hooks/hooks.cpp @@ -1,6 +1,7 @@ #include "pch-il2cpp.h" #include "Hooks.hpp" #include "../features/menu.hpp" +#include "../settings/settings.hpp" #include "../main.h" #include "../utils/utils.hpp" @@ -41,6 +42,16 @@ TDebug_2_Log oDebug_2_Warning = NULL; TDebug_2_Log oDebug_2_Error = NULL; void __stdcall hDebug_Log(app::Object* message, MethodInfo* method) { std::cout << ToString(message) << std::endl; + il2cppi_log_write(ToString(message)); +} + +typedef void(__stdcall* TNolanBehaviour_OnAttributeUpdateValue)(app::NolanBehaviour*, app::Attribute_1*, MethodInfo*); +TNolanBehaviour_OnAttributeUpdateValue oNolanBehaviour_OnAttributeUpdateValue = NULL; +void __stdcall hNolanBehaviour_OnAttributeUpdateValue(app::NolanBehaviour* __this, app::Attribute_1* attribute, MethodInfo* method) { + if (settings::unlimited_uv && strcmp(il2cppi_to_string(attribute->fields.m_Name).c_str(), "Battery") == 0) { + attribute->fields.m_Value = 100.0f; + } + oNolanBehaviour_OnAttributeUpdateValue(__this, attribute, method); } void CreateHooks() { @@ -67,9 +78,14 @@ void CreateHooks() { std::cout << "Failed to create Debug_LogWarning hook: " << MH_StatusToString(status_Debug_Log) << std::endl; return; } + MH_STATUS status_uv = MH_CreateHook((LPVOID*)app::NolanBehaviour_OnAttributeUpdateValue , &hNolanBehaviour_OnAttributeUpdateValue, reinterpret_cast(&oNolanBehaviour_OnAttributeUpdateValue)); + if (status_uv != MH_OK) { + std::cout << "Failed to create uv hook: " << MH_StatusToString(status_uv) << std::endl; + return; + } MH_STATUS enable_status_Debug_Log = MH_EnableHook(MH_ALL_HOOKS); if (enable_status_Debug_Log != MH_OK) { - std::cout << "Failed to enable Debug_Warning hook: " << MH_StatusToString(enable_status_Debug_Log) << std::endl; + std::cout << "Failed to enable hooks: " << MH_StatusToString(enable_status_Debug_Log) << std::endl; return; } }