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;
|
ResourceModule = hinstDLL;
|
||||||
NamespaceInit();
|
NamespaceInit();
|
||||||
NciInit();
|
NciInit();
|
||||||
|
DevmgmtInit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
DevmgmtCleanup();
|
||||||
NciCleanup();
|
NciCleanup();
|
||||||
NamespaceCleanup();
|
NamespaceCleanup();
|
||||||
break;
|
break;
|
||||||
|
@ -126,3 +126,9 @@ typedef BOOL(CALLBACK *WINTUN_ENUMPROC)(_In_ const WINTUN_ADAPTER *Adapter, _In_
|
|||||||
|
|
||||||
WINTUN_STATUS WINAPI
|
WINTUN_STATUS WINAPI
|
||||||
WintunEnumAdapters(_In_z_count_c_(MAX_POOL) const WCHAR *Pool, _In_ WINTUN_ENUMPROC Func, _In_ LPARAM Param);
|
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,
|
0x4c03,
|
||||||
{ 0x82, 0xe6, 0x71, 0xa8, 0x7a, 0xba, 0xc3, 0x61 } };
|
{ 0x82, 0xe6, 0x71, 0xa8, 0x7a, 0xba, 0xc3, 0x61 } };
|
||||||
|
|
||||||
|
static _locale_t Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a specified Plug and Play device property.
|
* Retrieves a specified Plug and Play device property.
|
||||||
*
|
*
|
||||||
@ -385,14 +387,14 @@ IsPoolMember(
|
|||||||
goto cleanupDeviceDesc;
|
goto cleanupDeviceDesc;
|
||||||
WCHAR PoolDeviceTypeName[MAX_POOL_DEVICE_TYPE];
|
WCHAR PoolDeviceTypeName[MAX_POOL_DEVICE_TYPE];
|
||||||
GetPoolDeviceTypeName(Pool, PoolDeviceTypeName);
|
GetPoolDeviceTypeName(Pool, PoolDeviceTypeName);
|
||||||
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
|
if (!_wcsicmp_l(FriendlyName, PoolDeviceTypeName, Locale) || !_wcsicmp_l(DeviceDesc, PoolDeviceTypeName, Locale))
|
||||||
{
|
{
|
||||||
*IsMember = TRUE;
|
*IsMember = TRUE;
|
||||||
goto cleanupFriendlyName;
|
goto cleanupFriendlyName;
|
||||||
}
|
}
|
||||||
RemoveNumberedSuffix(FriendlyName, FriendlyName);
|
RemoveNumberedSuffix(FriendlyName, FriendlyName);
|
||||||
RemoveNumberedSuffix(DeviceDesc, DeviceDesc);
|
RemoveNumberedSuffix(DeviceDesc, DeviceDesc);
|
||||||
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
|
if (!_wcsicmp_l(FriendlyName, PoolDeviceTypeName, Locale) || !_wcsicmp_l(DeviceDesc, PoolDeviceTypeName, Locale))
|
||||||
{
|
{
|
||||||
*IsMember = TRUE;
|
*IsMember = TRUE;
|
||||||
goto cleanupFriendlyName;
|
goto cleanupFriendlyName;
|
||||||
@ -608,7 +610,7 @@ WintunGetAdapter(
|
|||||||
continue;
|
continue;
|
||||||
Name2[_countof(Name2) - 1] = 0;
|
Name2[_countof(Name2) - 1] = 0;
|
||||||
RemoveNumberedSuffix(Name2, Name3);
|
RemoveNumberedSuffix(Name2, Name3);
|
||||||
if (_wcsicmp(Name, Name2) && _wcsicmp(Name, Name3))
|
if (_wcsicmp_l(Name, Name2, Locale) && _wcsicmp_l(Name, Name3, Locale))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Check the Hardware ID to make sure it's a real Wintun device. This avoids doing slow operations on non-Wintun
|
/* 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);
|
ReleaseNameMutex(Mutex);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DevmgmtInit()
|
||||||
|
{
|
||||||
|
Locale = _wcreate_locale(LC_ALL, L"");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DevmgmtCleanup()
|
||||||
|
{
|
||||||
|
_free_locale(Locale);
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <bcrypt.h>
|
#include <bcrypt.h>
|
||||||
#include <cfgmgr32.h>
|
#include <cfgmgr32.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
|
#include <locale.h>
|
||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#include <sddl.h>
|
#include <sddl.h>
|
||||||
#include <SetupAPI.h>
|
#include <SetupAPI.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user