DIB section problem

Stefan Dösinger stefandoesinger at gmx.at
Thu Apr 20 12:35:54 CDT 2006

While working on an implementation for IWineD3DSurface::GetDC and 
IWineD3DSurface::ReleaseDC, I think I stubled accross a bug in the DIB code. 
It appears to me that the memory of the DIB section isn't unprotected 
correctly when the dib section is destroyed.

I have pasted my code here: http://wine.pastebin.com/671601

What I do is basically:
->Lock the surface
->Create a DIB section for the locked surface memory(Allocated with 
->Get a DC for the dib section
->Setup the dc and return it to the app

In ReleaseDC, I do it the reverse way:
->Release the DC
->Delete the DIB section
->Unlock the surface

But all accesses to the surface's memory fail after deleting the dib section. 
Therefore I unlock the surface before destroying the dib, and upload the 
texture to opengl, to be able to free the memory.

For testing, I've inserted

VirtualProtect(This->resource.allocatedMemory, This->resource.size, 

after the DeleteObject, and then I can access the surface normally again. But 
the image that the app wrote with GDI commands isn't there, it looks like the 
image is left in the X server and dropped.

Can someone with more knowledge of the DIB code have a quick look at this?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20060420/8ac60c35/attachment.pgp

More information about the wine-devel mailing list