forked from Dniel97/segatools
added AimePay, E-MONEY DNS redirects
This commit is contained in:
parent
ca36a879cb
commit
629ded4018
@ -3,6 +3,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windns.h>
|
#include <windns.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
#include <winhttp.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -66,6 +67,12 @@ static int WSAAPI hook_getaddrinfo(
|
|||||||
const ADDRINFOA *pHints,
|
const ADDRINFOA *pHints,
|
||||||
ADDRINFOA **ppResult);
|
ADDRINFOA **ppResult);
|
||||||
|
|
||||||
|
static HINTERNET WINAPI hook_WinHttpConnect(
|
||||||
|
HINTERNET hSession,
|
||||||
|
const wchar_t *pwszServerName,
|
||||||
|
INTERNET_PORT nServerPort,
|
||||||
|
DWORD dwReserved);
|
||||||
|
|
||||||
/* Link pointers */
|
/* Link pointers */
|
||||||
|
|
||||||
static DNS_STATUS (WINAPI *next_DnsQuery_A)(
|
static DNS_STATUS (WINAPI *next_DnsQuery_A)(
|
||||||
@ -95,6 +102,12 @@ static int (WSAAPI *next_getaddrinfo)(
|
|||||||
const ADDRINFOA *pHints,
|
const ADDRINFOA *pHints,
|
||||||
ADDRINFOA **ppResult);
|
ADDRINFOA **ppResult);
|
||||||
|
|
||||||
|
static HINTERNET (WINAPI *next_WinHttpConnect)(
|
||||||
|
HINTERNET hSession,
|
||||||
|
const wchar_t *pwszServerName,
|
||||||
|
INTERNET_PORT nServerPort,
|
||||||
|
DWORD dwReserved);
|
||||||
|
|
||||||
static const struct hook_symbol dns_hook_syms_dnsapi[] = {
|
static const struct hook_symbol dns_hook_syms_dnsapi[] = {
|
||||||
{
|
{
|
||||||
.name = "DnsQuery_A",
|
.name = "DnsQuery_A",
|
||||||
@ -120,6 +133,14 @@ static const struct hook_symbol dns_hook_syms_ws2[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct hook_symbol dns_hook_syms_winhttp[] = {
|
||||||
|
{
|
||||||
|
.name = "WinHttpConnect",
|
||||||
|
.patch = hook_WinHttpConnect,
|
||||||
|
.link = (void **) &next_WinHttpConnect,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static bool dns_hook_initted;
|
static bool dns_hook_initted;
|
||||||
static CRITICAL_SECTION dns_hook_lock;
|
static CRITICAL_SECTION dns_hook_lock;
|
||||||
static struct dns_hook_entry *dns_hook_entries;
|
static struct dns_hook_entry *dns_hook_entries;
|
||||||
@ -145,6 +166,12 @@ static void dns_hook_init(void)
|
|||||||
"ws2_32.dll",
|
"ws2_32.dll",
|
||||||
dns_hook_syms_ws2,
|
dns_hook_syms_ws2,
|
||||||
_countof(dns_hook_syms_ws2));
|
_countof(dns_hook_syms_ws2));
|
||||||
|
|
||||||
|
hook_table_apply(
|
||||||
|
NULL,
|
||||||
|
"winhttp.dll",
|
||||||
|
dns_hook_syms_winhttp,
|
||||||
|
_countof(dns_hook_syms_winhttp));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT dns_hook_push(const wchar_t *from_src, const wchar_t *to_src)
|
HRESULT dns_hook_push(const wchar_t *from_src, const wchar_t *to_src)
|
||||||
@ -460,3 +487,38 @@ end:
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HINTERNET WINAPI hook_WinHttpConnect(
|
||||||
|
HINTERNET hSession,
|
||||||
|
const wchar_t *pwszServerName,
|
||||||
|
INTERNET_PORT nServerPort,
|
||||||
|
DWORD dwReserved)
|
||||||
|
{
|
||||||
|
const struct dns_hook_entry *pos;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (pwszServerName == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&dns_hook_lock);
|
||||||
|
|
||||||
|
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
||||||
|
pos = &dns_hook_entries[i];
|
||||||
|
|
||||||
|
if (_wcsicmp(pwszServerName, pos->from) == 0) {
|
||||||
|
if(pos->to == NULL) {
|
||||||
|
LeaveCriticalSection(&dns_hook_lock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pwszServerName = pos->to;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&dns_hook_lock);
|
||||||
|
|
||||||
|
return next_WinHttpConnect(hSession, pwszServerName, nServerPort, dwReserved);
|
||||||
|
}
|
||||||
|
@ -82,6 +82,26 @@ HRESULT dns_platform_hook_init(const struct dns_config *cfg)
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AimePay
|
||||||
|
hr = dns_hook_push(L"api-aime.am-all.net", cfg->startup);
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// E-MONEY
|
||||||
|
hr = dns_hook_push(L"tasms-api-basis.thincacloud.com", cfg->startup);
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = dns_hook_push(L"shop.tfps.thincacloud.com", cfg->startup);
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
// if your ISP resolves bad domains, it will kill the network. These 2
|
// if your ISP resolves bad domains, it will kill the network. These 2
|
||||||
// *cannot* resolve
|
// *cannot* resolve
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user