wined3d: Fix LockRect memory location calculation for
WINED3DFMT_DXT*
Erich Hoover
ehoover at mines.edu
Mon Mar 12 19:46:27 CDT 2007
Skipped content of type multipart/alternative-------------- next part --------------
From 3c3ec719ade27cba552de0dcdb7090c2f90ba867 Mon Sep 17 00:00:00 2001
From: Erich Hoover <ehoover at mediaserver.(none)>
Date: Mon, 12 Mar 2007 18:39:29 -0600
Subject: wined3d: Fix LockRect memory location calculation for WINED3DFMT_DXT*
---
dlls/wined3d/surface.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index c8d39f6..e0330cd 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -624,7 +624,10 @@ static HRESULT WINAPI IWineD3DSurfaceImp
}
if (This->resource.format == WINED3DFMT_DXT1) { /* DXT1 is half byte per pixel */
- pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * This->bytesPerPixel / 2));
+ pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + ((pRect->left * 2));
+ } else if (This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3
+ || This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) {
+ pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 4);
} else {
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
}
@@ -633,6 +636,11 @@ static HRESULT WINAPI IWineD3DSurfaceImp
This->lockedRect.right = pRect->right;
This->lockedRect.bottom = pRect->bottom;
}
+ if ((char*) pLockedRect->pBits > (char*)(This->resource.allocatedMemory + This->resource.size)) {
+ ERR("Invalid memory location calculated!\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
if (This->Flags & SFLAG_NONPOW2) {
TRACE("Locking non-power 2 texture\n");
--
1.4.1
More information about the wine-patches
mailing list