mirror of
https://git.chinosk6.cn/chinosk/gkms-localify-dmm.git
synced 2026-07-01 22:12:58 +07:00
update handle
This commit is contained in:
@@ -381,7 +381,7 @@ namespace GakumasLocal::HookMain {
|
|||||||
|
|
||||||
typedef std::unordered_set<std::wstring, TransparentStringHash, std::equal_to<void>> AssetPathsType;
|
typedef std::unordered_set<std::wstring, TransparentStringHash, std::equal_to<void>> AssetPathsType;
|
||||||
std::map<std::string, AssetPathsType> CustomAssetBundleAssetPaths;
|
std::map<std::string, AssetPathsType> CustomAssetBundleAssetPaths;
|
||||||
std::unordered_map<std::string, uint32_t> CustomAssetBundleHandleMap{};
|
std::unordered_map<std::string, uint64_t> CustomAssetBundleHandleMap{};
|
||||||
std::list<std::string> g_extra_assetbundle_paths{};
|
std::list<std::string> g_extra_assetbundle_paths{};
|
||||||
|
|
||||||
void LoadExtraAssetBundle() {
|
void LoadExtraAssetBundle() {
|
||||||
@@ -394,8 +394,11 @@ namespace GakumasLocal::HookMain {
|
|||||||
// CustomAssetBundleAssetPaths.clear();
|
// CustomAssetBundleAssetPaths.clear();
|
||||||
// assert(!ExtraAssetBundleHandle && ExtraAssetBundleAssetPaths.empty());
|
// assert(!ExtraAssetBundleHandle && ExtraAssetBundleAssetPaths.empty());
|
||||||
|
|
||||||
static auto AssetBundle_GetAllAssetNames = reinterpret_cast<void* (*)(void*)>(
|
static auto AssetBundle_GetAllAssetNames = Il2cppUtils::GetMethod(
|
||||||
Il2cppUtils::il2cpp_resolve_icall("UnityEngine.AssetBundle::GetAllAssetNames()")
|
"UnityEngine.AssetBundleModule.dll",
|
||||||
|
"UnityEngine",
|
||||||
|
"AssetBundle",
|
||||||
|
"GetAllAssetNames"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const auto& i : g_extra_assetbundle_paths) {
|
for (const auto& i : g_extra_assetbundle_paths) {
|
||||||
@@ -404,7 +407,7 @@ namespace GakumasLocal::HookMain {
|
|||||||
const auto extraAssetBundle = WinHooks::LoadAssetBundle(i);
|
const auto extraAssetBundle = WinHooks::LoadAssetBundle(i);
|
||||||
if (extraAssetBundle)
|
if (extraAssetBundle)
|
||||||
{
|
{
|
||||||
const auto allAssetPaths = AssetBundle_GetAllAssetNames(extraAssetBundle);
|
const auto allAssetPaths = AssetBundle_GetAllAssetNames->Invoke<void*>(extraAssetBundle);
|
||||||
AssetPathsType assetPath{};
|
AssetPathsType assetPath{};
|
||||||
Il2cppUtils::iterate_IEnumerable<Il2CppString*>(allAssetPaths, [&assetPath](Il2CppString* path)
|
Il2cppUtils::iterate_IEnumerable<Il2CppString*>(allAssetPaths, [&assetPath](Il2CppString* path)
|
||||||
{
|
{
|
||||||
@@ -413,7 +416,7 @@ namespace GakumasLocal::HookMain {
|
|||||||
assetPath.emplace(path->start_char);
|
assetPath.emplace(path->start_char);
|
||||||
});
|
});
|
||||||
CustomAssetBundleAssetPaths.emplace(i, assetPath);
|
CustomAssetBundleAssetPaths.emplace(i, assetPath);
|
||||||
CustomAssetBundleHandleMap.emplace(i, UnityResolve::Invoke<uint32_t>("il2cpp_gchandle_new", extraAssetBundle, false));
|
CustomAssetBundleHandleMap.emplace(i, UnityResolve::Invoke<uint64_t>("il2cpp_gchandle_new", extraAssetBundle, false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -422,7 +425,7 @@ namespace GakumasLocal::HookMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetBundleHandleByAssetName(std::wstring assetName) {
|
uint64_t GetBundleHandleByAssetName(std::wstring assetName) {
|
||||||
for (const auto& i : CustomAssetBundleAssetPaths) {
|
for (const auto& i : CustomAssetBundleAssetPaths) {
|
||||||
for (const auto& m : i.second) {
|
for (const auto& m : i.second) {
|
||||||
if (std::equal(m.begin(), m.end(), assetName.begin(), assetName.end(),
|
if (std::equal(m.begin(), m.end(), assetName.begin(), assetName.end(),
|
||||||
@@ -436,11 +439,11 @@ namespace GakumasLocal::HookMain {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetBundleHandleByAssetName(std::string assetName) {
|
uint64_t GetBundleHandleByAssetName(std::string assetName) {
|
||||||
return GetBundleHandleByAssetName(utility::conversions::to_string_t(assetName));
|
return GetBundleHandleByAssetName(utility::conversions::to_string_t(assetName));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ReplaceFontHandle;
|
uint64_t ReplaceFontHandle;
|
||||||
|
|
||||||
void* GetReplaceFont() {
|
void* GetReplaceFont() {
|
||||||
static auto FontClass = Il2cppUtils::GetClass("UnityEngine.TextRenderingModule.dll", "UnityEngine", "Font");
|
static auto FontClass = Il2cppUtils::GetClass("UnityEngine.TextRenderingModule.dll", "UnityEngine", "Font");
|
||||||
@@ -451,7 +454,7 @@ namespace GakumasLocal::HookMain {
|
|||||||
const auto fontPath = "assets/fonts/gkamszhfontmix.otf";
|
const auto fontPath = "assets/fonts/gkamszhfontmix.otf";
|
||||||
|
|
||||||
void* replaceFont{};
|
void* replaceFont{};
|
||||||
const auto& bundleHandle = GetBundleHandleByAssetName(fontPath);
|
const auto bundleHandle = GetBundleHandleByAssetName(fontPath);
|
||||||
if (bundleHandle)
|
if (bundleHandle)
|
||||||
{
|
{
|
||||||
if (ReplaceFontHandle)
|
if (ReplaceFontHandle)
|
||||||
@@ -471,14 +474,18 @@ namespace GakumasLocal::HookMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto extraAssetBundle = UnityResolve::Invoke<void*>("il2cpp_gchandle_get_target", bundleHandle);
|
const auto extraAssetBundle = UnityResolve::Invoke<void*>("il2cpp_gchandle_get_target", bundleHandle);
|
||||||
static auto AssetBundle_LoadAsset = reinterpret_cast<void* (*)(void* _this, Il2CppString* name, Il2cppUtils::Il2CppReflectionType* type)>(
|
static auto AssetBundle_LoadAsset = Il2cppUtils::GetMethod(
|
||||||
Il2cppUtils::il2cpp_resolve_icall("UnityEngine.AssetBundle::LoadAsset_Internal(System.String,System.Type)")
|
"UnityEngine.AssetBundleModule.dll",
|
||||||
);;
|
"UnityEngine",
|
||||||
|
"AssetBundle",
|
||||||
|
"LoadAsset_Internal",
|
||||||
|
{ "System.String", "System.Type" }
|
||||||
|
);
|
||||||
|
|
||||||
replaceFont = AssetBundle_LoadAsset(extraAssetBundle, Il2cppString::New(fontPath), Font_Type);
|
replaceFont = AssetBundle_LoadAsset->Invoke<void*>(extraAssetBundle, Il2cppString::New(fontPath), Font_Type);
|
||||||
if (replaceFont)
|
if (replaceFont)
|
||||||
{
|
{
|
||||||
ReplaceFontHandle = UnityResolve::Invoke<uint32_t>("il2cpp_gchandle_new", replaceFont, false);
|
ReplaceFontHandle = UnityResolve::Invoke<uint64_t>("il2cpp_gchandle_new", replaceFont, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -206,7 +206,8 @@ namespace GakumasLocal::WinHooks {
|
|||||||
using Il2cppString = UnityResolve::UnityType::String;
|
using Il2cppString = UnityResolve::UnityType::String;
|
||||||
|
|
||||||
void* LoadAssetBundle(const std::string& path) {
|
void* LoadAssetBundle(const std::string& path) {
|
||||||
Il2cppString* bundlePath = Il2cppString::New(path);
|
std::filesystem::path abs_path = std::filesystem::absolute(path).lexically_normal();
|
||||||
|
Il2cppString* bundlePath = Il2cppString::New(abs_path.string());
|
||||||
|
|
||||||
static auto LoadFromFileAsync = Il2cppUtils::GetMethod("UnityEngine.AssetBundleModule.dll", "UnityEngine", "AssetBundle", "LoadFromFileAsync");
|
static auto LoadFromFileAsync = Il2cppUtils::GetMethod("UnityEngine.AssetBundleModule.dll", "UnityEngine", "AssetBundle", "LoadFromFileAsync");
|
||||||
static auto get_assetBundle = Il2cppUtils::GetMethod("UnityEngine.AssetBundleModule.dll", "UnityEngine", "AssetBundleCreateRequest", "get_assetBundle");
|
static auto get_assetBundle = Il2cppUtils::GetMethod("UnityEngine.AssetBundleModule.dll", "UnityEngine", "AssetBundleCreateRequest", "get_assetBundle");
|
||||||
|
|||||||
Reference in New Issue
Block a user