[NETAPI32] Add the NetpAllocStrFromWStr helper function
authorEric Kohl <eric.kohl@reactos.org>
Sat, 24 Aug 2019 12:00:33 +0000 (14:00 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 24 Aug 2019 12:00:33 +0000 (14:00 +0200)
dll/win32/netapi32/misc.c
dll/win32/netapi32/netapi32.h
dll/win32/netapi32/netapi32.spec

index 129dda8..8fa84a0 100644 (file)
@@ -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(
index 35004bb..4f4bcb6 100644 (file)
@@ -69,6 +69,11 @@ WINAPI
 NetpAllocAnsiStrFromWStr(
     _In_ PWSTR InString);
 
+PSTR
+WINAPI
+NetpAllocStrFromWStr(
+    _In_ PWSTR InString);
+
 PWSTR
 WINAPI
 NetpAllocWStrFromAnsiStr(
index f4e8824..75845a4 100644 (file)
 @ stub NetpAddTlnFtinfoEntry
 @ stub NetpAllocConfigName
 @ stub NetpAllocFtinfoEntry
-@ stub NetpAllocStrFromWStr
+@ stdcall NetpAllocStrFromWStr(wstr)
 @ stdcall NetpAllocWStrFromStr(str)
 @ stdcall NetpAllocWStrFromWStr(wstr)
 @ stub NetpApiStatusToNtStatus