From: Paul Gofman pgofman@codeweavers.com
--- dlls/cfgmgr32/cfgmgr32.spec | 4 +- dlls/cfgmgr32/tests/cfgmgr32.c | 43 ++++++++++++++++ dlls/setupapi/devinst.c | 90 ++++++++++++++++++++++++++++++++++ dlls/setupapi/setupapi.spec | 4 +- dlls/setupapi/stubs.c | 22 --------- 5 files changed, 137 insertions(+), 26 deletions(-)
diff --git a/dlls/cfgmgr32/cfgmgr32.spec b/dlls/cfgmgr32/cfgmgr32.spec index 955482a5ec8..a990b2538eb 100644 --- a/dlls/cfgmgr32/cfgmgr32.spec +++ b/dlls/cfgmgr32/cfgmgr32.spec @@ -71,11 +71,11 @@ @ stdcall CM_Get_Device_ID_ExW(ptr ptr long long ptr) setupapi.CM_Get_Device_ID_ExW @ stdcall CM_Get_Device_ID_ListA(str ptr long long) setupapi.CM_Get_Device_ID_ListA @ stdcall CM_Get_Device_ID_ListW(wstr ptr long long) setupapi.CM_Get_Device_ID_ListW -@ stub CM_Get_Device_ID_List_ExA +@ stdcall CM_Get_Device_ID_List_ExA(str ptr long long ptr) setupapi.CM_Get_Device_ID_List_ExA @ stdcall CM_Get_Device_ID_List_ExW(wstr ptr long long) setupapi.CM_Get_Device_ID_List_ExW @ stdcall CM_Get_Device_ID_List_SizeA(ptr str long) setupapi.CM_Get_Device_ID_List_SizeA @ stdcall CM_Get_Device_ID_List_SizeW(ptr wstr long) setupapi.CM_Get_Device_ID_List_SizeW -@ stub CM_Get_Device_ID_List_Size_ExA +@ stdcall CM_Get_Device_ID_List_Size_ExA(ptr str long ptr) setupapi.CM_Get_Device_ID_List_Size_ExA @ stdcall CM_Get_Device_ID_List_Size_ExW(ptr wstr long ptr) setupapi.CM_Get_Device_ID_List_Size_ExW @ stdcall CM_Get_Device_ID_Size(ptr ptr long) setupapi.CM_Get_Device_ID_Size @ stub CM_Get_Device_ID_Size_Ex diff --git a/dlls/cfgmgr32/tests/cfgmgr32.c b/dlls/cfgmgr32/tests/cfgmgr32.c index da9796e019c..d6c27fab539 100644 --- a/dlls/cfgmgr32/tests/cfgmgr32.c +++ b/dlls/cfgmgr32/tests/cfgmgr32.c @@ -118,12 +118,16 @@ static void test_CM_MapCrToWin32Err(void) static void test_CM_Get_Device_ID_List(void) { WCHAR wguid_str[64], *wbuf, *wp; + char guid_str[64], *buf, *p; unsigned int count; CONFIGRET ret; ULONG len;
StringFromGUID2(&GUID_DEVCLASS_DISPLAY, wguid_str, ARRAY_SIZE(wguid_str)); wp = wguid_str; + p = guid_str; + while ((*p++ = *wp++)) + ;
ret = CM_Get_Device_ID_List_SizeW(NULL, wguid_str, CM_GETIDLIST_FILTER_CLASS); ok(ret == CR_INVALID_POINTER, "got %#lx.\n", ret); @@ -136,12 +140,24 @@ static void test_CM_Get_Device_ID_List(void) ok(ret == CR_INVALID_DATA, "got %#lx.\n", ret); ok(!len, "got %#lx.\n", len);
+ ret = CM_Get_Device_ID_List_SizeA(NULL, guid_str, CM_GETIDLIST_FILTER_CLASS); + ok(ret == CR_INVALID_POINTER, "got %#lx.\n", ret); + len = 0xdeadbeef; + ret = CM_Get_Device_ID_List_SizeA(&len, NULL, CM_GETIDLIST_FILTER_CLASS); + ok(ret == CR_INVALID_POINTER, "got %#lx.\n", ret); + ok(!len, "got %#lx.\n", len); + len = 0xdeadbeef; + ret = CM_Get_Device_ID_List_SizeA(&len, "q", CM_GETIDLIST_FILTER_CLASS); + ok(ret == CR_INVALID_DATA, "got %#lx.\n", ret); + ok(!len, "got %#lx.\n", len); + len = 0xdeadbeef; ret = CM_Get_Device_ID_List_SizeW(&len, NULL, 0); ok(!ret, "got %#lx.\n", ret); ok(len > 2, "got %#lx.\n", len);
wbuf = malloc(len * sizeof(*wbuf)); + buf = malloc(len);
ret = CM_Get_Device_ID_ListW(NULL, wbuf, len, 0); ok(!ret, "got %#lx.\n", ret); @@ -159,6 +175,19 @@ static void test_CM_Get_Device_ID_List(void) ok(ret == CR_BUFFER_SMALL, "got %#lx.\n", ret); ok(!wbuf[0], "got %#x.\n", wbuf[0]);
+ len = 0xdeadbeef; + ret = CM_Get_Device_ID_List_SizeA(&len, guid_str, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT); + ok(!ret, "got %#lx.\n", ret); + ok(len > 2, "got %lu.\n", len); + memset(buf, 0x7c, len); + ret = CM_Get_Device_ID_ListA(guid_str, buf, 0, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT); + ok(ret == CR_INVALID_POINTER, "got %#lx.\n", ret); + ok(buf[0] == 0x7c, "got %#x.\n", buf[0]); + memset(buf, 0x7c, len); + ret = CM_Get_Device_ID_ListA(guid_str, buf, 1, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT); + ok(ret == CR_BUFFER_SMALL, "got %#lx.\n", ret); + ok(buf[0] == 0x7c, "got %#x.\n", buf[0]); + memset(wbuf, 0xcc, len * sizeof(*wbuf)); ret = CM_Get_Device_ID_ListW(wguid_str, wbuf, len, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT); ok(!ret, "got %#lx.\n", ret); @@ -172,7 +201,21 @@ static void test_CM_Get_Device_ID_List(void) } ok(count, "got 0.\n");
+ memset(buf, 0xcc, len * sizeof(*buf)); + ret = CM_Get_Device_ID_ListA(guid_str, buf, len, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT); + ok(!ret, "got %#lx.\n", ret); + count = 0; + p = buf; + while (*p) + { + ++count; + ok(!strnicmp(p, "PCI\", 4) || !strnicmp(p, "VMBUS\", 6), "got %s.\n", debugstr_a(p)); + p += strlen(p) + 1; + } + ok(count, "got 0.\n"); + free(wbuf); + free(buf); }
START_TEST(cfgmgr32) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 4de7d5c9b14..139f167a2f2 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4403,6 +4403,96 @@ CONFIGRET WINAPI CM_Get_Device_ID_List_SizeW(ULONG *len, const WCHAR *filter, UL return get_device_id_list(filter, NULL, len, flags); }
+/*********************************************************************** + * CM_Get_Device_ID_List_ExA (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Get_Device_ID_List_ExA(const char *filter, char *buffer, ULONG len, ULONG flags, HMACHINE machine) +{ + WCHAR *wbuffer, *wfilter = NULL, *p; + unsigned int slen; + CONFIGRET ret; + + TRACE("%s %p %ld %#lx.\n", debugstr_a(filter), buffer, len, flags); + + if (machine) + FIXME("machine %p.\n", machine); + + if (!buffer || !len) + return CR_INVALID_POINTER; + + if (!(wbuffer = malloc(len * sizeof(*wbuffer)))) + return CR_OUT_OF_MEMORY; + + if (filter) + { + slen = strlen(filter) + 1; + if (!(wfilter = malloc(slen * sizeof(*wfilter)))) + { + free(wbuffer); + return CR_OUT_OF_MEMORY; + } + MultiByteToWideChar(CP_ACP, 0, filter, slen, wfilter, slen); + } + + if (!(ret = CM_Get_Device_ID_ListW(wfilter, wbuffer, len, flags))) + { + p = wbuffer; + while (*p) + { + slen = wcslen(p) + 1; + WideCharToMultiByte(CP_ACP, 0, p, slen, buffer, slen, NULL, NULL); + p += slen; + buffer += slen; + } + *buffer = 0; + } + free(wfilter); + free(wbuffer); + return ret; +} + +/*********************************************************************** + * CM_Get_Device_ID_ListA (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Get_Device_ID_ListA(const char *filter, char *buffer, ULONG len, ULONG flags) +{ + return CM_Get_Device_ID_List_ExA(filter, buffer, len, flags, NULL); +} + +/*********************************************************************** + * CM_Get_Device_ID_List_Size_ExA (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExA(ULONG *len, const char *filter, ULONG flags, HMACHINE machine) +{ + WCHAR *wfilter = NULL; + unsigned int slen; + CONFIGRET ret; + + TRACE("%p %s %#lx.\n", len, debugstr_a(filter), flags); + + if (machine) + FIXME("machine %p.\n", machine); + + if (filter) + { + slen = strlen(filter) + 1; + if (!(wfilter = malloc(slen * sizeof(*wfilter)))) + return CR_OUT_OF_MEMORY; + MultiByteToWideChar(CP_ACP, 0, filter, slen, wfilter, slen); + } + ret = CM_Get_Device_ID_List_SizeW(len, wfilter, flags); + free(wfilter); + return ret; +} + +/*********************************************************************** + * CM_Get_Device_ID_List_SizeA (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA(ULONG *len, const char *filter, ULONG flags) +{ + return CM_Get_Device_ID_List_Size_ExA(len, filter, flags, NULL); +} + /*********************************************************************** * SetupDiGetINFClassA (SETUPAPI.@) */ diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 088466ce537..f77cb301dfe 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -81,11 +81,11 @@ @ stdcall CM_Get_Device_ID_ExW(ptr ptr long long ptr) @ stdcall CM_Get_Device_ID_ListA(str ptr long long) @ stdcall CM_Get_Device_ID_ListW(wstr ptr long long) -@ stub CM_Get_Device_ID_List_ExA +@ stdcall CM_Get_Device_ID_List_ExA(str ptr long long ptr) @ stdcall CM_Get_Device_ID_List_ExW(wstr ptr long long ptr) @ stdcall CM_Get_Device_ID_List_SizeA(ptr str long) @ stdcall CM_Get_Device_ID_List_SizeW(ptr wstr long) -@ stub CM_Get_Device_ID_List_Size_ExA +@ stdcall CM_Get_Device_ID_List_Size_ExA(ptr str long ptr) @ stdcall CM_Get_Device_ID_List_Size_ExW(ptr wstr long ptr) @ stdcall CM_Get_Device_ID_Size(ptr ptr long) @ stub CM_Get_Device_ID_Size_Ex diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index f031afb48e3..419168d0f1e 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -130,28 +130,6 @@ DWORD WINAPI CM_Get_Device_ID_ExW( return CR_SUCCESS; }
-/*********************************************************************** - * CM_Get_Device_ID_ListA (SETUPAPI.@) - */ -CONFIGRET WINAPI CM_Get_Device_ID_ListA( - PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags ) -{ - FIXME("%s %p %ld 0x%08lx: stub\n", debugstr_a(pszFilter), Buffer, BufferLen, ulFlags); - - if (BufferLen >= 2) Buffer[0] = Buffer[1] = 0; - return CR_SUCCESS; -} - -/*********************************************************************** - * CM_Get_Device_ID_List_SizeA (SETUPAPI.@) - */ -CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA( PULONG pulLen, PCSTR pszFilter, ULONG ulFlags ) -{ - FIXME("%p %s 0x%08lx: stub\n", pulLen, debugstr_a(pszFilter), ulFlags); - - return CR_SUCCESS; -} - /*********************************************************************** * CM_Get_Parent (SETUPAPI.@) */