1
0
mirror of https://gitea.tendokyu.moe/Hay1tsme/segatools.git synced 2024-11-12 04:40:46 +01:00

hooklib/dns.c: Fix locking

This commit is contained in:
Tau 2019-09-07 16:25:44 -04:00
parent 63729cc95e
commit 697c6c6893

View File

@ -216,6 +216,7 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
}
mbstowcs_s(NULL, wstr, wstr_c, pszName, wstr_c - 1);
EnterCriticalSection(&dns_hook_lock);
for (i = 0 ; i < dns_hook_nentries ; i++) {
pos = &dns_hook_entries[i];
@ -225,6 +226,7 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
str = malloc(str_c * sizeof(char));
if (str == NULL) {
LeaveCriticalSection(&dns_hook_lock);
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
goto end;
@ -237,6 +239,8 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
}
}
LeaveCriticalSection(&dns_hook_lock);
code = next_DnsQuery_A(
pszName,
wType,
@ -269,6 +273,8 @@ static DNS_STATUS WINAPI hook_DnsQuery_W(
return ERROR_INVALID_PARAMETER;
}
EnterCriticalSection(&dns_hook_lock);
for (i = 0 ; i < dns_hook_nentries ; i++) {
pos = &dns_hook_entries[i];
@ -279,6 +285,8 @@ static DNS_STATUS WINAPI hook_DnsQuery_W(
}
}
LeaveCriticalSection(&dns_hook_lock);
return next_DnsQuery_W(
pszName,
wType,
@ -304,6 +312,7 @@ static DNS_STATUS WINAPI hook_DnsQueryEx(
}
orig = pRequest->QueryName;
EnterCriticalSection(&dns_hook_lock);
for (i = 0 ; i < dns_hook_nentries ; i++) {
pos = &dns_hook_entries[i];
@ -315,6 +324,8 @@ static DNS_STATUS WINAPI hook_DnsQueryEx(
}
}
LeaveCriticalSection(&dns_hook_lock);
code = next_DnsQueryEx(pRequest, pQueryResults, pCancelHandle);
/* Caller might not appreciate QueryName changing under its feet. It is