From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/setupapi/devinst.c | 27 ++++++++++++++--- dlls/setupapi/tests/devinst.c | 55 +++++++++++++++++------------------ 2 files changed, 49 insertions(+), 33 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 718fe66adbe..e70431e4ec9 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -6110,6 +6110,7 @@ static DWORD driver_package_delete(const struct driver_package *package) BOOL WINAPI SetupCopyOEMInfW(const WCHAR *source, const WCHAR *location, DWORD media_type, DWORD style, WCHAR *dest, DWORD buffer_size, DWORD *required_size, WCHAR **filepart) { + struct driver_package package; WCHAR target[MAX_PATH]; DWORD size, ret;
@@ -6122,14 +6123,32 @@ BOOL WINAPI SetupCopyOEMInfW(const WCHAR *source, const WCHAR *location, DWORD m return FALSE; }
- /* check for a relative path */ - if (!(*source == '\' || (*source && source[1] == ':'))) + if ((ret = parse_inf(&package, source))) { - SetLastError(ERROR_FILE_NOT_FOUND); + SetLastError(ret); return FALSE; }
- ret = copy_inf(source, style, target); + if (package.already_installed) + { + if (find_existing_inf(source, target)) + { + if (style & SP_COPY_NOOVERWRITE) + ret = ERROR_FILE_EXISTS; + else + ret = ERROR_SUCCESS; + } + else + { + ERR("Inf %s is already installed to driver store, but not found in C:\windows\inf!\n", + debugstr_w(source)); + ret = ERROR_FILE_NOT_FOUND; + } + } + else + { + ret = driver_package_install_to_store(&package, style, target); + }
if (style & SP_COPY_DELETESOURCE) DeleteFileW(source); diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 6bbb7f25778..80b895b5c4f 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -3794,29 +3794,26 @@ static void test_copy_oem_inf(struct testsign_context *ctx) SetLastError(0xdeadbeef); memset(dest, 0xcc, sizeof(dest)); ret = SetupCopyOEMInfA("winetest.inf", NULL, 0, SP_COPY_NOOVERWRITE, dest, sizeof(dest), NULL, &filepart); - todo_wine ok(ret == TRUE, "Got %d.\n", ret); - todo_wine ok(!GetLastError(), "Got error %#lx.\n", GetLastError()); + ok(ret == TRUE, "Got %d.\n", ret); + ok(!GetLastError(), "Got error %#lx.\n", GetLastError()); ok(file_exists("winetest.inf"), "Expected source inf to exist.\n"); - if (ret) - { - ok(file_exists(dest), "Expected dest file to exist.\n"); - ok(is_in_inf_dir(dest), "Got unexpected path '%s'.\n", dest); - ok(filepart == strrchr(dest, '\') + 1, "Got unexpected file part %s.\n", filepart); + ok(file_exists(dest), "Expected dest file to exist.\n"); + ok(is_in_inf_dir(dest), "Got unexpected path '%s'.\n", dest); + ok(filepart == strrchr(dest, '\') + 1, "Got unexpected file part %s.\n", filepart);
- ret = SetupUninstallOEMInfA("bogus.inf", 0, NULL); - ok(!ret, "Got %d.\n", ret); - ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Got error %#lx.\n", GetLastError()); + ret = SetupUninstallOEMInfA("bogus.inf", 0, NULL); + ok(!ret, "Got %d.\n", ret); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Got error %#lx.\n", GetLastError());
- strcpy(pnf, dest); - *(strrchr(pnf, '.') + 1) = 'p'; - SetLastError(0xdeadbeef); - ret = SetupUninstallOEMInfA(filepart, 0, NULL); - ok(ret == TRUE, "Got %d.\n", ret); - ok(!GetLastError(), "Got error %#lx.\n", GetLastError()); - ok(!file_exists(dest), "Expected inf '%s' not to exist.\n", dest); - DeleteFileA(dest); - ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf); - } + strcpy(pnf, dest); + *(strrchr(pnf, '.') + 1) = 'p'; + SetLastError(0xdeadbeef); + ret = SetupUninstallOEMInfA(filepart, 0, NULL); + ok(ret == TRUE, "Got %d.\n", ret); + ok(!GetLastError(), "Got error %#lx.\n", GetLastError()); + ok(!file_exists(dest), "Expected inf '%s' not to exist.\n", dest); + DeleteFileA(dest); + ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf);
/* try SP_COPY_REPLACEONLY, dest does not exist */ SetLastError(0xdeadbeef); @@ -3912,10 +3909,10 @@ static void test_copy_oem_inf(struct testsign_context *ctx) *(strrchr(pnf, '.') + 1) = 'p';
ret = SetupUninstallOEMInfA(strrchr(dest, '\') + 1, 0, NULL); - todo_wine ok(ret, "Failed to uninstall '%s', error %#lx.\n", dest, GetLastError()); - todo_wine ok(!file_exists(dest), "Expected inf '%s' not to exist.\n", dest); + ok(ret, "Failed to uninstall '%s', error %#lx.\n", dest, GetLastError()); + ok(!file_exists(dest), "Expected inf '%s' not to exist.\n", dest); DeleteFileA(dest); - todo_wine ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf); + ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf);
create_file("winetest.inf", inf_data1); SetLastError(0xdeadbeef); @@ -3950,20 +3947,20 @@ static void test_copy_oem_inf(struct testsign_context *ctx) ok(strcmp(dest, orig_dest), "Expected INF files to be copied to different paths.\n");
ret = SetupUninstallOEMInfA(strrchr(dest, '\') + 1, 0, NULL); - todo_wine ok(ret, "Failed to uninstall '%s', error %#lx.\n", dest, GetLastError()); - todo_wine ok(!file_exists(dest), "Expected inf '%s' not to exist.\n", dest); + ok(ret, "Failed to uninstall '%s', error %#lx.\n", dest, GetLastError()); + ok(!file_exists(dest), "Expected inf '%s' not to exist.\n", dest); DeleteFileA(dest); strcpy(pnf, dest); *(strrchr(pnf, '.') + 1) = 'p'; - todo_wine ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf); + ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf);
ret = SetupUninstallOEMInfA(strrchr(orig_dest, '\') + 1, 0, NULL); - todo_wine ok(ret, "Failed to uninstall '%s', error %#lx.\n", orig_dest, GetLastError()); - todo_wine ok(!file_exists(orig_dest), "Expected inf '%s' not to exist.\n", dest); + ok(ret, "Failed to uninstall '%s', error %#lx.\n", orig_dest, GetLastError()); + ok(!file_exists(orig_dest), "Expected inf '%s' not to exist.\n", dest); DeleteFileA(orig_dest); strcpy(pnf, dest); *(strrchr(pnf, '.') + 1) = 'p'; - todo_wine ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf); + ok(!file_exists(pnf), "Expected pnf '%s' not to exist.\n", pnf);
ret = DeleteFileA("winetest2.cat"); ok(ret, "Failed to delete file, error %#lx.\n", GetLastError());