setupapi: Use the original INF source path if possible when copying files.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=35903
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Zebediah Figura 2020-06-11 11:16:32 -05:00 committed by Alexandre Julliard
parent 547d62da22
commit f779f36da3
1 changed files with 25 additions and 1 deletions

View File

@ -32,6 +32,7 @@
#include "winnls.h"
#include "winsvc.h"
#include "shlobj.h"
#include "shlwapi.h"
#include "objidl.h"
#include "objbase.h"
#include "setupapi.h"
@ -112,6 +113,29 @@ static WCHAR *dup_section_line_field( HINF hinf, const WCHAR *section, const WCH
return buffer;
}
static void get_inf_src_path( HINF hinf, WCHAR *path )
{
const WCHAR *inf_path = PARSER_get_inf_filename( hinf );
WCHAR pnf_path[MAX_PATH];
FILE *pnf;
wcscpy( pnf_path, inf_path );
PathRemoveExtensionW( pnf_path );
PathAddExtensionW( pnf_path, L".pnf" );
if ((pnf = _wfopen( pnf_path, L"r" )))
{
if (fgetws( path, MAX_PATH, pnf ) && !wcscmp( path, PNF_HEADER ))
{
fgetws( path, MAX_PATH, pnf );
TRACE("using original source path %s\n", debugstr_w(path));
fclose( pnf );
return;
}
fclose( pnf );
}
wcscpy( path, inf_path );
}
/***********************************************************************
* copy_files_callback
*
@ -141,7 +165,7 @@ static BOOL copy_files_callback( HINF hinf, PCWSTR field, void *arg )
}
else
{
lstrcpyW( src_root, PARSER_get_inf_filename( hinf ) );
get_inf_src_path( hinf, src_root );
if ((p = wcsrchr( src_root, '\\' ))) *p = 0;
}
}