https://git.reactos.org/?p=reactos.git;a=commitdiff;h=61ac4f1ee9322834bef9a…
commit 61ac4f1ee9322834bef9a99154af649e4a23fe0b
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sat Aug 24 14:00:33 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sat Aug 24 14:00:33 2019 +0200
[NETAPI32] Add the NetpAllocStrFromWStr helper function
---
dll/win32/netapi32/misc.c | 32 ++++++++++++++++++++++++++++++++
dll/win32/netapi32/netapi32.h | 5 +++++
dll/win32/netapi32/netapi32.spec | 2 +-
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/dll/win32/netapi32/misc.c b/dll/win32/netapi32/misc.c
index 129dda80484..8fa84a07c6b 100644
--- a/dll/win32/netapi32/misc.c
+++ b/dll/win32/netapi32/misc.c
@@ -167,6 +167,38 @@ NetpAllocAnsiStrFromWStr(
}
+PSTR
+WINAPI
+NetpAllocStrFromWStr(
+ _In_ PWSTR InString)
+{
+ UNICODE_STRING UnicodeString;
+ OEM_STRING OemString;
+ ULONG Size;
+ NET_API_STATUS NetStatus;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&UnicodeString, InString);
+
+ Size = RtlUnicodeStringToOemSize(&UnicodeString);
+ NetStatus = NetApiBufferAllocate(Size,
+ (PVOID*)&OemString.Buffer);
+ if (NetStatus != NERR_Success)
+ return NULL;
+
+ Status = RtlUnicodeStringToOemString(&OemString,
+ &UnicodeString,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ NetApiBufferFree(OemString.Buffer);
+ return NULL;
+ }
+
+ return OemString.Buffer;
+}
+
+
PWSTR
WINAPI
NetpAllocWStrFromAnsiStr(
diff --git a/dll/win32/netapi32/netapi32.h b/dll/win32/netapi32/netapi32.h
index 35004bba368..4f4bcb63a43 100644
--- a/dll/win32/netapi32/netapi32.h
+++ b/dll/win32/netapi32/netapi32.h
@@ -69,6 +69,11 @@ WINAPI
NetpAllocAnsiStrFromWStr(
_In_ PWSTR InString);
+PSTR
+WINAPI
+NetpAllocStrFromWStr(
+ _In_ PWSTR InString);
+
PWSTR
WINAPI
NetpAllocWStrFromAnsiStr(
diff --git a/dll/win32/netapi32/netapi32.spec b/dll/win32/netapi32/netapi32.spec
index f4e88244641..75845a487a8 100644
--- a/dll/win32/netapi32/netapi32.spec
+++ b/dll/win32/netapi32/netapi32.spec
@@ -268,7 +268,7 @@
@ stub NetpAddTlnFtinfoEntry
@ stub NetpAllocConfigName
@ stub NetpAllocFtinfoEntry
-@ stub NetpAllocStrFromWStr
+@ stdcall NetpAllocStrFromWStr(wstr)
@ stdcall NetpAllocWStrFromStr(str)
@ stdcall NetpAllocWStrFromWStr(wstr)
@ stub NetpApiStatusToNtStatus