Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45455
-- v2: setupapi: Add stub for DriverStoreFindDriverPackageW
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45455 --- dlls/setupapi/query.c | 10 ++++++ dlls/setupapi/setupapi.spec | 1 + dlls/setupapi/tests/query.c | 67 +++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+)
diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c index 88efea17473..ae06871670b 100644 --- a/dlls/setupapi/query.c +++ b/dlls/setupapi/query.c @@ -732,6 +732,16 @@ BOOL WINAPI SetupGetInfDriverStoreLocationW( return FALSE; }
+HRESULT WINAPI DriverStoreFindDriverPackageW(const WCHAR *path_in, void *unk2, void *unk3, DWORD flags, void *unk5, WCHAR *path_out, DWORD *path_size) +{ + FIXME("%s, %p, %p, %lu, %p, %p, %p, %lu stub!\n", debugstr_w(path_in), unk2, unk3, flags, unk5, path_out, path_size, path_size ? *path_size : 0); + if (!path_in || !path_out || !path_size || *path_size < 260) + return E_INVALIDARG; + + wcscpy(path_out, path_in); + return S_OK; +} + BOOL WINAPI SetupQueryInfVersionInformationA(SP_INF_INFORMATION *info, UINT index, const char *key, char *buff, DWORD size, DWORD *req_size) { diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 7578fb25c9c..f80d389daac 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -208,6 +208,7 @@ @ stub DelimStringToMultiSz @ stub DestroyTextFileReadBuffer @ stdcall DoesUserHavePrivilege(wstr) +@ stdcall DriverStoreFindDriverPackageW(ptr ptr ptr long ptr ptr ptr) @ stdcall DuplicateString(wstr) @ stdcall EnablePrivilege(wstr long) @ stub ExtensionPropSheetPageProc diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c index 6258727c076..88be66e1a69 100644 --- a/dlls/setupapi/tests/query.c +++ b/dlls/setupapi/tests/query.c @@ -513,6 +513,72 @@ static void test_SetupGetTargetPath(void) DeleteFileA(inf_filename); }
+static void test_DriverStoreFindDriverPackageW(void) +{ + HMODULE library; + HRESULT result; + WCHAR buffer[500]; + DWORD len; + HRESULT (WINAPI *pDriverStoreFindDriverPackageW)(const WCHAR*, void*, void*, DWORD, void*, WCHAR*, DWORD*); + + library = LoadLibraryA("setupapi.dll"); + ok(library != NULL, "Failed to load setupapi.dll\n"); + if (!library) return; + + pDriverStoreFindDriverPackageW = (void *)GetProcAddress(library, "DriverStoreFindDriverPackageW"); + if (!pDriverStoreFindDriverPackageW) + { + win_skip("Can't find DriverStoreFindDriverPackageW\n"); + return; + } + + len = 500; + + /* No invalid parameters, with flags */ + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 9, 0, buffer, &len); + todo_wine + ok(result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Got %lx\n", result); + + /* No invalid parameters, no flags */ + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 0, 0, buffer, &len); + if (sizeof(void *) == 4) + todo_wine + ok(result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Got %lx\n", result); + else + todo_wine + ok(result == E_INVALIDARG, "Got %lx\n", result); /* Win64 needs flags 0x9, or it gives invalid parameter */ + + /* Invalid parameter tests */ + + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 9, 0, 0, &len); + ok(result == E_INVALIDARG, "Got %lx\n", result); + + result = pDriverStoreFindDriverPackageW(0, 0, 0, 9, 0, buffer, &len); + ok(result == E_INVALIDARG, "Got %lx\n", result); + + result = pDriverStoreFindDriverPackageW(L"", 0, 0, 9, 0, buffer, &len); + todo_wine + ok(result == 0x8007007b || result == E_INVALIDARG, "Got %lx\n", result); /* Win7 and Win10 have different results */ + + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 9, 0, buffer, 0); + ok(result == E_INVALIDARG, "Got %lx\n", result); + + /* Tests with different length parameter */ + + len = 0; + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 9, 0, buffer, &len); + ok(result == E_INVALIDARG, "Got %lx\n", result); + + len = 259; + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 9, 0, buffer, &len); + ok(result == E_INVALIDARG, "Got %lx\n", result); + + len = 260; + result = pDriverStoreFindDriverPackageW(L"c:\nonexistant.inf", 0, 0, 9, 0, buffer, &len); + todo_wine + ok(result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Got %lx\n", result); +} + START_TEST(query) { get_directories(); @@ -521,4 +587,5 @@ START_TEST(query) test_SetupGetSourceFileLocation(); test_SetupGetSourceInfo(); test_SetupGetTargetPath(); + test_DriverStoreFindDriverPackageW(); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139865
Your paranoid android.
=== w7pro64 (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w864 (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w1064v1507 (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w1064v1809 (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w1064_2qxl (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w1064_adm (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w1064_tsign (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w10pro64 (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w10pro64_ar (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w10pro64_ja (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w10pro64_zh_CN (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
=== w11pro64_amd (64 bit report) ===
setupapi: query.c:549: Test failed: Got 80070002
On Thu Nov 9 04:51:29 2023 +0000, Alex Henrie wrote:
There should probably be a couple of tests that call this function and check for E_INVALIDARG. The tests would show that we have at least a vague idea of what the parameters do, and they would prove that calling the function with the cleanly-reverse-engineered signature does not crash. I suspect that DriverStoreFindDriverPackageW also returns E_INVALIDARG when *path_in or *path_size is 0, so I think it would be a good idea to check that too.
I added a bunch of tests. Please keep in mind that I can't reasonable test success, since I don't know how to make it succeed on Windows. That's also why I just made the "semi successful" tests `todo_wine`, since I can't distinguish between parameters that give 0x80070002 and success.