[ros-dev] [ros-diffs] [reactos] 01/01: [NETAPI32] Add the NetpAllocStrFromWStr helper function

Thomas Faber thomas.faber at reactos.org
Wed Sep 4 07:19:42 UTC 2019


Hey Eric,

On 2019-08-24 14:01, Eric Kohl wrote:
> +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;
> +

It seems like OemString.MaximumLength should be initialized before 
calling RtlUnicodeStringToOemString?

> +    Status = RtlUnicodeStringToOemString(&OemString,
> +                                         &UnicodeString,
> +                                         FALSE);
> +    if (!NT_SUCCESS(Status))
> +    {
> +        NetApiBufferFree(OemString.Buffer);
> +        return NULL;
> +    }
> +
> +    return OemString.Buffer;
> +}


Best,
Thomas



More information about the Ros-dev mailing list