From 49c31853e6c5cb31f1c9e20a322168462b795fd9 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 10 Dec 2023 18:48:40 -0500 Subject: [PATCH] move reg and epay hook insert to it's own function --- hooklib/reg.c | 7 ++++++- hooklib/reg.h | 2 ++ platform/epay.c | 17 +++++++++++------ platform/epay.h | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hooklib/reg.c b/hooklib/reg.c index 64e72fb..fe890a5 100644 --- a/hooklib/reg.c +++ b/hooklib/reg.c @@ -274,11 +274,16 @@ static void reg_hook_init(void) } reg_hook_initted = true; + reg_hook_apply_hooks(NULL); InitializeCriticalSection(®_hook_lock); dprintf("Reg hook init\n"); +} + +void reg_hook_apply_hooks(HMODULE target) +{ hook_table_apply( - NULL, + target, "advapi32.dll", reg_hook_syms, _countof(reg_hook_syms)); diff --git a/hooklib/reg.h b/hooklib/reg.h index eb280c6..7da5645 100644 --- a/hooklib/reg.h +++ b/hooklib/reg.h @@ -5,6 +5,8 @@ #include #include +void reg_hook_apply_hooks(HMODULE target); + struct reg_hook_val { const wchar_t *name; HRESULT (*read)(void *bytes, uint32_t *nbytes); diff --git a/platform/epay.c b/platform/epay.c index 0faf145..ddac417 100644 --- a/platform/epay.c +++ b/platform/epay.c @@ -163,12 +163,8 @@ HRESULT epay_hook_init(const struct epay_config *cfg) { epay_tcap_url1_keys, _countof(epay_tcap_url1_keys)); - hook_table_apply( - NULL, - "ThincaPayment.dll", - epay_syms, - _countof(epay_syms)); - + epay_insert_hook(NULL); + thinca_stub = (struct thinca_main *)malloc(sizeof(struct thinca_main)); thinca_stub->impl1 = (struct thinca_impl *)malloc(sizeof(struct thinca_impl)); @@ -194,6 +190,15 @@ HRESULT epay_hook_init(const struct epay_config *cfg) { return hr; } +void epay_insert_hook(HMODULE target) +{ + hook_table_apply( + target, + "ThincaPayment.dll", + epay_syms, + _countof(epay_syms)); +} + static HRESULT misc_read_thinca_adapter(void *bytes, uint32_t *nbytes) { return reg_hook_read_wstr(bytes, nbytes, L"aime_rw_adapterMD.dll"); diff --git a/platform/epay.h b/platform/epay.h index c94eceb..2c40e3f 100644 --- a/platform/epay.h +++ b/platform/epay.h @@ -60,4 +60,5 @@ struct thinca_main { }; #pragma pack(pop) -HRESULT epay_hook_init(const struct epay_config *cfg); \ No newline at end of file +HRESULT epay_hook_init(const struct epay_config *cfg); +void epay_insert_hook(HMODULE target); \ No newline at end of file