mirror of
https://gitea.tendokyu.moe/TeamTofuShop/segatools.git
synced 2026-09-22 22:37:59 +03:00
Untested, I don't have a real e-money server to verify this with Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/110 Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
This commit is contained in:
+17
-101
@@ -14,6 +14,8 @@
|
||||
|
||||
#include <hooklib/path.h>
|
||||
|
||||
#include "hook/iohook.h"
|
||||
#include "hooklib/serial.h"
|
||||
#include "util/dprintf.h"
|
||||
|
||||
static HRESULT misc_read_thinca_adapter(void *bytes, uint32_t *nbytes);
|
||||
@@ -49,65 +51,13 @@ static struct thinca_main* (*next_ThincaPaymentGetInstance)(uint64_t ver);
|
||||
|
||||
static struct thinca_main* thinca_stub;
|
||||
|
||||
static const struct reg_hook_val epay_adapter_keys[] = {
|
||||
{
|
||||
.name = L"TfpsAimeRwAdapter",
|
||||
.read = misc_read_thinca_adapter,
|
||||
.type = REG_SZ,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct reg_hook_val epay_tcap_keys[] = {
|
||||
{
|
||||
.name = L"CaLocation",
|
||||
.read = misc_read_ca_loc,
|
||||
.type = REG_SZ,
|
||||
},
|
||||
{
|
||||
.name = L"ThincaTcapClientPath",
|
||||
.read = misc_read_ca_client_loc,
|
||||
.type = REG_SZ,
|
||||
},
|
||||
{
|
||||
.name = L"ClientNetworkTimeout",
|
||||
.read = misc_read_network_timeout,
|
||||
.type = REG_DWORD,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct reg_hook_val epay_tcap_url0_keys[] = {
|
||||
{
|
||||
.name = L"Pattern",
|
||||
.read = misc_read_pattern0,
|
||||
.type = REG_SZ,
|
||||
},
|
||||
{
|
||||
.name = L"ClientNetworkTimeout",
|
||||
.read = misc_read_network_timeout0,
|
||||
.type = REG_DWORD,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct reg_hook_val epay_tcap_url1_keys[] = {
|
||||
{
|
||||
.name = L"Pattern",
|
||||
.read = misc_read_pattern1,
|
||||
.type = REG_SZ,
|
||||
},
|
||||
{
|
||||
.name = L"ClientNetworkTimeout",
|
||||
.read = misc_read_network_timeout1,
|
||||
.type = REG_DWORD,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct hook_symbol epay_syms[] = {
|
||||
{
|
||||
.name = "ThincaPaymentGetVersion",
|
||||
.patch = my_ThincaPaymentGetVersion,
|
||||
.link = (void **) &next_ThincaPaymentGetVersion,
|
||||
.ordinal = 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = "__imp_ThincaPaymentGetInstance",
|
||||
.patch = my_ThincaPaymentGetInstance,
|
||||
@@ -122,61 +72,14 @@ static const struct hook_symbol epay_syms[] = {
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT epay_apply_registry_hooks(){
|
||||
HRESULT hr = reg_hook_push_key(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\TFPaymentService\\ThincaRwAdapter",
|
||||
epay_adapter_keys,
|
||||
_countof(epay_adapter_keys));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = reg_hook_push_key(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\TFPaymentService\\ThincaTcapClient",
|
||||
epay_tcap_keys,
|
||||
_countof(epay_tcap_keys));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = reg_hook_push_key(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\TFPaymentService\\ThincaTcapClient\\URL0",
|
||||
epay_tcap_url0_keys,
|
||||
_countof(epay_tcap_url0_keys));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = reg_hook_push_key(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\TFPaymentService\\ThincaTcapClient\\URL1",
|
||||
epay_tcap_url1_keys,
|
||||
_countof(epay_tcap_url1_keys));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT epay_hook_init(const struct epay_config *cfg) {
|
||||
HRESULT hr;
|
||||
HRESULT hr = S_OK;
|
||||
assert(cfg != NULL);
|
||||
|
||||
if (!cfg->enable) {
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
hr = epay_apply_registry_hooks();
|
||||
if (FAILED(hr)){
|
||||
return hr;
|
||||
}
|
||||
|
||||
dprintf("EPay: Registry initialized\n");
|
||||
|
||||
// HACK:(?) the DLLs are loaded dynamically so we just preload it and apply DNS and VFS hooks to it
|
||||
HMODULE thincahttpclient = LoadLibraryA("thincahttpclient.dll");
|
||||
if (thincahttpclient != NULL){
|
||||
@@ -191,8 +94,21 @@ HRESULT epay_hook_init(const struct epay_config *cfg) {
|
||||
if (thincatcapclient != NULL){
|
||||
path_hook_insert_hooks(thincatcapclient);
|
||||
}
|
||||
HMODULE aime_adapter = LoadLibraryA("aime_rw_adapterMD.dll");
|
||||
if (aime_adapter != NULL){
|
||||
path_hook_insert_hooks(aime_adapter);
|
||||
serial_hook_apply_hooks(aime_adapter);
|
||||
iohook_apply_hooks(aime_adapter);
|
||||
}
|
||||
HMODULE aime_adapter_debug = LoadLibraryA("aime_rw_adapterMDD.dll");
|
||||
if (aime_adapter_debug != NULL){
|
||||
path_hook_insert_hooks(aime_adapter_debug);
|
||||
serial_hook_apply_hooks(aime_adapter_debug);
|
||||
iohook_apply_hooks(aime_adapter_debug);
|
||||
}
|
||||
|
||||
if (cfg->hook) {
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"ThincaPayment.dll",
|
||||
|
||||
@@ -63,4 +63,3 @@ struct thinca_main {
|
||||
|
||||
#pragma pack(pop)
|
||||
HRESULT epay_hook_init(const struct epay_config *cfg);
|
||||
HRESULT epay_apply_registry_hooks();
|
||||
Reference in New Issue
Block a user