Index: reactos/dll/win32/setupapi/query.c =================================================================== --- reactos/dll/win32/setupapi/query.c (revision 71153) +++ reactos/dll/win32/setupapi/query.c (working copy) @@ -282,6 +282,19 @@ } /*********************************************************************** + * SetupQueryInfVersionInformationA (SETUPAPI.@) + */ + +BOOL WINAPI SetupQueryInfVersionInformationA( PSP_INF_INFORMATION info, UINT index, + PCSTR key, PSTR buffer, DWORD buffer_size, + PDWORD required_size ) +{ + TRACE("%p, %u, %s, %p, %u, %u\n", info, index, debugstr_a(key), buffer, + buffer_size, required_size); + return FALSE; +} + +/*********************************************************************** * SetupGetSourceFileLocationA (SETUPAPI.@) */ Index: reactos/dll/win32/setupapi/setupapi.spec =================================================================== --- reactos/dll/win32/setupapi/setupapi.spec (revision 71153) +++ reactos/dll/win32/setupapi/setupapi.spec (working copy) @@ -476,7 +476,7 @@ @ stdcall SetupQueryInfFileInformationW(ptr long wstr long ptr) @ stdcall SetupQueryInfOriginalFileInformationA(ptr long ptr ptr) @ stdcall SetupQueryInfOriginalFileInformationW(ptr long ptr ptr) -@ stub SetupQueryInfVersionInformationA +@ stdcall SetupQueryInfVersionInformationA(ptr long str str long ptr) @ stub SetupQueryInfVersionInformationW @ stub SetupQuerySourceListA @ stub SetupQuerySourceListW Index: rostests/winetests/setupapi/query.c =================================================================== --- rostests/winetests/setupapi/query.c (revision 71153) +++ rostests/winetests/setupapi/query.c (working copy) @@ -99,6 +99,16 @@ "[CopyAlways.Windir.Files]\n" "WindowsCodecs.dll\n"; +static const char inf_data7[] = + "[Version]\n" + "Signature = \"$Windows NT$\"\n" + "Class = Mouse\n" + "DriverVer = 12/05/2007,2.0.0.0\n" + "Provider = \"Microsoft\"\n" + "[CopyAlways.Windir.Files]\n" + "WindowsCodecs.dll\n"; + + static void create_inf_file(LPSTR filename, const char *data, DWORD size) { DWORD dwNumberOfBytesWritten; @@ -504,6 +514,169 @@ DeleteFileA(inf_filename); } +#define INIT_QRY_X(INFDATA, TESTDATA) { INFDATA, sizeof(INFDATA)-1, TESTDATA, sizeof(TESTDATA) } +#define NULCHR "\0" + +static struct { + const char* inf_data; + size_t inf_size; + const char* test_data; + size_t test_size; +} query_test[] = { + INIT_QRY_X(inf_data1, "Signature" NULCHR "$Chicago$" NULCHR "AdvancedINF" NULCHR "2.5" NULCHR), + INIT_QRY_X(inf_data3, "Signature" NULCHR "$Windows NT$" NULCHR), + INIT_QRY_X(inf_data4, "Signature" NULCHR "$Windows NT$" NULCHR), + INIT_QRY_X(inf_data5, "Signature" NULCHR "$Windows NT$" NULCHR), + INIT_QRY_X(inf_data6, "Signature" NULCHR "$Windows NT$" NULCHR), + INIT_QRY_X(inf_data7, "Signature" NULCHR "$Windows NT$" NULCHR "Class" NULCHR "Mouse" NULCHR "DriverVer" + NULCHR "12/05/2007" NULCHR "Provider" NULCHR "Microsoft" NULCHR), + { NULL, 0, NULL, 0 } +}; + +#undef INIT_QRY_X +#undef NULCHR + +const char *wine_dbgstr_an( const char *str, int n ) +{ + static const char hex[17] = "0123456789abcdef"; + static char buf[2][200]; + static int idx = 1; + char *dst, *res; + size_t size; + + idx ^= 1; + + if (!((ULONG_PTR)str >> 16)) + { + if (!str) return "(null)"; + res = buf[idx]; + sprintf( res, "#%04x", LOWORD(str) ); + return res; + } + if (n == -1) n = strlen(str); + if (n < 0) n = 0; + size = 10 + min( 300, n * 4 ); + dst = res = buf[idx]; + *dst++ = '"'; + while (n-- > 0 && dst <= res + size - 9) + { + unsigned char c = *str++; + switch (c) + { + case '\n': *dst++ = '\\'; *dst++ = 'n'; break; + case '\r': *dst++ = '\\'; *dst++ = 'r'; break; + case '\t': *dst++ = '\\'; *dst++ = 't'; break; + case '"': *dst++ = '\\'; *dst++ = '"'; break; + case '\\': *dst++ = '\\'; *dst++ = '\\'; break; + default: + if (c >= ' ' && c <= 126) + *dst++ = c; + else + { + *dst++ = '\\'; + *dst++ = 'x'; + *dst++ = hex[(c >> 4) & 0x0f]; + *dst++ = hex[c & 0x0f]; + } + } + } + *dst++ = '"'; + if (n > 0) + { + *dst++ = '.'; + *dst++ = '.'; + *dst++ = '.'; + } + *dst++ = 0; + //release_temp_buffer( res, dst - res ); + return res; +} + +static void SetupQueryInf_one(PSP_INF_INFORMATION info, const char* input, const char* expected_data, size_t expected_size, int test_num) +{ + char* data; + DWORD size, size2; + BOOL ret; + + size = 0; + ret = SetupQueryInfVersionInformationA(info, 0, input, NULL, 0, &size); + ok(ret == TRUE, "Expected SetupQueryInfVersionInformation to succeed (%d:%s)\n", test_num, input); + ok(size == expected_size, "Expected size %u, got: %u (%d:%s)\n", expected_size, size, test_num, input); + + if (ret && size == expected_size) + { + data = HeapAlloc(GetProcessHeap(), 0, size + 1); + memset(data, 0xcb, size + 1); + size2 = 0xdeadbeef; + ret = SetupQueryInfVersionInformationA(info, 0, input, data, size, &size2); + ok(ret == TRUE, "Expected SetupQueryInfVersionInformation to succeed (%d:%s)\n", test_num, input); + ok(size == size2, "Expected sizes to equal, was: %u:%u (%d:%s)\n", size, size2, test_num, input); + ok(!memcmp(data, expected_data, expected_size), "Expected data to be %s, was: %s (%d:%s)\n", + wine_dbgstr_an(expected_data, expected_size), wine_dbgstr_an(data, size2), test_num, input); + + HeapFree(GetProcessHeap(), 0, data); + } +} + + + +static void test_SetupQueryInf(void) +{ + char inf_filename[MAX_PATH]; + const char *name, *value; + int test_num; + HINF hinf; + PSP_INF_INFORMATION info; + DWORD size, err; + BOOL ret; + + lstrcpyA(inf_filename, CURR_DIR); + lstrcatA(inf_filename, "\\test.inf"); + + for (test_num = 0; query_test[test_num].inf_data; ++test_num) + { + create_inf_file(inf_filename, query_test[test_num].inf_data, query_test[test_num].inf_size); + + hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL); + ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file (%d)\n", test_num); + info = alloc_inf_info(hinf, INFINFO_INF_SPEC_IS_HINF, &size); + ret = SetupGetInfInformationA(hinf, INFINFO_INF_SPEC_IS_HINF, info, size, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed (%d)\n", test_num); + ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal (%d)\n", test_num); + + if (info) + { + ok(info->InfCount == 1, "Expected InfoCount to be 1, was: %u (%d)\n", info->InfCount, test_num); + + size = 0xdeadbeef; + ret = SetupQueryInfVersionInformationA(info, 1, NULL, NULL, 0, &size); + err = GetLastError(); + ok(ret == FALSE, "Expected SetupQueryInfVersionInformation to fail (%d)\n", test_num); + ok(err == ERROR_NO_MORE_ITEMS, "Expected LastError to be %u, was %u (%d)\n", ERROR_NO_MORE_ITEMS, err, test_num); + ok(size == 0xdeadbeef, "Expected size not to change, was: %u (%d)\n", size, test_num); + + SetupQueryInf_one(info, NULL, query_test[test_num].test_data, query_test[test_num].test_size, test_num); + + name = query_test[test_num].test_data; + while (name && *name) + { + value = name + strlen(name) + 1; + if (!*value) + break; + + SetupQueryInf_one(info, name, value, strlen(value) + 1, test_num); + name = value + strlen(value) + 1; + } + + HeapFree(GetProcessHeap(), 0, info); + } + SetupCloseInfFile(hinf); + DeleteFileA(inf_filename); + } +} + + + START_TEST(query) { get_directories(); @@ -512,4 +685,5 @@ test_SetupGetSourceFileLocation(); test_SetupGetSourceInfo(); test_SetupGetTargetPath(); + test_SetupQueryInf(); }