Wine-devel
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
April 2021
- 70 participants
- 697 discussions
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d8/tests/visual.c | 88 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index fc8a05a3c40..f25549388d0 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -11070,6 +11070,93 @@ static void test_desktop_window(void)
IDirect3D8_Release(d3d);
}
+static void test_sample_mask(void)
+{
+ IDirect3DSurface8 *rt, *ms_rt;
+ struct surface_readback rb;
+ IDirect3DDevice8 *device;
+ IDirect3D8 *d3d;
+ ULONG refcount;
+ DWORD colour;
+ HWND window;
+ HRESULT hr;
+
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f, 0.1f}, 0xffffffff},
+ {{-1.0f, 1.0f, 0.1f}, 0xffffffff},
+ {{ 1.0f, -1.0f, 0.1f}, 0xffffffff},
+ {{ 1.0f, 1.0f, 0.1f}, 0xffffffff},
+ };
+
+ window = create_window();
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+
+ if (FAILED(IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES)))
+ {
+ skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n");
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a 3D device.\n");
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128,
+ D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, FALSE, &ms_rt);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetRenderTarget(device, ms_rt, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEMASK, 0x5);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ get_rt_readback(rt, &rb);
+ colour = get_readback_color(&rb, 64, 64);
+ ok(color_match(colour, 0xffff8080, 1), "Got unexpected colour %08x.\n", colour);
+ release_surface_readback(&rb);
+
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ IDirect3DSurface8_Release(ms_rt);
+ IDirect3DSurface8_Release(rt);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER8 identifier;
@@ -11147,4 +11234,5 @@ START_TEST(visual)
test_sysmem_draw();
test_alphatest();
test_desktop_window();
+ test_sample_mask();
}
--
2.30.2
2
9
28 Apr '21
sock.c is huge. This doesn't bother some people, but I find that it can be
harder to navigate and slower to compile. Splitting it is tricky, but I think
there's a pretty natural divide between functions that operate on sockets
(e.g. bind, listen, recv, getsockname) and functions that don't (e.g.
get*info, inet_*, get*by*, WSC*).
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/ws2_32/tests/protocol.c | 809 ++++++++++++++++++++++++++++++++++-
dlls/ws2_32/tests/sock.c | 805 ----------------------------------
2 files changed, 808 insertions(+), 806 deletions(-)
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index d6e454a5fbd..21b26d12aec 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -23,9 +23,18 @@
#include <windef.h>
#include <winbase.h>
#include <winsock2.h>
+#include <ws2tcpip.h>
#include "wine/test.h"
+static void (WINAPI *pFreeAddrInfoExW)(ADDRINFOEXW *ai);
+static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname, DWORD namespace,
+ GUID *namespace_id, const ADDRINFOEXW *hints, ADDRINFOEXW **result,
+ struct timeval *timeout, OVERLAPPED *overlapped,
+ LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle);
+static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped);
+static const char *(WINAPI *p_inet_ntop)(int family, void *addr, char *string, ULONG size);
+
/* TCP and UDP over IP fixed set of service flags */
#define TCPIP_SERVICE_FLAGS (XP1_GUARANTEED_DELIVERY \
| XP1_GUARANTEED_ORDER \
@@ -290,15 +299,813 @@ static void test_getprotobynumber(void)
}
}
+/* Tests used in both getaddrinfo and GetAddrInfoW */
+static const struct addr_hint_tests
+{
+ int family, socktype, protocol;
+ DWORD error;
+}
+hinttests[] =
+{
+ {AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0},
+ {AF_UNSPEC, SOCK_STREAM, IPPROTO_UDP, 0},
+ {AF_UNSPEC, SOCK_STREAM, IPPROTO_IPV6,0},
+ {AF_UNSPEC, SOCK_DGRAM, IPPROTO_TCP, 0},
+ {AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, 0},
+ {AF_UNSPEC, SOCK_DGRAM, IPPROTO_IPV6,0},
+ {AF_INET, SOCK_STREAM, IPPROTO_TCP, 0},
+ {AF_INET, SOCK_STREAM, IPPROTO_UDP, 0},
+ {AF_INET, SOCK_STREAM, IPPROTO_IPV6,0},
+ {AF_INET, SOCK_DGRAM, IPPROTO_TCP, 0},
+ {AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0},
+ {AF_INET, SOCK_DGRAM, IPPROTO_IPV6,0},
+ {AF_UNSPEC, 0, IPPROTO_TCP, 0},
+ {AF_UNSPEC, 0, IPPROTO_UDP, 0},
+ {AF_UNSPEC, 0, IPPROTO_IPV6,0},
+ {AF_UNSPEC, SOCK_STREAM, 0, 0},
+ {AF_UNSPEC, SOCK_DGRAM, 0, 0},
+ {AF_INET, 0, IPPROTO_TCP, 0},
+ {AF_INET, 0, IPPROTO_UDP, 0},
+ {AF_INET, 0, IPPROTO_IPV6,0},
+ {AF_INET, SOCK_STREAM, 0, 0},
+ {AF_INET, SOCK_DGRAM, 0, 0},
+ {AF_UNSPEC, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT},
+ {AF_UNSPEC, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT},
+ {AF_UNSPEC, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT},
+ {AF_INET, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT},
+ {AF_INET, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT},
+ {AF_INET, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT},
+ {AF_UNSPEC, SOCK_STREAM, 999, 0},
+ {AF_UNSPEC, SOCK_STREAM, 999, 0},
+ {AF_INET, SOCK_DGRAM, 999, 0},
+ {AF_INET, SOCK_DGRAM, 999, 0},
+};
+
+static void compare_addrinfow(ADDRINFOW *a, ADDRINFOW *b)
+{
+ for (; a && b; a = a->ai_next, b = b->ai_next)
+ {
+ ok(a->ai_flags == b->ai_flags,
+ "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
+ ok(a->ai_family == b->ai_family,
+ "Wrong family %d != %d\n", a->ai_family, b->ai_family);
+ ok(a->ai_socktype == b->ai_socktype,
+ "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
+ ok(a->ai_protocol == b->ai_protocol,
+ "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
+ ok(a->ai_addrlen == b->ai_addrlen,
+ "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
+ ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
+ "Wrong address data\n");
+ if (a->ai_canonname && b->ai_canonname)
+ {
+ ok(!lstrcmpW(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
+ wine_dbgstr_w(a->ai_canonname), wine_dbgstr_w(b->ai_canonname));
+ }
+ else
+ ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
+ a->ai_canonname, b->ai_canonname);
+ }
+ ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
+}
+
+static void test_GetAddrInfoW(void)
+{
+ static const WCHAR port[] = {'8','0',0};
+ static const WCHAR empty[] = {0};
+ static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
+ static const WCHAR nxdomain[] =
+ {'n','x','d','o','m','a','i','n','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+ static const WCHAR zero[] = {'0',0};
+ int i, ret;
+ ADDRINFOW *result, *result2, *p, hint;
+ WCHAR name[256];
+ DWORD size = ARRAY_SIZE(name);
+ /* te su to.winehq.org written in katakana */
+ static const WCHAR idn_domain[] =
+ {0x30C6,0x30B9,0x30C8,'.','w','i','n','e','h','q','.','o','r','g',0};
+ static const WCHAR idn_punycode[] =
+ {'x','n','-','-','z','c','k','z','a','h','.','w','i','n','e','h','q','.','o','r','g',0};
+
+ memset(&hint, 0, sizeof(ADDRINFOW));
+ name[0] = 0;
+ GetComputerNameExW( ComputerNamePhysicalDnsHostname, name, &size );
+
+ result = (ADDRINFOW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(NULL, NULL, NULL, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(empty, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(NULL, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ result2 = NULL;
+ ret = GetAddrInfoW(NULL, empty, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ result = NULL;
+ ret = GetAddrInfoW(empty, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ result2 = NULL;
+ ret = GetAddrInfoW(empty, empty, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, empty, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, port, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, NULL, &hint, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(localhost, port, &hint, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ /* try to get information from the computer name, result is the same
+ * as if requesting with an empty host name. */
+ ret = GetAddrInfoW(name, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = GetAddrInfoW(empty, NULL, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ ret = GetAddrInfoW(name, empty, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = GetAddrInfoW(empty, empty, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ result = (ADDRINFOW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(NULL, NULL, NULL, &result);
+ if (ret == 0)
+ {
+ skip("nxdomain returned success. Broken ISP redirects?\n");
+ return;
+ }
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ result = (ADDRINFOW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(nxdomain, NULL, NULL, &result);
+ if (ret == 0)
+ {
+ skip("nxdomain returned success. Broken ISP redirects?\n");
+ return;
+ }
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ for (i = 0; i < ARRAY_SIZE(hinttests); i++)
+ {
+ hint.ai_family = hinttests[i].family;
+ hint.ai_socktype = hinttests[i].socktype;
+ hint.ai_protocol = hinttests[i].protocol;
+
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(localhost, NULL, &hint, &result);
+ todo_wine_if (hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
+ if (!ret)
+ {
+ for (p = result; p; p = p->ai_next)
+ {
+ /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
+ if (hinttests[i].family == AF_UNSPEC)
+ ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
+ "test %d: expected AF_INET or AF_INET6, got %d\n",
+ i, p->ai_family);
+ else
+ ok(p->ai_family == hinttests[i].family,
+ "test %d: expected family %d, got %d\n",
+ i, hinttests[i].family, p->ai_family);
+
+ ok(p->ai_socktype == hinttests[i].socktype,
+ "test %d: expected type %d, got %d\n",
+ i, hinttests[i].socktype, p->ai_socktype);
+ ok(p->ai_protocol == hinttests[i].protocol,
+ "test %d: expected protocol %d, got %d\n",
+ i, hinttests[i].protocol, p->ai_protocol);
+ }
+ FreeAddrInfoW(result);
+ }
+ else
+ {
+ ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
+ }
+ }
+
+ /* Test IDN resolution (Internationalized Domain Names) present since Windows 8 */
+ result = NULL;
+ ret = GetAddrInfoW(idn_punycode, NULL, NULL, &result);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result != NULL, "got %p\n", result);
+ FreeAddrInfoW(result);
+
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = 0;
+
+ result = NULL;
+ ret = GetAddrInfoW(idn_punycode, NULL, &hint, &result);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result != NULL, "got %p\n", result);
+
+ result2 = NULL;
+ ret = GetAddrInfoW(idn_domain, NULL, NULL, &result2);
+ if (broken(ret == WSAHOST_NOT_FOUND))
+ {
+ FreeAddrInfoW(result);
+ win_skip("IDN resolution not supported in Win <= 7\n");
+ return;
+ }
+
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result2 != NULL, "got %p\n", result2);
+ FreeAddrInfoW(result2);
+
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = 0;
+
+ result2 = NULL;
+ ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result2 != NULL, "got %p\n", result2);
+
+ /* ensure manually resolved punycode and unicode hosts result in same data */
+ compare_addrinfow(result, result2);
+
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = 0;
+
+ result2 = NULL;
+ ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result2 != NULL, "got %p\n", result2);
+ FreeAddrInfoW(result2);
+
+ /* Disable IDN resolution and test again*/
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = AI_DISABLE_IDN_ENCODING;
+
+ SetLastError(0xdeadbeef);
+ result2 = NULL;
+ ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result2 == NULL, "got %p\n", result2);
+}
+
+static struct completion_routine_test
+{
+ WSAOVERLAPPED *overlapped;
+ DWORD error;
+ ADDRINFOEXW **result;
+ HANDLE event;
+ DWORD called;
+} completion_routine_test;
+
+static void CALLBACK completion_routine(DWORD error, DWORD byte_count, WSAOVERLAPPED *overlapped)
+{
+ struct completion_routine_test *test = &completion_routine_test;
+
+ ok(error == test->error, "got %u\n", error);
+ ok(!byte_count, "got %u\n", byte_count);
+ ok(overlapped == test->overlapped, "got %p\n", overlapped);
+ ok(overlapped->Internal == test->error, "got %lu\n", overlapped->Internal);
+ ok(overlapped->Pointer == test->result, "got %p\n", overlapped->Pointer);
+ ok(overlapped->hEvent == NULL, "got %p\n", overlapped->hEvent);
+
+ test->called++;
+ SetEvent(test->event);
+}
+
+static void test_GetAddrInfoExW(void)
+{
+ static const WCHAR empty[] = {0};
+ static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
+ static const WCHAR winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
+ static const WCHAR nxdomain[] = {'n','x','d','o','m','a','i','n','.','w','i','n','e','h','q','.','o','r','g',0};
+ ADDRINFOEXW *result;
+ OVERLAPPED overlapped;
+ HANDLE event;
+ int ret;
+
+ if (!pGetAddrInfoExW || !pGetAddrInfoExOverlappedResult)
+ {
+ win_skip("GetAddrInfoExW and/or GetAddrInfoExOverlappedResult not present\n");
+ return;
+ }
+
+ event = WSACreateEvent();
+
+ result = (ADDRINFOEXW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(empty, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+ ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ pFreeAddrInfoExW(result);
+
+ result = NULL;
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+ ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoExW(result);
+
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ overlapped.hEvent = event;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ pFreeAddrInfoExW(result);
+
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ ResetEvent(event);
+ overlapped.hEvent = event;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == ERROR_IO_PENDING, "expected 11001, got %d\n", WSAGetLastError());
+ ret = overlapped.Internal;
+ ok(ret == WSAEINPROGRESS || ret == ERROR_SUCCESS, "overlapped.Internal = %u\n", ret);
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == event, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
+ ok(result != NULL, "result == NULL\n");
+ ok(!result->ai_blob, "ai_blob != NULL\n");
+ ok(!result->ai_bloblen, "ai_bloblen != 0\n");
+ ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider));
+ pFreeAddrInfoExW(result);
+
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ ResetEvent(event);
+ overlapped.hEvent = event;
+ ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
+ todo_wine
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ todo_wine
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+ ret = WaitForSingleObject(event, 0);
+ todo_wine_if(ret != WAIT_TIMEOUT) /* Remove when abowe todo_wines are fixed */
+ ok(ret == WAIT_TIMEOUT, "wait failed\n");
+
+ /* event + completion routine */
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ overlapped.hEvent = event;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
+ ok(ret == WSAEINVAL, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+
+ /* completion routine, existing domain */
+ result = (void *)0xdeadbeef;
+ overlapped.hEvent = NULL;
+ completion_routine_test.overlapped = &overlapped;
+ completion_routine_test.error = ERROR_SUCCESS;
+ completion_routine_test.result = &result;
+ completion_routine_test.event = event;
+ completion_routine_test.called = 0;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
+ ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
+ pFreeAddrInfoExW(result);
+
+ /* completion routine, non-existing domain */
+ result = (void *)0xdeadbeef;
+ completion_routine_test.overlapped = &overlapped;
+ completion_routine_test.error = WSAHOST_NOT_FOUND;
+ completion_routine_test.called = 0;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(nxdomain, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(ret == WSAHOST_NOT_FOUND, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == WSAHOST_NOT_FOUND, "overlapped.Internal = %lx\n", overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
+ ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
+ ok(result == NULL, "got %p\n", result);
+
+ WSACloseEvent(event);
+}
+
+static void verify_ipv6_addrinfo(ADDRINFOA *result, const char *expect)
+{
+ SOCKADDR_IN6 *sockaddr6;
+ char buffer[256];
+ const char *ret;
+
+ ok(result->ai_family == AF_INET6, "ai_family == %d\n", result->ai_family);
+ ok(result->ai_addrlen >= sizeof(struct sockaddr_in6), "ai_addrlen == %d\n", (int)result->ai_addrlen);
+ ok(result->ai_addr != NULL, "ai_addr == NULL\n");
+
+ sockaddr6 = (SOCKADDR_IN6 *)result->ai_addr;
+ ok(sockaddr6->sin6_family == AF_INET6, "ai_addr->sin6_family == %d\n", sockaddr6->sin6_family);
+ ok(sockaddr6->sin6_port == 0, "ai_addr->sin6_port == %d\n", sockaddr6->sin6_port);
+
+ memset(buffer, 0, sizeof(buffer));
+ ret = p_inet_ntop(AF_INET6, &sockaddr6->sin6_addr, buffer, sizeof(buffer));
+ ok(ret != NULL, "inet_ntop failed (%d)\n", WSAGetLastError());
+ ok(!strcmp(buffer, expect), "ai_addr->sin6_addr == '%s' (expected '%s')\n", buffer, expect);
+}
+
+static void compare_addrinfo(ADDRINFO *a, ADDRINFO *b)
+{
+ for (; a && b ; a = a->ai_next, b = b->ai_next)
+ {
+ ok(a->ai_flags == b->ai_flags,
+ "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
+ ok(a->ai_family == b->ai_family,
+ "Wrong family %d != %d\n", a->ai_family, b->ai_family);
+ ok(a->ai_socktype == b->ai_socktype,
+ "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
+ ok(a->ai_protocol == b->ai_protocol,
+ "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
+ ok(a->ai_addrlen == b->ai_addrlen,
+ "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
+ ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
+ "Wrong address data\n");
+ if (a->ai_canonname && b->ai_canonname)
+ {
+ ok(!strcmp(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
+ a->ai_canonname, b->ai_canonname);
+ }
+ else
+ ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
+ a->ai_canonname, b->ai_canonname);
+ }
+ ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
+}
+
+static void test_getaddrinfo(void)
+{
+ int i, ret;
+ ADDRINFOA *result, *result2, *p, hint;
+ SOCKADDR_IN *sockaddr;
+ CHAR name[256], *ip;
+ DWORD size = sizeof(name);
+
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ GetComputerNameExA( ComputerNamePhysicalDnsHostname, name, &size );
+
+ result = (ADDRINFOA *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo(NULL, NULL, NULL, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "getaddrinfo failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo(NULL, "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "getaddrinfo failed\n");
+
+ result2 = NULL;
+ ret = getaddrinfo(NULL, "", NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "getaddrinfo failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("", "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ ok(result != NULL, "getaddrinfo failed\n");
+
+ result2 = NULL;
+ ret = getaddrinfo("", "", NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "getaddrinfo failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", "", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", "80", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", NULL, &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("localhost", "80", &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ hint.ai_flags = AI_NUMERICHOST;
+ result = (void *)0xdeadbeef;
+ ret = getaddrinfo("localhost", "80", &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected WSAHOST_NOT_FOUND, got %d\n", WSAGetLastError());
+ ok(!result, "result = %p\n", result);
+ hint.ai_flags = 0;
+
+ /* try to get information from the computer name, result is the same
+ * as if requesting with an empty host name. */
+ ret = getaddrinfo(name, NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = getaddrinfo("", NULL, NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ ret = getaddrinfo(name, "", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = getaddrinfo("", "", NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ result = (ADDRINFOA *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("nxdomain.codeweavers.com", NULL, NULL, &result);
+ if (ret == 0)
+ {
+ skip("nxdomain returned success. Broken ISP redirects?\n");
+ return;
+ }
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ /* Test IPv4 address conversion */
+ result = NULL;
+ ret = getaddrinfo("192.168.1.253", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ ok(result->ai_family == AF_INET, "ai_family == %d\n", result->ai_family);
+ ok(result->ai_addrlen >= sizeof(struct sockaddr_in), "ai_addrlen == %d\n", (int)result->ai_addrlen);
+ ok(result->ai_addr != NULL, "ai_addr == NULL\n");
+ sockaddr = (SOCKADDR_IN *)result->ai_addr;
+ ok(sockaddr->sin_family == AF_INET, "ai_addr->sin_family == %d\n", sockaddr->sin_family);
+ ok(sockaddr->sin_port == 0, "ai_addr->sin_port == %d\n", sockaddr->sin_port);
+
+ ip = inet_ntoa(sockaddr->sin_addr);
+ ok(strcmp(ip, "192.168.1.253") == 0, "sockaddr->ai_addr == '%s'\n", ip);
+ freeaddrinfo(result);
+
+ /* Test IPv4 address conversion with port */
+ result = NULL;
+ hint.ai_flags = AI_NUMERICHOST;
+ ret = getaddrinfo("192.168.1.253:1024", NULL, &hint, &result);
+ hint.ai_flags = 0;
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo returned unexpected result: %d\n", ret);
+ ok(result == NULL, "expected NULL, got %p\n", result);
+
+ /* Test IPv6 address conversion */
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = getaddrinfo("2a00:2039:dead:beef:cafe::6666", NULL, NULL, &result);
+
+ if (result != NULL)
+ {
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "2a00:2039:dead:beef:cafe::6666");
+ freeaddrinfo(result);
+
+ /* Test IPv6 address conversion with brackets */
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ freeaddrinfo(result);
+
+ /* Test IPv6 address conversion with brackets and hints */
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ hint.ai_flags = AI_NUMERICHOST;
+ hint.ai_family = AF_INET6;
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ freeaddrinfo(result);
+
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ hint.ai_flags = AI_NUMERICHOST;
+ hint.ai_family = AF_INET;
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+
+ /* Test IPv6 address conversion with brackets and port */
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]:10239", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ freeaddrinfo(result);
+
+ /* Test IPv6 address conversion with unmatched brackets */
+ result = NULL;
+ hint.ai_flags = AI_NUMERICHOST;
+ ret = getaddrinfo("[beef::cafe", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+
+ ret = getaddrinfo("beef::cafe]", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+ }
+ else
+ {
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+ win_skip("getaddrinfo does not support IPV6\n");
+ }
+
+ hint.ai_flags = 0;
+
+ for (i = 0; i < ARRAY_SIZE(hinttests); i++)
+ {
+ hint.ai_family = hinttests[i].family;
+ hint.ai_socktype = hinttests[i].socktype;
+ hint.ai_protocol = hinttests[i].protocol;
+
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = getaddrinfo("localhost", NULL, &hint, &result);
+ todo_wine_if (hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
+ if (!ret)
+ {
+ for (p = result; p; p = p->ai_next)
+ {
+ /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
+ if (hinttests[i].family == AF_UNSPEC)
+ ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
+ "test %d: expected AF_INET or AF_INET6, got %d\n",
+ i, p->ai_family);
+ else
+ ok(p->ai_family == hinttests[i].family,
+ "test %d: expected family %d, got %d\n",
+ i, hinttests[i].family, p->ai_family);
+
+ ok(p->ai_socktype == hinttests[i].socktype,
+ "test %d: expected type %d, got %d\n",
+ i, hinttests[i].socktype, p->ai_socktype);
+ ok(p->ai_protocol == hinttests[i].protocol,
+ "test %d: expected protocol %d, got %d\n",
+ i, hinttests[i].protocol, p->ai_protocol);
+ }
+ freeaddrinfo(result);
+ }
+ else
+ {
+ ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
+ }
+ }
+
+ memset(&hint, 0, sizeof(hint));
+ ret = getaddrinfo(NULL, "nonexistentservice", &hint, &result);
+ ok(ret == WSATYPE_NOT_FOUND, "got %d\n", ret);
+}
+
START_TEST( protocol )
{
WSADATA data;
WORD version = MAKEWORD( 2, 2 );
-
+
+ pFreeAddrInfoExW = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "FreeAddrInfoExW");
+ pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "GetAddrInfoExOverlappedResult");
+ pGetAddrInfoExW = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "GetAddrInfoExW");
+ p_inet_ntop = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "inet_ntop");
+
if (WSAStartup( version, &data )) return;
test_WSAEnumProtocolsA();
test_WSAEnumProtocolsW();
test_getprotobyname();
test_getprotobynumber();
+
+ test_GetAddrInfoW();
+ test_GetAddrInfoExW();
+ test_getaddrinfo();
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 61af5b0183a..877c21377aa 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -65,12 +65,6 @@
k.keepaliveinterval = interval;
/* Function pointers */
-static void (WINAPI *pFreeAddrInfoExW)(ADDRINFOEXW *ai);
-static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname, DWORD namespace,
- GUID *namespace_id, const ADDRINFOEXW *hints, ADDRINFOEXW **result,
- struct timeval *timeout, OVERLAPPED *overlapped,
- LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle);
-static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped);
static int (WINAPI *pGetHostNameW)(WCHAR *, int);
static PCSTR (WINAPI *pInetNtop)(INT,LPVOID,LPSTR,ULONG);
static PCWSTR(WINAPI *pInetNtopW)(INT,LPVOID,LPWSTR,ULONG);
@@ -163,46 +157,6 @@ typedef struct select_thread_params
BOOL ReadKilled;
} select_thread_params;
-/* Tests used in both getaddrinfo and GetAddrInfoW */
-static const struct addr_hint_tests
-{
- int family, socktype, protocol;
- DWORD error;
-} hinttests[] = {
- {AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0 },
- {AF_UNSPEC, SOCK_STREAM, IPPROTO_UDP, 0 },
- {AF_UNSPEC, SOCK_STREAM, IPPROTO_IPV6,0 },
- {AF_UNSPEC, SOCK_DGRAM, IPPROTO_TCP, 0 },
- {AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, 0 },
- {AF_UNSPEC, SOCK_DGRAM, IPPROTO_IPV6,0 },
- {AF_INET, SOCK_STREAM, IPPROTO_TCP, 0 },
- {AF_INET, SOCK_STREAM, IPPROTO_UDP, 0 },
- {AF_INET, SOCK_STREAM, IPPROTO_IPV6,0 },
- {AF_INET, SOCK_DGRAM, IPPROTO_TCP, 0 },
- {AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0 },
- {AF_INET, SOCK_DGRAM, IPPROTO_IPV6,0 },
- {AF_UNSPEC, 0, IPPROTO_TCP, 0 },
- {AF_UNSPEC, 0, IPPROTO_UDP, 0 },
- {AF_UNSPEC, 0, IPPROTO_IPV6,0 },
- {AF_UNSPEC, SOCK_STREAM, 0, 0 },
- {AF_UNSPEC, SOCK_DGRAM, 0, 0 },
- {AF_INET, 0, IPPROTO_TCP, 0 },
- {AF_INET, 0, IPPROTO_UDP, 0 },
- {AF_INET, 0, IPPROTO_IPV6,0 },
- {AF_INET, SOCK_STREAM, 0, 0 },
- {AF_INET, SOCK_DGRAM, 0, 0 },
- {AF_UNSPEC, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT },
- {AF_UNSPEC, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT },
- {AF_UNSPEC, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT },
- {AF_INET, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT },
- {AF_INET, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT },
- {AF_INET, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT },
- {AF_UNSPEC, SOCK_STREAM, 999, 0 },
- {AF_UNSPEC, SOCK_STREAM, 999, 0 },
- {AF_INET, SOCK_DGRAM, 999, 0 },
- {AF_INET, SOCK_DGRAM, 999, 0 },
-};
-
/**************** Static variables ***************/
static DWORD tls; /* Thread local storage index */
@@ -390,62 +344,6 @@ static void check_so_opentype (void)
ok ( tmp == 0, "check_so_opentype: wrong startup value of SO_OPENTYPE: %d\n", tmp );
}
-static void compare_addrinfo (ADDRINFO *a, ADDRINFO *b)
-{
- for (; a && b ; a = a->ai_next, b = b->ai_next)
- {
- ok(a->ai_flags == b->ai_flags,
- "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
- ok(a->ai_family == b->ai_family,
- "Wrong family %d != %d\n", a->ai_family, b->ai_family);
- ok(a->ai_socktype == b->ai_socktype,
- "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
- ok(a->ai_protocol == b->ai_protocol,
- "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
- ok(a->ai_addrlen == b->ai_addrlen,
- "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
- ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
- "Wrong address data\n");
- if (a->ai_canonname && b->ai_canonname)
- {
- ok(!strcmp(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
- a->ai_canonname, b->ai_canonname);
- }
- else
- ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
- a->ai_canonname, b->ai_canonname);
- }
- ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
-}
-
-static void compare_addrinfow (ADDRINFOW *a, ADDRINFOW *b)
-{
- for (; a && b ; a = a->ai_next, b = b->ai_next)
- {
- ok(a->ai_flags == b->ai_flags,
- "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
- ok(a->ai_family == b->ai_family,
- "Wrong family %d != %d\n", a->ai_family, b->ai_family);
- ok(a->ai_socktype == b->ai_socktype,
- "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
- ok(a->ai_protocol == b->ai_protocol,
- "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
- ok(a->ai_addrlen == b->ai_addrlen,
- "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
- ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
- "Wrong address data\n");
- if (a->ai_canonname && b->ai_canonname)
- {
- ok(!lstrcmpW(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
- wine_dbgstr_w(a->ai_canonname), wine_dbgstr_w(b->ai_canonname));
- }
- else
- ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
- a->ai_canonname, b->ai_canonname);
- }
- ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
-}
-
/**************** Server utility functions ***************/
/*
@@ -1201,9 +1099,6 @@ static void Init (void)
WSADATA data;
HMODULE hws2_32 = GetModuleHandleA("ws2_32.dll"), ntdll;
- pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW");
- pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW");
- pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32, "GetAddrInfoExOverlappedResult");
pGetHostNameW = (void *)GetProcAddress(hws2_32, "GetHostNameW");
pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop");
pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
@@ -6537,703 +6432,6 @@ todo_wine
#undef POLL_ISSET
#undef POLL_CLEAR
-static void test_GetAddrInfoW(void)
-{
- static const WCHAR port[] = {'8','0',0};
- static const WCHAR empty[] = {0};
- static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
- static const WCHAR nxdomain[] =
- {'n','x','d','o','m','a','i','n','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
- static const WCHAR zero[] = {'0',0};
- int i, ret;
- ADDRINFOW *result, *result2, *p, hint;
- WCHAR name[256];
- DWORD size = ARRAY_SIZE(name);
- /* te su to.winehq.org written in katakana */
- static const WCHAR idn_domain[] =
- {0x30C6,0x30B9,0x30C8,'.','w','i','n','e','h','q','.','o','r','g',0};
- static const WCHAR idn_punycode[] =
- {'x','n','-','-','z','c','k','z','a','h','.','w','i','n','e','h','q','.','o','r','g',0};
-
- memset(&hint, 0, sizeof(ADDRINFOW));
- name[0] = 0;
- GetComputerNameExW( ComputerNamePhysicalDnsHostname, name, &size );
-
- result = (ADDRINFOW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(NULL, NULL, NULL, &result);
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(empty, NULL, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(NULL, zero, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- result2 = NULL;
- ret = GetAddrInfoW(NULL, empty, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- result = NULL;
- ret = GetAddrInfoW(empty, zero, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- result2 = NULL;
- ret = GetAddrInfoW(empty, empty, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, NULL, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, empty, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, zero, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, port, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, NULL, &hint, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = GetAddrInfoW(localhost, port, &hint, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- /* try to get information from the computer name, result is the same
- * as if requesting with an empty host name. */
- ret = GetAddrInfoW(name, NULL, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = GetAddrInfoW(empty, NULL, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- ret = GetAddrInfoW(name, empty, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = GetAddrInfoW(empty, empty, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- result = (ADDRINFOW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(NULL, NULL, NULL, &result);
- if(ret == 0)
- {
- skip("nxdomain returned success. Broken ISP redirects?\n");
- return;
- }
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
-
- result = (ADDRINFOW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(nxdomain, NULL, NULL, &result);
- if(ret == 0)
- {
- skip("nxdomain returned success. Broken ISP redirects?\n");
- return;
- }
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
-
- for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
- {
- hint.ai_family = hinttests[i].family;
- hint.ai_socktype = hinttests[i].socktype;
- hint.ai_protocol = hinttests[i].protocol;
-
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = GetAddrInfoW(localhost, NULL, &hint, &result);
- todo_wine_if(hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
- if(!ret)
- {
- for (p = result; p; p = p->ai_next)
- {
- /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
- if (hinttests[i].family == AF_UNSPEC)
- ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
- "test %d: expected AF_INET or AF_INET6, got %d\n",
- i, p->ai_family);
- else
- ok(p->ai_family == hinttests[i].family,
- "test %d: expected family %d, got %d\n",
- i, hinttests[i].family, p->ai_family);
-
- ok(p->ai_socktype == hinttests[i].socktype,
- "test %d: expected type %d, got %d\n",
- i, hinttests[i].socktype, p->ai_socktype);
- ok(p->ai_protocol == hinttests[i].protocol,
- "test %d: expected protocol %d, got %d\n",
- i, hinttests[i].protocol, p->ai_protocol);
- }
- FreeAddrInfoW(result);
- }
- else
- {
- ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
- }
- }
-
- /* Test IDN resolution (Internationalized Domain Names) present since Windows 8 */
- result = NULL;
- ret = GetAddrInfoW(idn_punycode, NULL, NULL, &result);
- ok(!ret, "got %d expected success\n", ret);
- ok(result != NULL, "got %p\n", result);
- FreeAddrInfoW(result);
-
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = 0;
-
- result = NULL;
- ret = GetAddrInfoW(idn_punycode, NULL, &hint, &result);
- ok(!ret, "got %d expected success\n", ret);
- ok(result != NULL, "got %p\n", result);
-
- result2 = NULL;
- ret = GetAddrInfoW(idn_domain, NULL, NULL, &result2);
- if (broken(ret == WSAHOST_NOT_FOUND))
- {
- FreeAddrInfoW(result);
- win_skip("IDN resolution not supported in Win <= 7\n");
- return;
- }
-
- ok(!ret, "got %d expected success\n", ret);
- ok(result2 != NULL, "got %p\n", result2);
- FreeAddrInfoW(result2);
-
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = 0;
-
- result2 = NULL;
- ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
- ok(!ret, "got %d expected success\n", ret);
- ok(result2 != NULL, "got %p\n", result2);
-
- /* ensure manually resolved punycode and unicode hosts result in same data */
- compare_addrinfow(result, result2);
-
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = 0;
-
- result2 = NULL;
- ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
- ok(!ret, "got %d expected success\n", ret);
- ok(result2 != NULL, "got %p\n", result2);
- FreeAddrInfoW(result2);
-
- /* Disable IDN resolution and test again*/
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = AI_DISABLE_IDN_ENCODING;
-
- SetLastError(0xdeadbeef);
- result2 = NULL;
- ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result2 == NULL, "got %p\n", result2);
-}
-
-static struct completion_routine_test
-{
- WSAOVERLAPPED *overlapped;
- DWORD error;
- ADDRINFOEXW **result;
- HANDLE event;
- DWORD called;
-} completion_routine_test;
-
-static void CALLBACK completion_routine(DWORD error, DWORD byte_count, WSAOVERLAPPED *overlapped)
-{
- struct completion_routine_test *test = &completion_routine_test;
-
- ok(error == test->error, "got %u\n", error);
- ok(!byte_count, "got %u\n", byte_count);
- ok(overlapped == test->overlapped, "got %p\n", overlapped);
- ok(overlapped->Internal == test->error, "got %lu\n", overlapped->Internal);
- ok(overlapped->Pointer == test->result, "got %p\n", overlapped->Pointer);
- ok(overlapped->hEvent == NULL, "got %p\n", overlapped->hEvent);
-
- test->called++;
- SetEvent(test->event);
-}
-
-static void test_GetAddrInfoExW(void)
-{
- static const WCHAR empty[] = {0};
- static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
- static const WCHAR winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
- static const WCHAR nxdomain[] = {'n','x','d','o','m','a','i','n','.','w','i','n','e','h','q','.','o','r','g',0};
- ADDRINFOEXW *result;
- OVERLAPPED overlapped;
- HANDLE event;
- int ret;
-
- if (!pGetAddrInfoExW || !pGetAddrInfoExOverlappedResult)
- {
- win_skip("GetAddrInfoExW and/or GetAddrInfoExOverlappedResult not present\n");
- return;
- }
-
- event = WSACreateEvent();
-
- result = (ADDRINFOEXW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = pGetAddrInfoExW(empty, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
- ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- pFreeAddrInfoExW(result);
-
- result = NULL;
- ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
- ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- pFreeAddrInfoExW(result);
-
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- overlapped.hEvent = event;
- ResetEvent(event);
- ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(!result, "result != NULL\n");
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(!ret, "overlapped result is %d\n", ret);
- pFreeAddrInfoExW(result);
-
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- ResetEvent(event);
- overlapped.hEvent = event;
- WSASetLastError(0xdeadbeef);
- ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == ERROR_IO_PENDING, "expected 11001, got %d\n", WSAGetLastError());
- ret = overlapped.Internal;
- ok(ret == WSAEINPROGRESS || ret == ERROR_SUCCESS, "overlapped.Internal = %u\n", ret);
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(!ret, "overlapped result is %d\n", ret);
- ok(overlapped.hEvent == event, "hEvent changed %p\n", overlapped.hEvent);
- ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
- ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
- ok(result != NULL, "result == NULL\n");
- if (result != NULL)
- {
- ok(!result->ai_blob, "ai_blob != NULL\n");
- ok(!result->ai_bloblen, "ai_bloblen != 0\n");
- ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider));
- pFreeAddrInfoExW(result);
- }
-
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- ResetEvent(event);
- overlapped.hEvent = event;
- ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
- todo_wine
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- todo_wine
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
- ret = WaitForSingleObject(event, 0);
- todo_wine_if(ret != WAIT_TIMEOUT) /* Remove when abowe todo_wines are fixed */
- ok(ret == WAIT_TIMEOUT, "wait failed\n");
-
- /* event + completion routine */
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- overlapped.hEvent = event;
- ResetEvent(event);
- ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
- ok(ret == WSAEINVAL, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
-
- /* completion routine, existing domain */
- result = (void *)0xdeadbeef;
- overlapped.hEvent = NULL;
- completion_routine_test.overlapped = &overlapped;
- completion_routine_test.error = ERROR_SUCCESS;
- completion_routine_test.result = &result;
- completion_routine_test.event = event;
- completion_routine_test.called = 0;
- ResetEvent(event);
- ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(!result, "result != NULL\n");
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(!ret, "overlapped result is %d\n", ret);
- ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
- ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
- ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
- ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
- pFreeAddrInfoExW(result);
-
- /* completion routine, non-existing domain */
- result = (void *)0xdeadbeef;
- completion_routine_test.overlapped = &overlapped;
- completion_routine_test.error = WSAHOST_NOT_FOUND;
- completion_routine_test.called = 0;
- ResetEvent(event);
- ret = pGetAddrInfoExW(nxdomain, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(!result, "result != NULL\n");
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(ret == WSAHOST_NOT_FOUND, "overlapped result is %d\n", ret);
- ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
- ok(overlapped.Internal == WSAHOST_NOT_FOUND, "overlapped.Internal = %lx\n", overlapped.Internal);
- ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
- ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
- ok(result == NULL, "got %p\n", result);
-
- WSACloseEvent(event);
-}
-
-static void verify_ipv6_addrinfo(ADDRINFOA *result, const char *expectedIp)
-{
- SOCKADDR_IN6 *sockaddr6;
- char ipBuffer[256];
- const char *ret;
-
- ok(result->ai_family == AF_INET6, "ai_family == %d\n", result->ai_family);
- ok(result->ai_addrlen >= sizeof(struct sockaddr_in6), "ai_addrlen == %d\n", (int)result->ai_addrlen);
- ok(result->ai_addr != NULL, "ai_addr == NULL\n");
-
- if (result->ai_addr != NULL)
- {
- sockaddr6 = (SOCKADDR_IN6 *)result->ai_addr;
- ok(sockaddr6->sin6_family == AF_INET6, "ai_addr->sin6_family == %d\n", sockaddr6->sin6_family);
- ok(sockaddr6->sin6_port == 0, "ai_addr->sin6_port == %d\n", sockaddr6->sin6_port);
-
- ZeroMemory(ipBuffer, sizeof(ipBuffer));
- ret = pInetNtop(AF_INET6, &sockaddr6->sin6_addr, ipBuffer, sizeof(ipBuffer));
- ok(ret != NULL, "inet_ntop failed (%d)\n", WSAGetLastError());
- ok(strcmp(ipBuffer, expectedIp) == 0, "ai_addr->sin6_addr == '%s' (expected '%s')\n", ipBuffer, expectedIp);
- }
-}
-
-static void test_getaddrinfo(void)
-{
- int i, ret;
- ADDRINFOA *result, *result2, *p, hint;
- SOCKADDR_IN *sockaddr;
- CHAR name[256], *ip;
- DWORD size = sizeof(name);
-
- memset(&hint, 0, sizeof(ADDRINFOA));
- GetComputerNameExA( ComputerNamePhysicalDnsHostname, name, &size );
-
- result = (ADDRINFOA *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo(NULL, NULL, NULL, &result);
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "getaddrinfo failed\n");
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo(NULL, "0", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "getaddrinfo failed\n");
-
- result2 = NULL;
- ret = getaddrinfo(NULL, "", NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "getaddrinfo failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("", "0", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- ok(result != NULL, "getaddrinfo failed\n");
-
- result2 = NULL;
- ret = getaddrinfo("", "", NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "getaddrinfo failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- result = NULL;
- ret = getaddrinfo("localhost", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", "", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", "0", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", "80", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", NULL, &hint, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("localhost", "80", &hint, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- hint.ai_flags = AI_NUMERICHOST;
- result = (void*)0xdeadbeef;
- ret = getaddrinfo("localhost", "80", &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected WSAHOST_NOT_FOUND, got %d\n", WSAGetLastError());
- ok(!result, "result = %p\n", result);
- hint.ai_flags = 0;
-
- /* try to get information from the computer name, result is the same
- * as if requesting with an empty host name. */
- ret = getaddrinfo(name, NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = getaddrinfo("", NULL, NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- ret = getaddrinfo(name, "", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = getaddrinfo("", "", NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- result = (ADDRINFOA *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("nxdomain.codeweavers.com", NULL, NULL, &result);
- if(ret == 0)
- {
- skip("nxdomain returned success. Broken ISP redirects?\n");
- return;
- }
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
-
- /* Test IPv4 address conversion */
- result = NULL;
- ret = getaddrinfo("192.168.1.253", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- ok(result->ai_family == AF_INET, "ai_family == %d\n", result->ai_family);
- ok(result->ai_addrlen >= sizeof(struct sockaddr_in), "ai_addrlen == %d\n", (int)result->ai_addrlen);
- ok(result->ai_addr != NULL, "ai_addr == NULL\n");
- sockaddr = (SOCKADDR_IN *)result->ai_addr;
- ok(sockaddr->sin_family == AF_INET, "ai_addr->sin_family == %d\n", sockaddr->sin_family);
- ok(sockaddr->sin_port == 0, "ai_addr->sin_port == %d\n", sockaddr->sin_port);
-
- ip = inet_ntoa(sockaddr->sin_addr);
- ok(strcmp(ip, "192.168.1.253") == 0, "sockaddr->ai_addr == '%s'\n", ip);
- freeaddrinfo(result);
-
- /* Test IPv4 address conversion with port */
- result = NULL;
- hint.ai_flags = AI_NUMERICHOST;
- ret = getaddrinfo("192.168.1.253:1024", NULL, &hint, &result);
- hint.ai_flags = 0;
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo returned unexpected result: %d\n", ret);
- ok(result == NULL, "expected NULL, got %p\n", result);
-
- /* Test IPv6 address conversion */
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = getaddrinfo("2a00:2039:dead:beef:cafe::6666", NULL, NULL, &result);
-
- if (result != NULL)
- {
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "2a00:2039:dead:beef:cafe::6666");
- freeaddrinfo(result);
-
- /* Test IPv6 address conversion with brackets */
- result = NULL;
- ret = getaddrinfo("[beef::cafe]", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "beef::cafe");
- freeaddrinfo(result);
-
- /* Test IPv6 address conversion with brackets and hints */
- memset(&hint, 0, sizeof(ADDRINFOA));
- hint.ai_flags = AI_NUMERICHOST;
- hint.ai_family = AF_INET6;
- result = NULL;
- ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "beef::cafe");
- freeaddrinfo(result);
-
- memset(&hint, 0, sizeof(ADDRINFOA));
- hint.ai_flags = AI_NUMERICHOST;
- hint.ai_family = AF_INET;
- result = NULL;
- ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
-
- /* Test IPv6 address conversion with brackets and port */
- result = NULL;
- ret = getaddrinfo("[beef::cafe]:10239", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "beef::cafe");
- freeaddrinfo(result);
-
- /* Test IPv6 address conversion with unmatched brackets */
- result = NULL;
- hint.ai_flags = AI_NUMERICHOST;
- ret = getaddrinfo("[beef::cafe", NULL, &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
-
- ret = getaddrinfo("beef::cafe]", NULL, &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
- }
- else
- {
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
- win_skip("getaddrinfo does not support IPV6\n");
- }
-
- hint.ai_flags = 0;
-
- for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
- {
- hint.ai_family = hinttests[i].family;
- hint.ai_socktype = hinttests[i].socktype;
- hint.ai_protocol = hinttests[i].protocol;
-
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = getaddrinfo("localhost", NULL, &hint, &result);
- todo_wine_if(hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
- if(!ret)
- {
- for (p = result; p; p = p->ai_next)
- {
- /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
- if (hinttests[i].family == AF_UNSPEC)
- ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
- "test %d: expected AF_INET or AF_INET6, got %d\n",
- i, p->ai_family);
- else
- ok(p->ai_family == hinttests[i].family,
- "test %d: expected family %d, got %d\n",
- i, hinttests[i].family, p->ai_family);
-
- ok(p->ai_socktype == hinttests[i].socktype,
- "test %d: expected type %d, got %d\n",
- i, hinttests[i].socktype, p->ai_socktype);
- ok(p->ai_protocol == hinttests[i].protocol,
- "test %d: expected protocol %d, got %d\n",
- i, hinttests[i].protocol, p->ai_protocol);
- }
- freeaddrinfo(result);
- }
- else
- {
- ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
- }
- }
-
- memset(&hint, 0, sizeof(hint));
- ret = getaddrinfo(NULL, "nonexistentservice", &hint, &result);
- ok(ret == WSATYPE_NOT_FOUND, "got %d\n", ret);
-}
-
static void test_ConnectEx(void)
{
SOCKET listener = INVALID_SOCKET;
@@ -10680,9 +9878,6 @@ START_TEST( sock )
test_ipv6only();
test_TransmitFile();
- test_GetAddrInfoW();
- test_GetAddrInfoExW();
- test_getaddrinfo();
test_AcceptEx();
test_ConnectEx();
test_DisconnectEx();
--
2.30.2
2
7
Patch by Robert Wilhelm from bug
https://bugs.winehq.org/show_bug.cgi?id=49905
1
0
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
configure.ac | 1 -
dlls/msvcrt/math.c | 54 ++++++++++++++++++++++++++++++++++---------
dlls/msvcrt/unixlib.c | 14 -----------
dlls/msvcrt/unixlib.h | 1 -
4 files changed, 43 insertions(+), 27 deletions(-)
1
0
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
configure.ac | 1 -
dlls/msvcrt/math.c | 238 +++++++++++++++++++++++++++++++++++++++++-
dlls/msvcrt/unixlib.c | 14 ---
dlls/msvcrt/unixlib.h | 1 -
4 files changed, 235 insertions(+), 19 deletions(-)
1
0
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcrt/math.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
1
0
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
Used by Forza Horizon 4.
.../api-ms-win-core-processthreads-l1-1-3.spec | 2 +-
dlls/kernel32/kernel32.spec | 1 +
dlls/kernelbase/kernelbase.spec | 2 +-
dlls/kernelbase/memory.c | 11 +++++++++++
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/api-ms-win-core-processthreads-l1-1-3/api-ms-win-core-processthreads-l1-1-3.spec b/dlls/api-ms-win-core-processthreads-l1-1-3/api-ms-win-core-processthreads-l1-1-3.spec
index 8f2daaefe74..77893f24225 100644
--- a/dlls/api-ms-win-core-processthreads-l1-1-3/api-ms-win-core-processthreads-l1-1-3.spec
+++ b/dlls/api-ms-win-core-processthreads-l1-1-3/api-ms-win-core-processthreads-l1-1-3.spec
@@ -7,4 +7,4 @@
@ stub SetProcessInformation
@ stdcall SetThreadDescription(ptr wstr) kernel32.SetThreadDescription
@ stdcall SetThreadIdealProcessor(long long) kernel32.SetThreadIdealProcessor
-@ stub SetThreadSelectedCpuSets
+@ stdcall SetThreadSelectedCpuSets(ptr ptr long) kernel32.SetThreadSelectedCpuSets
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 6948ba45fce..87e67d3743d 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1471,6 +1471,7 @@
@ stdcall -import SetThreadPreferredUILanguages(long ptr ptr)
@ stdcall -import SetThreadPriority(long long)
@ stdcall -import SetThreadPriorityBoost(long long)
+@ stdcall -import SetThreadSelectedCpuSets(ptr ptr long)
@ stdcall -import SetThreadStackGuarantee(ptr)
# @ stub SetThreadToken
@ stdcall -import SetThreadUILanguage(long)
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 28cfd842223..9a66c5c2ac0 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -1494,7 +1494,7 @@
@ stdcall SetThreadPreferredUILanguages(long ptr ptr)
@ stdcall SetThreadPriority(long long)
@ stdcall SetThreadPriorityBoost(long long)
-# @ stub SetThreadSelectedCpuSets
+@ stdcall SetThreadSelectedCpuSets(ptr ptr long)
@ stdcall SetThreadStackGuarantee(ptr)
@ stdcall SetThreadToken(ptr ptr)
@ stdcall SetThreadUILanguage(long)
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
index 4b71c0cc6ec..fb5f5100399 100644
--- a/dlls/kernelbase/memory.c
+++ b/dlls/kernelbase/memory.c
@@ -1168,6 +1168,17 @@ BOOL WINAPI GetSystemCpuSetInformation(SYSTEM_CPU_SET_INFORMATION *info, ULONG b
}
+/***********************************************************************
+ * SetThreadSelectedCpuSets (kernelbase.@)
+ */
+BOOL WINAPI SetThreadSelectedCpuSets(HANDLE thread, const ULONG *cpu_set_ids, ULONG count)
+{
+ FIXME( "thread %p, cpu_set_ids %p, count %u stub.\n", thread, cpu_set_ids, count );
+
+ return TRUE;
+}
+
+
/**********************************************************************
* GetNumaHighestNodeNumber (kernelbase.@)
*/
--
2.31.1
1
0
Largely based on a patch by Nikolay Sivov for NtGetNextProcess().
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
v2:
- stop searching for thread even if handle allocation failed;
- do not zero reply handle in server;
- set output handle to NULL in case of error (also add tests supporting that);
- move return handle assignment outside of SERVER_START_REQ() scope.
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/tests/om.c | 93 ++++++++++++++++++++++++++++++++++++++++
dlls/ntdll/unix/thread.c | 29 +++++++++++++
server/protocol.def | 12 ++++++
server/thread.c | 50 +++++++++++++++++++++
5 files changed, 185 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index a93fa08c406..cade83da4b1 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -223,6 +223,7 @@
@ stdcall -norelay -syscall NtGetContextThread(long ptr)
@ stdcall -syscall NtGetCurrentProcessorNumber()
# @ stub NtGetDevicePowerState
+@ stdcall -syscall NtGetNextThread(ptr ptr long long long ptr)
@ stdcall -syscall NtGetNlsSectionPtr(long long long ptr ptr)
@ stub NtGetPlugPlayEvent
@ stdcall NtGetTickCount()
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index e0988769c9c..7d9ca47be12 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -78,6 +78,8 @@ static void (WINAPI *pRtlWakeAddressAll)( const void * );
static void (WINAPI *pRtlWakeAddressSingle)( const void * );
static NTSTATUS (WINAPI *pNtOpenProcess)( HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES *, const CLIENT_ID * );
static NTSTATUS (WINAPI *pNtCreateDebugObject)( HANDLE *, ACCESS_MASK, OBJECT_ATTRIBUTES *, ULONG );
+static NTSTATUS (WINAPI *pNtGetNextThread)(HANDLE process, HANDLE thread, ACCESS_MASK access, ULONG attributes,
+ ULONG flags, HANDLE *handle);
#define KEYEDEVENT_WAIT 0x0001
#define KEYEDEVENT_WAKE 0x0002
@@ -2564,6 +2566,95 @@ static void test_object_types(void)
}
}
+static DWORD WINAPI test_get_next_thread_proc( void *arg )
+{
+ HANDLE event = (HANDLE)arg;
+
+ WaitForSingleObject(event, INFINITE);
+ return 0;
+}
+
+static void test_get_next_thread(void)
+{
+ HANDLE hprocess = GetCurrentProcess();
+ HANDLE handle, thread, event, prev;
+ NTSTATUS status;
+ DWORD thread_id;
+ BOOL found;
+
+ if (!pNtGetNextThread)
+ {
+ win_skip("NtGetNextThread is not available.\n");
+ return;
+ }
+
+ event = CreateEventA(NULL, FALSE, FALSE, NULL);
+
+ thread = CreateThread( NULL, 0, test_get_next_thread_proc, event, 0, &thread_id );
+
+ status = pNtGetNextThread(hprocess, NULL, THREAD_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, NULL);
+ ok(status == STATUS_ACCESS_VIOLATION, "Got unexected status %#x.\n", status);
+
+ found = FALSE;
+ prev = NULL;
+ while (!(status = pNtGetNextThread(hprocess, prev, THREAD_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle)))
+ {
+ if (prev)
+ {
+ if (GetThreadId(handle) == thread_id)
+ found = TRUE;
+ pNtClose(prev);
+ }
+ else
+ {
+ ok(GetThreadId(handle) == GetCurrentThreadId(), "Got unexpected thread id %04x, current %04x.\n",
+ GetThreadId(handle), GetCurrentThreadId());
+ }
+ prev = handle;
+ handle = (HANDLE)0xdeadbeef;
+ }
+ pNtClose(prev);
+ ok(!handle, "Got unexpected handle %p.\n", handle);
+ ok(status == STATUS_NO_MORE_ENTRIES, "Unexpected status %#x.\n", status);
+ ok(found, "Thread not found.\n");
+
+ handle = (HANDLE)0xdeadbeef;
+ status = pNtGetNextThread((void *)0xdeadbeef, 0, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle);
+ ok(status == STATUS_INVALID_HANDLE, "Unexpected status %#x.\n", status);
+ ok(!handle, "Got unexpected handle %p.\n", handle);
+ handle = (HANDLE)0xdeadbeef;
+ status = pNtGetNextThread(hprocess, (void *)0xdeadbeef, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle);
+ ok(status == STATUS_INVALID_HANDLE, "Unexpected status %#x.\n", status);
+ ok(!handle, "Got unexpected handle %p.\n", handle);
+
+ /* Reversed search is only supported on recent enough Win10. */
+ status = pNtGetNextThread(hprocess, 0, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 1, &handle);
+ ok(!status || broken(status == STATUS_INVALID_PARAMETER), "Unexpected status %#x.\n", status);
+ if (!status)
+ pNtClose(handle);
+
+ status = pNtGetNextThread(hprocess, 0, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 2, &handle);
+ ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %#x.\n", status);
+
+ SetEvent(event);
+ WaitForSingleObject(thread, INFINITE);
+
+ found = FALSE;
+ prev = NULL;
+ while (!(status = pNtGetNextThread(hprocess, prev, THREAD_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle)))
+ {
+ if (prev)
+ pNtClose(prev);
+ if (GetThreadId(handle) == thread_id)
+ found = TRUE;
+ prev = handle;
+ }
+ pNtClose(prev);
+ ok(found, "Thread not found.\n");
+
+ CloseHandle(thread);
+}
+
START_TEST(om)
{
HMODULE hntdll = GetModuleHandleA("ntdll.dll");
@@ -2615,6 +2706,7 @@ START_TEST(om)
pRtlWakeAddressSingle = (void *)GetProcAddress(hntdll, "RtlWakeAddressSingle");
pNtOpenProcess = (void *)GetProcAddress(hntdll, "NtOpenProcess");
pNtCreateDebugObject = (void *)GetProcAddress(hntdll, "NtCreateDebugObject");
+ pNtGetNextThread = (void *)GetProcAddress(hntdll, "NtGetNextThread");
test_case_sensitive();
test_namespace_pipe();
@@ -2632,4 +2724,5 @@ START_TEST(om)
test_wait_on_address();
test_process();
test_object_types();
+ test_get_next_thread();
}
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 274fae24873..36f90372611 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -1382,3 +1382,32 @@ ULONG WINAPI NtGetCurrentProcessorNumber(void)
/* fallback to the first processor */
return 0;
}
+
+
+/******************************************************************************
+ * NtGetNextThread (NTDLL.@)
+ */
+NTSTATUS WINAPI NtGetNextThread(HANDLE hprocess, HANDLE hthread, ACCESS_MASK access, ULONG attributes,
+ ULONG flags, HANDLE *handle)
+{
+ HANDLE ret_handle;
+ NTSTATUS ret;
+
+ TRACE( "hprocess %p, hthread %p, access %#x, attributes %#x, flags %#x, handle %p.\n",
+ hprocess, hthread, access, attributes, flags, handle );
+
+ SERVER_START_REQ( get_next_thread )
+ {
+ req->process = wine_server_obj_handle( hprocess );
+ req->last = wine_server_obj_handle( hthread );
+ req->access = access;
+ req->attributes = attributes;
+ req->flags = flags;
+ ret = wine_server_call( req );
+ ret_handle = ret ? NULL : wine_server_ptr_handle( reply->handle );
+ }
+ SERVER_END_REQ;
+
+ *handle = ret_handle;
+ return ret;
+}
diff --git a/server/protocol.def b/server/protocol.def
index d061fca7073..9361933d47c 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3687,3 +3687,15 @@ struct handle_info
@REQ(resume_process)
obj_handle_t handle; /* process handle */
@END
+
+
+/* Iterate thread list for process */
+(a)REQ(get_next_thread)
+ obj_handle_t process; /* process handle */
+ obj_handle_t last; /* thread handle to start with */
+ unsigned int access; /* desired access for returned handle */
+ unsigned int attributes; /* returned handle attributes */
+ unsigned int flags; /* controls iteration direction */
+(a)REPLY
+ obj_handle_t handle; /* next thread handle */
+(a)END
diff --git a/server/thread.c b/server/thread.c
index 48f793b6a74..fc8362e2ca0 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1925,3 +1925,53 @@ DECL_HANDLER(get_selector_entry)
release_object( thread );
}
}
+
+/* Iterate thread list for process. Use global thread list to also
+ * return terminated but not yet destroyed threads. */
+DECL_HANDLER(get_next_thread)
+{
+ struct thread *thread, *next;
+ struct process *process;
+ struct list *ptr;
+
+ if ( req->flags > 1 )
+ {
+ set_error( STATUS_INVALID_PARAMETER );
+ return;
+ }
+
+ if (!(process = get_process_from_handle( req->process, PROCESS_QUERY_INFORMATION )))
+ return;
+
+ if (!req->last)
+ {
+ ptr = req->flags ? list_tail( &thread_list ) : list_head( &thread_list );
+ }
+ else if ((thread = get_thread_from_handle( req->last, 0 )))
+ {
+ ptr = req->flags ? list_prev( &thread_list, &thread->entry ) :
+ list_next( &thread_list, &thread->entry );
+ release_object( thread );
+ }
+ else
+ {
+ release_object( process );
+ return;
+ }
+
+ while (ptr)
+ {
+ next = LIST_ENTRY( ptr, struct thread, entry );
+ if (next->process == process)
+ {
+ reply->handle = alloc_handle( current->process, next, req->access, req->attributes );
+ release_object( process );
+ return;
+ }
+ ptr = req->flags ? list_prev( &thread_list, &next->entry )
+ : list_next( &thread_list, &next->entry );
+ }
+
+ set_error( STATUS_NO_MORE_ENTRIES );
+ release_object( process );
+}
--
2.31.1
1
0
[PATCH] reg/tests: Verify that only the (Default) value is overwritten when neither /v nor /ve is specified
by Hugh McMaster 28 Apr '21
by Hugh McMaster 28 Apr '21
28 Apr '21
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
---
programs/reg/tests/add.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c
index 6973eefd892..fdd09c885bc 100644
--- a/programs/reg/tests/add.c
+++ b/programs/reg/tests/add.c
@@ -384,6 +384,15 @@ static void test_add(void)
verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0);
todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_NONE /d Test /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ verify_key(HKEY_CURRENT_USER, KEY_BASE);
+ verify_key(hkey, "Subkey");
+ verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
+ verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0);
+ verify_reg(hkey, NULL, REG_NONE, "T\0e\0s\0t\0\0", 10, 0);
+
close_key(hkey);
delete_tree(HKEY_CURRENT_USER, KEY_BASE);
}
--
2.31.1
1
0
28 Apr '21
The main goal is to get WineTest reports to state that the test was
skipped because rtworkq.dll is missing rather than because of a
possibly unrelated API.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
Restating differently, currently looking at a WineTest report (or
test.winehq.org) I see that the test was skipped on Vista because
of a missing API and I am left to guess whether rtworkq.dll was
available at all.
This patch takes out the guessing part even if nothing can be tested
(so far).
---
dlls/rtworkq/tests/rtworkq.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/dlls/rtworkq/tests/rtworkq.c b/dlls/rtworkq/tests/rtworkq.c
index 627e024d761..6337eb35f3d 100644
--- a/dlls/rtworkq/tests/rtworkq.c
+++ b/dlls/rtworkq/tests/rtworkq.c
@@ -25,6 +25,9 @@
#include "wine/test.h"
+/* functions that are not present on all versions of Windows */
+static HRESULT (WINAPI * pCoGetApartmentType)(APTTYPE *type, APTTYPEQUALIFIER *qualifier);
+
static void test_platform_init(void)
{
APTTYPEQUALIFIER qualifier;
@@ -32,13 +35,13 @@ static void test_platform_init(void)
HRESULT hr;
/* Startup initializes MTA. */
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == CO_E_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = RtwqStartup();
ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr);
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == S_OK || broken(FAILED(hr)) /* Win8 */, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
ok(apttype == APTTYPE_MTA && qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
@@ -47,14 +50,14 @@ static void test_platform_init(void)
hr = RtwqShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == CO_E_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
/* Try with STA initialized before startup. */
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ok(hr == S_OK, "Failed to initialize, hr %#x.\n", hr);
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(apttype == APTTYPE_MAINSTA && qualifier == APTTYPEQUALIFIER_NONE,
"Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
@@ -62,7 +65,7 @@ static void test_platform_init(void)
hr = RtwqStartup();
ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr);
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(apttype == APTTYPE_MAINSTA && qualifier == APTTYPEQUALIFIER_NONE,
"Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
@@ -76,7 +79,7 @@ static void test_platform_init(void)
hr = RtwqStartup();
ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr);
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == S_OK || broken(FAILED(hr)) /* Win8 */, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
ok(apttype == APTTYPE_MTA && qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
@@ -85,14 +88,14 @@ static void test_platform_init(void)
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ok(hr == S_OK, "Failed to initialize, hr %#x.\n", hr);
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(apttype == APTTYPE_MAINSTA && qualifier == APTTYPEQUALIFIER_NONE,
"Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
CoUninitialize();
- hr = CoGetApartmentType(&apttype, &qualifier);
+ hr = pCoGetApartmentType(&apttype, &qualifier);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(apttype == APTTYPE_MTA && qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
"Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
@@ -103,5 +106,13 @@ static void test_platform_init(void)
START_TEST(rtworkq)
{
+ HMODULE hOle32 = GetModuleHandleA("ole32");
+ pCoGetApartmentType = (void*)GetProcAddress(hOle32, "CoGetApartmentType");
+ if (!pCoGetApartmentType)
+ {
+ win_skip("CoGetApartmentType() is missing\n");
+ return;
+ }
+
test_platform_init();
}
--
2.20.1
2
2