Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
[+] 完善多开支持
Browse files Browse the repository at this point in the history
  • Loading branch information
EtherealAO committed Aug 6, 2022
1 parent a15c062 commit 47d8ec8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ namespace
}
}

void* GetMasterdataDirectory_orig = nullptr;
Il2CppString* GetMasterdataDirectory_hook() {
if (g_savedata_path.empty())
{
return reinterpret_cast<decltype(GetMasterdataDirectory_hook)*>(GetMasterdataDirectory_orig)();
}
else
{
Il2CppString* ovr = il2cpp_string_new(g_savedata_path.c_str());
wprintf(L"Override GetMasterdataDirectory to %s\n", ovr->start_char);
return ovr;
}
}

void adjust_size()
{
thread([]() {
Expand Down Expand Up @@ -445,7 +459,6 @@ namespace
auto _name_##_offset = reinterpret_cast<void*>(_name_##_addr); \
\
printf(_fmt_, _name_##_offset); \
dump_bytes(_name_##_offset); \
\
MH_CreateHook(_name_##_offset, _name_##_hook, &_name_##_orig); \
MH_EnableHook(_name_##_offset);
Expand Down Expand Up @@ -596,6 +609,11 @@ namespace
"SaveDataManager", "get_DatabaseSavePath", 0
);

auto GetMasterdataDirectory_addr = il2cpp_symbols::get_method_pointer(
"umamusume.dll", "Gallop",
"MasterDataManager", "GetMasterdataDirectory", 0
);

auto load_scene_internal_addr = il2cpp_resolve_icall("UnityEngine.SceneManagement.SceneManager::LoadSceneAsyncNameIndexInternal_Injected(System.String,System.Int32,UnityEngine.SceneManagement.LoadSceneParameters&,System.Boolean)");
#pragma endregion

Expand Down Expand Up @@ -646,6 +664,7 @@ namespace
if (!g_savedata_path.empty())
{
ADD_HOOK(get_DatabaseSavePath, "get_DatabaseSavePath at %p\n");
ADD_HOOK(GetMasterdataDirectory, "GetMasterdataDirectory at %p\n");
}

if (g_dump_entries)
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void* CreateMutexDetour(
BOOL bInitialOwner,
LPCSTR lpName)
{
if (strstr(lpName, "-SingleInstanceMutex-")) {
if (lpName != NULL && strstr(lpName, "-SingleInstanceMutex-")) {
std::ostringstream oss;
oss << lpName << '-' << std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
return reinterpret_cast<decltype(CreateMutex)*>(CreateMutex_orig)(lpMutexAttributes, bInitialOwner, oss.str().c_str());
Expand Down

0 comments on commit 47d8ec8

Please sign in to comment.