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

Thomas Faber <[email protected]> Wed, 4 Sep 2019 09:19:42 +0200
Newsgroups gmane.os.reactos.kernel
Message-ID <[email protected]>
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

_______________________________________________
Ros-dev mailing list
[email protected]
http://reactos.org/mailman/listinfo/ros-dev