[PATCH 1/2] wtsapi32: Implement WTSQuerySessionInformationA.

Alexandre Julliard julliard at winehq.org
Wed May 27 14:13:28 CDT 2020


Gijs Vermeulen <gijsvrm at gmail.com> writes:

> +BOOL WINAPI WTSQuerySessionInformationA(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, char **buffer, DWORD *count)
>  {
> -    /* FIXME: Forward request to winsta.dll::WinStationQueryInformationA */
> -    FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
> -        Buffer, BytesReturned);
> +    WCHAR *bufferW = NULL;
> +
> +    TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
>  
> +    if (!buffer || !count)
> +    {
> +        SetLastError(ERROR_INVALID_USER_BUFFER);
> +        return FALSE;
> +    }
> +
> +    if (WTSQuerySessionInformationW(server, session_id, class, &bufferW, count))
> +    {
> +        *count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
> +        if (*count)
> +        {
> +            if (!(*buffer = heap_alloc(*count))) return FALSE;
> +            if ((*count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, *buffer, *count, NULL, NULL)))
> +                return TRUE;
> +        }
> +    }

You are leaking bufferW and potentially *buffer also.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list