[PATCH resend 1/4] winex11.drv: Store monitor information in the wineserver for EnumDisplayMonitors().

Alexandre Julliard julliard at winehq.org
Mon Mar 15 15:15:53 CDT 2021


Zhiyi Zhang <zzhang at codeweavers.com> writes:

> +    SERVER_START_REQ( get_monitor_info )
> +    {
> +        req->handle = wine_server_user_handle( handle );
> +        wine_server_set_reply( req, adapter_name, sizeof(adapter_name) );
> +        if (!wine_server_call( req ))
> +        {
> +            SetRect( &info->rcMonitor, reply->monitor_rect.left, reply->monitor_rect.top,
> +                     reply->monitor_rect.right, reply->monitor_rect.bottom );
> +            SetRect( &info->rcWork, reply->work_rect.left, reply->work_rect.top,
> +                     reply->work_rect.right, reply->work_rect.bottom );
> +            if (!IsRectEmpty( &info->rcMonitor ) && !info->rcMonitor.top && !info->rcMonitor.left)
> +                info->dwFlags = MONITORINFOF_PRIMARY;
> +            else
> +                info->dwFlags = 0;
> +            if (info->cbSize >= sizeof(MONITORINFOEXW))
> +                lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, adapter_name );
> +            return TRUE;

Strings in server requests should not be null-terminated. Also please
don't return out of a request block.

> +        SERVER_START_REQ(create_monitor)
> +        {
> +            req->monitor_rect.top = monitor->rc_monitor.top;
> +            req->monitor_rect.left = monitor->rc_monitor.left;
> +            req->monitor_rect.right = monitor->rc_monitor.right;
> +            req->monitor_rect.bottom = monitor->rc_monitor.bottom;
> +            req->work_rect.top = monitor->rc_work.top;
> +            req->work_rect.left = monitor->rc_work.left;
> +            req->work_rect.right = monitor->rc_work.right;
> +            req->work_rect.bottom = monitor->rc_work.bottom;
> +            wine_server_add_data(req, bufferW, size);
> +            if (wine_server_call(req))
> +                goto done;

Same issues here.

> +failed:
> +    if (monitor)
> +    {
> +        if (monitor->adapter_name)
> +            free( monitor->adapter_name );
> +        free( monitor );
> +    }
> +    set_error( STATUS_UNSUCCESSFUL );

Don't use such generic errors. You should simply return the error
already set by the various allocation functions.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list