Code: Select all
int __usercall wcsicmp@<eax>(WCHAR * wstr1@<eax>, WCHAR * wstr2@<edx>)
{
int result;
CHAR tmp2[260];
CHAR tmp1[260];
WCHAR wtmp2[1024];
WCHAR wtmp1[1024];
if ( win_dwPlatformId == 2 ) // Windows NT
{
wcsncpyEx(wtmp1, 1023, wstr1);
wcsncpyEx(wtmp2, 1023, wstr2);
wstr_lower(wtmp1);
wstr_lower(wtmp2);
result = wcscmp(wtmp1, wtmp2);
}
else
{
WideCharToMultiByte(0, 0, wstr1, -1, tmp1, 259, 0, 0);
WideCharToMultiByte(0, 0, wstr2, -1, tmp2, 259, 0, 0);
str_lower(tmp1);
str_lower(tmp2);
result = strcmp(tmp1, tmp2);
}
return result;
}
If the length of wstr1 or wstr2 is will be more than 259, then WideCharToMultiByte not insert null terminator!
After function strcmp will compare trash!
Recomendation: All this code needs to be replaced with a call shlwapi.dll@StrCmpIW