mirror of
https://gitea.tendokyu.moe/TeamTofuShop/taitools.git
synced 2026-10-08 14:48:12 +03:00
simplify crackurl hook
This commit is contained in:
+6
-28
@@ -498,45 +498,23 @@ static BOOL my_WinHttpCrackUrl(
|
||||
DWORD dwFlags,
|
||||
LPURL_COMPONENTS lpUrlComponents)
|
||||
{
|
||||
size_t i;
|
||||
const struct dns_hook_entry *pos;
|
||||
wchar_t bfr[1024] = {0};
|
||||
if (!next_WinHttpCrackUrl(pwszUrl, dwUrlLength, dwFlags, lpUrlComponents)) {
|
||||
dprintf("DNS: next_WinHttpCrackUrl FAIL %08X\n", (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (dns_hook_lock.DebugInfo == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//dprintf("DNS: crack URL %S\n", lpUrlComponents->lpszHostName);
|
||||
|
||||
EnterCriticalSection(&dns_hook_lock);
|
||||
|
||||
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
||||
pos = &dns_hook_entries[i];
|
||||
for (size_t i = 0 ; i < dns_hook_nentries ; i++) {
|
||||
struct dns_hook_entry* pos = &dns_hook_entries[i];
|
||||
if (_wcsnicmp(lpUrlComponents->lpszHostName, pos->from, wcslen(pos->from)) == 0) {
|
||||
wchar_t *path = wcsstr(lpUrlComponents->lpszHostName, L"/");
|
||||
|
||||
if (path == NULL){
|
||||
dprintf("DNS: Replace url %S -> %S\n", lpUrlComponents->lpszHostName, pos->to);
|
||||
|
||||
lpUrlComponents->lpszHostName = pos->to;
|
||||
lpUrlComponents->dwHostNameLength = wcslen(pos->to);
|
||||
} else {
|
||||
wcscat_s(bfr, _countof(bfr), pos->to);
|
||||
wcscat_s(bfr, _countof(bfr), path);
|
||||
dprintf("DNS: Replace url with path %S -> %S\n", lpUrlComponents->lpszHostName, pos->to);
|
||||
|
||||
lpUrlComponents->lpszHostName = bfr;
|
||||
lpUrlComponents->dwHostNameLength = wcslen(pos->to);
|
||||
}
|
||||
dprintf("DNS: Replace url %S -> %S\n", lpUrlComponents->lpszHostName, pos->to);
|
||||
lpUrlComponents->lpszHostName = pos->to;
|
||||
lpUrlComponents->dwHostNameLength = wcslen(pos->to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user