mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 04:35:53 +00:00
[NETAPI32] Implement NetpAllocWStrFromStr(), NetpAllocWStrFromAnsiStr() (not public, but useful) and NetpAllocWStrFromWStr().
This commit is contained in:
parent
9a39315d46
commit
968bdeddf3
3 changed files with 107 additions and 6 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue