Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 43b86c7dd0..a5e875d8e6 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1798,18 +1798,37 @@ BOOL WINAPI SetupDiGetDeviceInstanceIdW(HDEVINFO devinfo, SP_DEVINFO_DATA *devic }
/*********************************************************************** - * SetupDiGetActualSectionToInstallA (SETUPAPI.@) + * SetupDiGetActualSectionToInstallA (SETUPAPI.@) */ -BOOL WINAPI SetupDiGetActualSectionToInstallA( - HINF InfHandle, - PCSTR InfSectionName, - PSTR InfSectionWithExt, - DWORD InfSectionWithExtSize, - PDWORD RequiredSize, - PSTR *Extension) +BOOL WINAPI SetupDiGetActualSectionToInstallA(HINF hinf, const char *section, + char *section_ext, DWORD size, DWORD *needed, char **extptr) { - FIXME("\n"); - return FALSE; + WCHAR sectionW[LINE_LEN], section_extW[LINE_LEN], *extptrW; + BOOL ret; + + MultiByteToWideChar(CP_ACP, 0, section, -1, sectionW, ARRAY_SIZE(sectionW)); + + ret = SetupDiGetActualSectionToInstallW(hinf, sectionW, section_extW, + ARRAY_SIZE(section_extW), NULL, &extptrW); + if (ret) + { + if (needed) + *needed = WideCharToMultiByte(CP_ACP, 0, section_extW, -1, NULL, 0, NULL, NULL); + + if (section_ext) + ret = !!WideCharToMultiByte(CP_ACP, 0, section_extW, -1, section_ext, size, NULL, NULL); + + if (extptr) + { + if (extptrW) + *extptr = section_ext + WideCharToMultiByte(CP_ACP, 0, section_extW, + extptrW - section_extW, NULL, 0, NULL, NULL); + else + *extptr = NULL; + } + } + + return ret; }
/***********************************************************************
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index a5e875d8e6..12e92e1ef8 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -55,7 +55,15 @@ static const WCHAR NoDisplayClass[] = {'N','o','D','i','s','p','l','a','y','C', static const WCHAR NoInstallClass[] = {'N','o','I','n','s','t','a','l','l','C','l','a','s','s',0}; static const WCHAR NoUseClass[] = {'N','o','U','s','e','C','l','a','s','s',0}; static const WCHAR NtExtension[] = {'.','N','T',0}; +#ifdef __i386__ static const WCHAR NtPlatformExtension[] = {'.','N','T','x','8','6',0}; +#elif defined(__x86_64__) +static const WCHAR NtPlatformExtension[] = {'.','N','T','a','m','d','6','4',0}; +#elif defined(__arm__) +static const WCHAR NtPlatformExtension[] = {'.','N','T','a','r','m',0}; +#elif defined(__aarch64__) +static const WCHAR NtPlatformExtension[] = {'.','N','T','a','r','m','6','4',0}; +#endif static const WCHAR Signature[] = {'S','i','g','n','a','t','u','r','e',0}; static const WCHAR Version[] = {'V','e','r','s','i','o','n',0}; static const WCHAR WinExtension[] = {'.','W','i','n',0};
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 203 ++++++++++++++++++++++++++++++---- 1 file changed, 182 insertions(+), 21 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 46715512ee..88d4748aaf 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -41,6 +41,19 @@ static GUID guid2 = {0x6a55b5a5, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c, BOOL (WINAPI *pSetupDiSetDevicePropertyW)(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE, const BYTE *, DWORD, DWORD); BOOL (WINAPI *pSetupDiGetDevicePropertyW)(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE *, BYTE *, DWORD, DWORD *, DWORD);
+static void create_file(const char *name, const char *data) +{ + HANDLE file; + DWORD size; + BOOL ret; + + file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "Failed to create %s, error %u.\n", name, GetLastError()); + ret = WriteFile(file, data, strlen(data), &size, NULL); + ok(ret && size == strlen(data), "Failed to write %s, error %u.\n", name, GetLastError()); + CloseHandle(file); +} + static void test_create_device_list_ex(void) { static const WCHAR machine[] = { 'd','u','m','m','y',0 }; @@ -103,26 +116,6 @@ todo_wine RegCloseKey(root_key); }
-static void create_inf_file(LPCSTR filename) -{ - DWORD dwNumberOfBytesWritten; - HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - static const char data[] = - "[Version]\n" - "Signature="$Chicago$"\n" - "Class=Bogus\n" - "ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}\n" - "[ClassInstall32]\n" - "AddReg=BogusClass.NT.AddReg\n" - "[BogusClass.NT.AddReg]\n" - "HKR,,,,"Wine test devices"\n"; - - WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL); - CloseHandle(hf); -} - static void get_temp_filename(LPSTR path) { static char curr[MAX_PATH] = { 0 }; @@ -148,10 +141,20 @@ static void test_install_class(void) char tmpfile[MAX_PATH]; BOOL ret;
+ static const char inf_data[] = + "[Version]\n" + "Signature="$Chicago$"\n" + "Class=Bogus\n" + "ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}\n" + "[ClassInstall32]\n" + "AddReg=BogusClass.NT.AddReg\n" + "[BogusClass.NT.AddReg]\n" + "HKR,,,,"Wine test devices"\n"; + tmpfile[0] = '.'; tmpfile[1] = '\'; get_temp_filename(tmpfile + 2); - create_inf_file(tmpfile + 2); + create_file(tmpfile + 2, inf_data);
ret = SetupDiInstallClassA(NULL, NULL, 0, NULL); ok(!ret, "Expected failure.\n"); @@ -1960,10 +1963,168 @@ static void test_device_install_params(void) SetupDiDestroyDeviceInfoList(set); }
+#ifdef __i386__ +#define MYEXT "x86" +#define WOWEXT "AMD64" +#define WRONGEXT "ARM" +#elif defined(__x86_64__) +#define MYEXT "AMD64" +#define WOWEXT "x86" +#define WRONGEXT "ARM64" +#elif defined(__arm__) +#define MYEXT "ARM" +#define WOWEXT "ARM64" +#define WRONGEXT "x86" +#elif defined(__aarch64__) +#define MYEXT "ARM64" +#define WOWEXT "ARM" +#define WRONGEXT "AMD64" +#else +#define MYEXT +#define WOWEXT +#define WRONGEXT +#endif + +static void test_get_actual_section(void) +{ + static const char inf_data[] = "[Version]\n" + "Signature="$Chicago$"\n" + "[section1]\n" + "[section2]\n" + "[section2.nt]\n" + "[section3]\n" + "[section3.nt" MYEXT "]\n" + "[section4]\n" + "[section4.nt]\n" + "[section4.nt" MYEXT "]\n" + "[section5.nt]\n" + "[section6.nt" MYEXT "]\n" + "[section7]\n" + "[section7.nt" WRONGEXT "]\n" + "[section8.nt" WRONGEXT "]\n" + "[section9.nt" MYEXT "]\n" + "[section9.nt" WOWEXT "]\n" + "[section10.nt" WOWEXT "]\n"; + + char inf_path[MAX_PATH], section[LINE_LEN], *extptr; + DWORD size; + HINF hinf; + BOOL ret; + + GetTempPathA(sizeof(inf_path), inf_path); + strcat(inf_path, "setupapi_test.inf"); + create_file(inf_path, inf_data); + + hinf = SetupOpenInfFileA(inf_path, NULL, INF_STYLE_WIN4, NULL); + ok(hinf != INVALID_HANDLE_VALUE, "Failed to open INF file, error %#x.\n", GetLastError()); + + ret = SetupDiGetActualSectionToInstallA(hinf, "section1", section, ARRAY_SIZE(section), NULL, NULL); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcmp(section, "section1"), "Got unexpected section %s.\n", section); + + size = 0xdeadbeef; + ret = SetupDiGetActualSectionToInstallA(hinf, "section1", NULL, 5, &size, NULL); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(size == 9, "Got size %u.\n", size); + + SetLastError(0xdeadbeef); + size = 0xdeadbeef; + ret = SetupDiGetActualSectionToInstallA(hinf, "section1", section, 5, &size, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + ok(size == 9, "Got size %u.\n", size); + + SetLastError(0xdeadbeef); + ret = SetupDiGetActualSectionToInstallA(hinf, "section1", section, ARRAY_SIZE(section), &size, NULL); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section1"), "Got unexpected section %s.\n", section); + ok(size == 9, "Got size %u.\n", size); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section1", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section1"), "Got unexpected section %s.\n", section); + ok(!extptr || !*extptr /* Windows 10 1809 */, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section2", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section2.NT"), "Got unexpected section %s.\n", section); + ok(extptr == section + 8, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section3", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section3.NT" MYEXT), "Got unexpected section %s.\n", section); + ok(extptr == section + 8, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section4", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section4.NT" MYEXT), "Got unexpected section %s.\n", section); + ok(extptr == section + 8, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section5", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section5.NT"), "Got unexpected section %s.\n", section); + ok(extptr == section + 8, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section6", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section6.NT" MYEXT), "Got unexpected section %s.\n", section); + ok(extptr == section + 8, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section7", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section7"), "Got unexpected section %s.\n", section); + ok(!extptr || !*extptr /* Windows 10 1809 */, "Got extension %s.\n", extptr); + +todo_wine { + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section8", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section8"), "Got unexpected section %s.\n", section); + ok(!extptr || !*extptr /* Windows 10 1809 */, "Got extension %s.\n", extptr); + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "nonexistent", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "nonexistent"), "Got unexpected section %s.\n", section); + ok(!extptr || !*extptr /* Windows 10 1809 */, "Got extension %s.\n", extptr); +} + + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section9", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section9.NT" MYEXT), "Got unexpected section %s.\n", section); + ok(extptr == section + 8, "Got extension %s.\n", extptr); + +todo_wine { + if (0) + { + /* For some reason, this call hangs on Windows 10 1809. */ + extptr = section; + ret = SetupDiGetActualSectionToInstallA(hinf, "section10", section, ARRAY_SIZE(section), NULL, &extptr); + ok(ret, "Failed to get section, error %#x.\n", GetLastError()); + ok(!strcasecmp(section, "section10"), "Got unexpected section %s.\n", section); + ok(!extptr, "Got extension %s.\n", extptr); + } +} + + SetupCloseInfFile(hinf); + ret = DeleteFileA(inf_path); + ok(ret, "Failed to delete %s, error %u.\n", inf_path, GetLastError()); +} + START_TEST(devinst) { HKEY hkey;
+ test_get_actual_section(); + if ((hkey = SetupDiOpenClassRegKey(NULL, KEY_ALL_ACCESS)) == INVALID_HANDLE_VALUE) { skip("needs admin rights\n");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 12 +----------- dlls/setupapi/tests/devinst.c | 4 ---- 2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 12e92e1ef8..78f6559152 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1879,17 +1879,7 @@ BOOL WINAPI SetupDiGetActualSectionToInstallW( }
if (lLineCount == -1) - { - /* Test section name without extension */ - szBuffer[dwLength] = 0; - lLineCount = SetupGetLineCountW(InfHandle, szBuffer); - } - - if (lLineCount == -1) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + szBuffer[dwLength] = 0;
dwFullLength = lstrlenW(szBuffer);
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 88d4748aaf..d2a32fc623 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2082,7 +2082,6 @@ static void test_get_actual_section(void) ok(!strcasecmp(section, "section7"), "Got unexpected section %s.\n", section); ok(!extptr || !*extptr /* Windows 10 1809 */, "Got extension %s.\n", extptr);
-todo_wine { extptr = section; ret = SetupDiGetActualSectionToInstallA(hinf, "section8", section, ARRAY_SIZE(section), NULL, &extptr); ok(ret, "Failed to get section, error %#x.\n", GetLastError()); @@ -2094,7 +2093,6 @@ todo_wine { ok(ret, "Failed to get section, error %#x.\n", GetLastError()); ok(!strcasecmp(section, "nonexistent"), "Got unexpected section %s.\n", section); ok(!extptr || !*extptr /* Windows 10 1809 */, "Got extension %s.\n", extptr); -}
extptr = section; ret = SetupDiGetActualSectionToInstallA(hinf, "section9", section, ARRAY_SIZE(section), NULL, &extptr); @@ -2102,7 +2100,6 @@ todo_wine { ok(!strcasecmp(section, "section9.NT" MYEXT), "Got unexpected section %s.\n", section); ok(extptr == section + 8, "Got extension %s.\n", extptr);
-todo_wine { if (0) { /* For some reason, this call hangs on Windows 10 1809. */ @@ -2112,7 +2109,6 @@ todo_wine { ok(!strcasecmp(section, "section10"), "Got unexpected section %s.\n", section); ok(!extptr, "Got extension %s.\n", extptr); } -}
SetupCloseInfFile(hinf); ret = DeleteFileA(inf_path);