forked from Hay1tsme/segatools
Add switch for replaceHost
This commit is contained in:
parent
97b8b373b5
commit
d9ce894bbc
@ -157,10 +157,6 @@ static struct hook_symbol dns_hook_syms_ws2[] = {
|
||||
.ordinal = 176,
|
||||
.patch = hook_getaddrinfo,
|
||||
.link = (void **) &next_getaddrinfo,
|
||||
}, {
|
||||
.name = "send",
|
||||
.patch = hook_send,
|
||||
.link = (void **) &next_send
|
||||
},
|
||||
};
|
||||
|
||||
@ -174,7 +170,14 @@ static const struct hook_symbol dns_hook_syms_winhttp[] = {
|
||||
.patch = hook_WinHttpCrackUrl,
|
||||
.link = (void **) &next_WinHttpCrackUrl,
|
||||
}
|
||||
};
|
||||
|
||||
static struct hook_symbol http_hook_syms_ws2[] = {
|
||||
{
|
||||
.name = "send",
|
||||
.patch = hook_send,
|
||||
.link = (void **) &next_send
|
||||
},
|
||||
};
|
||||
|
||||
static bool dns_hook_initted;
|
||||
@ -192,10 +195,6 @@ static void dns_hook_init(void)
|
||||
dns_hook_initted = true;
|
||||
InitializeCriticalSection(&dns_hook_lock);
|
||||
|
||||
for (size_t i = 0; i < _countof(dns_hook_syms_ws2); ++i) {
|
||||
dns_hook_syms_ws2[i].ordinal = get_function_ordinal("ws2_32.dll", dns_hook_syms_ws2[i].name);
|
||||
}
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"dnsapi.dll",
|
||||
@ -215,6 +214,18 @@ static void dns_hook_init(void)
|
||||
_countof(dns_hook_syms_winhttp));
|
||||
}
|
||||
|
||||
void http_hook_init(){
|
||||
for (size_t i = 0; i < _countof(http_hook_syms_ws2); ++i) {
|
||||
http_hook_syms_ws2[i].ordinal = get_function_ordinal("ws2_32.dll", http_hook_syms_ws2[i].name);
|
||||
}
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"ws2_32.dll",
|
||||
http_hook_syms_ws2,
|
||||
_countof(http_hook_syms_ws2));
|
||||
}
|
||||
|
||||
// This function match domain and subdomains like *.naominet.jp.
|
||||
bool match_domain(const wchar_t* target, const wchar_t* pattern) {
|
||||
if (_wcsicmp(pattern, target) == 0) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void http_hook_init();
|
||||
// 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);
|
||||
|
||||
|
@ -121,6 +121,8 @@ void dns_config_load(struct dns_config *cfg, const wchar_t *filename)
|
||||
cfg->title,
|
||||
_countof(cfg->title),
|
||||
filename);
|
||||
|
||||
cfg->replaceHost = GetPrivateProfileIntW(L"dns", L"replaceHost", 0, filename);
|
||||
}
|
||||
|
||||
void hwmon_config_load(struct hwmon_config *cfg, const wchar_t *filename)
|
||||
|
@ -16,6 +16,10 @@ HRESULT dns_platform_hook_init(const struct dns_config *cfg)
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
if(cfg->replaceHost){
|
||||
http_hook_init();
|
||||
}
|
||||
|
||||
hr = dns_hook_push(L"tenporouter.loc", cfg->router);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
|
@ -12,6 +12,7 @@ struct dns_config {
|
||||
wchar_t billing[128];
|
||||
wchar_t aimedb[128];
|
||||
wchar_t title[128];
|
||||
bool replaceHost;
|
||||
};
|
||||
|
||||
HRESULT dns_platform_hook_init(const struct dns_config *cfg);
|
||||
|
Loading…
Reference in New Issue
Block a user