fixed AMFS path redirect with no E:/ drive present

This commit is contained in:
Dniel97 2024-02-27 16:49:27 +01:00
parent 629ded4018
commit f570869946
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
# Segatools
Version: `2024-02-22`
Version: `2024-02-27`
Loaders and hardware emulators for SEGA games that run on the Nu and ALLS platforms.

View File

@ -277,11 +277,12 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
const wchar_t *redir;
size_t required;
size_t redir_len;
size_t src_len;
assert(src != NULL);
assert(count != NULL);
if (src[0] == L'\0' || src[1] != L':' || !path_is_separator_w(src[2])) {
if (src[0] == L'\0' || src[1] != L':') {
return S_FALSE;
}
@ -304,10 +305,15 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
return S_FALSE;
}
/* GetFileAttributesW would request the src "E:", so fix the src_len in
in order to redirect the drive letter successfully */
src_len = path_is_separator_w(src[2]) ? 3 : 2;
/* Cut off <prefix>\, replace with redir path, count NUL terminator */
redir_len = wcslen(redir);
required = wcslen(src) - 3 + redir_len + 1;
required = wcslen(src) - src_len + redir_len + 1;
if (dest != NULL) {
if (required > *count) {
@ -315,7 +321,7 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
}
wcscpy_s(dest, *count, redir);
wcscpy_s(dest + redir_len, *count - redir_len, src + 3);
wcscpy_s(dest + redir_len, *count - redir_len, src + src_len);
}
*count = required;