GetCurrentObject(hdc,OBJ_BITMAP) should not return zero.

Rein Klazes rklazes at
Wed Jan 22 07:32:29 CST 2003


( cc'd to the developer list. There might well be some better way to
solve the problem.)

Eurdora 4.x and 5.x crash when handling a WM_PAINT message. The program
gets a hdc from BeginPaint() and does a GetCurrentObject(hdc,OBJ_BITMAP)
on that device context. In wine zero is returned and the program crashes
as a result of that (step tracing it shows some math on it and then uses
the result as a pointer).
The same problem was reported on the developer list in:

Since the program does not do anything suspicious between aquiring the
dc handle and the GetCurrentObject, Checking under Windows (Win2000).
I found that GetCurrentObject(,OBJ_BITMAP) on the the dc returned both
by BeginPaint() and CreateDC(), retrieves a non-zero handle. The handle
looks genuine, but the bitmap does not appear to be valid (funny
dimensions and so).
My proposed solution is to do what CreatCompatibleDC already does: load
a default bitmap in CreateDC(). This has worked here for a long time
without any aparent problems.


	objects:	dc.c
	Load default stock bitmap in CreateDC()

Rein Klazes
rklazes at
-------------- next part --------------
--- wine/objects/dc.c	2002-12-03 20:18:41.000000000 +0100
+++ mywine/objects/dc.c	2003-01-19 15:58:45.000000000 +0100
@@ -596,6 +596,7 @@
         return 0;
+    dc->hBitmap      = GetStockObject( DEFAULT_BITMAP );
     dc->flags = 0;
     TRACE("(driver=%s, device=%s, output=%s): returning %p\n",

More information about the wine-patches mailing list