From: Zebediah Figura zfigura@codeweavers.com
--- dlls/setupapi/query.c | 24 +++++++++++++++++++++--- dlls/setupapi/tests/query.c | 14 +++++++------- 2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c index 88efea17473..c94fec77124 100644 --- a/dlls/setupapi/query.c +++ b/dlls/setupapi/query.c @@ -413,9 +413,27 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR TRACE("%p, %p, %s, %p, %p, 0x%08lx, %p\n", hinf, context, debugstr_w(filename), source_id, buffer, buffer_size, required_size);
- if (!context) context = &ctx; + if (context) + { + WCHAR *ctx_filename; + DWORD filename_size; + + if (!SetupGetStringFieldW( context, 1, NULL, 0, &filename_size )) + return FALSE; + if (!(ctx_filename = malloc( filename_size * sizeof(WCHAR) ))) + return FALSE; + SetupGetStringFieldW( context, 1, ctx_filename, filename_size, NULL ); + + source_id_str = get_source_id( hinf, &ctx, ctx_filename ); + + free( ctx_filename ); + } + else + { + source_id_str = get_source_id( hinf, &ctx, filename ); + }
- if (!(source_id_str = get_source_id( hinf, context, filename ))) + if (!source_id_str) return FALSE;
*source_id = wcstol( source_id_str, &end, 10 ); @@ -426,7 +444,7 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR } free( source_id_str );
- if (SetupGetStringFieldW( context, 4, buffer, buffer_size, required_size )) + if (SetupGetStringFieldW( &ctx, 4, buffer, buffer_size, required_size )) return TRUE;
if (required_size) *required_size = 1; diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c index 145ca6e12eb..8f4400b802e 100644 --- a/dlls/setupapi/tests/query.c +++ b/dlls/setupapi/tests/query.c @@ -356,12 +356,12 @@ static void test_SetupGetSourceFileLocation(void)
ret = SetupGetSourceFileLocationA(hinf, &ctx, "two.txt", &source_id, buffer, sizeof(buffer), NULL); ok(ret, "Got error %lu.\n", GetLastError()); - todo_wine ok(source_id == 2, "Got source id %u.\n", source_id); - todo_wine ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer)); + ok(source_id == 2, "Got source id %u.\n", source_id); + ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer));
/* ctx should not be changed. */ ret = SetupGetLineTextA(&ctx, NULL, NULL, NULL, buffer, sizeof(buffer), NULL); - todo_wine ok(!strcmp(buffer, "one.txt,,2"), "Got line %s.\n", debugstr_a(buffer)); + ok(!strcmp(buffer, "one.txt,,2"), "Got line %s.\n", debugstr_a(buffer));
/* Test when the source name differs from the destination name. * It seems SetupGetSourceFileLocation() is buggy and doesn't take that @@ -370,18 +370,18 @@ static void test_SetupGetSourceFileLocation(void) ret = SetupFindNextLine(&ctx, &ctx); ok(ret, "Got error %lu.\n", GetLastError()); ret = SetupFindNextLine(&ctx, &ctx); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + ok(ret, "Got error %lu.\n", GetLastError());
SetLastError(0xdeadbeef); ret = SetupGetSourceFileLocationA(hinf, &ctx, "two.txt", &source_id, buffer, sizeof(buffer), NULL); - todo_wine ok(!ret, "Expected failure.\n"); - todo_wine ok(GetLastError() == ERROR_LINE_NOT_FOUND, "Got error %lu.\n", GetLastError()); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_LINE_NOT_FOUND, "Got error %lu.\n", GetLastError());
ret = SetupFindNextLine(&ctx, &ctx); ok(ret, "Got error %lu.\n", GetLastError());
ret = SetupGetSourceFileLocationA(hinf, &ctx, "two.txt", &source_id, buffer, sizeof(buffer), NULL); - ok(ret, "Got error %lu.\n", GetLastError()); + todo_wine ok(ret, "Got error %lu.\n", GetLastError()); todo_wine ok(source_id == 10, "Got source id %u.\n", source_id); todo_wine ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer));