diff --git a/hooklib/dns.c b/hooklib/dns.c index d7f0c4a..ba25923 100644 --- a/hooklib/dns.c +++ b/hooklib/dns.c @@ -175,20 +175,24 @@ static void dns_hook_init(void) dns_hook_initted = true; InitializeCriticalSection(&dns_hook_lock); + dns_hook_apply_hooks(NULL); +} + +void dns_hook_apply_hooks(HMODULE mod){ hook_table_apply( - NULL, + mod, "dnsapi.dll", dns_hook_syms_dnsapi, _countof(dns_hook_syms_dnsapi)); hook_table_apply( - NULL, + mod, "ws2_32.dll", dns_hook_syms_ws2, _countof(dns_hook_syms_ws2)); - + hook_table_apply( - NULL, + mod, "winhttp.dll", dns_hook_syms_winhttp, _countof(dns_hook_syms_winhttp)); @@ -488,6 +492,8 @@ static int WSAAPI hook_getaddrinfo( goto end; } + dprintf("getaddrinfo: %s, %s\n", pNodeName, pServiceName); + mbstowcs_s(&wstr_c, NULL, 0, pNodeName, 0); wstr = malloc(wstr_c * sizeof(wchar_t)); diff --git a/hooklib/dns.h b/hooklib/dns.h index 1f93b0f..ef63e36 100644 --- a/hooklib/dns.h +++ b/hooklib/dns.h @@ -7,3 +7,4 @@ // if to_src is NULL, all lookups for from_src will fail HRESULT dns_hook_push(const wchar_t *from_src, const wchar_t *to_src); +void dns_hook_apply_hooks(HMODULE mod); diff --git a/platform/epay.c b/platform/epay.c index 802124d..a91477d 100644 --- a/platform/epay.c +++ b/platform/epay.c @@ -7,6 +7,7 @@ #include "hook/table.h" +#include "hooklib/dns.h" #include "hooklib/reg.h" #include "platform/epay.h" @@ -172,6 +173,15 @@ HRESULT epay_hook_init(const struct epay_config *cfg) { return hr; } + dprintf("EPay: Registry initialized\n"); + + // HACK:(?) thincahttpclient.dll is loaded dynamically so we just preload it and apply DNS hooks to it + HMODULE thincahttpclient = LoadLibraryA("thincahttpclient.dll"); + if (thincahttpclient != NULL){ + dns_hook_apply_hooks(thincahttpclient); + dprintf("EPay: DNS hooked\n"); + } + if (cfg->hook) { hook_table_apply( NULL, @@ -199,7 +209,7 @@ HRESULT epay_hook_init(const struct epay_config *cfg) { thinca_stub->impl1->unk220 = thinca_unk; thinca_stub->impl1->unk228 = thinca_unk; - dprintf("Epay: Init\n"); + dprintf("Epay: Hooks initialized\n"); } return hr;