From f57d1b8d02183550389ccd943e1ee4e4455c6656 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 29 Jan 2020 10:57:47 +1100 Subject: [PATCH] Updated ntdll-RtlIpv4StringToAddress patchset --- ...plement-RtlIpv6StringToAddress-Ex-AW.patch | 331 ++++++++++++++++++ ...ude-Add-RtlIpv6StringToAddress-Ex-AW.patch | 31 ++ ...nt-ParseNetworkString-for-IPv6-addre.patch | 73 ++++ ...tub-for-RtlIpv6AddressToString-Ex-A.patch} | 18 +- ...plement-RtlIpv6AddressToString-Ex-W.patch} | 18 +- patches/patchinstall.sh | 12 +- 6 files changed, 462 insertions(+), 21 deletions(-) create mode 100644 patches/ntdll-RtlIpv4StringToAddress/0001-ntdll-Implement-RtlIpv6StringToAddress-Ex-AW.patch create mode 100644 patches/ntdll-RtlIpv4StringToAddress/0002-include-Add-RtlIpv6StringToAddress-Ex-AW.patch create mode 100644 patches/ntdll-RtlIpv4StringToAddress/0003-iphlpapi-Implement-ParseNetworkString-for-IPv6-addre.patch rename patches/ntdll-RtlIpv4StringToAddress/{0003-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch => 0004-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch} (98%) rename patches/ntdll-RtlIpv4StringToAddress/{0004-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch => 0005-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch} (83%) diff --git a/patches/ntdll-RtlIpv4StringToAddress/0001-ntdll-Implement-RtlIpv6StringToAddress-Ex-AW.patch b/patches/ntdll-RtlIpv4StringToAddress/0001-ntdll-Implement-RtlIpv6StringToAddress-Ex-AW.patch new file mode 100644 index 00000000..10d5b341 --- /dev/null +++ b/patches/ntdll-RtlIpv4StringToAddress/0001-ntdll-Implement-RtlIpv6StringToAddress-Ex-AW.patch @@ -0,0 +1,331 @@ +From 816aa308b6a808839760e69679f38498cdd0f4df Mon Sep 17 00:00:00 2001 +From: Alex Henrie +Date: Mon, 27 Jan 2020 23:08:43 -0700 +Subject: [PATCH 1/5] ntdll: Implement RtlIpv6StringToAddress(Ex)[AW] + +Signed-off-by: Alex Henrie +--- + dlls/ntdll/ntdll.spec | 6 +- + dlls/ntdll/rtl.c | 245 +++++++++++++++++++++++++++++++++++++----- + 2 files changed, 222 insertions(+), 29 deletions(-) + +diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec +index fe36235bda..bcd9950a76 100644 +--- a/dlls/ntdll/ntdll.spec ++++ b/dlls/ntdll/ntdll.spec +@@ -778,10 +778,10 @@ + # @ stub RtlIpv6AddressToStringExA + # @ stub RtlIpv6AddressToStringExW + # @ stub RtlIpv6AddressToStringW +-# @ stub RtlIpv6StringToAddressA +-# @ stub RtlIpv6StringToAddressExA ++@ stdcall RtlIpv6StringToAddressA(str ptr ptr) ++@ stdcall RtlIpv6StringToAddressExA(str ptr ptr) + @ stdcall RtlIpv6StringToAddressExW(wstr ptr ptr ptr) +-# @ stub RtlIpv6StringToAddressW ++@ stdcall RtlIpv6StringToAddressW(wstr ptr ptr ptr) + @ stdcall RtlIsActivationContextActive(ptr) + @ stdcall RtlIsCriticalSectionLocked(ptr) + @ stdcall RtlIsCriticalSectionLockedByThread(ptr) +diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c +index 15ff037fef..12c0ed430d 100644 +--- a/dlls/ntdll/rtl.c ++++ b/dlls/ntdll/rtl.c +@@ -98,6 +98,21 @@ static const DWORD CRC_table[256] = + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + }; + ++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 */ ++}; ++ ++static BOOL is_hex(WCHAR c) ++{ ++ return c < ARRAY_SIZE(hex_table) && hex_table[c] != -1; ++} ++ + /* + * resource functions + */ +@@ -884,18 +899,9 @@ 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 BOOL parse_ip_component(const WCHAR **str, int base, 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; ++ int d; + WCHAR c; + ULONG cur_value, prev_value = 0; + BOOL success = FALSE; +@@ -906,19 +912,23 @@ static BOOL parse_ipv4_component(const WCHAR **str, BOOL strict, ULONG *value) + return FALSE; + } + +- if ((*str)[0] == '0') ++ if (!base) + { +- if ((*str)[1] == 'x' || (*str)[1] == 'X') ++ base = 10; ++ if ((*str)[0] == '0') + { +- *str += 2; +- if (strict) return FALSE; +- base = 16; +- } +- else if ((*str)[1] >= '0' && (*str)[1] <= '9') +- { +- *str += 1; +- if (strict) return FALSE; +- base = 8; ++ 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; ++ } + } + } + +@@ -946,7 +956,7 @@ static NTSTATUS ipv4_string_to_address(const WCHAR *str, BOOL strict, + + for (;;) + { +- if (!parse_ipv4_component(&str, strict, &fields[n])) ++ if (!parse_ip_component(&str, 0, strict, &fields[n])) + goto error; + n++; + if (*str != '.') +@@ -1000,7 +1010,7 @@ static NTSTATUS ipv4_string_to_address(const WCHAR *str, BOOL strict, + if (*str == ':') + { + str++; +- if (!parse_ipv4_component(&str, FALSE, &fields[0])) ++ if (!parse_ip_component(&str, 0, FALSE, &fields[0])) + goto error; + if (!fields[0] || fields[0] > 0xFFFF || *str) + goto error; +@@ -1074,13 +1084,196 @@ NTSTATUS WINAPI RtlIpv4StringToAddressA(const char *str, BOOLEAN strict, const c + return ret; + } + ++static NTSTATUS ipv6_string_to_address(const WCHAR *str, BOOL ex, ++ const WCHAR **terminator, IN6_ADDR *address, ULONG *scope, USHORT *port) ++{ ++ static const WCHAR hex_digits[] = { ++ '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F',0 ++ }; ++ BOOL expecting_port = FALSE, ipv4_in_hex = FALSE; ++ int n_bytes = 0, n_ipv4_bytes = 0, gap = -1; ++ ULONG ip_component, scope_component = 0, port_component = 0; ++ const WCHAR *component_terminator; ++ ++ size_t component_len; ++ WCHAR delimiter; ++ ++ if (str[0] == '[') ++ { ++ if (!ex) goto error; ++ expecting_port = TRUE; ++ str++; ++ } ++ ++ if (str[0] == ':') ++ { ++ if (str[1] != ':') goto error; ++ /* Windows bug: a double colon at the beginning is treated as 4 bytes of zeros instead of 2 */ ++ address->u.Word[0] = 0; ++ address->u.Word[1] = 0; ++ n_bytes += 4; ++ str++; ++ } ++ ++ for (;;) ++ { ++ component_len = strspnW(str, hex_digits); ++ delimiter = str[component_len]; ++ if (terminator && delimiter != ':' && delimiter != '.') *terminator = str + component_len; ++ if (!n_ipv4_bytes && str[0] == '0' && (str[1] == 'x' || str[1] == 'X') && is_hex(str[2])) ++ { ++ /* IPv4 address as single hex value */ ++ if (n_bytes > 12) goto error; ++ component_terminator = str + 2; ++ if (!parse_ip_component(&component_terminator, 16, TRUE, &ip_component)) goto error; ++ if (terminator) *terminator = str + 1; /* Windows bug: terminator is off by 1 */ ++ if (gap == -1 && *component_terminator == ':') return STATUS_INVALID_PARAMETER; ++ address->u.Byte[n_bytes++] = (ip_component & 0xFF000000) >> 24; ++ address->u.Byte[n_bytes++] = (ip_component & 0x00FF0000) >> 16; ++ address->u.Byte[n_bytes++] = (ip_component & 0x0000FF00) >> 8; ++ address->u.Byte[n_bytes++] = (ip_component & 0x000000FF); ++ str = component_terminator; ++ ipv4_in_hex = TRUE; ++ goto fill_gap; ++ } ++ if (!n_ipv4_bytes && delimiter == '.' && n_bytes <= 12) n_ipv4_bytes = 1; ++ if (n_ipv4_bytes) ++ { ++ /* dotted IPv4 address */ ++ if (!parse_ip_component(&str, 0, TRUE, &ip_component)) goto error; ++ if (ip_component > 255) return STATUS_INVALID_PARAMETER; ++ if (delimiter != '.' && (n_ipv4_bytes < 4 || (n_bytes < 15 && gap == -1))) goto error; ++ address->u.Byte[n_bytes] = ip_component; ++ n_bytes++; ++ if (n_ipv4_bytes == 4) break; ++ n_ipv4_bytes++; ++ } ++ else ++ { ++ /* IPv6 */ ++ if (*str == ':') ++ { ++ gap = n_bytes; ++ if (!is_hex(str[1])) ++ { ++ str++; ++ break; ++ } ++ } ++ else ++ { ++ if (!parse_ip_component(&str, 16, TRUE, &ip_component)) goto error; ++ if (component_len > 4) return STATUS_INVALID_PARAMETER; ++ if (delimiter != ':' && n_bytes < 14 && gap == -1) goto error; ++ address->u.Word[n_bytes/2] = htons(ip_component); ++ n_bytes += 2; ++ } ++ } ++ if (n_bytes == 16 || *str != delimiter || (delimiter != ':' && delimiter != '.')) break; ++ if (gap != -1 && str[0] == ':' && str[1] == ':') break; ++ str++; ++ } ++ ++ if (terminator) *terminator = str; ++ ++fill_gap: ++ if (gap == -1) ++ { ++ if (n_bytes < 16) goto error; ++ } ++ else ++ { ++ memmove(address->u.Byte + 16 - (n_bytes - gap), address->u.Byte + gap, n_bytes - gap); ++ memset(address->u.Byte + gap, 0, 16 - n_bytes); ++ } ++ ++ if (ex) ++ { ++ if (ipv4_in_hex) goto error; ++ ++ if (*str == '%') ++ { ++ str++; ++ if (!parse_ip_component(&str, 10, TRUE, &scope_component)) goto error; ++ } ++ ++ if (expecting_port) ++ { ++ if (*str != ']') goto error; ++ str++; ++ if (*str == ':') ++ { ++ str++; ++ if (!parse_ip_component(&str, 0, FALSE, &port_component)) goto error; ++ if (!port_component || port_component > 0xFFFF || *str) goto error; ++ port_component = htons(port_component); ++ } ++ } ++ } ++ ++ if (!terminator && *str) return STATUS_INVALID_PARAMETER; ++ ++ if (scope) *scope = scope_component; ++ if (port) *port = port_component; ++ ++ return STATUS_SUCCESS; ++ ++error: ++ if (terminator) *terminator = str; ++ return STATUS_INVALID_PARAMETER; ++} ++ + /*********************************************************************** + * RtlIpv6StringToAddressExW [NTDLL.@] + */ + NTSTATUS NTAPI RtlIpv6StringToAddressExW(const WCHAR *str, IN6_ADDR *address, ULONG *scope, USHORT *port) + { +- FIXME("(%s, %p, %p, %p): stub\n", debugstr_w(str), address, scope, port); +- return STATUS_NOT_IMPLEMENTED; ++ TRACE("(%s, %p, %p, %p)\n", debugstr_w(str), address, scope, port); ++ return ipv6_string_to_address(str, TRUE, NULL, address, scope, port); ++} ++ ++/*********************************************************************** ++ * RtlIpv6StringToAddressW [NTDLL.@] ++ */ ++NTSTATUS WINAPI RtlIpv6StringToAddressW(const WCHAR *str, const WCHAR **terminator, IN6_ADDR *address) ++{ ++ TRACE("(%s, %p, %p)\n", debugstr_w(str), terminator, address); ++ return ipv6_string_to_address(str, FALSE, terminator, address, NULL, NULL); ++} ++ ++/*********************************************************************** ++ * RtlIpv6StringToAddressExA [NTDLL.@] ++ */ ++NTSTATUS WINAPI RtlIpv6StringToAddressExA(const char *str, IN6_ADDR *address, ULONG *scope, USHORT *port) ++{ ++ WCHAR wstr[64]; ++ ++ TRACE("(%s, %p, %p, %p)\n", debugstr_a(str), address, scope, port); ++ ++ if (!str || !address || !scope || !port) ++ return STATUS_INVALID_PARAMETER; ++ ++ RtlMultiByteToUnicodeN(wstr, sizeof(wstr), NULL, str, strlen(str) + 1); ++ wstr[ARRAY_SIZE(wstr) - 1] = 0; ++ return ipv6_string_to_address(wstr, TRUE, NULL, address, scope, port); ++} ++ ++/*********************************************************************** ++ * RtlIpv6StringToAddressA [NTDLL.@] ++ */ ++NTSTATUS WINAPI RtlIpv6StringToAddressA(const char *str, const char **terminator, IN6_ADDR *address) ++{ ++ WCHAR wstr[64]; ++ const WCHAR *wterminator = NULL; ++ NTSTATUS ret; ++ ++ TRACE("(%s, %p, %p)\n", debugstr_a(str), terminator, address); ++ ++ RtlMultiByteToUnicodeN(wstr, sizeof(wstr), NULL, str, strlen(str) + 1); ++ wstr[ARRAY_SIZE(wstr) - 1] = 0; ++ ret = ipv6_string_to_address(wstr, FALSE, &wterminator, address, NULL, NULL); ++ if (terminator && wterminator) *terminator = str + (wterminator - wstr); ++ return ret; + } + + /*********************************************************************** +-- +2.24.1 + diff --git a/patches/ntdll-RtlIpv4StringToAddress/0002-include-Add-RtlIpv6StringToAddress-Ex-AW.patch b/patches/ntdll-RtlIpv4StringToAddress/0002-include-Add-RtlIpv6StringToAddress-Ex-AW.patch new file mode 100644 index 00000000..4abd3373 --- /dev/null +++ b/patches/ntdll-RtlIpv4StringToAddress/0002-include-Add-RtlIpv6StringToAddress-Ex-AW.patch @@ -0,0 +1,31 @@ +From 62d8d5c8322be7bf07f95bca2c26057e708eff5a Mon Sep 17 00:00:00 2001 +From: Alex Henrie +Date: Mon, 27 Jan 2020 23:08:45 -0700 +Subject: [PATCH 2/5] include: Add RtlIpv6StringToAddress(Ex)[AW] + +Signed-off-by: Alex Henrie +--- + include/ip2string.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/include/ip2string.h b/include/ip2string.h +index 6c96c8d76d..0753ee82a9 100644 +--- a/include/ip2string.h ++++ b/include/ip2string.h +@@ -30,6 +30,13 @@ NTSTATUS WINAPI RtlIpv4StringToAddressExA(const char *str, BOOLEAN strict, IN_AD + NTSTATUS WINAPI RtlIpv4StringToAddressExW(const WCHAR *str, BOOLEAN strict, IN_ADDR *address, USHORT *port); + #define RtlIpv4StringToAddressEx WINELIB_NAME_AW(RtlIpv4StringToAddressEx) + ++NTSTATUS WINAPI RtlIpv6StringToAddressA(const char *str, const char **terminator, IN6_ADDR *address); ++NTSTATUS WINAPI RtlIpv6StringToAddressW(const WCHAR *str, const WCHAR **terminator, IN6_ADDR *address); ++#define RtlIpv6StringToAddress WINELIB_NAME_AW(RtlIpv6StringToAddress) ++NTSTATUS WINAPI RtlIpv6StringToAddressExA(const char *str, IN6_ADDR *address, ULONG *scope, USHORT *port); ++NTSTATUS WINAPI RtlIpv6StringToAddressExW(const WCHAR *str, IN6_ADDR *address, ULONG *scope, USHORT *port); ++#define RtlIpv6StringToAddressEx WINELIB_NAME_AW(RtlIpv6StringToAddressEx) ++ + #ifdef __cplusplus + } + #endif +-- +2.24.1 + diff --git a/patches/ntdll-RtlIpv4StringToAddress/0003-iphlpapi-Implement-ParseNetworkString-for-IPv6-addre.patch b/patches/ntdll-RtlIpv4StringToAddress/0003-iphlpapi-Implement-ParseNetworkString-for-IPv6-addre.patch new file mode 100644 index 00000000..7be974e8 --- /dev/null +++ b/patches/ntdll-RtlIpv4StringToAddress/0003-iphlpapi-Implement-ParseNetworkString-for-IPv6-addre.patch @@ -0,0 +1,73 @@ +From f5b94c6bf870d8734f86d8b6062d0b51942b5c39 Mon Sep 17 00:00:00 2001 +From: Alex Henrie +Date: Mon, 27 Jan 2020 23:08:46 -0700 +Subject: [PATCH 3/5] iphlpapi: Implement ParseNetworkString for IPv6 addresses + and services + +Signed-off-by: Alex Henrie +--- + dlls/iphlpapi/iphlpapi_main.c | 38 ++++++++++++++++++++++++++++++++++- + 1 file changed, 37 insertions(+), 1 deletion(-) + +diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c +index 8c7c9018c4..0afde6e119 100644 +--- a/dlls/iphlpapi/iphlpapi_main.c ++++ b/dlls/iphlpapi/iphlpapi_main.c +@@ -3343,6 +3343,8 @@ DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type, + NET_ADDRESS_INFO *info, USHORT *port, BYTE *prefix_len) + { + IN_ADDR temp_addr4; ++ IN6_ADDR temp_addr6; ++ ULONG temp_scope; + USHORT temp_port = 0; + NTSTATUS status; + +@@ -3383,10 +3385,44 @@ DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type, + return ERROR_SUCCESS; + } + } ++ if (type & NET_STRING_IPV6_ADDRESS) ++ { ++ status = RtlIpv6StringToAddressExW(str, &temp_addr6, &temp_scope, &temp_port); ++ if (SUCCEEDED(status) && !temp_port) ++ { ++ if (info) ++ { ++ info->Format = NET_ADDRESS_IPV6; ++ info->u.Ipv6Address.sin6_addr = temp_addr6; ++ info->u.Ipv6Address.sin6_scope_id = temp_scope; ++ info->u.Ipv6Address.sin6_port = 0; ++ } ++ if (port) *port = 0; ++ if (prefix_len) *prefix_len = 255; ++ return ERROR_SUCCESS; ++ } ++ } ++ if (type & NET_STRING_IPV6_SERVICE) ++ { ++ status = RtlIpv6StringToAddressExW(str, &temp_addr6, &temp_scope, &temp_port); ++ if (SUCCEEDED(status) && temp_port) ++ { ++ if (info) ++ { ++ info->Format = NET_ADDRESS_IPV6; ++ info->u.Ipv6Address.sin6_addr = temp_addr6; ++ info->u.Ipv6Address.sin6_scope_id = temp_scope; ++ info->u.Ipv6Address.sin6_port = temp_port; ++ } ++ if (port) *port = ntohs(temp_port); ++ if (prefix_len) *prefix_len = 255; ++ return ERROR_SUCCESS; ++ } ++ } + + if (info) info->Format = NET_ADDRESS_FORMAT_UNSPECIFIED; + +- if (type & ~(NET_STRING_IPV4_ADDRESS|NET_STRING_IPV4_SERVICE)) ++ if (type & ~(NET_STRING_IPV4_ADDRESS|NET_STRING_IPV4_SERVICE|NET_STRING_IPV6_ADDRESS|NET_STRING_IPV6_SERVICE)) + { + FIXME("Unimplemented type 0x%x\n", type); + return ERROR_NOT_SUPPORTED; +-- +2.24.1 + diff --git a/patches/ntdll-RtlIpv4StringToAddress/0003-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch b/patches/ntdll-RtlIpv4StringToAddress/0004-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch similarity index 98% rename from patches/ntdll-RtlIpv4StringToAddress/0003-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch rename to patches/ntdll-RtlIpv4StringToAddress/0004-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch index 70799783..ee21256c 100644 --- a/patches/ntdll-RtlIpv4StringToAddress/0003-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch +++ b/patches/ntdll-RtlIpv4StringToAddress/0004-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch @@ -1,7 +1,7 @@ -From fc9f2edd5b456e2b2eedecc87a175f2cdae54c35 Mon Sep 17 00:00:00 2001 +From 804ef82bf8b604f86662bde396b537e57e6e9ec1 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Fri, 30 Aug 2019 13:43:17 -0600 -Subject: [PATCH 3/4] ntdll: Add semi-stub for RtlIpv6AddressToString(Ex)A +Subject: [PATCH 4/5] 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 @@ -15,10 +15,10 @@ Signed-off-by: Alex Henrie 3 files changed, 180 insertions(+), 93 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 8cacc97ec4..13e39e09b4 100644 +index bcd9950a76..ac918bfa33 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -764,8 +764,8 @@ +@@ -774,8 +774,8 @@ @ stdcall RtlIpv4StringToAddressExA(str long ptr ptr) @ stdcall RtlIpv4StringToAddressExW(wstr long ptr ptr) @ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr) @@ -28,12 +28,12 @@ index 8cacc97ec4..13e39e09b4 100644 +@ stdcall RtlIpv6AddressToStringExA(ptr long long ptr ptr) # @ stub RtlIpv6AddressToStringExW # @ stub RtlIpv6AddressToStringW - # @ stub RtlIpv6StringToAddressA + @ stdcall RtlIpv6StringToAddressA(str ptr ptr) diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c -index 1604513e7e..8b6826e181 100644 +index 12c0ed430d..d2a7a6aac9 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c -@@ -1194,6 +1194,85 @@ CHAR * WINAPI RtlIpv4AddressToStringA(const IN_ADDR *pin, LPSTR buffer) +@@ -1389,6 +1389,85 @@ CHAR * WINAPI RtlIpv4AddressToStringA(const IN_ADDR *pin, LPSTR buffer) return buffer + size - 1; } @@ -120,7 +120,7 @@ index 1604513e7e..8b6826e181 100644 * get_pointer_obfuscator (internal) */ diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c -index 3e1d92c3d2..b7822d370d 100644 +index e49888022f..20b7f162c2 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -1775,80 +1775,81 @@ static void test_RtlIpv6AddressToString(void) @@ -406,5 +406,5 @@ index 3e1d92c3d2..b7822d370d 100644 "got len %d with '%s' (expected %d with '%s')\n", len, buffer, (int)strlen(tests[i].address), tests[i].address); } -- -2.23.0 +2.24.1 diff --git a/patches/ntdll-RtlIpv4StringToAddress/0004-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch b/patches/ntdll-RtlIpv4StringToAddress/0005-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch similarity index 83% rename from patches/ntdll-RtlIpv4StringToAddress/0004-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch rename to patches/ntdll-RtlIpv4StringToAddress/0005-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch index a41fa2ff..0fc502dd 100644 --- a/patches/ntdll-RtlIpv4StringToAddress/0004-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch +++ b/patches/ntdll-RtlIpv4StringToAddress/0005-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch @@ -1,7 +1,7 @@ -From cbc86e2e9b964df11a2d7c0e9e933123ef45b69c Mon Sep 17 00:00:00 2001 +From e32483cc37bc466fdf009acbf8c1c9fb404ec972 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Fri, 30 Aug 2019 13:43:52 -0600 -Subject: [PATCH 4/4] ntdll: Implement RtlIpv6AddressToString(Ex)W +Subject: [PATCH 5/5] ntdll: Implement RtlIpv6AddressToString(Ex)W Signed-off-by: Alex Henrie --- @@ -10,10 +10,10 @@ Signed-off-by: Alex Henrie 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 13e39e09b4..9816017c79 100644 +index ac918bfa33..5a69721270 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -766,8 +766,8 @@ +@@ -776,8 +776,8 @@ @ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr) @ stdcall RtlIpv6AddressToStringA(ptr ptr) @ stdcall RtlIpv6AddressToStringExA(ptr long long ptr ptr) @@ -21,14 +21,14 @@ index 13e39e09b4..9816017c79 100644 -# @ stub RtlIpv6AddressToStringW +@ stdcall RtlIpv6AddressToStringExW(ptr long long ptr ptr) +@ stdcall RtlIpv6AddressToStringW(ptr ptr) - # @ stub RtlIpv6StringToAddressA - # @ stub RtlIpv6StringToAddressExA + @ stdcall RtlIpv6StringToAddressA(str ptr ptr) + @ stdcall RtlIpv6StringToAddressExA(str ptr ptr) @ stdcall RtlIpv6StringToAddressExW(wstr ptr ptr ptr) diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c -index 8b6826e181..f481969549 100644 +index d2a7a6aac9..eb23639edc 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c -@@ -1273,6 +1273,30 @@ char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str) +@@ -1468,6 +1468,30 @@ char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str) return str + len - 1; } @@ -60,5 +60,5 @@ index 8b6826e181..f481969549 100644 * get_pointer_obfuscator (internal) */ -- -2.23.0 +2.24.1 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index eb183e86..1d59bded 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -5039,12 +5039,18 @@ fi # | * [#46788] ntdll: Implement RtlIpv6AddressToStringA # | # | Modified files: -# | * dlls/ntdll/ntdll.spec, dlls/ntdll/rtl.c, dlls/ntdll/tests/rtl.c +# | * dlls/iphlpapi/iphlpapi_main.c, dlls/ntdll/ntdll.spec, dlls/ntdll/rtl.c, dlls/ntdll/tests/rtl.c, include/ip2string.h # | if test "$enable_ntdll_RtlIpv4StringToAddress" -eq 1; then - 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 + patch_apply ntdll-RtlIpv4StringToAddress/0001-ntdll-Implement-RtlIpv6StringToAddress-Ex-AW.patch + patch_apply ntdll-RtlIpv4StringToAddress/0002-include-Add-RtlIpv6StringToAddress-Ex-AW.patch + patch_apply ntdll-RtlIpv4StringToAddress/0003-iphlpapi-Implement-ParseNetworkString-for-IPv6-addre.patch + patch_apply ntdll-RtlIpv4StringToAddress/0004-ntdll-Add-semi-stub-for-RtlIpv6AddressToString-Ex-A.patch + patch_apply ntdll-RtlIpv4StringToAddress/0005-ntdll-Implement-RtlIpv6AddressToString-Ex-W.patch ( + printf '%s\n' '+ { "Alex Henrie", "ntdll: Implement RtlIpv6StringToAddress(Ex)[AW].", 1 },'; + printf '%s\n' '+ { "Alex Henrie", "include: Add RtlIpv6StringToAddress(Ex)[AW].", 1 },'; + printf '%s\n' '+ { "Alex Henrie", "iphlpapi: Implement ParseNetworkString for IPv6 addresses and services.", 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"