From 43da4e83136c89dff234df37a0addc379a2c4363 Mon Sep 17 00:00:00 2001 From: chinosk <2248589280@qq.com> Date: Sat, 13 Jun 2026 17:59:58 +0800 Subject: [PATCH] fixed wide string adapt --- src/deps/UnityResolve/UnityResolve.hpp | 7 +++++++ src/windowsPlatform.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/deps/UnityResolve/UnityResolve.hpp b/src/deps/UnityResolve/UnityResolve.hpp index 67ed306..bf5b4df 100644 --- a/src/deps/UnityResolve/UnityResolve.hpp +++ b/src/deps/UnityResolve/UnityResolve.hpp @@ -1512,6 +1512,13 @@ public: if (mode_ == Mode::Il2Cpp) return UnityResolve::Invoke("il2cpp_string_new", str.c_str()); return UnityResolve::Invoke("mono_string_new", UnityResolve::Invoke("mono_get_root_domain"), str.c_str()); } + + static auto New(const std::wstring& str) -> String* { + auto len = static_cast(str.length()); + + if (mode_ == Mode::Il2Cpp) return UnityResolve::Invoke("il2cpp_string_new_utf16", str.c_str(), len); + return UnityResolve::Invoke("mono_string_new_utf16", UnityResolve::Invoke("mono_get_root_domain"), str.c_str(), len); + } }; template diff --git a/src/windowsPlatform.cpp b/src/windowsPlatform.cpp index c63663d..018b7a3 100644 --- a/src/windowsPlatform.cpp +++ b/src/windowsPlatform.cpp @@ -207,7 +207,7 @@ namespace GakumasLocal::WinHooks { void* LoadAssetBundle(const std::string& path) { std::filesystem::path abs_path = std::filesystem::absolute(path).lexically_normal(); - Il2cppString* bundlePath = Il2cppString::New(abs_path.string()); + Il2cppString* bundlePath = Il2cppString::New(abs_path.wstring()); static auto LoadFromFileAsync = Il2cppUtils::GetMethod("UnityEngine.AssetBundleModule.dll", "UnityEngine", "AssetBundle", "LoadFromFileAsync"); static auto get_assetBundle = Il2cppUtils::GetMethod("UnityEngine.AssetBundleModule.dll", "UnityEngine", "AssetBundleCreateRequest", "get_assetBundle");