From: Oleh Nykyforchyn Subject: [PATCH] gdi32: Accept 16-bit handles in get_dc_attr(). Message-Id: <20211023073459.25299-1-olen.nyk@gmail.com> Date: Sat, 23 Oct 2021 10:34:58 +0300 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 --- 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; -- 2.33.0