[PATCH] gdi32: Accept 16-bit handles in get_dc_attr().

Nikolay Sivov nsivov at codeweavers.com
Sat Oct 23 15:32:25 CDT 2021


On 10/23/21 10:34 AM, Oleh Nykyforchyn wrote:
> When background is erased in a 16 bit app, a handle to DC is passed
> through USER16 functions, namely CallWindowProc16 (USER.122) and
> DefDriverProc16 (USER.255), whose respective parameters are of type
> WPARAM16, hence the upper part of the handle is cut. Later
> the returned handle is rejected by get_dc_attr() in GDI32 because
> its type is 0, although such handles are accepted by handle_entry().
> This results in black and not cleared background.  Allowing type==0
> in get_dc_attr() solves the problem.
>
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51899
> Signed-off-by: Oleh Nykyforchyn <oleh.nyk at gmail.com>
> ---
>  dlls/gdi32/dc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
> index 1511c565194..a161b3cb640 100644
> --- a/dlls/gdi32/dc.c
> +++ b/dlls/gdi32/dc.c
> @@ -56,7 +56,7 @@ DC_ATTR *get_dc_attr( HDC hdc )
>  {
>      DWORD type = gdi_handle_type( hdc );
>      DC_ATTR *dc_attr;
> -    if ((type & 0x1f0000) != NTGDI_OBJ_DC || !(dc_attr = get_gdi_client_ptr( hdc, 0 )))
> +    if ((type && (type & 0x1f0000) != NTGDI_OBJ_DC) || !(dc_attr = get_gdi_client_ptr( hdc, 0 )))
>      {
>          SetLastError( ERROR_INVALID_HANDLE );
>          return NULL;
This doesn't look right, type mask shouldn't just disappear with no
consequences. I think what has to happen is appropriate wow32 conversion
in default procedure. It has to be applied for every affected message
obviously. Please try attached patch.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 576 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20211023/594c7b94/attachment.bin>


More information about the wine-devel mailing list