From a9bdd62d84b675c9ff36b60220be3695df48edf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vesel=C3=BD?= Date: Mon, 8 Jul 2024 20:34:36 +0200 Subject: [PATCH] [GDI32] SetBkMode: Avoid invalid input. CORE-19656 (#7089) Fixes a bug in Midori 0.5.11 installer which caused bad rendering that was making the text hard to read (no background). In Windows it's visible as FillRect(0x89011a1f, 0x0019f87c, 0xabababab), and in ReactOS as SetBkMode(0xb5010fce, -1546139919). After a number of attempts to get the same behavior, I haven't found a way to fix it without a hack to make the installer look identical to Windows. At least I added handling for the incorrect value in SetBkMode. This shouldn't matter anywhere. It may not look the same as on Windows, but the text will at least be readable. --- win32ss/gdi/gdi32/objects/dc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win32ss/gdi/gdi32/objects/dc.c b/win32ss/gdi/gdi32/objects/dc.c index 580776819f9..d1ace6718ba 100644 --- a/win32ss/gdi/gdi32/objects/dc.c +++ b/win32ss/gdi/gdi32/objects/dc.c @@ -1060,6 +1060,13 @@ SetBkMode( PDC_ATTR pdcattr; INT iOldMode; + /* Avoid bad mode setting */ + if ((iBkMode != TRANSPARENT) && (iBkMode != OPAQUE)) + { + DPRINT1("SetBkMode: Incorrect value\n"); + return 0; + } + HANDLE_METADC(INT, SetBkMode, 0, hdc, iBkMode); /* Get the DC attribute */