Updated ntdll-RtlIpv4StringToAddress patchset

This commit is contained in:
Alistair Leslie-Hughes 2019-08-31 14:25:05 +10:00
parent fd3bb06a4c
commit 6589142220
6 changed files with 693 additions and 230 deletions

View File

@ -0,0 +1,182 @@
From e180b88a8c4c1d2d43cd084264fea48b93c17b3a Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Sun, 25 Aug 2019 18:02:28 -0600
Subject: [PATCH 1/4] ntdll: Implement RtlIpv4StringToAddress(Ex)W
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46149
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
dlls/ntdll/rtl.c | 145 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 141 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index e0d855138f..72ecfd937a 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -884,13 +884,150 @@ void WINAPI RtlCopyLuidAndAttributesArray(
for (i = 0; i < Count; i++) Dest[i] = Src[i];
}
+static BOOL parse_ipv4_component(const WCHAR **str, BOOL strict, ULONG *value)
+{
+ static const int hex_table[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00-0x0F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10-0x1F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x20-0x2F */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 0x30-0x3F */
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x40-0x4F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x50-0x5F */
+ -1, 10, 11, 12, 13, 14, 15 /* 0x60-0x66 */
+ };
+ int base = 10, d;
+ WCHAR c;
+ ULONG cur_value, prev_value = 0;
+ BOOL success = FALSE;
+
+ if (**str == '.')
+ {
+ *str += 1;
+ return FALSE;
+ }
+
+ if ((*str)[0] == '0')
+ {
+ if ((*str)[1] == 'x' || (*str)[1] == 'X')
+ {
+ *str += 2;
+ if (strict) return FALSE;
+ base = 16;
+ }
+ else if ((*str)[1] >= '0' && (*str)[1] <= '9')
+ {
+ *str += 1;
+ if (strict) return FALSE;
+ base = 8;
+ }
+ }
+
+ for (cur_value = 0; **str; *str += 1)
+ {
+ c = **str;
+ if (c >= ARRAY_SIZE(hex_table)) break;
+ d = hex_table[c];
+ if (d == -1 || d >= base) break;
+ cur_value = cur_value * base + d;
+ success = TRUE;
+ if (cur_value < prev_value) return FALSE; /* overflow */
+ prev_value = cur_value;
+ }
+
+ if (success) *value = cur_value;
+ return success;
+}
+
+static NTSTATUS ipv4_string_to_address(const WCHAR *str, BOOL strict,
+ const WCHAR **terminator, IN_ADDR *address, USHORT *port)
+{
+ ULONG fields[4];
+ int n = 0;
+
+ for (;;)
+ {
+ if (!parse_ipv4_component(&str, strict, &fields[n]))
+ goto error;
+ n++;
+ if (*str != '.')
+ break;
+ if (n == 4)
+ goto error;
+ str++;
+ }
+
+ if (strict && n < 4)
+ goto error;
+
+ switch (n)
+ {
+ case 4:
+ if (fields[0] > 0xFF || fields[1] > 0xFF || fields[2] > 0xFF || fields[3] > 0xFF)
+ goto error;
+ address->S_un.S_un_b.s_b1 = fields[0];
+ address->S_un.S_un_b.s_b2 = fields[1];
+ address->S_un.S_un_b.s_b3 = fields[2];
+ address->S_un.S_un_b.s_b4 = fields[3];
+ break;
+ case 3:
+ if (fields[0] > 0xFF || fields[1] > 0xFF || fields[2] > 0xFFFF)
+ goto error;
+ address->S_un.S_un_b.s_b1 = fields[0];
+ address->S_un.S_un_b.s_b2 = fields[1];
+ address->S_un.S_un_b.s_b3 = (fields[2] & 0xFF00) >> 8;
+ address->S_un.S_un_b.s_b4 = (fields[2] & 0x00FF);
+ break;
+ case 2:
+ if (fields[0] > 0xFF || fields[1] > 0xFFFFFF)
+ goto error;
+ address->S_un.S_un_b.s_b1 = fields[0];
+ address->S_un.S_un_b.s_b2 = (fields[1] & 0xFF0000) >> 16;
+ address->S_un.S_un_b.s_b3 = (fields[1] & 0x00FF00) >> 8;
+ address->S_un.S_un_b.s_b4 = (fields[1] & 0x0000FF);
+ break;
+ case 1:
+ address->S_un.S_un_b.s_b1 = (fields[0] & 0xFF000000) >> 24;
+ address->S_un.S_un_b.s_b2 = (fields[0] & 0x00FF0000) >> 16;
+ address->S_un.S_un_b.s_b3 = (fields[0] & 0x0000FF00) >> 8;
+ address->S_un.S_un_b.s_b4 = (fields[0] & 0x000000FF);
+ break;
+ default:
+ goto error;
+ }
+
+ if (terminator) *terminator = str;
+
+ if (*str == ':')
+ {
+ str++;
+ if (!parse_ipv4_component(&str, FALSE, &fields[0]))
+ goto error;
+ if (!fields[0] || fields[0] > 0xFFFF || *str)
+ goto error;
+ if (port)
+ {
+ *port = htons(fields[0]);
+ if (terminator) *terminator = str;
+ }
+ }
+
+ if (!terminator && *str)
+ return STATUS_INVALID_PARAMETER;
+ return STATUS_SUCCESS;
+
+error:
+ if (terminator) *terminator = str;
+ return STATUS_INVALID_PARAMETER;
+}
+
/***********************************************************************
* RtlIpv4StringToAddressExW [NTDLL.@]
*/
NTSTATUS WINAPI RtlIpv4StringToAddressExW(const WCHAR *str, BOOLEAN strict, IN_ADDR *address, USHORT *port)
{
- FIXME("(%s, %u, %p, %p): stub\n", debugstr_w(str), strict, address, port);
- return STATUS_NOT_IMPLEMENTED;
+ TRACE("(%s, %u, %p, %p)\n", debugstr_w(str), strict, address, port);
+ if (!str || !address || !port) return STATUS_INVALID_PARAMETER;
+ return ipv4_string_to_address(str, strict, NULL, address, port);
}
/***********************************************************************
@@ -898,8 +1035,8 @@ NTSTATUS WINAPI RtlIpv4StringToAddressExW(const WCHAR *str, BOOLEAN strict, IN_A
*/
NTSTATUS WINAPI RtlIpv4StringToAddressW(const WCHAR *str, BOOLEAN strict, const WCHAR **terminator, IN_ADDR *address)
{
- FIXME("(%s, %u, %p, %p): stub\n", debugstr_w(str), strict, terminator, address);
- return STATUS_NOT_IMPLEMENTED;
+ TRACE("(%s, %u, %p, %p)\n", debugstr_w(str), strict, terminator, address);
+ return ipv4_string_to_address(str, strict, terminator, address, NULL);
}
/***********************************************************************
--
2.23.0

View File

@ -1,21 +1,20 @@
From 602c4ef16d69695bcce9484e34fb72fb36ea8684 Mon Sep 17 00:00:00 2001
From 2f39a185e26072c7c776a1475236d798ebf267f0 Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Thu, 4 Jul 2019 10:22:40 -0600
Subject: [PATCH 2/3] ntdll: Implement RtlIpv4StringToAddress(Ex)A
Date: Sun, 25 Aug 2019 17:18:06 -0600
Subject: [PATCH 2/4] ntdll: Implement RtlIpv4StringToAddress(Ex)A
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46149
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
dlls/ntdll/ntdll.spec | 4 +-
dlls/ntdll/rtl.c | 155 ++++++++++++++++++++++++++++
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 4 +-
3 files changed, 159 insertions(+), 4 deletions(-)
dlls/ntdll/ntdll.spec | 4 ++--
dlls/ntdll/rtl.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 323d5eae77..0821da0fd5 100644
index 82c78f6e78..8cacc97ec4 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -757,8 +757,8 @@
@@ -760,8 +760,8 @@
@ stdcall RtlIpv4AddressToStringExA(ptr long ptr ptr)
@ stdcall RtlIpv4AddressToStringExW(ptr long ptr ptr)
@ stdcall RtlIpv4AddressToStringW(ptr ptr)
@ -27,157 +26,27 @@ index 323d5eae77..0821da0fd5 100644
@ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr)
# @ stub RtlIpv6AddressToStringA
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index e0d855138f..30fcb00e05 100644
index 72ecfd937a..1604513e7e 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -884,6 +884,161 @@ void WINAPI RtlCopyLuidAndAttributesArray(
for (i = 0; i < Count; i++) Dest[i] = Src[i];
@@ -1039,6 +1039,39 @@ NTSTATUS WINAPI RtlIpv4StringToAddressW(const WCHAR *str, BOOLEAN strict, const
return ipv4_string_to_address(str, strict, terminator, address, NULL);
}
+static BOOL parse_ipv4_component(const char **str, BOOL strict, ULONG *value)
+{
+ static const int hex_table[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00-0x0F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10-0x1F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x20-0x2F */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 0x30-0x3F */
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x40-0x4F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x50-0x5F */
+ -1, 10, 11, 12, 13, 14, 15 /* 0x60-0x66 */
+ };
+ int base = 10, d;
+ unsigned char c;
+ ULONG cur_value, prev_value = 0;
+ BOOL success = FALSE;
+
+ if (**str == '.')
+ {
+ *str += 1;
+ return FALSE;
+ }
+
+ if ((*str)[0] == '0')
+ {
+ if (tolower((*str)[1]) == 'x')
+ {
+ *str += 2;
+ if (strict) return FALSE;
+ base = 16;
+ }
+ else if (isdigit((*str)[1]))
+ {
+ *str += 1;
+ if (strict) return FALSE;
+ base = 8;
+ }
+ }
+
+ for (cur_value = 0; **str; *str += 1)
+ {
+ c = (unsigned char)**str;
+ if (c >= ARRAY_SIZE(hex_table)) break;
+ d = hex_table[c];
+ if (d == -1 || d >= base) break;
+ cur_value = cur_value * base + d;
+ success = TRUE;
+ if (cur_value < prev_value) return FALSE; /* overflow */
+ prev_value = cur_value;
+ }
+
+ if (success) *value = cur_value;
+ return success;
+}
+
+static NTSTATUS ipv4_string_to_address(const char *str, BOOL strict,
+ const char **terminator, IN_ADDR *address, USHORT *port)
+{
+ ULONG fields[4];
+ int n = 0;
+
+ for (;;)
+ {
+ if (!parse_ipv4_component(&str, strict, &fields[n]))
+ goto error;
+ n++;
+ if (*str != '.')
+ break;
+ if (n == 4)
+ goto error;
+ str++;
+ }
+
+ if (strict && n < 4)
+ goto error;
+
+ switch (n)
+ {
+ case 4:
+ if (fields[0] > 0xFF || fields[1] > 0xFF || fields[2] > 0xFF || fields[3] > 0xFF)
+ goto error;
+ address->S_un.S_un_b.s_b1 = fields[0];
+ address->S_un.S_un_b.s_b2 = fields[1];
+ address->S_un.S_un_b.s_b3 = fields[2];
+ address->S_un.S_un_b.s_b4 = fields[3];
+ break;
+ case 3:
+ if (fields[0] > 0xFF || fields[1] > 0xFF || fields[2] > 0xFFFF)
+ goto error;
+ address->S_un.S_un_b.s_b1 = fields[0];
+ address->S_un.S_un_b.s_b2 = fields[1];
+ address->S_un.S_un_b.s_b3 = (fields[2] & 0xFF00) >> 8;
+ address->S_un.S_un_b.s_b4 = (fields[2] & 0x00FF);
+ break;
+ case 2:
+ if (fields[0] > 0xFF || fields[1] > 0xFFFFFF)
+ goto error;
+ address->S_un.S_un_b.s_b1 = fields[0];
+ address->S_un.S_un_b.s_b2 = (fields[1] & 0xFF0000) >> 16;
+ address->S_un.S_un_b.s_b3 = (fields[1] & 0x00FF00) >> 8;
+ address->S_un.S_un_b.s_b4 = (fields[1] & 0x0000FF);
+ break;
+ case 1:
+ address->S_un.S_un_b.s_b1 = (fields[0] & 0xFF000000) >> 24;
+ address->S_un.S_un_b.s_b2 = (fields[0] & 0x00FF0000) >> 16;
+ address->S_un.S_un_b.s_b3 = (fields[0] & 0x0000FF00) >> 8;
+ address->S_un.S_un_b.s_b4 = (fields[0] & 0x000000FF);
+ break;
+ default:
+ goto error;
+ }
+
+ if (terminator) *terminator = str;
+
+ if (*str == ':')
+ {
+ str++;
+ if (!parse_ipv4_component(&str, FALSE, &fields[0]))
+ goto error;
+ if (!fields[0] || fields[0] > 0xFFFF || *str)
+ goto error;
+ if (port)
+ {
+ *port = (fields[0] << 8) | (fields[0] >> 8);
+ if (terminator) *terminator = str;
+ }
+ }
+
+ if (!terminator && *str)
+ return STATUS_INVALID_PARAMETER;
+ return STATUS_SUCCESS;
+
+error:
+ if (terminator) *terminator = str;
+ return STATUS_INVALID_PARAMETER;
+}
+
+/***********************************************************************
+ * RtlIpv4StringToAddressExA [NTDLL.@]
+ */
+NTSTATUS WINAPI RtlIpv4StringToAddressExA(const char *str, BOOLEAN strict, IN_ADDR *address, USHORT *port)
+{
+ WCHAR wstr[32];
+
+ TRACE("(%s, %u, %p, %p)\n", debugstr_a(str), strict, address, port);
+ if (!str || !address || !port) return STATUS_INVALID_PARAMETER;
+ return ipv4_string_to_address(str, strict, NULL, address, port);
+
+ if (!str || !address || !port)
+ return STATUS_INVALID_PARAMETER;
+
+ RtlMultiByteToUnicodeN(wstr, sizeof(wstr), NULL, str, strlen(str) + 1);
+ return ipv4_string_to_address(wstr, strict, NULL, address, port);
+}
+
+/***********************************************************************
@ -185,28 +54,21 @@ index e0d855138f..30fcb00e05 100644
+ */
+NTSTATUS WINAPI RtlIpv4StringToAddressA(const char *str, BOOLEAN strict, const char **terminator, IN_ADDR *address)
+{
+ WCHAR wstr[32];
+ const WCHAR *wterminator;
+ NTSTATUS ret;
+
+ TRACE("(%s, %u, %p, %p)\n", debugstr_a(str), strict, terminator, address);
+ return ipv4_string_to_address(str, strict, terminator, address, NULL);
+
+ RtlMultiByteToUnicodeN(wstr, sizeof(wstr), NULL, str, strlen(str) + 1);
+ ret = ipv4_string_to_address(wstr, strict, &wterminator, address, NULL);
+ if (terminator) *terminator = str + (wterminator - wstr);
+ return ret;
+}
+
/***********************************************************************
* RtlIpv4StringToAddressExW [NTDLL.@]
* RtlIpv6StringToAddressExW [NTDLL.@]
*/
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 359e2d9e69..439cae3097 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -1101,8 +1101,8 @@
@ stdcall RtlIpv4AddressToStringExA(ptr long ptr ptr)
@ stdcall RtlIpv4AddressToStringExW(ptr long ptr ptr)
@ stdcall RtlIpv4AddressToStringW(ptr ptr)
-@ stub RtlIpv4StringToAddressA
-@ stub RtlIpv4StringToAddressExA
+@ stdcall RtlIpv4StringToAddressA(str long ptr ptr) ntdll.RtlIpv4StringToAddressA
+@ stdcall RtlIpv4StringToAddressExA(str long ptr ptr) ntdll.RtlIpv4StringToAddressExA
@ stdcall RtlIpv4StringToAddressExW(wstr long ptr ptr)
@ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr)
@ stub RtlIpv6AddressToStringA
--
2.20.1
2.23.0

View File

@ -0,0 +1,410 @@
From fc9f2edd5b456e2b2eedecc87a175f2cdae54c35 Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Fri, 30 Aug 2019 13:43:17 -0600
Subject: [PATCH 3/4] ntdll: Add semi-stub for RtlIpv6AddressToString(Ex)A
All of the strings produced by the semi-stub are valid IPv6 addresses,
though not necessarily in the same format that Windows would give them
in.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
dlls/ntdll/ntdll.spec | 4 +-
dlls/ntdll/rtl.c | 79 +++++++++++++++++
dlls/ntdll/tests/rtl.c | 190 +++++++++++++++++++++--------------------
3 files changed, 180 insertions(+), 93 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 8cacc97ec4..13e39e09b4 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -764,8 +764,8 @@
@ stdcall RtlIpv4StringToAddressExA(str long ptr ptr)
@ stdcall RtlIpv4StringToAddressExW(wstr long ptr ptr)
@ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr)
-# @ stub RtlIpv6AddressToStringA
-# @ stub RtlIpv6AddressToStringExA
+@ stdcall RtlIpv6AddressToStringA(ptr ptr)
+@ stdcall RtlIpv6AddressToStringExA(ptr long long ptr ptr)
# @ stub RtlIpv6AddressToStringExW
# @ stub RtlIpv6AddressToStringW
# @ stub RtlIpv6StringToAddressA
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 1604513e7e..8b6826e181 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -1194,6 +1194,85 @@ CHAR * WINAPI RtlIpv4AddressToStringA(const IN_ADDR *pin, LPSTR buffer)
return buffer + size - 1;
}
+/***********************************************************************
+ * RtlIpv6AddressToStringExA [NTDLL.@]
+ */
+NTSTATUS WINAPI RtlIpv6AddressToStringExA(const IN6_ADDR *address, ULONG scope, USHORT port, char *str, ULONG *len)
+{
+ char buffer[64];
+ int buffer_len;
+ NTSTATUS ret;
+
+ FIXME("(%p %u %u %p %p): semi-stub\n", address, scope, port, str, len);
+
+ if (!address || !str || !len)
+ return STATUS_INVALID_PARAMETER;
+
+ if (scope && port)
+ {
+ buffer_len = sprintf(buffer, "[%x:%x:%x:%x:%x:%x:%x:%x%%%u]:%u",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]),
+ scope, ntohs(port));
+ }
+ else if (scope)
+ {
+ buffer_len = sprintf(buffer, "%x:%x:%x:%x:%x:%x:%x:%x%%%u",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]),
+ scope);
+ }
+ else if (port)
+ {
+ buffer_len = sprintf(buffer, "[%x:%x:%x:%x:%x:%x:%x:%x]:%u",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]),
+ ntohs(port));
+ }
+ else
+ {
+ buffer_len = sprintf(buffer, "%x:%x:%x:%x:%x:%x:%x:%x",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]));
+ }
+ buffer[buffer_len] = 0;
+ buffer_len++;
+
+ if (buffer_len <= *len)
+ {
+ strcpy(str, buffer);
+ ret = STATUS_SUCCESS;
+ }
+ else
+ {
+ ret = STATUS_INVALID_PARAMETER;
+ }
+
+ *len = buffer_len;
+ return ret;
+}
+
+/***********************************************************************
+ * RtlIpv6AddressToStringA [NTDLL.@]
+ */
+char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str)
+{
+ ULONG len = 46;
+ if (!address || !str) return str;
+ str[45] = 0;
+ if (FAILED(RtlIpv6AddressToStringExA(address, 0, 0, str, &len)))
+ return str;
+ return str + len - 1;
+}
+
/***********************************************************************
* get_pointer_obfuscator (internal)
*/
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 3e1d92c3d2..b7822d370d 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -1775,80 +1775,81 @@ static void test_RtlIpv6AddressToString(void)
LPCSTR result;
IN6_ADDR ip;
DWORD_PTR len;
- struct
+ static const struct
{
PCSTR address;
int ip[8];
+ BOOL todo;
} tests[] =
{
/* ipv4 addresses & ISATAP addresses */
- { "::13.1.68.3", { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "::ffff:13.1.68.3", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0x344 } },
- { "::feff:d01:4403", { 0, 0, 0, 0, 0, 0xfffe, 0x10d, 0x344 } },
- { "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 } },
- { "::100:d01:4403", { 0, 0, 0, 0, 0, 1, 0x10d, 0x344 } },
- { "::1:d01:4403", { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "::ffff:0:4403", { 0, 0, 0, 0, 0, 0xffff, 0, 0x344 } },
- { "::ffff:13.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0 } },
- { "::ffff:0:0", { 0, 0, 0, 0, 0, 0xffff, 0, 0 } },
- { "::ffff:0:13.1.68.3", { 0, 0, 0, 0, 0xffff, 0, 0x10d, 0x344 } },
- { "::ffff:ffff:d01:4403", { 0, 0, 0, 0, 0xffff, 0xffff, 0x10d, 0x344 } },
- { "::ffff:0:0:d01:4403", { 0, 0, 0, 0xffff, 0, 0, 0x10d, 0x344 } },
- { "::ffff:255.255.255.255", { 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff } },
- { "::ffff:129.144.52.38", { 0, 0, 0, 0, 0, 0xffff, 0x9081, 0x2634 } },
- { "::5efe:129.144.52.38", { 0, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333:4444:0:5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333::5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222::5efe:129.144.52.38", { 0x1111, 0x2222, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111::5efe:129.144.52.38", { 0x1111, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "::200:5efe:129.144.52.38", { 0, 0, 0, 0, 2, 0xfe5e, 0x9081, 0x2634 } },
- { "::100:5efe:8190:3426", { 0, 0, 0, 0, 1, 0xfe5e, 0x9081, 0x2634 } },
+ { "::13.1.68.3", { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::ffff:13.1.68.3", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0x344 }, TRUE },
+ { "::feff:d01:4403", { 0, 0, 0, 0, 0, 0xfffe, 0x10d, 0x344 }, TRUE },
+ { "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 }, TRUE },
+ { "::100:d01:4403", { 0, 0, 0, 0, 0, 1, 0x10d, 0x344 }, TRUE },
+ { "::1:d01:4403", { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "::ffff:0:4403", { 0, 0, 0, 0, 0, 0xffff, 0, 0x344 }, TRUE },
+ { "::ffff:13.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0 }, TRUE },
+ { "::ffff:0:0", { 0, 0, 0, 0, 0, 0xffff, 0, 0 }, TRUE },
+ { "::ffff:0:13.1.68.3", { 0, 0, 0, 0, 0xffff, 0, 0x10d, 0x344 }, TRUE },
+ { "::ffff:ffff:d01:4403", { 0, 0, 0, 0, 0xffff, 0xffff, 0x10d, 0x344 }, TRUE },
+ { "::ffff:0:0:d01:4403", { 0, 0, 0, 0xffff, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::ffff:255.255.255.255", { 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff }, TRUE },
+ { "::ffff:129.144.52.38", { 0, 0, 0, 0, 0, 0xffff, 0x9081, 0x2634 }, TRUE },
+ { "::5efe:129.144.52.38", { 0, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333::5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222::5efe:129.144.52.38", { 0x1111, 0x2222, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111::5efe:129.144.52.38", { 0x1111, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "::200:5efe:129.144.52.38", { 0, 0, 0, 0, 2, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "::100:5efe:8190:3426", { 0, 0, 0, 0, 1, 0xfe5e, 0x9081, 0x2634 }, TRUE },
/* 'normal' addresses */
- { "::1", { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
+ { "::1", { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
{ "0:1:2:3:4:5:6:7", { 0, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700 } },
- { "1080::8:800:200c:417a", { 0x8010, 0, 0, 0, 0x800, 0x8, 0x0c20, 0x7a41 } },
+ { "1080::8:800:200c:417a", { 0x8010, 0, 0, 0, 0x800, 0x8, 0x0c20, 0x7a41 }, TRUE },
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111:2222:3333:4444:5555:6666::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0 } },
+ { "1111:2222:3333:4444:5555:6666::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0 }, TRUE },
{ "1111:2222:3333:4444:5555:6666:0:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0x8888 } },
- { "1111:2222:3333:4444:5555::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0 } },
+ { "1111:2222:3333:4444:5555::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0 }, TRUE },
{ "1111:2222:3333:4444:5555:0:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0x7b7b, 0x7b7b } },
{ "1111:2222:3333:4444:5555:0:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0x7777, 0x8888 } },
- { "1111:2222:3333:4444:5555::8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8888 } },
- { "1111::", { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "1111::7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } },
+ { "1111:2222:3333:4444:5555::8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8888 }, TRUE },
+ { "1111::", { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b }, TRUE },
{ "1111:0:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "1111:0:3333:4444:5555:6666:7777:8888", { 0x1111, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111::4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::4444:5555:6666:7777:8888", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111::5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::5555:6666:7777:8888", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111::6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::6666:7777:8888", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7777, 0x8888 } },
- { "1111::7777:8888", { 0x1111, 0, 0, 0, 0, 0, 0x7777, 0x8888 } },
- { "1111::8888", { 0x1111, 0, 0, 0, 0, 0, 0, 0x8888 } },
+ { "1111::4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b }, TRUE },
+ { "1111::4444:5555:6666:7777:8888", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 }, TRUE },
+ { "1111::5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7b7b, 0x7b7b }, TRUE },
+ { "1111::5555:6666:7777:8888", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7777, 0x8888 }, TRUE },
+ { "1111::6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7b7b, 0x7b7b }, TRUE },
+ { "1111::6666:7777:8888", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7777, 0x8888 }, TRUE },
+ { "1111::7777:8888", { 0x1111, 0, 0, 0, 0, 0, 0x7777, 0x8888 }, TRUE },
+ { "1111::8888", { 0x1111, 0, 0, 0, 0, 0, 0, 0x8888 }, TRUE },
{ "1:2:3:4:5:6:102:304", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x201, 0x403 } },
{ "1:2:3:4:5:6:7:8", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700, 0x800 } },
- { "1:2:3:4:5:6::", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0 } },
+ { "1:2:3:4:5:6::", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0 }, TRUE },
{ "1:2:3:4:5:6:0:8", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0x800 } },
- { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 } },
+ { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 }, TRUE },
{ "2001:0:4136:e378:8000:63bf:3fff:fdd2", { 0x120, 0, 0x3641, 0x78e3, 0x80, 0xbf63, 0xff3f, 0xd2fd } },
- { "2001:db8::1428:57ab", { 0x120, 0xb80d, 0, 0, 0, 0, 0x2814, 0xab57 } },
+ { "2001:db8::1428:57ab", { 0x120, 0xb80d, 0, 0, 0, 0, 0x2814, 0xab57 }, TRUE },
{ "2001:db8:1234:ffff:ffff:ffff:ffff:ffff", { 0x120, 0xb80d, 0x3412, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } },
{ "2001:0:ce49:7601:2cad:dfff:7c94:fffe", { 0x120, 0, 0x49ce, 0x176, 0xad2c, 0xffdf, 0x947c, 0xfeff } },
- { "2001:db8:85a3::8a2e:370:7334", { 0x120, 0xb80d, 0xa385, 0, 0, 0x2e8a, 0x7003, 0x3473 } },
- { "3ffe:b00::1:0:0:a", { 0xfe3f, 0xb, 0, 0, 0x100, 0, 0, 0xa00 } },
- { "::a:b:c:d:e", { 0, 0, 0, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00 } },
- { "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } },
+ { "2001:db8:85a3::8a2e:370:7334", { 0x120, 0xb80d, 0xa385, 0, 0, 0x2e8a, 0x7003, 0x3473 }, TRUE },
+ { "3ffe:b00::1:0:0:a", { 0xfe3f, 0xb, 0, 0, 0x100, 0, 0, 0xa00 }, TRUE },
+ { "::a:b:c:d:e", { 0, 0, 0, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00 }, TRUE },
+ { "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b }, TRUE },
{ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } },
{ "1111:2222:3333:4444:5555:6666:7777:1", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x100 } },
{ "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 } },
- { "1111::3333:4444:5555:6666:7777", { 0x1111, 0, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777 } },
- { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 } },
- { "1111::3333", { 0x1111, 0, 0, 0, 0, 0, 0, 0x3333 } },
- { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 } },
- { "2001::ffd3", { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
+ { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::3333:4444:5555:6666:7777", { 0x1111, 0, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777 }, TRUE },
+ { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::3333", { 0x1111, 0, 0, 0, 0, 0, 0, 0x3333 }, TRUE },
+ { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 }, TRUE },
+ { "2001::ffd3", { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
};
unsigned int i;
@@ -1864,10 +1865,12 @@ static void test_RtlIpv6AddressToString(void)
result = pRtlIpv6AddressToStringA(&ip, buffer);
len = strlen(buffer);
+todo_wine
ok(result == (buffer + len) && !strcmp(buffer, "::"),
"got %p with '%s' (expected %p with '::')\n", result, buffer, buffer + len);
result = pRtlIpv6AddressToStringA(&ip, NULL);
+todo_wine
ok(result == (LPCSTR)~0 || broken(result == (LPCSTR)len) /* WinXP / Win2k3 */,
"got %p, expected %p\n", result, (LPCSTR)~0);
@@ -1879,6 +1882,7 @@ static void test_RtlIpv6AddressToString(void)
result = pRtlIpv6AddressToStringA(&ip, buffer);
len = strlen(buffer);
+todo_wine_if(tests[i].todo)
ok(result == (buffer + len) && !strcmp(buffer, tests[i].address),
"got %p with '%s' (expected %p with '%s')\n", result, buffer, buffer + len, tests[i].address);
@@ -1894,42 +1898,43 @@ static void test_RtlIpv6AddressToStringEx(void)
NTSTATUS res;
IN6_ADDR ip;
ULONG len;
- struct
+ static const struct
{
PCSTR address;
ULONG scopeid;
USHORT port;
int ip[8];
+ BOOL todo;
} tests[] =
{
/* ipv4 addresses & ISATAP addresses */
- { "::13.1.68.3", 0, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "::13.1.68.3%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "::13.1.68.3%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "[::13.1.68.3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "[::13.1.68.3%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "[::13.1.68.3]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
-
- { "::1:d01:4403", 0, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "::1:d01:4403%1", 1, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "::1:d01:4403%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "[::1:d01:4403%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "[::1:d01:4403%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "[::1:d01:4403]:256", 0, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
-
- { "1111:2222:3333:4444:0:5efe:129.144.52.38", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333:4444:0:5efe:129.144.52.38%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819", 0xffffbbbb, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:65518",0xffffbbbb, 0xeeff, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "[1111:2222:3333:4444:0:5efe:129.144.52.38]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
-
- { "::1", 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "::1%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "::1%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "[::1%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "[::1%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "[::1]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
+ { "::13.1.68.3", 0, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::13.1.68.3%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::13.1.68.3%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "[::13.1.68.3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "[::13.1.68.3%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "[::13.1.68.3]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+
+ { "::1:d01:4403", 0, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "::1:d01:4403%1", 1, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "::1:d01:4403%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "[::1:d01:4403%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "[::1:d01:4403%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "[::1:d01:4403]:256", 0, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819", 0xffffbbbb, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:65518",0xffffbbbb, 0xeeff, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "[1111:2222:3333:4444:0:5efe:129.144.52.38]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+
+ { "::1", 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "::1%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "::1%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "[::1%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "[::1%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "[::1]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
@@ -1938,19 +1943,19 @@ static void test_RtlIpv6AddressToStringEx(void)
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::", 0, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "1111::%1", 1, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "1111::%4294949819", 0xffffbbbb, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "[1111::%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "[1111::%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "[1111::]:256", 0, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
-
- { "2001::ffd3", 0, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "2001::ffd3%1", 1, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "2001::ffd3%4294949819", 0xffffbbbb, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "[2001::ffd3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "[2001::ffd3%4294949819]:256", 0xffffbbbb, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "[2001::ffd3]:256", 0, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
+ { "1111::", 0, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::%1", 1, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::%4294949819", 0xffffbbbb, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "[1111::%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "[1111::%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "[1111::]:256", 0, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+
+ { "2001::ffd3", 0, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "2001::ffd3%1", 1, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "2001::ffd3%4294949819", 0xffffbbbb, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "[2001::ffd3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "[2001::ffd3%4294949819]:256", 0xffffbbbb, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "[2001::ffd3]:256", 0, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
};
unsigned int i;
@@ -1967,6 +1972,7 @@ static void test_RtlIpv6AddressToStringEx(void)
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, &len);
ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res);
+todo_wine
ok(len == 3 && !strcmp(buffer, "::"),
"got len %d with '%s' (expected 3 with '::')\n", len, buffer);
@@ -1990,6 +1996,7 @@ static void test_RtlIpv6AddressToStringEx(void)
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, &len);
ok(res == STATUS_INVALID_PARAMETER, "[null length] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res);
ok(buffer[0] == '#', "got first char %c (expected '#')\n", buffer[0]);
+todo_wine
ok(len == 3, "got len %d (expected len 3)\n", len);
for (i = 0; i < ARRAY_SIZE(tests); i++)
@@ -2002,6 +2009,7 @@ static void test_RtlIpv6AddressToStringEx(void)
res = pRtlIpv6AddressToStringExA(&ip, tests[i].scopeid, tests[i].port, buffer, &len);
ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res);
+todo_wine_if(tests[i].todo)
ok(len == (strlen(tests[i].address) + 1) && !strcmp(buffer, tests[i].address),
"got len %d with '%s' (expected %d with '%s')\n", len, buffer, (int)strlen(tests[i].address), tests[i].address);
}
--
2.23.0

View File

@ -1,59 +0,0 @@
From 9bb81fd1205daf2cccacf4c6a4f8d23eb3a1c216 Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Thu, 4 Jul 2019 10:22:41 -0600
Subject: [PATCH 3/3] ntdll: Implement RtlIpv4StringToAddress(Ex)W
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46149
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
dlls/ntdll/rtl.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 30fcb00e05..3eb8181e32 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -1044,8 +1044,17 @@ NTSTATUS WINAPI RtlIpv4StringToAddressA(const char *str, BOOLEAN strict, const c
*/
NTSTATUS WINAPI RtlIpv4StringToAddressExW(const WCHAR *str, BOOLEAN strict, IN_ADDR *address, USHORT *port)
{
- FIXME("(%s, %u, %p, %p): stub\n", debugstr_w(str), strict, address, port);
- return STATUS_NOT_IMPLEMENTED;
+ char cstr[32];
+ ULONG clen;
+
+ TRACE("(%s, %u, %p, %p)\n", debugstr_w(str), strict, address, port);
+
+ if (!str || !address || !port)
+ return STATUS_INVALID_PARAMETER;
+
+ RtlUnicodeToMultiByteN(cstr, sizeof(cstr) - 1, &clen, str, strlenW(str));
+ cstr[clen] = 0;
+ return ipv4_string_to_address(cstr, strict, NULL, address, port);
}
/***********************************************************************
@@ -1053,8 +1062,18 @@ NTSTATUS WINAPI RtlIpv4StringToAddressExW(const WCHAR *str, BOOLEAN strict, IN_A
*/
NTSTATUS WINAPI RtlIpv4StringToAddressW(const WCHAR *str, BOOLEAN strict, const WCHAR **terminator, IN_ADDR *address)
{
- FIXME("(%s, %u, %p, %p): stub\n", debugstr_w(str), strict, terminator, address);
- return STATUS_NOT_IMPLEMENTED;
+ char cstr[32];
+ ULONG clen;
+ const char *cterminator;
+ NTSTATUS ret;
+
+ TRACE("(%s, %u, %p, %p)\n", debugstr_w(str), strict, terminator, address);
+
+ RtlUnicodeToMultiByteN(cstr, sizeof(cstr) - 1, &clen, str, strlenW(str));
+ cstr[clen] = 0;
+ ret = ipv4_string_to_address(cstr, strict, &cterminator, address, NULL);
+ if (terminator) *terminator = str + (cterminator - cstr);
+ return ret;
}
/***********************************************************************
--
2.20.1

View File

@ -0,0 +1,64 @@
From cbc86e2e9b964df11a2d7c0e9e933123ef45b69c Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Fri, 30 Aug 2019 13:43:52 -0600
Subject: [PATCH 4/4] ntdll: Implement RtlIpv6AddressToString(Ex)W
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
dlls/ntdll/ntdll.spec | 4 ++--
dlls/ntdll/rtl.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 13e39e09b4..9816017c79 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -766,8 +766,8 @@
@ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr)
@ stdcall RtlIpv6AddressToStringA(ptr ptr)
@ stdcall RtlIpv6AddressToStringExA(ptr long long ptr ptr)
-# @ stub RtlIpv6AddressToStringExW
-# @ stub RtlIpv6AddressToStringW
+@ stdcall RtlIpv6AddressToStringExW(ptr long long ptr ptr)
+@ stdcall RtlIpv6AddressToStringW(ptr ptr)
# @ stub RtlIpv6StringToAddressA
# @ stub RtlIpv6StringToAddressExA
@ stdcall RtlIpv6StringToAddressExW(wstr ptr ptr ptr)
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 8b6826e181..f481969549 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -1273,6 +1273,30 @@ char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str)
return str + len - 1;
}
+/***********************************************************************
+ * RtlIpv6AddressToStringExW [NTDLL.@]
+ */
+NTSTATUS WINAPI RtlIpv6AddressToStringExW(const IN6_ADDR *address, ULONG scope, USHORT port, WCHAR *str, ULONG *len)
+{
+ char cstr[64];
+ NTSTATUS ret = RtlIpv6AddressToStringExA(address, scope, port, cstr, len);
+ if (SUCCEEDED(ret)) RtlMultiByteToUnicodeN(str, *len * sizeof(WCHAR), NULL, cstr, *len);
+ return ret;
+}
+
+/***********************************************************************
+ * RtlIpv6AddressToStringW [NTDLL.@]
+ */
+WCHAR * WINAPI RtlIpv6AddressToStringW(const IN6_ADDR *address, WCHAR *str)
+{
+ ULONG len = 46;
+ if (!address || !str) return str;
+ str[45] = 0;
+ if (FAILED(RtlIpv6AddressToStringExW(address, 0, 0, str, &len)))
+ return str;
+ return str + len - 1;
+}
+
/***********************************************************************
* get_pointer_obfuscator (internal)
*/
--
2.23.0

View File

@ -4909,14 +4909,18 @@ fi
# | * [#46149] ntdll: Implement RtlIpv4StringToAddress(Ex)A/W
# |
# | Modified files:
# | * dlls/ntdll/ntdll.spec, dlls/ntdll/rtl.c, dlls/ntoskrnl.exe/ntoskrnl.exe.spec
# | * dlls/ntdll/ntdll.spec, dlls/ntdll/rtl.c, dlls/ntdll/tests/rtl.c
# |
if test "$enable_ntdll_RtlIpv4StringToAddress" -eq 1; then
patch_apply ntdll-RtlIpv4StringToAddress/0001-ntdll-Implement-RtlIpv4StringToAddress-Ex-W.patch
patch_apply ntdll-RtlIpv4StringToAddress/0002-ntdll-Implement-RtlIpv4StringToAddress-Ex-A.patch
patch_apply ntdll-RtlIpv4StringToAddress/0003-ntdll-Implement-RtlIpv4StringToAddress-Ex-W.patch
patch_apply ntdll-RtlIpv4StringToAddress/0003-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch
patch_apply ntdll-RtlIpv4StringToAddress/0004-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch
(
printf '%s\n' '+ { "Alex Henrie", "ntdll: Implement RtlIpv4StringToAddress(Ex)A.", 1 },';
printf '%s\n' '+ { "Alex Henrie", "ntdll: Implement RtlIpv4StringToAddress(Ex)W.", 1 },';
printf '%s\n' '+ { "Alex Henrie", "ntdll: Implement RtlIpv4StringToAddress(Ex)A.", 1 },';
printf '%s\n' '+ { "Alex Henrie", "ntdll: Add semi-stub for RtlIpv6AddressToString(Ex)A.", 1 },';
printf '%s\n' '+ { "Alex Henrie", "ntdll: Implement RtlIpv6AddressToString(Ex)W.", 1 },';
) >> "$patchlist"
fi