Module: wine Branch: master Commit: 7292edaf55bd18a83b4067e60e52bb8cfbdfcba0 URL: https://gitlab.winehq.org/wine/wine/-/commit/7292edaf55bd18a83b4067e60e52bb8...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Jun 6 08:56:09 2024 +0200
gdi.exe16: Fix some incorrect usage of NtGdiDdDDICreateDCFromMemory.
---
dlls/gdi.exe16/gdi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/gdi.exe16/gdi.c b/dlls/gdi.exe16/gdi.c index c634f0739c7..e81d335f127 100644 --- a/dlls/gdi.exe16/gdi.c +++ b/dlls/gdi.exe16/gdi.c @@ -1189,10 +1189,11 @@ HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output, D3DKMT_CREATEDCFROMMEMORY desc = { .Width = info->bmiHeader.biWidth, - .Height = info->bmiHeader.biHeight, - .Pitch = info->bmiHeader.biWidth * info->bmiHeader.biBitCount / 8, + .Height = abs( info->bmiHeader.biHeight ), + .Pitch = info->bmiHeader.biSizeImage / abs( info->bmiHeader.biHeight ), }; struct saved_bitmap *bitmap; + UINT status; int color;
if (info->bmiHeader.biBitCount <= 8) @@ -1230,7 +1231,14 @@ HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output, desc.pMemory = &info->bmiColors[0]; }
- if (NtGdiDdDDICreateDCFromMemory( &desc )) return 0; + if (!(desc.hDeviceDc = NtGdiCreateCompatibleDC( 0 ))) return 0; + if ((status = NtGdiDdDDICreateDCFromMemory( &desc ))) + { + NtGdiDeleteObjectApp( desc.hDeviceDc ); + ERR( "Failed to create HBITMAP over memory, status %#x\n", status ); + return 0; + } + NtGdiDeleteObjectApp( desc.hDeviceDc );
if ((bitmap = HeapAlloc( GetProcessHeap(), 0, sizeof(*bitmap) ))) {