mirror of
https://gitea.tendokyu.moe/Dniel97/segatools.git
synced 2024-11-23 21:10:57 +01:00
Allow dns hook to fail a resolve and add domains
This lets people with crap ISPs that resolve domains that they shouldn't to use the game without changing their DNS server
This commit is contained in:
parent
9f933bb371
commit
4bc7eee909
@ -156,7 +156,6 @@ HRESULT dns_hook_push(const wchar_t *from_src, const wchar_t *to_src)
|
||||
wchar_t *to;
|
||||
|
||||
assert(from_src != NULL);
|
||||
assert(to_src != NULL);
|
||||
|
||||
to = NULL;
|
||||
from = NULL;
|
||||
@ -172,12 +171,14 @@ HRESULT dns_hook_push(const wchar_t *from_src, const wchar_t *to_src)
|
||||
goto end;
|
||||
}
|
||||
|
||||
to = _wcsdup(to_src);
|
||||
if(to_src != NULL) {
|
||||
to = _wcsdup(to_src);
|
||||
|
||||
if (to == NULL) {
|
||||
hr = E_OUTOFMEMORY;
|
||||
if (to == NULL) {
|
||||
hr = E_OUTOFMEMORY;
|
||||
|
||||
goto end;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
newmem = realloc(
|
||||
@ -250,6 +251,13 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
|
||||
pos = &dns_hook_entries[i];
|
||||
|
||||
if (_wcsicmp(wstr, pos->from) == 0) {
|
||||
if(pos->to == NULL) {
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
hr = HRESULT_FROM_WIN32(DNS_ERROR_RCODE_NAME_ERROR);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
wcstombs_s(&str_c, NULL, 0, pos->to, 0);
|
||||
str = malloc(str_c * sizeof(char));
|
||||
|
||||
@ -307,6 +315,11 @@ static DNS_STATUS WINAPI hook_DnsQuery_W(
|
||||
pos = &dns_hook_entries[i];
|
||||
|
||||
if (_wcsicmp(pszName, pos->from) == 0) {
|
||||
if(pos->to == NULL) {
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
return HRESULT_FROM_WIN32(DNS_ERROR_RCODE_NAME_ERROR);
|
||||
}
|
||||
|
||||
pszName = pos->to;
|
||||
|
||||
break;
|
||||
@ -346,6 +359,11 @@ static DNS_STATUS WINAPI hook_DnsQueryEx(
|
||||
pos = &dns_hook_entries[i];
|
||||
|
||||
if (_wcsicmp(pRequest->QueryName, pos->from) == 0) {
|
||||
if(pos->to == NULL) {
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
return HRESULT_FROM_WIN32(DNS_ERROR_RCODE_NAME_ERROR);
|
||||
}
|
||||
|
||||
pRequest->QueryName = pos->to;
|
||||
|
||||
break;
|
||||
@ -408,6 +426,13 @@ static int WSAAPI hook_getaddrinfo(
|
||||
pos = &dns_hook_entries[i];
|
||||
|
||||
if (_wcsicmp(wstr, pos->from) == 0) {
|
||||
if(pos->to == NULL) {
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
result = EAI_NONAME;
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
wcstombs_s(&str_c, NULL, 0, pos->to, 0);
|
||||
str = malloc(str_c * sizeof(char));
|
||||
|
||||
|
@ -4,5 +4,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -64,5 +64,20 @@ HRESULT dns_platform_hook_init(const struct dns_config *cfg)
|
||||
return hr;
|
||||
}
|
||||
|
||||
// if your ISP resolves bad domains, it will kill the network. These 2
|
||||
// *cannot* resolve
|
||||
|
||||
hr = dns_hook_push(L"mobirouter.loc", NULL);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = dns_hook_push(L"dslrouter.loc", NULL);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user