Add CustomPreference URL override hooks
Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
+425
-7
@@ -3,8 +3,10 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using GetSchemeTypeFn = int (*)();
|
using GetSchemeTypeFn = int (*)(const MethodInfo*);
|
||||||
using GetStringFn = void* (*)();
|
using GetStringFn = void* (*)(const MethodInfo*);
|
||||||
|
using SetStringFn = void (*)(void*, const MethodInfo*);
|
||||||
|
using SetSchemeModeFn = void (*)(int, const MethodInfo*);
|
||||||
constexpr int kHttpSchemeType = 0;
|
constexpr int kHttpSchemeType = 0;
|
||||||
constexpr DWORD kHookPollIntervalMs = 500;
|
constexpr DWORD kHookPollIntervalMs = 500;
|
||||||
constexpr DWORD kGameAssemblySettleDelayMs = 5000;
|
constexpr DWORD kGameAssemblySettleDelayMs = 5000;
|
||||||
@@ -13,33 +15,200 @@ namespace {
|
|||||||
volatile LONG g_hook_installed = 0;
|
volatile LONG g_hook_installed = 0;
|
||||||
GetSchemeTypeFn g_orig_get_scheme_type = nullptr;
|
GetSchemeTypeFn g_orig_get_scheme_type = nullptr;
|
||||||
GetStringFn g_orig_get_application_server_url = nullptr;
|
GetStringFn g_orig_get_application_server_url = nullptr;
|
||||||
|
GetStringFn g_orig_get_tele_scope_server_url = nullptr;
|
||||||
|
GetStringFn g_orig_get_concert_server_url = nullptr;
|
||||||
GetStringFn g_orig_get_resource_server_url = nullptr;
|
GetStringFn g_orig_get_resource_server_url = nullptr;
|
||||||
|
GetStringFn g_orig_custom_preference_get_application_server_url = nullptr;
|
||||||
|
GetStringFn g_orig_custom_preference_get_tele_scope_server_url = nullptr;
|
||||||
|
GetStringFn g_orig_custom_preference_get_concert_server_url = nullptr;
|
||||||
|
GetStringFn g_orig_custom_preference_get_resource_server_url = nullptr;
|
||||||
|
SetStringFn g_orig_custom_preference_set_application_server_url = nullptr;
|
||||||
|
SetStringFn g_orig_custom_preference_set_tele_scope_server_url = nullptr;
|
||||||
|
SetStringFn g_orig_custom_preference_set_concert_server_url = nullptr;
|
||||||
|
SetStringFn g_orig_custom_preference_set_resource_server_url = nullptr;
|
||||||
|
SetSchemeModeFn g_orig_custom_preference_set_scheme_mode = nullptr;
|
||||||
volatile LONG g_logged_gameassembly = 0;
|
volatile LONG g_logged_gameassembly = 0;
|
||||||
volatile LONG g_exports_state = 0;
|
volatile LONG g_exports_state = 0;
|
||||||
ULONGLONG g_gameassembly_seen_tick = 0;
|
ULONGLONG g_gameassembly_seen_tick = 0;
|
||||||
volatile LONG g_scheme_hook_called = 0;
|
volatile LONG g_scheme_hook_called = 0;
|
||||||
|
volatile LONG g_application_hook_called = 0;
|
||||||
|
volatile LONG g_tele_scope_hook_called = 0;
|
||||||
|
volatile LONG g_concert_hook_called = 0;
|
||||||
|
volatile LONG g_resource_hook_called = 0;
|
||||||
|
volatile LONG g_cp_application_hook_called = 0;
|
||||||
|
volatile LONG g_cp_tele_scope_hook_called = 0;
|
||||||
|
volatile LONG g_cp_concert_hook_called = 0;
|
||||||
|
volatile LONG g_cp_resource_hook_called = 0;
|
||||||
|
volatile LONG g_cp_set_application_hook_called = 0;
|
||||||
|
volatile LONG g_cp_set_tele_scope_hook_called = 0;
|
||||||
|
volatile LONG g_cp_set_concert_hook_called = 0;
|
||||||
|
volatile LONG g_cp_set_resource_hook_called = 0;
|
||||||
|
volatile LONG g_cp_set_scheme_hook_called = 0;
|
||||||
|
|
||||||
int get_scheme_type_hook() {
|
int get_scheme_type_hook(const MethodInfo*) {
|
||||||
if (InterlockedCompareExchange(&g_scheme_hook_called, 1, 0) == 0) {
|
if (InterlockedCompareExchange(&g_scheme_hook_called, 1, 0) == 0) {
|
||||||
hook_log("[cgss-http-hook] GetSchemeType hook invoked");
|
hook_log("[cgss-http-hook] GetSchemeType hook invoked");
|
||||||
}
|
}
|
||||||
return kHttpSchemeType;
|
return kHttpSchemeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* get_application_server_url_hook() {
|
void* get_application_server_url_hook(const MethodInfo* method) {
|
||||||
const auto& urls = config::get();
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_application_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] GetApplicationServerUrl hook invoked");
|
||||||
|
}
|
||||||
if (!urls.api_url.empty()) {
|
if (!urls.api_url.empty()) {
|
||||||
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
}
|
}
|
||||||
return g_orig_get_application_server_url ? g_orig_get_application_server_url() : nullptr;
|
return g_orig_get_application_server_url ? g_orig_get_application_server_url(method) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* get_resource_server_url_hook() {
|
void* get_tele_scope_server_url_hook(const MethodInfo* method) {
|
||||||
const auto& urls = config::get();
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_tele_scope_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] GetTeleScopeServerUrl hook invoked");
|
||||||
|
}
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
return g_orig_get_tele_scope_server_url ? g_orig_get_tele_scope_server_url(method) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* get_concert_server_url_hook(const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_concert_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] GetConcertServerUrl hook invoked");
|
||||||
|
}
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
return g_orig_get_concert_server_url ? g_orig_get_concert_server_url(method) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* get_resource_server_url_hook(const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_resource_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] GetResourceServerUrl hook invoked");
|
||||||
|
}
|
||||||
if (!urls.asset_url.empty()) {
|
if (!urls.asset_url.empty()) {
|
||||||
return il2cpp_symbols::new_string(urls.asset_url.c_str());
|
return il2cpp_symbols::new_string(urls.asset_url.c_str());
|
||||||
}
|
}
|
||||||
return g_orig_get_resource_server_url ? g_orig_get_resource_server_url() : nullptr;
|
return g_orig_get_resource_server_url ? g_orig_get_resource_server_url(method) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* custom_preference_get_application_server_url_hook(const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_application_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.GetApplicationServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
return g_orig_custom_preference_get_application_server_url
|
||||||
|
? g_orig_custom_preference_get_application_server_url(method)
|
||||||
|
: nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* custom_preference_get_tele_scope_server_url_hook(const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_tele_scope_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.GetTeleScopeServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
return g_orig_custom_preference_get_tele_scope_server_url
|
||||||
|
? g_orig_custom_preference_get_tele_scope_server_url(method)
|
||||||
|
: nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* custom_preference_get_concert_server_url_hook(const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_concert_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.GetConcertServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
return il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
return g_orig_custom_preference_get_concert_server_url
|
||||||
|
? g_orig_custom_preference_get_concert_server_url(method)
|
||||||
|
: nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* custom_preference_get_resource_server_url_hook(const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_resource_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.GetResourceServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (!urls.asset_url.empty()) {
|
||||||
|
return il2cpp_symbols::new_string(urls.asset_url.c_str());
|
||||||
|
}
|
||||||
|
return g_orig_custom_preference_get_resource_server_url
|
||||||
|
? g_orig_custom_preference_get_resource_server_url(method)
|
||||||
|
: nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_preference_set_application_server_url_hook(void* value, const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_set_application_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.SetApplicationServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (g_orig_custom_preference_set_application_server_url) {
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
value = il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
g_orig_custom_preference_set_application_server_url(value, method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_preference_set_tele_scope_server_url_hook(void* value, const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_set_tele_scope_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.SetTeleScopeServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (g_orig_custom_preference_set_tele_scope_server_url) {
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
value = il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
g_orig_custom_preference_set_tele_scope_server_url(value, method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_preference_set_concert_server_url_hook(void* value, const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_set_concert_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.SetConcertServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (g_orig_custom_preference_set_concert_server_url) {
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
value = il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
}
|
||||||
|
g_orig_custom_preference_set_concert_server_url(value, method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_preference_set_resource_server_url_hook(void* value, const MethodInfo* method) {
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (InterlockedCompareExchange(&g_cp_set_resource_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.SetResourceServerURL hook invoked");
|
||||||
|
}
|
||||||
|
if (g_orig_custom_preference_set_resource_server_url) {
|
||||||
|
if (!urls.asset_url.empty()) {
|
||||||
|
value = il2cpp_symbols::new_string(urls.asset_url.c_str());
|
||||||
|
}
|
||||||
|
g_orig_custom_preference_set_resource_server_url(value, method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_preference_set_scheme_mode_hook(int scheme_type, const MethodInfo* method) {
|
||||||
|
if (InterlockedCompareExchange(&g_cp_set_scheme_hook_called, 1, 0) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] Cute.CustomPreference.SetScemeMode hook invoked");
|
||||||
|
}
|
||||||
|
if (g_orig_custom_preference_set_scheme_mode) {
|
||||||
|
g_orig_custom_preference_set_scheme_mode(
|
||||||
|
config::get().force_http ? kHttpSchemeType : scheme_type, method
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void patch_custom_preference_scheme() {
|
void patch_custom_preference_scheme() {
|
||||||
@@ -64,6 +233,66 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void apply_custom_preference_url_overrides() {
|
||||||
|
auto custom_preference = il2cpp_symbols::get_class(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference"
|
||||||
|
);
|
||||||
|
if (!custom_preference) {
|
||||||
|
hook_log("[cgss-http-hook] failed to resolve Cute.CustomPreference for URL overrides");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
il2cpp_symbols::il2cpp_runtime_class_init(custom_preference);
|
||||||
|
|
||||||
|
const auto& urls = config::get();
|
||||||
|
if (urls.force_http) {
|
||||||
|
auto set_scheme_mode_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetScemeMode", 1
|
||||||
|
);
|
||||||
|
if (set_scheme_mode_addr) {
|
||||||
|
auto set_scheme_mode = reinterpret_cast<SetSchemeModeFn>(set_scheme_mode_addr);
|
||||||
|
set_scheme_mode(kHttpSchemeType, nullptr);
|
||||||
|
hook_log("[cgss-http-hook] applied Cute.CustomPreference.SetScemeMode(0)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!urls.api_url.empty()) {
|
||||||
|
auto set_application_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetApplicationServerURL", 1
|
||||||
|
);
|
||||||
|
auto set_tele_scope_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetTeleScopeServerURL", 1
|
||||||
|
);
|
||||||
|
auto set_concert_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetConcertServerURL", 1
|
||||||
|
);
|
||||||
|
auto api_value = il2cpp_symbols::new_string(urls.api_url.c_str());
|
||||||
|
if (set_application_addr && api_value) {
|
||||||
|
reinterpret_cast<SetStringFn>(set_application_addr)(api_value, nullptr);
|
||||||
|
hook_log("[cgss-http-hook] applied Cute.CustomPreference.SetApplicationServerURL");
|
||||||
|
}
|
||||||
|
if (set_tele_scope_addr && api_value) {
|
||||||
|
reinterpret_cast<SetStringFn>(set_tele_scope_addr)(api_value, nullptr);
|
||||||
|
hook_log("[cgss-http-hook] applied Cute.CustomPreference.SetTeleScopeServerURL");
|
||||||
|
}
|
||||||
|
if (set_concert_addr && api_value) {
|
||||||
|
reinterpret_cast<SetStringFn>(set_concert_addr)(api_value, nullptr);
|
||||||
|
hook_log("[cgss-http-hook] applied Cute.CustomPreference.SetConcertServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!urls.asset_url.empty()) {
|
||||||
|
auto set_resource_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetResourceServerURL", 1
|
||||||
|
);
|
||||||
|
auto asset_value = il2cpp_symbols::new_string(urls.asset_url.c_str());
|
||||||
|
if (set_resource_addr && asset_value) {
|
||||||
|
reinterpret_cast<SetStringFn>(set_resource_addr)(asset_value, nullptr);
|
||||||
|
hook_log("[cgss-http-hook] applied Cute.CustomPreference.SetResourceServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void try_install_hook() {
|
void try_install_hook() {
|
||||||
if (InterlockedCompareExchange(&g_hook_installed, 1, 1) != 0) {
|
if (InterlockedCompareExchange(&g_hook_installed, 1, 1) != 0) {
|
||||||
return;
|
return;
|
||||||
@@ -107,9 +336,42 @@ namespace {
|
|||||||
auto get_application_server_url_addr = il2cpp_symbols::get_method_pointer(
|
auto get_application_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
"Assembly-CSharp.dll", "Stage", "NetworkUtil", "GetApplicationServerUrl", 0
|
"Assembly-CSharp.dll", "Stage", "NetworkUtil", "GetApplicationServerUrl", 0
|
||||||
);
|
);
|
||||||
|
auto get_tele_scope_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Stage", "NetworkUtil", "GetTeleScopeServerUrl", 0
|
||||||
|
);
|
||||||
|
auto get_concert_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Stage", "NetworkUtil", "GetConcertServerUrl", 0
|
||||||
|
);
|
||||||
auto get_resource_server_url_addr = il2cpp_symbols::get_method_pointer(
|
auto get_resource_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
"Assembly-CSharp.dll", "Stage", "NetworkUtil", "GetResourceServerUrl", 0
|
"Assembly-CSharp.dll", "Stage", "NetworkUtil", "GetResourceServerUrl", 0
|
||||||
);
|
);
|
||||||
|
auto cp_get_application_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "GetApplicationServerURL", 0
|
||||||
|
);
|
||||||
|
auto cp_get_tele_scope_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "GetTeleScopeServerURL", 0
|
||||||
|
);
|
||||||
|
auto cp_get_concert_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "GetConcertServerURL", 0
|
||||||
|
);
|
||||||
|
auto cp_get_resource_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "GetResourceServerURL", 0
|
||||||
|
);
|
||||||
|
auto cp_set_application_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetApplicationServerURL", 1
|
||||||
|
);
|
||||||
|
auto cp_set_tele_scope_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetTeleScopeServerURL", 1
|
||||||
|
);
|
||||||
|
auto cp_set_concert_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetConcertServerURL", 1
|
||||||
|
);
|
||||||
|
auto cp_set_resource_server_url_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetResourceServerURL", 1
|
||||||
|
);
|
||||||
|
auto cp_set_scheme_mode_addr = il2cpp_symbols::get_method_pointer(
|
||||||
|
"Assembly-CSharp.dll", "Cute", "CustomPreference", "SetScemeMode", 1
|
||||||
|
);
|
||||||
|
|
||||||
auto mh_status = MH_Initialize();
|
auto mh_status = MH_Initialize();
|
||||||
if (mh_status != MH_OK && mh_status != MH_ERROR_ALREADY_INITIALIZED) {
|
if (mh_status != MH_OK && mh_status != MH_ERROR_ALREADY_INITIALIZED) {
|
||||||
@@ -166,6 +428,162 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_tele_scope_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(get_tele_scope_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&get_tele_scope_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_get_tele_scope_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(get_tele_scope_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Stage.NetworkUtil.GetTeleScopeServerUrl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (get_concert_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(get_concert_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&get_concert_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_get_concert_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(get_concert_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Stage.NetworkUtil.GetConcertServerUrl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_get_application_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_get_application_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_get_application_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_get_application_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_get_application_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.GetApplicationServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_get_tele_scope_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_get_tele_scope_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_get_tele_scope_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_get_tele_scope_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_get_tele_scope_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.GetTeleScopeServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_get_concert_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_get_concert_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_get_concert_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_get_concert_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_get_concert_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.GetConcertServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_get_resource_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_get_resource_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_get_resource_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_get_resource_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_get_resource_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.GetResourceServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_set_application_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_set_application_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_set_application_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_set_application_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_set_application_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.SetApplicationServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_set_tele_scope_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_set_tele_scope_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_set_tele_scope_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_set_tele_scope_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_set_tele_scope_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.SetTeleScopeServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_set_concert_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_set_concert_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_set_concert_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_set_concert_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_set_concert_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.SetConcertServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_set_resource_server_url_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_set_resource_server_url_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_set_resource_server_url_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_set_resource_server_url)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_set_resource_server_url_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.SetResourceServerURL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_set_scheme_mode_addr) {
|
||||||
|
auto create_status = MH_CreateHook(
|
||||||
|
reinterpret_cast<void*>(cp_set_scheme_mode_addr),
|
||||||
|
reinterpret_cast<void*>(&custom_preference_set_scheme_mode_hook),
|
||||||
|
reinterpret_cast<void**>(&g_orig_custom_preference_set_scheme_mode)
|
||||||
|
);
|
||||||
|
if (create_status == MH_OK || create_status == MH_ERROR_ALREADY_CREATED) {
|
||||||
|
auto enable_status = MH_EnableHook(reinterpret_cast<void*>(cp_set_scheme_mode_addr));
|
||||||
|
if (enable_status == MH_OK || enable_status == MH_ERROR_ENABLED) {
|
||||||
|
hook_log("[cgss-http-hook] hooked Cute.CustomPreference.SetScemeMode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_custom_preference_url_overrides();
|
||||||
|
|
||||||
InterlockedExchange(&g_hook_installed, 1);
|
InterlockedExchange(&g_hook_installed, 1);
|
||||||
if (urls.force_http) {
|
if (urls.force_http) {
|
||||||
hook_log("[cgss-http-hook] hooked Stage.NetworkUtil.GetSchemeType");
|
hook_log("[cgss-http-hook] hooked Stage.NetworkUtil.GetSchemeType");
|
||||||
|
|||||||
+31
-1
@@ -11,6 +11,7 @@ il2cpp_method_get_name_t il2cpp_symbols::il2cpp_method_get_name = nullptr;
|
|||||||
il2cpp_thread_attach_t il2cpp_symbols::il2cpp_thread_attach = nullptr;
|
il2cpp_thread_attach_t il2cpp_symbols::il2cpp_thread_attach = nullptr;
|
||||||
il2cpp_thread_current_t il2cpp_symbols::il2cpp_thread_current = nullptr;
|
il2cpp_thread_current_t il2cpp_symbols::il2cpp_thread_current = nullptr;
|
||||||
il2cpp_string_new_t il2cpp_symbols::il2cpp_string_new = nullptr;
|
il2cpp_string_new_t il2cpp_symbols::il2cpp_string_new = nullptr;
|
||||||
|
il2cpp_object_new_t il2cpp_symbols::il2cpp_object_new = nullptr;
|
||||||
il2cpp_runtime_class_init_t il2cpp_symbols::il2cpp_runtime_class_init = nullptr;
|
il2cpp_runtime_class_init_t il2cpp_symbols::il2cpp_runtime_class_init = nullptr;
|
||||||
il2cpp_field_get_flags_t il2cpp_symbols::il2cpp_field_get_flags = nullptr;
|
il2cpp_field_get_flags_t il2cpp_symbols::il2cpp_field_get_flags = nullptr;
|
||||||
il2cpp_field_static_set_value_t il2cpp_symbols::il2cpp_field_static_set_value = nullptr;
|
il2cpp_field_static_set_value_t il2cpp_symbols::il2cpp_field_static_set_value = nullptr;
|
||||||
@@ -35,6 +36,7 @@ void il2cpp_symbols::init(HMODULE game_module) {
|
|||||||
resolve(game_module, "il2cpp_thread_attach", il2cpp_thread_attach);
|
resolve(game_module, "il2cpp_thread_attach", il2cpp_thread_attach);
|
||||||
resolve(game_module, "il2cpp_thread_current", il2cpp_thread_current);
|
resolve(game_module, "il2cpp_thread_current", il2cpp_thread_current);
|
||||||
resolve(game_module, "il2cpp_string_new", il2cpp_string_new);
|
resolve(game_module, "il2cpp_string_new", il2cpp_string_new);
|
||||||
|
resolve(game_module, "il2cpp_object_new", il2cpp_object_new);
|
||||||
resolve(game_module, "il2cpp_runtime_class_init", il2cpp_runtime_class_init);
|
resolve(game_module, "il2cpp_runtime_class_init", il2cpp_runtime_class_init);
|
||||||
resolve(game_module, "il2cpp_field_get_flags", il2cpp_field_get_flags);
|
resolve(game_module, "il2cpp_field_get_flags", il2cpp_field_get_flags);
|
||||||
resolve(game_module, "il2cpp_field_static_set_value", il2cpp_field_static_set_value);
|
resolve(game_module, "il2cpp_field_static_set_value", il2cpp_field_static_set_value);
|
||||||
@@ -44,7 +46,7 @@ bool il2cpp_symbols::ready() {
|
|||||||
return il2cpp_domain_get && il2cpp_domain_assembly_open && il2cpp_assembly_get_image &&
|
return il2cpp_domain_get && il2cpp_domain_assembly_open && il2cpp_assembly_get_image &&
|
||||||
il2cpp_class_from_name && il2cpp_class_get_method_from_name &&
|
il2cpp_class_from_name && il2cpp_class_get_method_from_name &&
|
||||||
il2cpp_class_get_field_from_name && il2cpp_thread_attach &&
|
il2cpp_class_get_field_from_name && il2cpp_thread_attach &&
|
||||||
il2cpp_string_new && il2cpp_runtime_class_init &&
|
il2cpp_string_new && il2cpp_object_new && il2cpp_runtime_class_init &&
|
||||||
il2cpp_field_get_flags && il2cpp_field_static_set_value;
|
il2cpp_field_get_flags && il2cpp_field_static_set_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +130,34 @@ bool il2cpp_symbols::set_static_int_field(void* klass, const char* field_name, i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool il2cpp_symbols::set_static_string_field(void* klass, const char* field_name, const char* value) {
|
||||||
|
if (!klass || !field_name || !value || !attach_thread()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
il2cpp_runtime_class_init(klass);
|
||||||
|
auto field = il2cpp_class_get_field_from_name(klass, field_name);
|
||||||
|
if (!field) {
|
||||||
|
hook_log("[cgss-http-hook] field not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto flags = il2cpp_field_get_flags(field);
|
||||||
|
if ((flags & 0x10U) == 0) {
|
||||||
|
hook_log("[cgss-http-hook] field is not static");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto string_object = new_string(value);
|
||||||
|
if (!string_object) {
|
||||||
|
hook_log("[cgss-http-hook] failed to allocate il2cpp string");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
il2cpp_field_static_set_value(field, &string_object);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
uintptr_t il2cpp_symbols::get_method_pointer(const char* assembly_name, const char* namespaze,
|
uintptr_t il2cpp_symbols::get_method_pointer(const char* assembly_name, const char* namespaze,
|
||||||
const char* klass_name, const char* method_name, int args_count) {
|
const char* klass_name, const char* method_name, int args_count) {
|
||||||
auto klass = get_class(assembly_name, namespaze, klass_name);
|
auto klass = get_class(assembly_name, namespaze, klass_name);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ typedef const char* (*il2cpp_method_get_name_t)(MethodInfo* method);
|
|||||||
typedef void (*il2cpp_thread_attach_t)(void* domain);
|
typedef void (*il2cpp_thread_attach_t)(void* domain);
|
||||||
typedef void* (*il2cpp_thread_current_t)();
|
typedef void* (*il2cpp_thread_current_t)();
|
||||||
typedef void* (*il2cpp_string_new_t)(const char* str);
|
typedef void* (*il2cpp_string_new_t)(const char* str);
|
||||||
|
typedef void* (*il2cpp_object_new_t)(void* klass);
|
||||||
typedef void (*il2cpp_runtime_class_init_t)(void* klass);
|
typedef void (*il2cpp_runtime_class_init_t)(void* klass);
|
||||||
typedef uint32_t (*il2cpp_field_get_flags_t)(FieldInfo* field);
|
typedef uint32_t (*il2cpp_field_get_flags_t)(FieldInfo* field);
|
||||||
typedef void (*il2cpp_field_static_set_value_t)(FieldInfo* field, void* value);
|
typedef void (*il2cpp_field_static_set_value_t)(FieldInfo* field, void* value);
|
||||||
@@ -53,6 +54,7 @@ namespace il2cpp_symbols {
|
|||||||
extern il2cpp_thread_attach_t il2cpp_thread_attach;
|
extern il2cpp_thread_attach_t il2cpp_thread_attach;
|
||||||
extern il2cpp_thread_current_t il2cpp_thread_current;
|
extern il2cpp_thread_current_t il2cpp_thread_current;
|
||||||
extern il2cpp_string_new_t il2cpp_string_new;
|
extern il2cpp_string_new_t il2cpp_string_new;
|
||||||
|
extern il2cpp_object_new_t il2cpp_object_new;
|
||||||
extern il2cpp_runtime_class_init_t il2cpp_runtime_class_init;
|
extern il2cpp_runtime_class_init_t il2cpp_runtime_class_init;
|
||||||
extern il2cpp_field_get_flags_t il2cpp_field_get_flags;
|
extern il2cpp_field_get_flags_t il2cpp_field_get_flags;
|
||||||
extern il2cpp_field_static_set_value_t il2cpp_field_static_set_value;
|
extern il2cpp_field_static_set_value_t il2cpp_field_static_set_value;
|
||||||
@@ -65,6 +67,7 @@ namespace il2cpp_symbols {
|
|||||||
void* new_string(const char* value);
|
void* new_string(const char* value);
|
||||||
void* get_class(const char* assembly_name, const char* namespaze, const char* klass_name);
|
void* get_class(const char* assembly_name, const char* namespaze, const char* klass_name);
|
||||||
bool set_static_int_field(void* klass, const char* field_name, int value);
|
bool set_static_int_field(void* klass, const char* field_name, int value);
|
||||||
|
bool set_static_string_field(void* klass, const char* field_name, const char* value);
|
||||||
uintptr_t get_method_pointer(const char* assembly_name, const char* namespaze,
|
uintptr_t get_method_pointer(const char* assembly_name, const char* namespaze,
|
||||||
const char* klass_name, const char* method_name, int args_count);
|
const char* klass_name, const char* method_name, int args_count);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user