[NETAPI32] Implement NetpAllocWStrFromStr(), NetpAllocWStrFromAnsiStr() (not public...
authorEric Kohl <eric.kohl@reactos.org>
Wed, 29 May 2019 10:56:43 +0000 (12:56 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 29 May 2019 10:59:44 +0000 (12:59 +0200)
dll/win32/netapi32/misc.c
dll/win32/netapi32/netapi32.h
dll/win32/netapi32/netapi32.spec

index 0d236e2..5e541b6 100644 (file)
@@ -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(
index 4518657..7a839ef 100644 (file)
 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
index dda3b36..f4e8824 100644 (file)
 @ stub NetpAllocConfigName
 @ stub NetpAllocFtinfoEntry
 @ stub NetpAllocStrFromWStr
-@ stub NetpAllocWStrFromStr
-@ stub NetpAllocWStrFromWStr
+@ stdcall NetpAllocWStrFromStr(str)
+@ stdcall NetpAllocWStrFromWStr(wstr)
 @ stub NetpApiStatusToNtStatus
 @ stub NetpAssertFailed
 @ stub NetpCleanFtinfoContext