DXGL r501 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r500‎ | r501 | r502 >
Date:22:34, 29 August 2014
Author:admin
Status:new
Tags:
Comment:
Return proper size DDSURFACEDESC when locking or getting surface description.
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -1875,7 +1875,16 @@
18761876 {
18771877 TRACE_ENTER(2,14,this,14,lpDDSurfaceDesc);
18781878 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
1879 - TRACE_RET(HRESULT,23,glDDS7->GetSurfaceDesc((LPDDSURFACEDESC2)lpDDSurfaceDesc));
 1879+ if (!lpDDSurfaceDesc) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1880+ if (lpDDSurfaceDesc->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1881+ DDSURFACEDESC2 ddsd;
 1882+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 1883+ HRESULT ret = glDDS7->GetSurfaceDesc(&ddsd);
 1884+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 1885+ ddsd.dwSize = sizeof(DDSURFACEDESC);
 1886+ memcpy(lpDDSurfaceDesc, &ddsd, sizeof(DDSURFACEDESC));
 1887+ TRACE_EXIT(23,ret);
 1888+ return ret;
18801889 }
18811890 HRESULT WINAPI glDirectDrawSurface1::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
18821891 {
@@ -1894,7 +1903,15 @@
18951904 {
18961905 TRACE_ENTER(5,14,this,26,lpDestRect,14,lpDDSurfaceDesc,9,dwFlags,14,hEvent);
18971906 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
1898 - TRACE_RET(HRESULT,23,glDDS7->Lock(lpDestRect,(LPDDSURFACEDESC2)lpDDSurfaceDesc,dwFlags,hEvent));
 1907+ DDSURFACEDESC2 ddsd;
 1908+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
 1909+ memcpy(&ddsd, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
 1910+ HRESULT ret = glDDS7->Lock(lpDestRect, &ddsd, dwFlags, hEvent);
 1911+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 1912+ ddsd.dwSize = sizeof(DDSURFACEDESC);
 1913+ memcpy(lpDDSurfaceDesc, &ddsd, sizeof(DDSURFACEDESC));
 1914+ TRACE_EXIT(23,ret);
 1915+ return ret;
18991916 }
19001917 HRESULT WINAPI glDirectDrawSurface1::ReleaseDC(HDC hDC)
19011918 {
@@ -2228,7 +2245,16 @@
22292246 {
22302247 TRACE_ENTER(2,14,this,14,lpDDSurfaceDesc);
22312248 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2232 - TRACE_RET(HRESULT,23,glDDS7->GetSurfaceDesc((LPDDSURFACEDESC2)lpDDSurfaceDesc));
 2249+ if (!lpDDSurfaceDesc) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2250+ if (lpDDSurfaceDesc->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2251+ DDSURFACEDESC2 ddsd;
 2252+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 2253+ HRESULT ret = glDDS7->GetSurfaceDesc(&ddsd);
 2254+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 2255+ ddsd.dwSize = sizeof(DDSURFACEDESC);
 2256+ memcpy(lpDDSurfaceDesc, &ddsd, sizeof(DDSURFACEDESC));
 2257+ TRACE_EXIT(23, ret);
 2258+ return ret;
22332259 }
22342260 HRESULT WINAPI glDirectDrawSurface2::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
22352261 {
@@ -2247,7 +2273,15 @@
22482274 {
22492275 TRACE_ENTER(5,14,this,26,lpDestRect,14,lpDDSurfaceDesc,9,dwFlags,14,hEvent);
22502276 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2251 - TRACE_RET(HRESULT,23,glDDS7->Lock(lpDestRect,(LPDDSURFACEDESC2)lpDDSurfaceDesc,dwFlags,hEvent));
 2277+ DDSURFACEDESC2 ddsd;
 2278+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
 2279+ memcpy(&ddsd, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
 2280+ HRESULT ret = glDDS7->Lock(lpDestRect, &ddsd, dwFlags, hEvent);
 2281+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 2282+ ddsd.dwSize = sizeof(DDSURFACEDESC);
 2283+ memcpy(lpDDSurfaceDesc, &ddsd, sizeof(DDSURFACEDESC));
 2284+ TRACE_EXIT(23, ret);
 2285+ return ret;
22522286 }
22532287 HRESULT WINAPI glDirectDrawSurface2::ReleaseDC(HDC hDC)
22542288 {
@@ -2606,7 +2640,16 @@
26072641 {
26082642 TRACE_ENTER(2,14,this,14,lpDDSurfaceDesc);
26092643 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2610 - TRACE_RET(HRESULT,23,glDDS7->GetSurfaceDesc((LPDDSURFACEDESC2)lpDDSurfaceDesc));
 2644+ if (!lpDDSurfaceDesc) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2645+ if (lpDDSurfaceDesc->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2646+ DDSURFACEDESC2 ddsd;
 2647+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 2648+ HRESULT ret = glDDS7->GetSurfaceDesc(&ddsd);
 2649+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 2650+ ddsd.dwSize = sizeof(DDSURFACEDESC);
 2651+ memcpy(lpDDSurfaceDesc, &ddsd, sizeof(DDSURFACEDESC));
 2652+ TRACE_EXIT(23, ret);
 2653+ return ret;
26112654 }
26122655 HRESULT WINAPI glDirectDrawSurface3::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
26132656 {
@@ -2625,7 +2668,15 @@
26262669 {
26272670 TRACE_ENTER(5,14,this,26,lpDestRect,14,lpDDSurfaceDesc,9,dwFlags,14,hEvent);
26282671 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2629 - TRACE_RET(HRESULT,23,glDDS7->Lock(lpDestRect,(LPDDSURFACEDESC2)lpDDSurfaceDesc,dwFlags,hEvent));
 2672+ DDSURFACEDESC2 ddsd;
 2673+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
 2674+ memcpy(&ddsd, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
 2675+ HRESULT ret = glDDS7->Lock(lpDestRect, &ddsd, dwFlags, hEvent);
 2676+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 2677+ ddsd.dwSize = sizeof(DDSURFACEDESC);
 2678+ memcpy(lpDDSurfaceDesc, &ddsd, sizeof(DDSURFACEDESC));
 2679+ TRACE_EXIT(23, ret);
 2680+ return ret;
26302681 }
26312682 HRESULT WINAPI glDirectDrawSurface3::ReleaseDC(HDC hDC)
26322683 {