forked from chinosk/gkms-local
				
			fixed `LoginAsIOS` not working in `1.8.0`
This commit is contained in:
		
							parent
							
								
									60c846b2f0
								
							
						
					
					
						commit
						0218543935
					
				| 
						 | 
					@ -16,7 +16,7 @@ android {
 | 
				
			||||||
        minSdk 29
 | 
					        minSdk 29
 | 
				
			||||||
        targetSdk 34
 | 
					        targetSdk 34
 | 
				
			||||||
        versionCode 10
 | 
					        versionCode 10
 | 
				
			||||||
        versionName "v2.0.1"
 | 
					        versionName "v2.0.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 | 
					        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 | 
				
			||||||
        vectorDrawables {
 | 
					        vectorDrawables {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1044,11 +1044,56 @@ namespace GakumasLocal::HookMain {
 | 
				
			||||||
        if (Config::loginAsIOS) {
 | 
					        if (Config::loginAsIOS) {
 | 
				
			||||||
            return Il2cppString::New("iOS");
 | 
					            return Il2cppString::New("iOS");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // auto ret = ApiBase_GetPlatformString_Orig(self, mtd);
 | 
					 | 
				
			||||||
        // Log::DebugFmt("ApiBase_GetPlatformString: %s", ret->ToString().c_str());
 | 
					        // Log::DebugFmt("ApiBase_GetPlatformString: %s", ret->ToString().c_str());
 | 
				
			||||||
        return ApiBase_GetPlatformString_Orig(self, mtd);
 | 
					        return ApiBase_GetPlatformString_Orig(self, mtd);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void ProcessApiBase(void* self) {
 | 
				
			||||||
 | 
					        static void* processedIOS = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (Config::loginAsIOS) {
 | 
				
			||||||
 | 
					            if (self == processedIOS) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            static auto ApiBase_klass = Il2cppUtils::get_class_from_instance(self);
 | 
				
			||||||
 | 
					            static auto platform_field = UnityResolve::Invoke<Il2cppUtils::FieldInfo*>("il2cpp_class_get_field_from_name", ApiBase_klass, "_platform");
 | 
				
			||||||
 | 
					             auto platform = Il2cppUtils::ClassGetFieldValue<Il2cppString*>(self, platform_field);
 | 
				
			||||||
 | 
					             Log::DebugFmt("ProcessApiBase platform: %s", platform ? platform->ToString().c_str() : "null");
 | 
				
			||||||
 | 
					             if (platform) {
 | 
				
			||||||
 | 
					                 const auto origPlatform = platform->ToString();
 | 
				
			||||||
 | 
					                 if (origPlatform != "iOS") {
 | 
				
			||||||
 | 
					                     Il2cppUtils::ClassSetFieldValue(self, platform_field, Il2cppString::New("iOS"));
 | 
				
			||||||
 | 
					                     processedIOS = self;
 | 
				
			||||||
 | 
					                 }
 | 
				
			||||||
 | 
					             }
 | 
				
			||||||
 | 
					             else {
 | 
				
			||||||
 | 
					                 Il2cppUtils::ClassSetFieldValue(self, platform_field, Il2cppString::New("iOS"));
 | 
				
			||||||
 | 
					                 processedIOS = self;
 | 
				
			||||||
 | 
					             }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            if (processedIOS) {
 | 
				
			||||||
 | 
					                Log::DebugFmt("Restore API to Android");
 | 
				
			||||||
 | 
					                static auto ApiBase_klass = Il2cppUtils::get_class_from_instance(self);
 | 
				
			||||||
 | 
					                static auto platform_field = UnityResolve::Invoke<Il2cppUtils::FieldInfo*>("il2cpp_class_get_field_from_name", ApiBase_klass, "_platform");
 | 
				
			||||||
 | 
					                Il2cppUtils::ClassSetFieldValue(self, platform_field, Il2cppString::New("Android"));
 | 
				
			||||||
 | 
					                processedIOS = nullptr;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DEFINE_HOOK(void, ApiBase_ctor, (void* self, void* mtd)) {
 | 
				
			||||||
 | 
					        ApiBase_ctor_Orig(self, mtd);
 | 
				
			||||||
 | 
					        ProcessApiBase(self);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DEFINE_HOOK(void*, ApiBase_get_Instance, (void* mtd)) {
 | 
				
			||||||
 | 
					        auto ret = ApiBase_get_Instance_Orig(mtd);
 | 
				
			||||||
 | 
					        if (ret) {
 | 
				
			||||||
 | 
					            ProcessApiBase(ret);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void UpdateSwingBreastBonesData(void* initializeData) {
 | 
					    void UpdateSwingBreastBonesData(void* initializeData) {
 | 
				
			||||||
        if (!Config::enableBreastParam) return;
 | 
					        if (!Config::enableBreastParam) return;
 | 
				
			||||||
| 
						 | 
					@ -1384,7 +1429,9 @@ namespace GakumasLocal::HookMain {
 | 
				
			||||||
            auto api_parent = UnityResolve::Invoke<Il2cppUtils::Il2CppClassHead*>("il2cpp_class_get_parent", api_klass->address);
 | 
					            auto api_parent = UnityResolve::Invoke<Il2cppUtils::Il2CppClassHead*>("il2cpp_class_get_parent", api_klass->address);
 | 
				
			||||||
            if (api_parent) {
 | 
					            if (api_parent) {
 | 
				
			||||||
                // Log::DebugFmt("api_parent at %p, name: %s::%s", api_parent, api_parent->namespaze, api_parent->name);
 | 
					                // Log::DebugFmt("api_parent at %p, name: %s::%s", api_parent, api_parent->namespaze, api_parent->name);
 | 
				
			||||||
                ADD_HOOK(ApiBase_GetPlatformString, Il2cppUtils::il2cpp_class_get_method_from_name(api_parent, "GetPlatformString", 0)->methodPointer);
 | 
					                ADD_HOOK(ApiBase_GetPlatformString, Il2cppUtils::il2cpp_class_get_method_pointer_from_name(api_parent, "GetPlatformString", 0));
 | 
				
			||||||
 | 
					                ADD_HOOK(ApiBase_ctor, Il2cppUtils::il2cpp_class_get_method_pointer_from_name(api_parent, ".ctor", 0));
 | 
				
			||||||
 | 
					                ADD_HOOK(ApiBase_get_Instance, Il2cppUtils::il2cpp_class_get_method_pointer_from_name(api_parent, "get_Instance", 0));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,6 +205,15 @@ namespace Il2cppUtils {
 | 
				
			||||||
        return UnityResolve::Invoke<MethodInfo*>("il2cpp_class_get_method_from_name", klass, name, argsCount);
 | 
					        return UnityResolve::Invoke<MethodInfo*>("il2cpp_class_get_method_from_name", klass, name, argsCount);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static uintptr_t il2cpp_class_get_method_pointer_from_name(void* klass, const char* name, int argsCount) {
 | 
				
			||||||
 | 
					        auto findKlass = il2cpp_class_get_method_from_name(klass, name, argsCount);
 | 
				
			||||||
 | 
					        if (findKlass) {
 | 
				
			||||||
 | 
					            return findKlass->methodPointer;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Log::ErrorFmt("method: %s not found", name);
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static void* find_nested_class(void* klass, std::predicate<void*> auto&& predicate) {
 | 
					    static void* find_nested_class(void* klass, std::predicate<void*> auto&& predicate) {
 | 
				
			||||||
        void* iter{};
 | 
					        void* iter{};
 | 
				
			||||||
        while (const auto curNestedClass = UnityResolve::Invoke<void*>("il2cpp_class_get_nested_types", klass, &iter))
 | 
					        while (const auto curNestedClass = UnityResolve::Invoke<void*>("il2cpp_class_get_nested_types", klass, &iter))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue