From 33964e308161e13d709c5ff4610c627600eed28b Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sat, 13 Apr 2024 18:07:02 +0200 Subject: [PATCH] fix: DebugLog hooks, works now --- IL2CppDLL.vcxproj | 2 ++ IL2CppDLL.vcxproj.filters | 9 +++++++++ user/hooks/hooks.cpp | 4 ++-- user/utils/utils.cpp | 12 ++++++++++++ user/utils/utils.hpp | 4 ++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 user/utils/utils.cpp create mode 100644 user/utils/utils.hpp diff --git a/IL2CppDLL.vcxproj b/IL2CppDLL.vcxproj index fbdd7a3..2fff91c 100644 --- a/IL2CppDLL.vcxproj +++ b/IL2CppDLL.vcxproj @@ -56,6 +56,7 @@ + @@ -91,6 +92,7 @@ + diff --git a/IL2CppDLL.vcxproj.filters b/IL2CppDLL.vcxproj.filters index 574541c..e3e2a6c 100644 --- a/IL2CppDLL.vcxproj.filters +++ b/IL2CppDLL.vcxproj.filters @@ -67,6 +67,9 @@ lib + + user\utils + @@ -168,6 +171,9 @@ lib + + user\utils + @@ -200,5 +206,8 @@ {64867ae6-a574-4a01-ac5f-22a732ca25e0} + + {05b8437a-8e9b-425b-acbc-3dd8bca051c3} + \ No newline at end of file diff --git a/user/hooks/hooks.cpp b/user/hooks/hooks.cpp index d6c6164..298564f 100644 --- a/user/hooks/hooks.cpp +++ b/user/hooks/hooks.cpp @@ -2,6 +2,7 @@ #include "Hooks.hpp" #include "../features/menu.hpp" #include "../main.h" +#include "../utils/utils.hpp" #include #include "helpers.h" @@ -39,8 +40,7 @@ TDebug_2_Log oDebug_2_Log = NULL; TDebug_2_Log oDebug_2_Warning = NULL; TDebug_2_Log oDebug_2_Error = NULL; void __stdcall hDebug_Log(app::Object* message, MethodInfo* method) { - std::string log = il2cppi_to_string(app::Object_ToString(message, nullptr)); - std::cout << log << "\n"; + std::cout << ToString(message) << std::endl; } void CreateHooks() { diff --git a/user/utils/utils.cpp b/user/utils/utils.cpp new file mode 100644 index 0000000..21b31d7 --- /dev/null +++ b/user/utils/utils.cpp @@ -0,0 +1,12 @@ +#include "pch-il2cpp.h" +#include "utils.hpp" +#include "helpers.h" + +std::string ToString(app::Object* object) { + std::string type = il2cppi_to_string(app::Object_ToString(object, NULL)); + if (type == "System.String") { + return il2cppi_to_string((app::String*)object); + } + return type; +} + diff --git a/user/utils/utils.hpp b/user/utils/utils.hpp new file mode 100644 index 0000000..9ba964a --- /dev/null +++ b/user/utils/utils.hpp @@ -0,0 +1,4 @@ +#pragma once +#include + +std::string ToString(app::Object* object);