[PATCH v2 0/2] MR10075: wow64win: Redirect system32 in NtGdiMakeFontDir().
-- v2: gdi32: Redirect system32 in AddFontResourceEx(). gdi32: Redirect system32 in CreateScalableFontResourceW(). https://gitlab.winehq.org/wine/wine/-/merge_requests/10075
From: Elizabeth Figura <zfigura@codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58963 --- dlls/gdi32/text.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c index 000878ccf6a..3a9a7c7a627 100644 --- a/dlls/gdi32/text.c +++ b/dlls/gdi32/text.c @@ -2512,6 +2512,24 @@ fail: return name; } +static void redirect_path( UNICODE_STRING *path ) +{ +#ifndef _WIN64 + static const WCHAR nt_sysdir[] = L"\\??\\C:\\windows\\system32\\"; +#ifdef __arm__ + const WCHAR *dir = L"C:\\windows\\sysarm32"; +#else + const WCHAR *dir = L"C:\\windows\\syswow64"; +#endif + + if (!NtCurrentTeb()->GdiBatchCount) return; /* not wow64 */ + if (((TEB64 *)NtCurrentTeb()->GdiBatchCount)->TlsSlots[WOW64_TLS_FILESYSREDIR]) return; /* disabled */ + if (path->Length <= sizeof(nt_sysdir)) return; + if (wcsnicmp( path->Buffer, nt_sysdir, wcslen(nt_sysdir))) return; + memcpy( path->Buffer + 4, dir, wcslen(dir) * sizeof(WCHAR) ); +#endif +} + static int add_font_resource( const WCHAR *str, DWORD flags, void *dv ) { UNICODE_STRING nt_name; @@ -2808,6 +2826,11 @@ BOOL WINAPI CreateScalableFontResourceW( DWORD hidden, const WCHAR *resource_fil } else if (!RtlDosPathNameToNtPathName_U( font_file, &nt_name, NULL, NULL )) goto done; + /* Windows does not redirect the path here, which is presumably a bug. + * Stratego (1997) tries to create a font resource in system32 + * and fails on 64-bit Windows. */ + redirect_path( &nt_name ); + ret = NtGdiMakeFontDir( hidden, (BYTE *)&fontdir, sizeof(fontdir), nt_name.Buffer, nt_name.Length + sizeof(WCHAR) ); RtlFreeUnicodeString( &nt_name ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10075
From: Elizabeth Figura <zfigura@codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58963 --- dlls/gdi32/text.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c index 3a9a7c7a627..52fac783801 100644 --- a/dlls/gdi32/text.c +++ b/dlls/gdi32/text.c @@ -2557,6 +2557,12 @@ static int add_font_resource( const WCHAR *str, DWORD flags, void *dv ) free( system_dir ); return 0; } + + /* Windows does not redirect the path here, which is presumably a bug. + * Stratego (1997) tries to create a font resource in system32 + * and fails on 64-bit Windows. */ + redirect_path( &nt_name ); + ret = NtGdiAddFontResourceW( nt_name.Buffer, nt_name.Length / sizeof(WCHAR) + 1, 1, flags, 0, dv ); RtlFreeUnicodeString( &nt_name ); @@ -2573,6 +2579,8 @@ INT WINAPI AddFontResourceExW( const WCHAR *str, DWORD flags, void *dv ) BOOL hidden; INT ret; + TRACE( "%s flags %#lx res %p\n", debugstr_w(str), flags, dv ); + if ((ret = add_font_resource( str, flags, dv ))) return ret; if (!(filename = get_scalable_filename( str, &hidden ))) return 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10075
None of the wow64win functions are supposed to handle redirection, so I'd prefer to have the workaround in `CreateScalableFontResourceW`.
Done now, sorry about the delay. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10075#note_132327
participants (2)
-
Elizabeth Figura -
Elizabeth Figura (@zfigura)