LockRect Problem

Erich Hoover ehoover at mines.edu
Mon Mar 12 00:04:26 CDT 2007

I'm looking into a problem that causes Supreme Commander to segfault (Bug
#7643 <http://bugs.winehq.org/show_bug.cgi?id=7643>) and I believe I may
have run into a problem with IWineD3DSurfaceImpl_LockRect.  I believe the
problem is a typo in the line:

> This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 , This->
> resource.size + 4);

I think that the allocated memory should be the size of the resource
multiplied by 4 (instead of adding 4).  With the current allocation, for
some textures, the operation to calculate the pBits location returns a
memory address that is past the end of the allocated memory. So, after this

> pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch
> * pRect->top) + (pRect->left * This->bytesPerPixel)
the value of pLockedRect->pBits is greater than "This->
resource.allocatedMemory + This->resource.size + 4".

I've dug around a bit to see if This->resource.size was just allocated
incorrectly but that does not appear the case.  So, if someone could confirm
or deny that this is a typo problem then I'd really appreciate it.

Erich Hoover
ehoover at mines.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winehq.org/pipermail/wine-devel/attachments/20070311/717d915a/attachment.htm

More information about the wine-devel mailing list