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

Commit

Permalink
[+] 允许更改SaveData.db路径
Browse files Browse the repository at this point in the history
  • Loading branch information
EtherealAO committed Aug 4, 2022
1 parent 42ac84b commit 38554ab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,20 @@ namespace
);
}

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

void adjust_size()
{
thread([]() {
Expand Down Expand Up @@ -581,6 +595,11 @@ namespace
"Screen", "SetResolution", 3
);

auto get_DatabaseSavePath_addr = il2cpp_symbols::get_method_pointer(
"umamusume.dll", "Gallop",
"SaveDataManager", "get_DatabaseSavePath", 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 @@ -628,6 +647,11 @@ namespace
adjust_size();
}

if (!g_savedata_path.empty())
{
ADD_HOOK(get_DatabaseSavePath, "get_DatabaseSavePath at %p\n");
}

if (g_dump_entries)
dump_all_entries();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ float g_aspect_ratio = 16.f / 9.f;
bool g_replace_font = true;
bool g_auto_fullscreen = true;
std::string g_notifier_host = "http://127.0.0.1:4693";
std::string g_savedata_path = "";

namespace
{
Expand Down Expand Up @@ -76,6 +77,8 @@ namespace
}
if (document.HasMember("notifier_host"))
g_notifier_host = document["notifier_host"].GetString();
if (document.HasMember("savedata_path"))
g_savedata_path = document["savedata_path"].GetString();

config_stream.close();
return dicts;
Expand Down
1 change: 1 addition & 0 deletions src/stdinclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ extern float g_aspect_ratio;
extern bool g_replace_font;
extern bool g_auto_fullscreen;
extern std::string g_notifier_host;
extern std::string g_savedata_path;

0 comments on commit 38554ab

Please sign in to comment.