wine-staging/patches/ntdll-RtlIpv4StringToAddress/0003-ntdll-Implement-RtlIpv4StringToAddress-Ex-W.patch

60 lines
2.2 KiB
Diff
Raw Normal View History

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