https://git.reactos.org/?p=reactos.git;a=commitdiff;h=968bdeddf3306aed5dfd2…
commit 968bdeddf3306aed5dfd2e1be375cd3bef324b60
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Wed May 29 12:56:43 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Wed May 29 12:59:44 2019 +0200
[NETAPI32] Implement NetpAllocWStrFromStr(), NetpAllocWStrFromAnsiStr() (not public,
but useful) and NetpAllocWStrFromWStr().
---
dll/win32/netapi32/misc.c | 85 ++++++++++++++++++++++++++++++++++++++++
dll/win32/netapi32/netapi32.h | 24 ++++++++++--
dll/win32/netapi32/netapi32.spec | 4 +-
3 files changed, 107 insertions(+), 6 deletions(-)
diff --git a/dll/win32/netapi32/misc.c b/dll/win32/netapi32/misc.c
index 0d236e2ed4..5e541b693f 100644
--- a/dll/win32/netapi32/misc.c
+++ b/dll/win32/netapi32/misc.c
@@ -135,6 +135,91 @@ NetUnregisterDomainNameChangeNotification(
}
+PWSTR
+WINAPI
+NetpAllocWStrFromAnsiStr(
+ _In_ PSTR InString)
+{
+ ANSI_STRING AnsiString;
+ UNICODE_STRING UnicodeString;
+ ULONG Size;
+ NET_API_STATUS NetStatus;
+ NTSTATUS Status;
+
+ RtlInitAnsiString(&AnsiString, InString);
+
+ Size = RtlAnsiStringToUnicodeSize(&AnsiString);
+ NetStatus = NetApiBufferAllocate(Size,
+ (PVOID*)&UnicodeString.Buffer);
+ if (NetStatus != NERR_Success)
+ return NULL;
+
+ Status = RtlAnsiStringToUnicodeString(&UnicodeString,
+ &AnsiString,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ NetApiBufferFree(UnicodeString.Buffer);
+ return NULL;
+ }
+
+ return UnicodeString.Buffer;
+}
+
+
+PWSTR
+WINAPI
+NetpAllocWStrFromStr(
+ _In_ PSTR InString)
+{
+ OEM_STRING OemString;
+ UNICODE_STRING UnicodeString;
+ ULONG Size;
+ NET_API_STATUS NetStatus;
+ NTSTATUS Status;
+
+ RtlInitAnsiString((PANSI_STRING)&OemString, InString);
+
+ Size = RtlOemStringToUnicodeSize(&OemString);
+ NetStatus = NetApiBufferAllocate(Size,
+ (PVOID*)&UnicodeString.Buffer);
+ if (NetStatus != NERR_Success)
+ return NULL;
+
+ Status = RtlOemStringToUnicodeString(&UnicodeString,
+ &OemString,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ NetApiBufferFree(UnicodeString.Buffer);
+ return NULL;
+ }
+
+ return UnicodeString.Buffer;
+}
+
+
+PWSTR
+WINAPI
+NetpAllocWStrFromWStr(
+ _In_ PWSTR InString)
+{
+ PWSTR OutString;
+ ULONG Size;
+ NET_API_STATUS Status;
+
+ Size = (wcslen(InString) + 1) * sizeof(WCHAR);
+ Status = NetApiBufferAllocate(Size,
+ (PVOID*)&OutString);
+ if (Status != NERR_Success)
+ return NULL;
+
+ wcscpy(OutString, InString);
+
+ return OutString;
+}
+
+
NET_API_STATUS
WINAPI
NetpNtStatusToApiStatus(
diff --git a/dll/win32/netapi32/netapi32.h b/dll/win32/netapi32/netapi32.h
index 451865707f..7a839ef51f 100644
--- a/dll/win32/netapi32/netapi32.h
+++ b/dll/win32/netapi32/netapi32.h
@@ -33,10 +33,6 @@
extern LIST_ENTRY g_EnumContextListHead;
extern CRITICAL_SECTION g_EnumContextListLock;
-NET_API_STATUS
-WINAPI
-NetpNtStatusToApiStatus(NTSTATUS Status);
-
/* misc.c */
NTSTATUS
@@ -68,6 +64,26 @@ CopySidFromSidAndRid(
_In_ PSID SrcSid,
_In_ ULONG RelativeId);
+PWSTR
+WINAPI
+NetpAllocWStrFromAnsiStr(
+ _In_ PSTR InString);
+
+PWSTR
+WINAPI
+NetpAllocWStrFromStr(
+ _In_ PSTR InString);
+
+PWSTR
+WINAPI
+NetpAllocWStrFromWStr(
+ _In_ PWSTR InString);
+
+NET_API_STATUS
+WINAPI
+NetpNtStatusToApiStatus(
+ _In_ NTSTATUS Status);
+
/* wksta.c */
BOOL
diff --git a/dll/win32/netapi32/netapi32.spec b/dll/win32/netapi32/netapi32.spec
index dda3b36b6e..f4e8824464 100644
--- a/dll/win32/netapi32/netapi32.spec
+++ b/dll/win32/netapi32/netapi32.spec
@@ -269,8 +269,8 @@
@ stub NetpAllocConfigName
@ stub NetpAllocFtinfoEntry
@ stub NetpAllocStrFromWStr
-@ stub NetpAllocWStrFromStr
-@ stub NetpAllocWStrFromWStr
+@ stdcall NetpAllocWStrFromStr(str)
+@ stdcall NetpAllocWStrFromWStr(wstr)
@ stub NetpApiStatusToNtStatus
@ stub NetpAssertFailed
@ stub NetpCleanFtinfoContext