From: Zebediah Figura zfigura@codeweavers.com
--- dlls/setupapi/query.c | 50 ++++++++++++------------------------------- 1 file changed, 14 insertions(+), 36 deletions(-)
diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c index 40ec30ae11f..707492ac984 100644 --- a/dlls/setupapi/query.c +++ b/dlls/setupapi/query.c @@ -369,30 +369,6 @@ BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR f return ret; }
-static LPWSTR get_source_id( HINF hinf, PINFCONTEXT context, PCWSTR filename ) -{ - DWORD size; - LPWSTR source_id; - - if (!SetupFindFirstLineW( hinf, source_disks_files_platform, filename, context ) && - !SetupFindFirstLineW( hinf, source_disks_files, filename, context )) - return NULL; - - if (!SetupGetStringFieldW( context, 1, NULL, 0, &size )) - return NULL; - - if (!(source_id = malloc( size * sizeof(WCHAR) ))) - return NULL; - - if (!SetupGetStringFieldW( context, 1, source_id, size, NULL )) - { - free( source_id ); - return NULL; - } - - return source_id; -} - /*********************************************************************** * SetupGetSourceFileLocationW (SETUPAPI.@) */ @@ -402,7 +378,7 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR PDWORD required_size ) { INFCONTEXT ctx; - WCHAR *end, *source_id_str; + int id;
TRACE("%p, %p, %s, %p, %p, 0x%08lx, %p\n", hinf, context, debugstr_w(filename), source_id, buffer, buffer_size, required_size); @@ -418,25 +394,27 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR return FALSE; SetupGetStringFieldW( context, 1, ctx_filename, filename_size, NULL );
- source_id_str = get_source_id( hinf, &ctx, ctx_filename ); + if (!SetupFindFirstLineW( hinf, source_disks_files_platform, ctx_filename, &ctx ) && + !SetupFindFirstLineW( hinf, source_disks_files, ctx_filename, &ctx )) + { + free( ctx_filename ); + return FALSE; + }
free( ctx_filename ); } else { - source_id_str = get_source_id( hinf, &ctx, filename ); + if (!SetupFindFirstLineW( hinf, source_disks_files_platform, filename, &ctx ) && + !SetupFindFirstLineW( hinf, source_disks_files, filename, &ctx )) + { + return FALSE; + } }
- if (!source_id_str) + if (!SetupGetIntField( &ctx, 1, &id )) return FALSE; - - *source_id = wcstol( source_id_str, &end, 10 ); - if (end == source_id_str || *end) - { - free( source_id_str ); - return FALSE; - } - free( source_id_str ); + *source_id = id;
if (SetupGetStringFieldW( &ctx, 2, buffer, buffer_size, required_size )) return TRUE;