mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-26 20:20:53 +03:00
winws: optimize network list search
This commit is contained in:
parent
7e2ed880dc
commit
1b65220878
Binary file not shown.
Binary file not shown.
@ -977,7 +977,7 @@ static bool str2guid(const char* str, GUID *guid)
|
|||||||
{
|
{
|
||||||
unsigned int u[11],k;
|
unsigned int u[11],k;
|
||||||
|
|
||||||
if (11 != sscanf(str, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", u+0, u+1, u+2, u+3, u+4, u+5, u+6, u+7, u+8, u+9, u+10))
|
if (36 != strlen(str) || 11 != sscanf(str, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", u+0, u+1, u+2, u+3, u+4, u+5, u+6, u+7, u+8, u+9, u+10))
|
||||||
return false;
|
return false;
|
||||||
guid->Data1 = u[0];
|
guid->Data1 = u[0];
|
||||||
if ((u[1] & 0xFFFF0000) || (u[2] & 0xFFFF0000)) return false;
|
if ((u[1] & 0xFFFF0000) || (u[2] & 0xFFFF0000)) return false;
|
||||||
@ -1110,11 +1110,11 @@ static bool nlm_filter_match(const struct str_list_head *nlm_list)
|
|||||||
bool bRet = true, bMatch = false;
|
bool bRet = true, bMatch = false;
|
||||||
IEnumNetworks* pEnum;
|
IEnumNetworks* pEnum;
|
||||||
|
|
||||||
if (SUCCEEDED(w_win32_error = pNetworkListManager->lpVtbl->GetNetworks(pNetworkListManager, NLM_ENUM_NETWORK_ALL, &pEnum)))
|
if (SUCCEEDED(w_win32_error = pNetworkListManager->lpVtbl->GetNetworks(pNetworkListManager, NLM_ENUM_NETWORK_CONNECTED, &pEnum)))
|
||||||
{
|
{
|
||||||
INetwork* pNet;
|
INetwork* pNet;
|
||||||
VARIANT_BOOL bIsConnected;
|
|
||||||
GUID idNet,g;
|
GUID idNet,g;
|
||||||
|
bool bIsGuid;
|
||||||
BSTR bstrName;
|
BSTR bstrName;
|
||||||
char Name[128];
|
char Name[128];
|
||||||
struct str_list *nlm;
|
struct str_list *nlm;
|
||||||
@ -1126,11 +1126,8 @@ static bool nlm_filter_match(const struct str_list_head *nlm_list)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!pNet) break;
|
if (!pNet) break;
|
||||||
if (SUCCEEDED(w_win32_error = pNet->lpVtbl->get_IsConnected(pNet, &bIsConnected)) &&
|
if (SUCCEEDED(w_win32_error = pNet->lpVtbl->GetNetworkId(pNet, &idNet)) &&
|
||||||
SUCCEEDED(w_win32_error = pNet->lpVtbl->GetNetworkId(pNet, &idNet)) &&
|
|
||||||
SUCCEEDED(w_win32_error = pNet->lpVtbl->GetName(pNet, &bstrName)))
|
SUCCEEDED(w_win32_error = pNet->lpVtbl->GetName(pNet, &bstrName)))
|
||||||
{
|
|
||||||
if (bIsConnected)
|
|
||||||
{
|
{
|
||||||
if (WideCharToMultiByte(CP_UTF8, 0, bstrName, -1, Name, sizeof(Name), NULL, NULL))
|
if (WideCharToMultiByte(CP_UTF8, 0, bstrName, -1, Name, sizeof(Name), NULL, NULL))
|
||||||
{
|
{
|
||||||
@ -1145,8 +1142,6 @@ static bool nlm_filter_match(const struct str_list_head *nlm_list)
|
|||||||
w_win32_error = HRESULT_FROM_WIN32(GetLastError());
|
w_win32_error = HRESULT_FROM_WIN32(GetLastError());
|
||||||
bRet = false;
|
bRet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
SysFreeString(bstrName);
|
SysFreeString(bstrName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user