Bug fixes

This commit is contained in:
Neo 2023-06-23 17:10:04 +01:00
parent 4ec638c579
commit 7bbf65660e
3 changed files with 19 additions and 11 deletions

View File

@ -7,6 +7,6 @@
/************************** /**************************
* Magia Translate Ver * * Magia Translate Ver *
**************************/ **************************/
#define MT_VERSION 120 #define MT_VERSION 121
#endif #endif

View File

@ -49,7 +49,7 @@ bool initialized = false;
const std::string assetBase = "/magica/resource"; const std::string assetBase = "/magica/resource";
const std::string assetTrunk = "/download/asset/master"; const std::string assetTrunk = "/download/asset/master";
const std::string assetScenario = "/resource/scenario"; const std::string assetScenario = "/resource/scenario";
std::vector<std::string> urlEndpoints(3); std::vector<std::shared_ptr<std::string>> urlEndpoints(3);
const std::string koruriFont("fonts/koruri-semibold.ttf"); 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 *(*setMaxLineWidthHooked)(uintptr_t label, float length);
void *(*setDimensionsHooked)(uintptr_t label, float width, float a3); 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; //void* urlConfig_ImplObj = nullptr;
@ -168,10 +168,11 @@ int *sceneLayerManagerCreateSceneLayer(uintptr_t *sceneLayerManager, BaseSceneLa
//std::string assetNameScriptProxy(assetNameScript.c_str()); //std::string assetNameScriptProxy(assetNameScript.c_str());
LOGD("Setting endpoint URLs."); LOGD("Setting endpoint URLs.");
LOGD("%s", assetNameScript.c_str());
urlEndpoints.at(UrlConfigResourceType::BaseUrl) = assetNameBase; urlEndpoints.at(UrlConfigResourceType::BaseUrl) = std::make_shared<std::string>(assetNameBase);
urlEndpoints.at(UrlConfigResourceType::TrunkUrl) = assetNameFull; urlEndpoints.at(UrlConfigResourceType::TrunkUrl) = std::make_shared<std::string>(assetNameFull);
urlEndpoints.at(UrlConfigResourceType::ScenarioUrl) = assetNameScript; urlEndpoints.at(UrlConfigResourceType::ScenarioUrl) = std::make_shared<std::string>(assetNameScript);
LOGD("Finished setting endpoint URLs."); LOGD("Finished setting endpoint URLs.");
break; break;
} }
@ -187,12 +188,14 @@ int *sceneLayerManagerCreateSceneLayer(uintptr_t *sceneLayerManager, BaseSceneLa
} }
// Change function to fetch resource URLs // 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); LOGD("Fetching URL config resource %d", (int)type);
if (type < UrlConfigResourceType::UrlConfigResourceTypeMaxValue) { if (type < UrlConfigResourceType::UrlConfigResourceTypeMaxValue) {
try { try {
if (!urlEndpoints.at(type).empty()) { if (urlEndpoints.at(type) != nullptr && urlEndpoints.at(type).get() != nullptr) {
return urlEndpoints.at(type); auto url = (urlEndpoints.at(type)).get();
LOGD("URL: %s", url->c_str());
return url;
} }
else { else {
LOGW("Empty endpoint found for endpoint type %d!", (int)type); 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"); void *audioSampleRateFix = lookup_symbol(libLocation, "criNcv_GetHardwareSamplingRate_ANDROID");
if (audioSampleRateFix != nullptr) { 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) { if (DobbyHook(audioSampleRateFix, (void *)criNcv_GetHardwareSamplingRate_ANDROID, (void **)&criNcv_GetHardwareSamplingRate_ANDROID_Hooked) == RS_SUCCESS) {
LOGI("Successfully hooked criNcv_GetHardwareSamplingRate_ANDROID."); LOGI("Successfully hooked criNcv_GetHardwareSamplingRate_ANDROID.");
} }

View File

@ -13,8 +13,13 @@
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#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__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "MagiaHook", __VA_ARGS__)
#else #else
#define LOGD(...) do {} while(false) #define LOGD(...) do {} while(false)