Module: wine Branch: stable Commit: c6af3a9002c6a7a8c2c6f96730415e5877640e2d URL: https://source.winehq.org/git/wine.git/?a=commit;h=c6af3a9002c6a7a8c2c6f9673... Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 11 09:00:43 2020 +0100 setupapi: Support a WineSourceDirs section to copy files from the Wine build or data dir. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> (cherry picked from commit aa76bec2417551952eec9cd8f5d8302dcb72f5bd) Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/setupapi/install.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c index e1667541680..0859739be5d 100644 --- a/dlls/setupapi/install.c +++ b/dlls/setupapi/install.c @@ -153,13 +153,31 @@ static WCHAR *dup_section_line_field( HINF hinf, const WCHAR *section, const WCH */ static BOOL copy_files_callback( HINF hinf, PCWSTR field, void *arg ) { + INFCONTEXT context; struct files_callback_info *info = arg; WCHAR src_root[MAX_PATH], *p; if (!info->src_root) { - lstrcpyW( src_root, PARSER_get_inf_filename( hinf ) ); - if ((p = wcsrchr( src_root, '\\' ))) *p = 0; + const WCHAR *build_dir = _wgetenv( L"WINEBUILDDIR" ); + const WCHAR *data_dir = _wgetenv( L"WINEDATADIR" ); + + if ((build_dir || data_dir) && SetupFindFirstLineW( hinf, L"WineSourceDirs", field, &context )) + { + lstrcpyW( src_root, build_dir ? build_dir : data_dir ); + src_root[1] = '\\'; /* change \??\ to \\?\ */ + p = src_root + lstrlenW(src_root); + *p++ = '\\'; + if (!build_dir || !SetupGetStringFieldW( &context, 2, p, MAX_PATH - (p - src_root), NULL )) + { + if (!SetupGetStringFieldW( &context, 1, p, MAX_PATH - (p - src_root), NULL )) p[-1] = 0; + } + } + else + { + lstrcpyW( src_root, PARSER_get_inf_filename( hinf ) ); + if ((p = wcsrchr( src_root, '\\' ))) *p = 0; + } } if (field[0] == '@') /* special case: copy single file */