diff --git a/cheat/SoloLevelling.vcxproj b/cheat/SoloLevelling.vcxproj index c21a76b..e97da14 100644 --- a/cheat/SoloLevelling.vcxproj +++ b/cheat/SoloLevelling.vcxproj @@ -124,6 +124,9 @@ + + + @@ -136,7 +139,6 @@ - diff --git a/cheat/SoloLevelling.vcxproj.filters b/cheat/SoloLevelling.vcxproj.filters index 4799a14..e495a2d 100644 --- a/cheat/SoloLevelling.vcxproj.filters +++ b/cheat/SoloLevelling.vcxproj.filters @@ -127,30 +127,15 @@ Header Files - - Header Files - - - Header Files - Header Files - - Header Files - - - Header Files - Header Files Header Files - - Header Files - Header Files @@ -166,12 +151,6 @@ Header Files - - Header Files - - - Header Files - Header Files @@ -181,9 +160,6 @@ Header Files - - Header Files - Header Files @@ -247,39 +223,21 @@ Header Files - - Header Files - - - Header Files - Header Files Header Files - - Header Files - Header Files - - Header Files - Header Files Header Files - - Header Files - - - Header Files - Header Files @@ -295,7 +253,55 @@ vendor\UnityResolve - + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + Header Files + + + Header Files + + Header Files @@ -330,45 +336,21 @@ Source Files - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - Source Files Source Files - - Source Files - Source Files Source Files - - Source Files - - - Source Files - - - Source Files - Source Files @@ -390,29 +372,53 @@ Source Files - + Source Files - + Source Files - - Source Files + + features + + + features - Source Files + features - - Source Files + + features - - Source Files + + features - - Source Files + + features - - Source Files + + features + + + features + + + features + + + features + + + features + + + features + + + features + + + features \ No newline at end of file diff --git a/cheat/src/Unity/methods.hpp b/cheat/src/Unity/methods.hpp deleted file mode 100644 index d22a986..0000000 --- a/cheat/src/Unity/methods.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -namespace methods -{ - const auto coreModule = UnityResolve::Get("UnityEngine.CoreModule.dll"); - const auto pTransform = coreModule->Get("GameObject"); -} \ No newline at end of file diff --git a/cheat/src/Utils.cpp b/cheat/src/Utils.cpp index 3ad524e..3005263 100644 --- a/cheat/src/Utils.cpp +++ b/cheat/src/Utils.cpp @@ -3,10 +3,13 @@ #include #include #include +#include #include #include #include +std::string logfilepath = ""; +LogType logType = LogType::Console; std::mutex mutex; void Utils::AttachConsole() @@ -95,6 +98,105 @@ char Utils::ConsoleReadKey() return std::cin.get(); } +void LogToFile(std::string& filepath, std::string& msg) +{ + std::ofstream myfile; + myfile.open(filepath, std::ios::out | std::ios::app | std::ios::binary); + myfile << msg << std::endl; + myfile.close(); +} + +void Utils::Log(const char* filepath, int line, LogLevel level, const char* fmt, ...) +{ + char buf[4096]; + const char* levelStr = ""; + WORD levelColor, filenameColor = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // Lighter Blue + WORD lineColor = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; // Lighter Yellow + + // Determine log level string and corresponding color + switch (level) + { + case Debug: + levelStr = "Debug"; + levelColor = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY; // Magenta + break; + case Error: + levelStr = "Error"; + levelColor = FOREGROUND_RED | FOREGROUND_INTENSITY; // Red + break; + case Warning: + levelStr = "Warning"; + levelColor = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; // Yellow + break; + } + + va_list va; + va_start(va, fmt); + vsprintf_s(buf, fmt, va); + va_end(va); + + const std::lock_guard lock(mutex); + + // Print with default color + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_SCREEN_BUFFER_INFO consoleInfo; + GetConsoleScreenBufferInfo(hConsole, &consoleInfo); + WORD saved_attributes = consoleInfo.wAttributes; + + // Print '[' in default color + std::cout << "["; + + auto filename = std::filesystem::path(filepath).filename().string(); + + // Print filename in blue + SetConsoleTextAttribute(hConsole, filenameColor); + std::cout << filename; + + // Print ':' in default color + SetConsoleTextAttribute(hConsole, saved_attributes); + std::cout << ":"; + + // Print line in lighter yellow + SetConsoleTextAttribute(hConsole, lineColor); + std::cout << line; + + // Reset to default color, print level in its color, and reset again + SetConsoleTextAttribute(hConsole, saved_attributes); + std::cout << "] ["; + SetConsoleTextAttribute(hConsole, levelColor); + std::cout << levelStr; + SetConsoleTextAttribute(hConsole, saved_attributes); + std::cout << "] " << buf << std::endl; + + if (logType == LogType::File) + { + + auto rawTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + struct tm gmtm; + gmtime_s(&gmtm, &rawTime); + auto logLineFile = string_format("[%02d:%02d:%02d] [%s] [%s:%d] %s", gmtm.tm_hour, gmtm.tm_min, gmtm.tm_sec, + levelStr, filename.c_str(), line, buf); + LogToFile(logfilepath, logLineFile); + } +} + + + +void Utils::PrepareFileLogging(std::string directory) +{ + auto rawTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + struct tm gmtm; + gmtime_s(&gmtm, &rawTime); + + if (!std::filesystem::is_directory(directory)) + std::filesystem::create_directories(directory); + + logfilepath = string_format("%s\\log_%04d-%02d-%02d_%02d-%02d.txt", directory.c_str(), + 1900 + gmtm.tm_year, gmtm.tm_mon, gmtm.tm_mday, gmtm.tm_hour, gmtm.tm_min); + + logType = LogType::File; +} + std::string Utils::GetAddressModuleName(uintptr_t address) { std::vector Modules{}; diff --git a/cheat/src/Utils.h b/cheat/src/Utils.h index 310dbfd..2a96908 100644 --- a/cheat/src/Utils.h +++ b/cheat/src/Utils.h @@ -5,7 +5,23 @@ #include #include "xorstr.h" +enum LogLevel +{ + Debug, + Error, + Warning +}; + +enum LogType +{ + Console, + File +}; + #define LOG(fmt, ...) Utils::ConsolePrint(__FILE__, __LINE__, fmt, __VA_ARGS__) +#define LOG_DEBUG(fmt, ...) Utils::Log(__FILE__, __LINE__, LogLevel::Debug, fmt, __VA_ARGS__) +#define LOG_ERROR(fmt, ...) Utils::Log(__FILE__, __LINE__, LogLevel::Error, fmt, __VA_ARGS__) +#define LOG_WARNING(fmt, ...) Utils::Log(__FILE__, __LINE__, LogLevel::Warning, fmt, __VA_ARGS__) namespace Utils { @@ -15,6 +31,8 @@ namespace Utils void ConsolePrint(const char* filepath, int line, const wchar_t* fmt, ...); void ClearConsole(); char ConsoleReadKey(); + void Log(const char* filepath, int line, LogLevel level, const char* fmt, ...); + void PrepareFileLogging(std::string directory); template std::string string_format(const std::string& format, Args ... args) diff --git a/cheat/src/appdata/il2cpp-functions.h b/cheat/src/appdata/il2cpp-functions.h index 30fa9d4..535ce12 100644 --- a/cheat/src/appdata/il2cpp-functions.h +++ b/cheat/src/appdata/il2cpp-functions.h @@ -14,16 +14,6 @@ DO_APP_FUNC(0x028E7240, String*, Marshal_PtrToStringUni, (void* ptr, MethodInfo* // FovChanger DO_APP_FUNC(0x03953C40, void, Camera_set_fieldOfView, (void* __this, float value, MethodInfo* method)); -// FPSUnlock -DO_APP_FUNC(0x0394C9E0, int, Application_get_targetFrameRate, (MethodInfo* method)); -DO_APP_FUNC(0x0394D100, void, Application_set_targetFrameRate, (int value, MethodInfo* method)); - -DO_APP_FUNC(0x03970F60, void, QualitySettings_set_vSyncCount, (int value, MethodInfo* method)); - -// TimeScale -DO_APP_FUNC(0x039A9F10, float, Time_get_timeScale, (MethodInfo* method)); -DO_APP_FUNC(0x039AA000, void, Time_set_timeScale, (float value, MethodInfo* method)); - // C# methods DO_APP_FUNC(0x02A29840, Type*, Type_GetType_3, (String* typeName, MethodInfo* method)); DO_APP_FUNC(0x028FE910, Type*, Assembly_GetType, (Assembly* __this, String* name, MethodInfo* method)); @@ -64,7 +54,6 @@ DO_APP_FUNC(0x00B0AE80, bool, PCILGJOEPJM_PPAKPBOJLIP, (ENNEJEPMJLJ* IGBKKNODEGM DO_APP_FUNC(0x00F3A7A0, void, StageReadyPage_EnterUI, (StageReadyPage* __this, MethodInfo* method)); DO_APP_FUNC(0x00F3E030, void, StoryQuestChapterPage_EnterUI, (StoryQuestChapterPage* __this,MethodInfo* method)); // Intro Movie -DO_APP_FUNC(0x00C16180, void, GameMovie_Update, (GameMovie* __this, MethodInfo* method)); DO_APP_FUNC(0x00C175B0, void, IntroMovie_Update, (IntroMovie* __this, MethodInfo* method)); // Disable Web View DO_APP_FUNC(0x02BD1040, void, WebViewDialog_Show, (void* __this, MethodInfo* method)); diff --git a/cheat/src/cheat/features/FPSUnlock.cpp b/cheat/src/cheat/features/FPSUnlock.cpp index e901edd..0bf0d74 100644 --- a/cheat/src/cheat/features/FPSUnlock.cpp +++ b/cheat/src/cheat/features/FPSUnlock.cpp @@ -10,24 +10,24 @@ namespace Cheat::Features { events::GameUpdateEvent += MY_METHOD_HANDLER(FPSUnlock::OnGameUpdate); } - - void FPSUnlock::OnGameUpdate() - { + + void FPSUnlock::OnGameUpdate() + { auto& vars = Vars::GetInstance(); - - if (m_LastEnableStatus && !vars.FPSUnlock.value()) - { - app::Application_set_targetFrameRate(m_OriginFPS, nullptr); - } - else if (!m_LastEnableStatus && vars.FPSUnlock.value()) - { - m_OriginFPS = app::Application_get_targetFrameRate(nullptr); - } - m_LastEnableStatus = vars.FPSUnlock.value(); - if (vars.FPSUnlock.value()) - { - app::Application_set_targetFrameRate(vars.FPSValue.value(), nullptr); - app::QualitySettings_set_vSyncCount(0, nullptr); - } - } + + if (m_LastEnableStatus && !vars.FPSUnlock.value()) + { + methods::Application::SetTargetFrameRate(m_OriginFPS); + } + else if (!m_LastEnableStatus && vars.FPSUnlock.value()) + { + m_OriginFPS = methods::Application::GetTargetFrameRate(); + } + m_LastEnableStatus = vars.FPSUnlock.value(); + if (vars.FPSUnlock.value()) + { + methods::Application::SetTargetFrameRate(vars.FPSValue.value()); + methods::QualitySettings::SetVSyncCount(0); + } + } } diff --git a/cheat/src/cheat/features/SkipIntroMovie.cpp b/cheat/src/cheat/features/SkipIntroMovie.cpp index 581950d..a43f56d 100644 --- a/cheat/src/cheat/features/SkipIntroMovie.cpp +++ b/cheat/src/cheat/features/SkipIntroMovie.cpp @@ -7,15 +7,14 @@ namespace Cheat::Features { SkipIntroMovie::SkipIntroMovie() { - // HookManager::install(app::GameMovie_Update, GameMovie_Update_Hook); HookManager::install(app::IntroMovie_Update, IntroMovie_Update_Hook); } - void SkipIntroMovie::GameMovie_Update_Hook(app::GameMovie* __this, MethodInfo* method) - { - __this->fields.EGHCFMDLNAB = app::GameMovie_PHMCJCHPFEF__Enum::FINISH; - CALL_ORIGIN(GameMovie_Update_Hook, __this, method); - } + //void SkipIntroMovie::GameMovie_Update_Hook(app::GameMovie* __this, MethodInfo* method) + //{ + // __this->fields.EGHCFMDLNAB = app::GameMovie_PHMCJCHPFEF__Enum::FINISH; + // CALL_ORIGIN(GameMovie_Update_Hook, __this, method); + //} void SkipIntroMovie::IntroMovie_Update_Hook(app::IntroMovie* __this, MethodInfo* method) { auto& vars = Vars::GetInstance(); diff --git a/cheat/src/cheat/features/SkipIntroMovie.h b/cheat/src/cheat/features/SkipIntroMovie.h index 3dbac0b..4c94eb4 100644 --- a/cheat/src/cheat/features/SkipIntroMovie.h +++ b/cheat/src/cheat/features/SkipIntroMovie.h @@ -10,7 +10,6 @@ namespace Cheat::Features SkipIntroMovie(); private: - static void GameMovie_Update_Hook(app::GameMovie* __this, MethodInfo* method); static void IntroMovie_Update_Hook(app::IntroMovie* __this, MethodInfo* method); }; } diff --git a/cheat/src/cheat/features/TimeScale.cpp b/cheat/src/cheat/features/TimeScale.cpp index 59e2754..0658792 100644 --- a/cheat/src/cheat/features/TimeScale.cpp +++ b/cheat/src/cheat/features/TimeScale.cpp @@ -17,14 +17,14 @@ namespace Cheat::Features if (vars.TimeScale.value()) { - app::Time_set_timeScale(vars.TimeScaleSpeed.value(), nullptr); + UnityResolve::UnityType::Time::SetTimeScale(vars.TimeScaleSpeed.value()); m_DidSpeed = true; } else { if (m_DidSpeed) { - app::Time_set_timeScale(1.0f, nullptr); + UnityResolve::UnityType::Time::SetTimeScale(1.0f); m_DidSpeed = false; } } diff --git a/cheat/src/global.h b/cheat/src/global.h index 302790f..7b2bf93 100644 --- a/cheat/src/global.h +++ b/cheat/src/global.h @@ -17,4 +17,6 @@ #include "events/joins/handlereventjoin.hpp" #include "events/joins/eventjoinwrapper.hpp" -#include "UnityResolve.hpp" \ No newline at end of file +#include "methods/Assembly-CSharp.hpp" +#include "methods/mscorlib.hpp" +#include "methods/UnityEngine.CoreModule.hpp" diff --git a/cheat/src/main.cpp b/cheat/src/main.cpp index b42dd96..520e91e 100644 --- a/cheat/src/main.cpp +++ b/cheat/src/main.cpp @@ -1,6 +1,7 @@ #include "main.h" #include #include "ConfigManager.hpp" +#include "UnityResolve.hpp" #include "appdata/helpers.h" #include "appdata/il2cpp-init.h" #include "cheat/cheat.h" @@ -21,7 +22,7 @@ void Run(HMODULE hModule) Init(Renderer::DXVersion::D3D11); - // UnityResolve::Init(GetModuleHandleA(xorstr("GameAssembly.dll")), UnityResolve::Mode::Il2Cpp); + UnityResolve::Init(GetModuleHandleA(xorstr("GameAssembly.dll")), UnityResolve::Mode::Il2Cpp); init_il2cpp(); init_cheat(); diff --git a/cheat/src/methods/Assembly-CSharp.hpp b/cheat/src/methods/Assembly-CSharp.hpp new file mode 100644 index 0000000..c26086b --- /dev/null +++ b/cheat/src/methods/Assembly-CSharp.hpp @@ -0,0 +1,6 @@ +#include + +namespace methods +{ + +} \ No newline at end of file diff --git a/cheat/src/methods/UnityEngine.CoreModule.hpp b/cheat/src/methods/UnityEngine.CoreModule.hpp new file mode 100644 index 0000000..f2bfcc3 --- /dev/null +++ b/cheat/src/methods/UnityEngine.CoreModule.hpp @@ -0,0 +1,32 @@ +#include + +namespace methods +{ + struct Application + { + static int GetTargetFrameRate() + { + static UnityResolve::Method* method; + if (!method) method = UnityResolve::Get("UnityEngine.CoreModule.dll")->Get("Application")->Get("get_targetFrameRate"); + if (method) return method->Invoke(); + return 0; + } + + static void SetTargetFrameRate(int value) + { + static UnityResolve::Method* method; + if (!method) method = UnityResolve::Get("UnityEngine.CoreModule.dll")->Get("Application")->Get("set_targetFrameRate"); + if (method) method->Invoke(value); + } + }; + + struct QualitySettings + { + static void SetVSyncCount(int value) + { + static UnityResolve::Method* method; + if (!method) method = UnityResolve::Get("UnityEngine.CoreModule.dll")->Get("QualitySettings")->Get("set_vSyncCount"); + if (method) method->Invoke(value); + } + }; +} \ No newline at end of file diff --git a/cheat/src/methods/mscorlib.hpp b/cheat/src/methods/mscorlib.hpp new file mode 100644 index 0000000..af2c823 --- /dev/null +++ b/cheat/src/methods/mscorlib.hpp @@ -0,0 +1,6 @@ +#include + +namespace methods +{ + +} \ No newline at end of file