[PATCH resend 3/3] ntdll: Implement RtlIpv4StringToAddress(Ex)W

Alex Henrie alexhenrie24 at gmail.com
Mon Aug 19 22:15:40 CDT 2019


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46149
Signed-off-by: Alex Henrie <alexhenrie24 at 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.23.0




More information about the wine-devel mailing list