diff --git a/hooklib/path.c b/hooklib/path.c index 887a9e9..864d2e2 100644 --- a/hooklib/path.c +++ b/hooklib/path.c @@ -388,6 +388,35 @@ end: return ok; } +int path_compare_w(const wchar_t *string1, const wchar_t *string2, size_t count) +{ + size_t i; + wchar_t c1, c2; + + assert(string1 != NULL); + assert(string2 != NULL); + + for (i = 0; i < count && string1[i] && string2[i]; i++) { + c1 = towlower(string1[i]); + + if (c1 == '/') { + c1 = '\\'; + } + + c2 = towlower(string2[i]); + + if (c2 == '/') { + c2 = '\\'; + } + + if (c1 != c2) { + break; + } + } + + return i == count ? 0 : string2[i] - string1[i]; +} + /* Dumping ground for kernel32 file system ops whose path parameters we have to hook into and translate. This list will grow over time as we go back and fix up older games that don't pay attention to the mount point registry. */ diff --git a/hooklib/path.h b/hooklib/path.h index 9e7b408..779e013 100644 --- a/hooklib/path.h +++ b/hooklib/path.h @@ -10,3 +10,4 @@ typedef HRESULT (*path_hook_t)( size_t *count); HRESULT path_hook_push(path_hook_t hook); +int path_compare_w(const wchar_t *string1, const wchar_t *string2, size_t count); diff --git a/platform/vfs.c b/platform/vfs.c index 689cd44..d78e6b5 100644 --- a/platform/vfs.c +++ b/platform/vfs.c @@ -273,7 +273,7 @@ static HRESULT vfs_path_hook_nthome( /* Case-insensitive check to see if src starts with vfs_nthome */ - if (_wcsnicmp(src, vfs_nthome, vfs_nthome_len) != 0) { + if (path_compare_w(src, vfs_nthome, vfs_nthome_len) != 0) { return S_FALSE; }