From 7bbf65660e983f27ade1d41905fb365b0814b8d0 Mon Sep 17 00:00:00 2001 From: Neo Date: Fri, 23 Jun 2023 17:10:04 +0100 Subject: [PATCH] Bug fixes --- src/Config.h | 2 +- src/MagiaClient.cpp | 21 ++++++++++++--------- src/Utils.h | 7 ++++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Config.h b/src/Config.h index 00d2dc0..2d1cfbf 100644 --- a/src/Config.h +++ b/src/Config.h @@ -7,6 +7,6 @@ /************************** * Magia Translate Ver * **************************/ -#define MT_VERSION 120 +#define MT_VERSION 121 #endif diff --git a/src/MagiaClient.cpp b/src/MagiaClient.cpp index 91bc6e4..310e5a5 100644 --- a/src/MagiaClient.cpp +++ b/src/MagiaClient.cpp @@ -49,7 +49,7 @@ bool initialized = false; const std::string assetBase = "/magica/resource"; const std::string assetTrunk = "/download/asset/master"; const std::string assetScenario = "/resource/scenario"; -std::vector urlEndpoints(3); +std::vector> urlEndpoints(3); const std::string koruriFont("fonts/koruri-semibold.ttf"); @@ -62,7 +62,7 @@ void *(*setPositionHooked)(uintptr_t label, cocos2d::Vec2 const& position); void *(*setMaxLineWidthHooked)(uintptr_t label, float length); void *(*setDimensionsHooked)(uintptr_t label, float width, float a3); -std::string (*urlConfigResourceHooked)(void* a1, UrlConfigResourceType type); // There is also api, chat, web, etc for other endpoints +const std::string* (*urlConfigResourceHooked)(void* a1, UrlConfigResourceType type); // There is also api, chat, web, etc for other endpoints //void* urlConfig_ImplObj = nullptr; @@ -168,10 +168,11 @@ int *sceneLayerManagerCreateSceneLayer(uintptr_t *sceneLayerManager, BaseSceneLa //std::string assetNameScriptProxy(assetNameScript.c_str()); LOGD("Setting endpoint URLs."); + LOGD("%s", assetNameScript.c_str()); - urlEndpoints.at(UrlConfigResourceType::BaseUrl) = assetNameBase; - urlEndpoints.at(UrlConfigResourceType::TrunkUrl) = assetNameFull; - urlEndpoints.at(UrlConfigResourceType::ScenarioUrl) = assetNameScript; + urlEndpoints.at(UrlConfigResourceType::BaseUrl) = std::make_shared(assetNameBase); + urlEndpoints.at(UrlConfigResourceType::TrunkUrl) = std::make_shared(assetNameFull); + urlEndpoints.at(UrlConfigResourceType::ScenarioUrl) = std::make_shared(assetNameScript); LOGD("Finished setting endpoint URLs."); break; } @@ -187,12 +188,14 @@ int *sceneLayerManagerCreateSceneLayer(uintptr_t *sceneLayerManager, BaseSceneLa } // Change function to fetch resource URLs -std::string urlConfigResource(void* a1, UrlConfigResourceType type) { +const std::string* urlConfigResource(void* a1, UrlConfigResourceType type) { LOGD("Fetching URL config resource %d", (int)type); if (type < UrlConfigResourceType::UrlConfigResourceTypeMaxValue) { try { - if (!urlEndpoints.at(type).empty()) { - return urlEndpoints.at(type); + if (urlEndpoints.at(type) != nullptr && urlEndpoints.at(type).get() != nullptr) { + auto url = (urlEndpoints.at(type)).get(); + LOGD("URL: %s", url->c_str()); + return url; } else { LOGW("Empty endpoint found for endpoint type %d!", (int)type); @@ -523,7 +526,7 @@ void *hook_loop(void *arguments) { void *audioSampleRateFix = lookup_symbol(libLocation, "criNcv_GetHardwareSamplingRate_ANDROID"); if (audioSampleRateFix != nullptr) { - LOGD("Found criNcv_GetHardwareSamplingRate_ANDROID at %p.", (void *)cocos2dnodeSetPosition); + LOGD("Found criNcv_GetHardwareSamplingRate_ANDROID at %p.", (void *)audioSampleRateFix); if (DobbyHook(audioSampleRateFix, (void *)criNcv_GetHardwareSamplingRate_ANDROID, (void **)&criNcv_GetHardwareSamplingRate_ANDROID_Hooked) == RS_SUCCESS) { LOGI("Successfully hooked criNcv_GetHardwareSamplingRate_ANDROID."); } diff --git a/src/Utils.h b/src/Utils.h index 60395e0..af9e01b 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -13,8 +13,13 @@ #include #include +#ifdef NDEBUG +#define RELEASE_BUILD +#else +#define DEBUG_BUILD +#endif -#if DEBUG +#ifdef DEBUG_BUILD #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "MagiaHook", __VA_ARGS__) #else #define LOGD(...) do {} while(false)