api: honor locale when comparing case-insensitive
Quote from MSDN: > You will need to call setlocale for _wcsicmp to work with Latin 1 > characters. The C locale is in effect by default, so, for example, ä > will not compare equal to Ä. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
c8711464bb
commit
4c131caa7d
@ -58,9 +58,11 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
||||
ResourceModule = hinstDLL;
|
||||
NamespaceInit();
|
||||
NciInit();
|
||||
DevmgmtInit();
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
DevmgmtCleanup();
|
||||
NciCleanup();
|
||||
NamespaceCleanup();
|
||||
break;
|
||||
|
@ -126,3 +126,9 @@ typedef BOOL(CALLBACK *WINTUN_ENUMPROC)(_In_ const WINTUN_ADAPTER *Adapter, _In_
|
||||
|
||||
WINTUN_STATUS WINAPI
|
||||
WintunEnumAdapters(_In_z_count_c_(MAX_POOL) const WCHAR *Pool, _In_ WINTUN_ENUMPROC Func, _In_ LPARAM Param);
|
||||
|
||||
void
|
||||
DevmgmtInit();
|
||||
|
||||
void
|
||||
DevmgmtCleanup();
|
||||
|
@ -15,6 +15,8 @@ const static GUID ADAPTER_NET_GUID = { 0xcac88484L,
|
||||
0x4c03,
|
||||
{ 0x82, 0xe6, 0x71, 0xa8, 0x7a, 0xba, 0xc3, 0x61 } };
|
||||
|
||||
static _locale_t Locale;
|
||||
|
||||
/**
|
||||
* Retrieves a specified Plug and Play device property.
|
||||
*
|
||||
@ -385,14 +387,14 @@ IsPoolMember(
|
||||
goto cleanupDeviceDesc;
|
||||
WCHAR PoolDeviceTypeName[MAX_POOL_DEVICE_TYPE];
|
||||
GetPoolDeviceTypeName(Pool, PoolDeviceTypeName);
|
||||
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
|
||||
if (!_wcsicmp_l(FriendlyName, PoolDeviceTypeName, Locale) || !_wcsicmp_l(DeviceDesc, PoolDeviceTypeName, Locale))
|
||||
{
|
||||
*IsMember = TRUE;
|
||||
goto cleanupFriendlyName;
|
||||
}
|
||||
RemoveNumberedSuffix(FriendlyName, FriendlyName);
|
||||
RemoveNumberedSuffix(DeviceDesc, DeviceDesc);
|
||||
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
|
||||
if (!_wcsicmp_l(FriendlyName, PoolDeviceTypeName, Locale) || !_wcsicmp_l(DeviceDesc, PoolDeviceTypeName, Locale))
|
||||
{
|
||||
*IsMember = TRUE;
|
||||
goto cleanupFriendlyName;
|
||||
@ -608,7 +610,7 @@ WintunGetAdapter(
|
||||
continue;
|
||||
Name2[_countof(Name2) - 1] = 0;
|
||||
RemoveNumberedSuffix(Name2, Name3);
|
||||
if (_wcsicmp(Name, Name2) && _wcsicmp(Name, Name3))
|
||||
if (_wcsicmp_l(Name, Name2, Locale) && _wcsicmp_l(Name, Name3, Locale))
|
||||
continue;
|
||||
|
||||
/* Check the Hardware ID to make sure it's a real Wintun device. This avoids doing slow operations on non-Wintun
|
||||
@ -1223,3 +1225,15 @@ cleanupMutex:
|
||||
ReleaseNameMutex(Mutex);
|
||||
return Result;
|
||||
}
|
||||
|
||||
void
|
||||
DevmgmtInit()
|
||||
{
|
||||
Locale = _wcreate_locale(LC_ALL, L"");
|
||||
}
|
||||
|
||||
void
|
||||
DevmgmtCleanup()
|
||||
{
|
||||
_free_locale(Locale);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user