mirror of
https://gitea.tendokyu.moe/Hay1tsme/segatools.git
synced 2024-12-01 03:57:16 +01:00
hooklib/dns.c: Fix locking
This commit is contained in:
parent
63729cc95e
commit
697c6c6893
@ -216,6 +216,7 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mbstowcs_s(NULL, wstr, wstr_c, pszName, wstr_c - 1);
|
mbstowcs_s(NULL, wstr, wstr_c, pszName, wstr_c - 1);
|
||||||
|
EnterCriticalSection(&dns_hook_lock);
|
||||||
|
|
||||||
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
||||||
pos = &dns_hook_entries[i];
|
pos = &dns_hook_entries[i];
|
||||||
@ -225,6 +226,7 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
|
|||||||
str = malloc(str_c * sizeof(char));
|
str = malloc(str_c * sizeof(char));
|
||||||
|
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
|
LeaveCriticalSection(&dns_hook_lock);
|
||||||
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
|
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
|
||||||
|
|
||||||
goto end;
|
goto end;
|
||||||
@ -237,6 +239,8 @@ static DNS_STATUS WINAPI hook_DnsQuery_A(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&dns_hook_lock);
|
||||||
|
|
||||||
code = next_DnsQuery_A(
|
code = next_DnsQuery_A(
|
||||||
pszName,
|
pszName,
|
||||||
wType,
|
wType,
|
||||||
@ -269,6 +273,8 @@ static DNS_STATUS WINAPI hook_DnsQuery_W(
|
|||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&dns_hook_lock);
|
||||||
|
|
||||||
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
||||||
pos = &dns_hook_entries[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(
|
return next_DnsQuery_W(
|
||||||
pszName,
|
pszName,
|
||||||
wType,
|
wType,
|
||||||
@ -304,6 +312,7 @@ static DNS_STATUS WINAPI hook_DnsQueryEx(
|
|||||||
}
|
}
|
||||||
|
|
||||||
orig = pRequest->QueryName;
|
orig = pRequest->QueryName;
|
||||||
|
EnterCriticalSection(&dns_hook_lock);
|
||||||
|
|
||||||
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
||||||
pos = &dns_hook_entries[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);
|
code = next_DnsQueryEx(pRequest, pQueryResults, pCancelHandle);
|
||||||
|
|
||||||
/* Caller might not appreciate QueryName changing under its feet. It is
|
/* Caller might not appreciate QueryName changing under its feet. It is
|
||||||
|
Loading…
Reference in New Issue
Block a user