[PATCH 0/1] MR10290: winebuild: Better handle file extensions.
#### From the commit message: ``` Right now WinRT DLLs are treated as if their name's part after last dot is their extension. This means the string spec->file_name in main() will only carry the module's name, without any file extension. Later on this string will be used as the DLL's export name and written to the name field of IMAGE_DIRECTORY_ENTRY_EXPORT. Meaning the stored name is going to be "windows.foo.bar" instead of "windows.foo.bar.dll", for example. Looking innoncent at first this will cause Wine's DLL loader to get confused, as this string will be used later on to try load builtin DLLs. Loading WinRT DLLs only works by chance right now, because the loader will fall back to treat them as native DLLs. ``` Not sure if this is a good solution though. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10290
From: Bernhard Kölbl <bkoelbl@codeweavers.com> Right now WinRT DLLs are treated as if their name's part after last dot is their extension. This means the string spec->file_name in main() will only carry the module's name, without any file extension. Later on this string will be used as the DLL's export name and written to the name field of IMAGE_DIRECTORY_ENTRY_EXPORT. Meaning the stored name is going to be "windows.foo.bar" instead of "windows.foo.bar.dll", for example. Looking innoncent at first this will cause Wine's DLL loader to get confused, as this string will be used later on to try load builtin DLLs. Loading WinRT DLLs only works by chance right now, because the loader will fall back to treat them as native DLLs. --- tools/winebuild/main.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index 33d871383ae..182de655dd0 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -569,6 +569,40 @@ static void check_target(void) fatal_error( "Non-PE builds are not supported on this platform.\n" ); } +static void set_module_extension( DLLSPEC *spec ) +{ + if (!spec->file_name) + return; + + if (strendswith( spec->file_name, ".tlb" ) || + strendswith( spec->file_name, ".cpl" ) || + strendswith( spec->file_name, ".drv" ) || + strendswith( spec->file_name, ".ocx" ) || + strendswith( spec->file_name, ".sys" ) || + strendswith( spec->file_name, ".vxd" ) || + strendswith( spec->file_name, ".acm" ) || + strendswith( spec->file_name, ".ax" ) || + strendswith( spec->file_name, ".ds" ) || + strendswith( spec->file_name, ".exe" ) || + strendswith( spec->file_name, ".dll" ) || + strendswith( spec->file_name, ".com" ) || + strendswith( spec->file_name, ".drv16" ) || + strendswith( spec->file_name, ".exe16" ) || + strendswith( spec->file_name, ".mod16" ) || + strendswith( spec->file_name, ".dll16" )) + return; + + /* ignore some naming schemes (WinRT, test DLLs) */ + if ((!strstr( spec->file_name, "windows." ) && + !strstr( spec->file_name, "wine." ) && + !strendswith( spec->file_name, ".appcore" )) && strchr( spec->file_name, '.' )) + { + fatal_error( "file %s has unknown extension\n", spec->file_name ); + } + + strcat( spec->file_name, exec_mode == MODE_EXE ? ".exe" : ".dll" ); +} + /******************************************************************* * main */ @@ -586,8 +620,7 @@ int main(int argc, char **argv) atexit( cleanup ); /* make sure we remove the output file on exit */ - if (spec->file_name && !strchr( spec->file_name, '.' )) - strcat( spec->file_name, exec_mode == MODE_EXE ? ".exe" : ".dll" ); + set_module_extension( spec ); init_dll_name( spec ); if (force_pointer_size) set_target_ptr_size( &target, force_pointer_size ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10290
Given the amount of ad-hoc code we already have, and what's introduced here, wouldn't it be simpler to just use the directory name "windows.foo.bar.dll" for these instead of "windows.foo.bar"? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10290#note_131737
participants (2)
-
Bernhard Kölbl -
Elizabeth Figura (@zfigura)