DXGL r95 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r94‎ | r95 | r96 >
Date:01:59, 3 February 2012
Author:admin
Status:new
Tags:
Comment:
Return error on null "this" pointers
Return error on null lpdddi pointer in GetDeviceIdentifier
Modified paths:
  • /ddraw/glClassFactory.cpp (modified) (history)
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DLight.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawPalette.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glClassFactory.cpp
@@ -24,11 +24,13 @@
2525
2626 ULONG WINAPI glClassFactory::AddRef()
2727 {
 28+ if(!this) return DDERR_INVALIDPARAMS;
2829 refcount++;
2930 return refcount;
3031 }
3132 ULONG WINAPI glClassFactory::Release()
3233 {
 34+ if(!this) return DDERR_INVALIDPARAMS;
3335 ULONG ret;
3436 refcount--;
3537 ret = refcount;
@@ -38,6 +40,7 @@
3941
4042 HRESULT WINAPI glClassFactory::QueryInterface(REFIID riid, void** ppvObj)
4143 {
 44+ if(!this) return DDERR_INVALIDPARAMS;
4245 if((riid == IID_IUnknown) || (riid == IID_IClassFactory))
4346 {
4447 *ppvObj = this;
@@ -52,6 +55,7 @@
5356 }
5457 HRESULT WINAPI glClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
5558 {
 59+ if(!this) return DDERR_INVALIDPARAMS;
5660 glDirectDraw7 *glDD7;
5761 if(pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
5862 if(riid == IID_IDirectDraw)
@@ -86,6 +90,7 @@
8791 }
8892 HRESULT WINAPI glClassFactory::LockServer(BOOL fLock)
8993 {
 94+ if(!this) return DDERR_INVALIDPARAMS;
9095 if(fLock) InterlockedIncrement(&locks);
9196 else InterlockedDecrement(&locks);
9297 return S_OK;
Index: ddraw/glDirect3D.cpp
@@ -35,11 +35,13 @@
3636
3737 ULONG WINAPI glDirect3D7::AddRef()
3838 {
 39+ if(!this) return 0;
3940 refcount++;
4041 return refcount;
4142 }
4243 ULONG WINAPI glDirect3D7::Release()
4344 {
 45+ if(!this) return 0;
4446 ULONG ret;
4547 refcount--;
4648 ret = refcount;
@@ -49,6 +51,7 @@
5052
5153 HRESULT WINAPI glDirect3D7::QueryInterface(REFIID riid, void** ppvObj)
5254 {
 55+ if(!this) return DDERR_INVALIDPARAMS;
5356 FIXME("glDirect3D7::QueryInterface: stub");
5457 return E_NOINTERFACE;
5558 }
@@ -56,6 +59,7 @@
5760
5861 HRESULT WINAPI glDirect3D7::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7 *lplpD3DDevice)
5962 {
 63+ if(!this) return DDERR_INVALIDPARAMS;
6064 glDirect3DDevice7 *glD3DDev7 = new glDirect3DDevice7(this,(glDirectDrawSurface7*)lpDDS);
6165 *lplpD3DDevice = (LPDIRECT3DDEVICE7) glD3DDev7;
6266 return D3D_OK;
@@ -62,16 +66,19 @@
6367 }
6468 HRESULT WINAPI glDirect3D7::CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIRECT3DVERTEXBUFFER7* lplpD3DVertexBuffer, DWORD dwFlags)
6569 {
 70+ if(!this) return DDERR_INVALIDPARAMS;
6671 FIXME("glDirect3D7::CreateVertexBuffer: stub");
6772 return DDERR_GENERIC;
6873 }
6974 HRESULT WINAPI glDirect3D7::EnumDevices(LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg)
7075 {
 76+ if(!this) return DDERR_INVALIDPARAMS;
7177 FIXME("glDirect3D7::EnumDevices: stub");
7278 return DDERR_GENERIC;
7379 }
7480 HRESULT WINAPI glDirect3D7::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
7581 {
 82+ if(!this) return DDERR_INVALIDPARAMS;
7683 DDPIXELFORMAT ddpf;
7784 ZeroMemory(&ddpf,sizeof(DDPIXELFORMAT));
7885 ddpf.dwSize = sizeof(DDPIXELFORMAT);
@@ -101,6 +108,7 @@
102109 }
103110 HRESULT WINAPI glDirect3D7::EvictManagedTextures()
104111 {
 112+ if(!this) return DDERR_INVALIDPARAMS;
105113 FIXME("glDirect3D7::EvictManagedTextures: stub");
106114 return DDERR_GENERIC;
107115 }
Index: ddraw/glDirect3DDevice.cpp
@@ -179,16 +179,19 @@
180180
181181 HRESULT WINAPI glDirect3DDevice7::QueryInterface(REFIID riid, void** ppvObj)
182182 {
 183+ if(!this) return DDERR_INVALIDPARAMS;
183184 ERR(E_NOINTERFACE);
184185 }
185186
186187 ULONG WINAPI glDirect3DDevice7::AddRef()
187188 {
 189+ if(!this) return 0;
188190 refcount++;
189191 return refcount;
190192 }
191193 ULONG WINAPI glDirect3DDevice7::Release()
192194 {
 195+ if(!this) return 0;
193196 ULONG ret;
194197 refcount--;
195198 ret = refcount;
@@ -198,11 +201,13 @@
199202
200203 HRESULT WINAPI glDirect3DDevice7::ApplyStateBlock(DWORD dwBlockHandle)
201204 {
 205+ if(!this) return DDERR_INVALIDPARAMS;
202206 FIXME("glDirect3DDevice7::ApplyStateBlock: stub");
203207 ERR(DDERR_GENERIC);
204208 }
205209 HRESULT WINAPI glDirect3DDevice7::BeginScene()
206210 {
 211+ if(!this) return DDERR_INVALIDPARAMS;
207212 if(inscene) return D3DERR_SCENE_IN_SCENE;
208213 inscene = true;
209214 return D3D_OK;
@@ -209,21 +214,25 @@
210215 }
211216 HRESULT WINAPI glDirect3DDevice7::BeginStateBlock()
212217 {
 218+ if(!this) return DDERR_INVALIDPARAMS;
213219 FIXME("glDirect3DDevice7::BeginStateBlock: stub");
214220 ERR(DDERR_GENERIC);
215221 }
216222 HRESULT WINAPI glDirect3DDevice7::CaptureStateBlock(DWORD dwBlockHandle)
217223 {
 224+ if(!this) return DDERR_INVALIDPARAMS;
218225 FIXME("glDirect3DDevice7::CaptureStateBlock: stub");
219226 ERR(DDERR_GENERIC);
220227 }
221228 HRESULT WINAPI glDirect3DDevice7::CreateStateBlock(D3DSTATEBLOCKTYPE d3dsbtype, LPDWORD lpdwBlockHandle)
222229 {
 230+ if(!this) return DDERR_INVALIDPARAMS;
223231 FIXME("glDirect3DDevice7::CreateStateBlock: stub");
224232 ERR(DDERR_GENERIC);
225233 }
226234 HRESULT WINAPI glDirect3DDevice7::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
227235 {
 236+ if(!this) return DDERR_INVALIDPARAMS;
228237 if(dwCount && !lpRects) return DDERR_INVALIDPARAMS;
229238 if(dwCount) ERR(DDERR_INVALIDPARAMS);
230239 GLfloat color[4];
@@ -251,11 +260,13 @@
252261 HRESULT WINAPI glDirect3DDevice7::ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres,
253262 DWORD dwFlags, LPDWORD lpdwReturnValues)
254263 {
 264+ if(!this) return DDERR_INVALIDPARAMS;
255265 FIXME("glDirect3DDevice7::ComputeSphereVisibility: stub");
256266 ERR(DDERR_GENERIC);
257267 }
258268 HRESULT WINAPI glDirect3DDevice7::DeleteStateBlock(DWORD dwBlockHandle)
259269 {
 270+ if(!this) return DDERR_INVALIDPARAMS;
260271 FIXME("glDirect3DDevice7::DeleteStateBlock: stub");
261272 ERR(DDERR_GENERIC);
262273 }
@@ -291,6 +302,7 @@
292303 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
293304 LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
294305 {
 306+ if(!this) return DDERR_INVALIDPARAMS;
295307 if(!inscene) return D3DERR_SCENE_NOT_IN_SCENE;
296308 int drawmode = setdrawmode(d3dptPrimitiveType);
297309 if(drawmode == -1) return DDERR_INVALIDPARAMS;
@@ -303,6 +315,7 @@
304316 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
305317 LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVerticexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
306318 {
 319+ if(!this) return DDERR_INVALIDPARAMS;
307320 FIXME("glDirect3DDevice7::DrawIndexedPrimitiveStrided: stub");
308321 ERR(DDERR_GENERIC);
309322 }
@@ -309,6 +322,7 @@
310323 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER7 lpd3dVertexBuffer,
311324 DWORD dwStartVertex, DWORD dwNumVertices, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
312325 {
 326+ if(!this) return DDERR_INVALIDPARAMS;
313327 FIXME("glDirect3DDevice7::DrawIndexedPrimitiveVB: stub");
314328 ERR(DDERR_GENERIC);
315329 }
@@ -315,6 +329,7 @@
316330 HRESULT WINAPI glDirect3DDevice7::DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
317331 DWORD dwVertexCount, DWORD dwFlags)
318332 {
 333+ if(!this) return DDERR_INVALIDPARAMS;
319334 FIXME("glDirect3DDevice7::DrawPrimitive: stub");
320335 ERR(DDERR_GENERIC);
321336 }
@@ -321,6 +336,7 @@
322337 HRESULT WINAPI glDirect3DDevice7::DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,
323338 LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, DWORD dwFlags)
324339 {
 340+ if(!this) return DDERR_INVALIDPARAMS;
325341 FIXME("glDirect3DDevice7::DrawPrimitiveStrided: stub");
326342 ERR(DDERR_GENERIC);
327343 }
@@ -327,11 +343,13 @@
328344 HRESULT WINAPI glDirect3DDevice7::DrawPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER7 lpd3dVertexBuffer,
329345 DWORD dwStartVertex, DWORD dwNumVertices, DWORD dwFlags)
330346 {
 347+ if(!this) return DDERR_INVALIDPARAMS;
331348 FIXME("glDirect3DDevice7::DrawPrimitiveVB: stub");
332349 ERR(DDERR_GENERIC);
333350 }
334351 HRESULT WINAPI glDirect3DDevice7::EndScene()
335352 {
 353+ if(!this) return DDERR_INVALIDPARAMS;
336354 if(!inscene) return D3DERR_SCENE_NOT_IN_SCENE;
337355 inscene = false;
338356 glFlush();
@@ -339,51 +357,61 @@
340358 }
341359 HRESULT WINAPI glDirect3DDevice7::EndStateBlock(LPDWORD lpdwBlockHandle)
342360 {
 361+ if(!this) return DDERR_INVALIDPARAMS;
343362 FIXME("glDirect3DDevice7::EndStateBlock: stub");
344363 ERR(DDERR_GENERIC);
345364 }
346365 HRESULT WINAPI glDirect3DDevice7::EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg)
347366 {
 367+ if(!this) return DDERR_INVALIDPARAMS;
348368 FIXME("glDirect3DDevice7::EnumTextureFormats: stub");
349369 ERR(DDERR_GENERIC);
350370 }
351371 HRESULT WINAPI glDirect3DDevice7::GetCaps(LPD3DDEVICEDESC7 lpD3DDevDesc)
352372 {
 373+ if(!this) return DDERR_INVALIDPARAMS;
353374 FIXME("glDirect3DDevice7::GetCaps: stub");
354375 ERR(DDERR_GENERIC);
355376 }
356377 HRESULT WINAPI glDirect3DDevice7::GetClipPlane(DWORD dwIndex, D3DVALUE *pPlaneEquation)
357378 {
 379+ if(!this) return DDERR_INVALIDPARAMS;
358380 FIXME("glDirect3DDevice7::GetClipPlane: stub");
359381 ERR(DDERR_GENERIC);
360382 }
361383 HRESULT WINAPI glDirect3DDevice7::GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
362384 {
 385+ if(!this) return DDERR_INVALIDPARAMS;
363386 FIXME("glDirect3DDevice7::GetClipStatus: stub");
364387 ERR(DDERR_GENERIC);
365388 }
366389 HRESULT WINAPI glDirect3DDevice7::GetDirect3D(LPDIRECT3D7 *lplpD3D)
367390 {
 391+ if(!this) return DDERR_INVALIDPARAMS;
368392 *lplpD3D = glD3D7;
369393 return D3D_OK;
370394 }
371395 HRESULT WINAPI glDirect3DDevice7::GetInfo(DWORD dwDevInfoID, LPVOID pDevInfoStruct, DWORD dwSize)
372396 {
 397+ if(!this) return DDERR_INVALIDPARAMS;
373398 FIXME("glDirect3DDevice7::GetInfo: stub");
374399 ERR(DDERR_GENERIC);
375400 }
376401 HRESULT WINAPI glDirect3DDevice7::GetLight(DWORD dwLightIndex, LPD3DLIGHT7 lpLight)
377402 {
 403+ if(!this) return DDERR_INVALIDPARAMS;
378404 FIXME("glDirect3DDevice7::GetLight: stub");
379405 ERR(DDERR_GENERIC);
380406 }
381407 HRESULT WINAPI glDirect3DDevice7::GetLightEnable(DWORD dwLightIndex, BOOL* pbEnable)
382408 {
 409+ if(!this) return DDERR_INVALIDPARAMS;
383410 FIXME("glDirect3DDevice7::GetLightEnalbe: stub");
384411 ERR(DDERR_GENERIC);
385412 }
386413 HRESULT WINAPI glDirect3DDevice7::GetMaterial(LPD3DMATERIAL7 lpMaterial)
387414 {
 415+ if(!this) return DDERR_INVALIDPARAMS;
388416 if(!lpMaterial) return DDERR_INVALIDPARAMS;
389417 memcpy(lpMaterial,&material,sizeof(D3DMATERIAL7));
390418 return D3D_OK;
@@ -390,6 +418,7 @@
391419 }
392420 HRESULT WINAPI glDirect3DDevice7::GetRenderState(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState)
393421 {
 422+ if(!this) return DDERR_INVALIDPARAMS;
394423 if(dwRenderStateType <= 152)
395424 {
396425 *lpdwRenderState = renderstate[dwRenderStateType];
@@ -399,26 +428,31 @@
400429 }
401430 HRESULT WINAPI glDirect3DDevice7::GetRenderTarget(LPDIRECTDRAWSURFACE7 *lplpRenderTarget)
402431 {
 432+ if(!this) return DDERR_INVALIDPARAMS;
403433 FIXME("glDirect3DDevice7::GetRenderTarget: stub");
404434 ERR(DDERR_GENERIC);
405435 }
406436 HRESULT WINAPI glDirect3DDevice7::GetStateData(DWORD dwState, LPVOID* lplpStateData)
407437 {
 438+ if(!this) return DDERR_INVALIDPARAMS;
408439 FIXME("glDirect3DDevice7::GetStateData: stub");
409440 ERR(DDERR_GENERIC);
410441 }
411442 HRESULT WINAPI glDirect3DDevice7::GetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 *lplpTexture)
412443 {
 444+ if(!this) return DDERR_INVALIDPARAMS;
413445 FIXME("glDirect3DDevice7::GetTexture: stub");
414446 ERR(DDERR_GENERIC);
415447 }
416448 HRESULT WINAPI glDirect3DDevice7::GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, LPDWORD lpdwValue)
417449 {
 450+ if(!this) return DDERR_INVALIDPARAMS;
418451 FIXME("glDirect3DDevice7::GetTextureStageState: stub");
419452 ERR(DDERR_GENERIC);
420453 }
421454 HRESULT WINAPI glDirect3DDevice7::GetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
422455 {
 456+ if(!this) return DDERR_INVALIDPARAMS;
423457 switch(dtstTransformStateType)
424458 {
425459 case D3DTRANSFORMSTATE_WORLD:
@@ -436,11 +470,13 @@
437471 }
438472 HRESULT WINAPI glDirect3DDevice7::GetViewport(LPD3DVIEWPORT7 lpViewport)
439473 {
 474+ if(!this) return DDERR_INVALIDPARAMS;
440475 memcpy(lpViewport,&viewport,sizeof(D3DVIEWPORT7));
441476 return D3D_OK;
442477 }
443478 HRESULT WINAPI glDirect3DDevice7::LightEnable(DWORD dwLightIndex, BOOL bEnable)
444479 {
 480+ if(!this) return DDERR_INVALIDPARAMS;
445481 int i;
446482 D3DLIGHT7 light;
447483 bool foundlight = false;
@@ -482,31 +518,37 @@
483519 HRESULT WINAPI glDirect3DDevice7::Load(LPDIRECTDRAWSURFACE7 lpDestTex, LPPOINT lpDestPoint, LPDIRECTDRAWSURFACE7 lpSrcTex,
484520 LPRECT lprcSrcRect, DWORD dwFlags)
485521 {
 522+ if(!this) return DDERR_INVALIDPARAMS;
486523 FIXME("glDirect3DDevice7::Load: stub");
487524 ERR(DDERR_GENERIC);
488525 }
489526 HRESULT WINAPI glDirect3DDevice7::MultiplyTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
490527 {
 528+ if(!this) return DDERR_INVALIDPARAMS;
491529 FIXME("glDirect3DDevice7::MultiplyTransform: stub");
492530 ERR(DDERR_GENERIC);
493531 }
494532 HRESULT WINAPI glDirect3DDevice7::PreLoad(LPDIRECTDRAWSURFACE7 lpddsTexture)
495533 {
 534+ if(!this) return DDERR_INVALIDPARAMS;
496535 FIXME("glDirect3DDevice7::PreLoad: stub");
497536 ERR(DDERR_GENERIC);
498537 }
499538 HRESULT WINAPI glDirect3DDevice7::SetClipPlane(DWORD dwIndex, D3DVALUE* pPlaneEquation)
500539 {
 540+ if(!this) return DDERR_INVALIDPARAMS;
501541 FIXME("glDirect3DDevice7::SetClipPland: stub");
502542 ERR(DDERR_GENERIC);
503543 }
504544 HRESULT WINAPI glDirect3DDevice7::SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
505545 {
 546+ if(!this) return DDERR_INVALIDPARAMS;
506547 FIXME("glDirect3DDevice7::SetClipStatus: stub");
507548 ERR(DDERR_GENERIC);
508549 }
509550 HRESULT WINAPI glDirect3DDevice7::SetLight(DWORD dwLightIndex, LPD3DLIGHT7 lpLight)
510551 {
 552+ if(!this) return DDERR_INVALIDPARAMS;
511553 bool foundlight = false;
512554 if(dwLightIndex >= lightsmax)
513555 {
@@ -518,6 +560,7 @@
519561 }
520562 HRESULT WINAPI glDirect3DDevice7::SetMaterial(LPD3DMATERIAL7 lpMaterial)
521563 {
 564+ if(!this) return DDERR_INVALIDPARAMS;
522565 if(!lpMaterial) return DDERR_INVALIDPARAMS;
523566 memcpy(&material,lpMaterial,sizeof(D3DMATERIAL7));
524567 return D3D_OK;
@@ -525,6 +568,7 @@
526569
527570 HRESULT WINAPI glDirect3DDevice7::SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
528571 {
 572+ if(!this) return DDERR_INVALIDPARAMS;
529573 GLfloat floats[4];
530574 if(dwRendStateType > 152) return DDERR_INVALIDPARAMS;
531575 if(dwRendStateType < 0) return DDERR_INVALIDPARAMS;
@@ -565,26 +609,31 @@
566610 }
567611 HRESULT WINAPI glDirect3DDevice7::SetRenderTarget(LPDIRECTDRAWSURFACE7 lpNewRenderTarget, DWORD dwFlags)
568612 {
 613+ if(!this) return DDERR_INVALIDPARAMS;
569614 FIXME("glDirect3DDevice7::SetRenderTarget: stub");
570615 ERR(DDERR_GENERIC);
571616 }
572617 HRESULT WINAPI glDirect3DDevice7::SetStateData(DWORD dwState, LPVOID lpStateData)
573618 {
 619+ if(!this) return DDERR_INVALIDPARAMS;
574620 FIXME("glDirect3DDevice7::SetStateData: stub");
575621 ERR(DDERR_GENERIC);
576622 }
577623 HRESULT WINAPI glDirect3DDevice7::SetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 lpTexture)
578624 {
 625+ if(!this) return DDERR_INVALIDPARAMS;
579626 FIXME("glDirect3DDevice7::SetTexture: stub");
580627 ERR(DDERR_GENERIC);
581628 }
582629 HRESULT WINAPI glDirect3DDevice7::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
583630 {
 631+ if(!this) return DDERR_INVALIDPARAMS;
584632 FIXME("glDirect3DDevice7::SetTextureStageState: stub");
585633 ERR(DDERR_GENERIC);
586634 }
587635 HRESULT WINAPI glDirect3DDevice7::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
588636 {
 637+ if(!this) return DDERR_INVALIDPARAMS;
589638 switch(dtstTransformStateType)
590639 {
591640 case D3DTRANSFORMSTATE_WORLD:
@@ -602,11 +651,13 @@
603652 }
604653 HRESULT WINAPI glDirect3DDevice7::SetViewport(LPD3DVIEWPORT7 lpViewport)
605654 {
 655+ if(!this) return DDERR_INVALIDPARAMS;
606656 memcpy(&viewport,lpViewport,sizeof(D3DVIEWPORT7));
607657 return D3D_OK;
608658 }
609659 HRESULT WINAPI glDirect3DDevice7::ValidateDevice(LPDWORD lpdwPasses)
610660 {
 661+ if(!this) return DDERR_INVALIDPARAMS;
611662 FIXME("glDirect3DDevice7::ValidateDevice: stub");
612663 ERR(DDERR_GENERIC);
613664 }
\ No newline at end of file
Index: ddraw/glDirect3DLight.cpp
@@ -46,11 +46,13 @@
4747
4848 ULONG WINAPI glDirect3DLight::AddRef()
4949 {
 50+ if(!this) return 0;
5051 refcount++;
5152 return refcount;
5253 }
5354 ULONG WINAPI glDirect3DLight::Release()
5455 {
 56+ if(!this) return 0;
5557 ULONG ret;
5658 refcount--;
5759 ret = refcount;
@@ -60,11 +62,13 @@
6163
6264 HRESULT WINAPI glDirect3DLight::Initialize(LPDIRECT3D lpDirect3D)
6365 {
 66+ if(!this) return DDERR_INVALIDPARAMS;
6467 return DDERR_ALREADYINITIALIZED;
6568 }
6669
6770 HRESULT WINAPI glDirect3DLight::QueryInterface(REFIID riid, void** ppvObj)
6871 {
 72+ if(!this) return DDERR_INVALIDPARAMS;
6973 return E_NOINTERFACE;
7074 }
7175
@@ -80,11 +84,13 @@
8185
8286 HRESULT WINAPI glDirect3DLight::GetLight(LPD3DLIGHT lpLight)
8387 {
 88+ if(!this) return DDERR_INVALIDPARAMS;
8489 FIXME("glDirect3DLight::GetLight: stub");
8590 ERR(DDERR_GENERIC);
8691 }
8792 HRESULT WINAPI glDirect3DLight::SetLight(LPD3DLIGHT lpLight)
8893 {
 94+ if(!this) return DDERR_INVALIDPARAMS;
8995 FIXME("glDirect3DLight::SetLight: stub");
9096 ERR(DDERR_GENERIC);
9197 }
Index: ddraw/glDirectDraw.cpp
@@ -596,6 +596,7 @@
597597
598598 HRESULT WINAPI glDirectDraw7::QueryInterface(REFIID riid, void** ppvObj)
599599 {
 600+ if(!this) return DDERR_INVALIDPARAMS;
600601 if(riid == IID_IDirectDraw)
601602 {
602603 // Create an IDirectDraw1 interface
@@ -665,11 +666,13 @@
666667 }
667668 ULONG WINAPI glDirectDraw7::AddRef()
668669 {
 670+ if(!this) return 0;
669671 refcount++;
670672 return refcount;
671673 }
672674 ULONG WINAPI glDirectDraw7::Release()
673675 {
 676+ if(!this) return 0;
674677 ULONG ret;
675678 refcount--;
676679 ret = refcount;
@@ -679,10 +682,12 @@
680683 }
681684 HRESULT WINAPI glDirectDraw7::Compact()
682685 {
 686+ if(!this) return DDERR_INVALIDPARAMS;
683687 return DD_OK;
684688 }
685689 HRESULT WINAPI glDirectDraw7::CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
686690 {
 691+ if(!this) return DDERR_INVALIDPARAMS;
687692 clippercount++;
688693 if(clippercount > clippercountmax)
689694 {
@@ -700,11 +705,13 @@
701706 }
702707 HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
703708 {
 709+ if(!this) return DDERR_INVALIDPARAMS;
704710 glDirectDrawPalette *pal = new glDirectDrawPalette(dwFlags,lpDDColorArray,lplpDDPalette);
705711 return DD_OK;
706712 }
707713 HRESULT WINAPI glDirectDraw7::CreateSurface(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
708714 {
 715+ if(!this) return DDERR_INVALIDPARAMS;
709716 if(!lpDDSurfaceDesc2) return DDERR_INVALIDPARAMS;
710717 if(primary && (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && (renderer->hRC == primary->hRC) )
711718 {
@@ -740,20 +747,24 @@
741748 }
742749 HRESULT WINAPI glDirectDraw7::DuplicateSurface(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDIRECTDRAWSURFACE7 FAR *lplpDupDDSurface)
743750 {
 751+ if(!this) return DDERR_INVALIDPARAMS;
744752 FIXME("IDirectDraw::DuplicateSurface: stub\n");
745753 ERR(DDERR_GENERIC);
746754 }
747755 HRESULT WINAPI glDirectDraw7::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback)
748756 {
 757+ if(!this) return DDERR_INVALIDPARAMS;
749758 return ::EnumDisplayModes(dwFlags,lpDDSurfaceDesc2,lpContext,lpEnumModesCallback);
750759 }
751760 HRESULT WINAPI glDirectDraw7::EnumSurfaces(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD2, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback)
752761 {
 762+ if(!this) return DDERR_INVALIDPARAMS;
753763 FIXME("IDirectDraw::EnumSurfaces: stub\n");
754764 ERR(DDERR_GENERIC);
755765 }
756766 HRESULT WINAPI glDirectDraw7::FlipToGDISurface()
757767 {
 768+ if(!this) return DDERR_INVALIDPARAMS;
758769 HRESULT error = DD_OK;
759770 if(primary)
760771 {
@@ -771,6 +782,7 @@
772783 }
773784 HRESULT WINAPI glDirectDraw7::GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
774785 {
 786+ if(!this) return DDERR_INVALIDPARAMS;
775787 //TODO: Fill in as implemented.
776788 DDCAPS_DX7 ddCaps;
777789 ZeroMemory(&ddCaps,sizeof(DDCAPS_DX7));
@@ -795,6 +807,7 @@
796808 }
797809 HRESULT WINAPI glDirectDraw7::GetDisplayMode(LPDDSURFACEDESC2 lpDDSurfaceDesc2)
798810 {
 811+ if(!this) return DDERR_INVALIDPARAMS;
799812 if(!lpDDSurfaceDesc2) ERR(DDERR_INVALIDPARAMS);
800813 DDSURFACEDESC2 ddsdMode;
801814 ZeroMemory(&ddsdMode, sizeof(DDSURFACEDESC2));
@@ -880,16 +893,19 @@
881894 }
882895 HRESULT WINAPI glDirectDraw7::GetFourCCCodes(LPDWORD lpNumCodes, LPDWORD lpCodes)
883896 {
 897+ if(!this) return DDERR_INVALIDPARAMS;
884898 FIXME("IDirectDraw::GetFourCCCodes: stub\n");
885899 ERR(DDERR_GENERIC);
886900 }
887901 HRESULT WINAPI glDirectDraw7::GetGDISurface(LPDIRECTDRAWSURFACE7 FAR *lplpGDIDDSurface)
888902 {
 903+ if(!this) return DDERR_INVALIDPARAMS;
889904 FIXME("IDirectDraw::GetGDISurface: stub\n");
890905 ERR(DDERR_GENERIC);
891906 }
892907 HRESULT WINAPI glDirectDraw7::GetMonitorFrequency(LPDWORD lpdwFrequency)
893908 {
 909+ if(!this) return DDERR_INVALIDPARAMS;
894910 DEBUG("IDirectDraw::GetMonitorFrequency: support multi-monitor\n");
895911 DEVMODE devmode;
896912 devmode.dmSize = sizeof(DEVMODE);
@@ -899,16 +915,19 @@
900916 }
901917 HRESULT WINAPI glDirectDraw7::GetScanLine(LPDWORD lpdwScanLine)
902918 {
 919+ if(!this) return DDERR_INVALIDPARAMS;
903920 FIXME("IDirectDraw::GetScanLine: stub\n");
904921 ERR(DDERR_GENERIC);
905922 }
906923 HRESULT WINAPI glDirectDraw7::GetVerticalBlankStatus(LPBOOL lpbIsInVB)
907924 {
 925+ if(!this) return DDERR_INVALIDPARAMS;
908926 FIXME("IDirectDraw::GetVerticalBlankStatus: stub\n");
909927 ERR(DDERR_GENERIC);
910928 }
911929 HRESULT WINAPI glDirectDraw7::Initialize(GUID FAR *lpGUID)
912930 {
 931+ if(!this) return DDERR_INVALIDPARAMS;
913932 if(initialized) return DDERR_ALREADYINITIALIZED;
914933 primarylost = true;
915934 glD3D7 = NULL;
@@ -953,6 +972,7 @@
954973 }
955974 HRESULT WINAPI glDirectDraw7::RestoreDisplayMode()
956975 {
 976+ if(!this) return DDERR_INVALIDPARAMS;
957977 if(oldmode.dmSize != 0)
958978 {
959979 ChangeDisplaySettingsEx(NULL,&oldmode,NULL,0,NULL);
@@ -961,6 +981,7 @@
962982 }
963983 HRESULT WINAPI glDirectDraw7::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
964984 {
 985+ if(!this) return DDERR_INVALIDPARAMS;
965986 this->hWnd = hWnd;
966987 if(renderer) DeleteGL();
967988 winstyle = GetWindowLongPtrA(hWnd,GWL_STYLE);
@@ -1090,6 +1111,7 @@
10911112
10921113 HRESULT WINAPI glDirectDraw7::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
10931114 {
 1115+ if(!this) return DDERR_INVALIDPARAMS;
10941116 DEBUG("IDirectDraw::SetDisplayMode: implement multiple monitors\n");
10951117 DEVMODE newmode,newmode2;
10961118 DEVMODE currmode;
@@ -1286,6 +1308,7 @@
12871309 }
12881310 HRESULT WINAPI glDirectDraw7::WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
12891311 {
 1312+ if(!this) return DDERR_INVALIDPARAMS;
12901313 if(dwFlags & DDWAITVB_BLOCKBEGINEVENT) return DDERR_UNSUPPORTED;
12911314 swapinterval=1;
12921315 primary->RenderScreen(primary->texture,primary);
@@ -1294,26 +1317,32 @@
12951318 }
12961319 HRESULT WINAPI glDirectDraw7::GetAvailableVidMem(LPDDSCAPS2 lpDDSCaps2, LPDWORD lpdwTotal, LPDWORD lpdwFree)
12971320 {
 1321+ if(!this) return DDERR_INVALIDPARAMS;
12981322 FIXME("IDirectDraw::GetAvailableVidMem: stub\n");
12991323 ERR(DDERR_GENERIC);
13001324 }
13011325 HRESULT WINAPI glDirectDraw7::GetSurfaceFromDC(HDC hdc, LPDIRECTDRAWSURFACE7 *lpDDS)
13021326 {
 1327+ if(!this) return DDERR_INVALIDPARAMS;
13031328 FIXME("IDirectDraw::GetSurfaceFromDC: stub\n");
13041329 ERR(DDERR_GENERIC);
13051330 }
13061331 HRESULT WINAPI glDirectDraw7::RestoreAllSurfaces()
13071332 {
 1333+ if(!this) return DDERR_INVALIDPARAMS;
13081334 FIXME("IDirectDraw::RestoreAllSurfaces: stub\n");
13091335 ERR(DDERR_GENERIC);
13101336 }
13111337 HRESULT WINAPI glDirectDraw7::TestCooperativeLevel()
13121338 {
 1339+ if(!this) return DDERR_INVALIDPARAMS;
13131340 FIXME("IDirectDraw::TestCooperativeLevel: stub\n");
13141341 ERR(DDERR_GENERIC);
13151342 }
13161343 HRESULT WINAPI glDirectDraw7::GetDeviceIdentifier(LPDDDEVICEIDENTIFIER2 lpdddi, DWORD dwFlags)
13171344 {
 1345+ if(!this) return DDERR_INVALIDPARAMS;
 1346+ if(!lpdddi) return DDERR_INVALIDPARAMS;
13181347 devid.guidDeviceIdentifier = device_template;
13191348 memcpy(lpdddi,&devid,sizeof(DDDEVICEIDENTIFIER2));
13201349 return DD_OK;
@@ -1320,11 +1349,13 @@
13211350 }
13221351 HRESULT WINAPI glDirectDraw7::StartModeTest(LPSIZE lpModesToTest, DWORD dwNumEntries, DWORD dwFlags)
13231352 {
 1353+ if(!this) return DDERR_INVALIDPARAMS;
13241354 FIXME("IDirectDraw::StartModeTest: stub\n");
13251355 ERR(DDERR_GENERIC);
13261356 }
13271357 HRESULT WINAPI glDirectDraw7::EvaluateMode(DWORD dwFlags, DWORD *pSecondsUntilTimeout)
13281358 {
 1359+ if(!this) return DDERR_INVALIDPARAMS;
13291360 FIXME("IDirectDraw::EvaluateMode: stub\n");
13301361 ERR(DDERR_GENERIC);
13311362 }
@@ -1370,15 +1401,18 @@
13711402 }
13721403 HRESULT WINAPI glDirectDraw1::QueryInterface(REFIID riid, void** ppvObj)
13731404 {
 1405+ if(!this) return DDERR_INVALIDPARAMS;
13741406 return glDD7->QueryInterface(riid,ppvObj);
13751407 }
13761408 ULONG WINAPI glDirectDraw1::AddRef()
13771409 {
 1410+ if(!this) return 0;
13781411 refcount++;
13791412 return refcount;
13801413 }
13811414 ULONG WINAPI glDirectDraw1::Release()
13821415 {
 1416+ if(!this) return 0;
13831417 ULONG ret;
13841418 refcount--;
13851419 ret = refcount;
@@ -1387,18 +1421,22 @@
13881422 }
13891423 HRESULT WINAPI glDirectDraw1::Compact()
13901424 {
 1425+ if(!this) return DDERR_INVALIDPARAMS;
13911426 return glDD7->Compact();
13921427 }
13931428 HRESULT WINAPI glDirectDraw1::CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
13941429 {
 1430+ if(!this) return DDERR_INVALIDPARAMS;
13951431 return glDD7->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter);
13961432 }
13971433 HRESULT WINAPI glDirectDraw1::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
13981434 {
 1435+ if(!this) return DDERR_INVALIDPARAMS;
13991436 return glDD7->CreatePalette(dwFlags,lpDDColorArray,lplpDDPalette,pUnkOuter);
14001437 }
14011438 HRESULT WINAPI glDirectDraw1::CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
14021439 {
 1440+ if(!this) return DDERR_INVALIDPARAMS;
14031441 LPDIRECTDRAWSURFACE7 lpDDS7;
14041442 HRESULT err = glDD7->CreateSurface((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter);
14051443 if(err == DD_OK)
@@ -1411,69 +1449,85 @@
14121450 }
14131451 HRESULT WINAPI glDirectDraw1::DuplicateSurface(LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE FAR *lplpDupDDSurface)
14141452 {
 1453+ if(!this) return DDERR_INVALIDPARAMS;
14151454 FIXME("glDirectDraw1::DuplicateSurface: stub\n");
14161455 ERR(DDERR_GENERIC);
14171456 }
14181457 HRESULT WINAPI glDirectDraw1::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
14191458 {
 1459+ if(!this) return DDERR_INVALIDPARAMS;
14201460 return ::EnumDisplayModes(dwFlags,lpDDSurfaceDesc,lpContext,lpEnumModesCallback);
14211461 }
14221462 HRESULT WINAPI glDirectDraw1::EnumSurfaces(DWORD dwFlags, LPDDSURFACEDESC lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
14231463 {
 1464+ if(!this) return DDERR_INVALIDPARAMS;
14241465 FIXME("glDirectDraw1::EnumSurfaces: stub\n");
14251466 ERR(DDERR_GENERIC);
14261467 }
14271468 HRESULT WINAPI glDirectDraw1::FlipToGDISurface()
14281469 {
 1470+ if(!this) return DDERR_INVALIDPARAMS;
14291471 return glDD7->FlipToGDISurface();
14301472 }
14311473 HRESULT WINAPI glDirectDraw1::GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
14321474 {
 1475+ if(!this) return DDERR_INVALIDPARAMS;
14331476 return glDD7->GetCaps(lpDDDriverCaps,lpDDHELCaps);
14341477 }
14351478 HRESULT WINAPI glDirectDraw1::GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc)
14361479 {
 1480+ if(!this) return DDERR_INVALIDPARAMS;
14371481 return glDD7->GetDisplayMode((LPDDSURFACEDESC2)lpDDSurfaceDesc);
14381482 }
14391483 HRESULT WINAPI glDirectDraw1::GetFourCCCodes(LPDWORD lpNumCodes, LPDWORD lpCodes)
14401484 {
 1485+ if(!this) return DDERR_INVALIDPARAMS;
14411486 return glDD7->GetFourCCCodes(lpNumCodes,lpCodes);
14421487 }
14431488 HRESULT WINAPI glDirectDraw1::GetGDISurface(LPDIRECTDRAWSURFACE FAR *lplpGDIDDSurface)
14441489 {
 1490+ if(!this) return DDERR_INVALIDPARAMS;
14451491 FIXME("glDirectDraw1::GetGDISurface: stub\n");
14461492 ERR(DDERR_GENERIC);
14471493 }
14481494 HRESULT WINAPI glDirectDraw1::GetMonitorFrequency(LPDWORD lpdwFrequency)
14491495 {
 1496+ if(!this) return DDERR_INVALIDPARAMS;
14501497 return glDD7->GetMonitorFrequency(lpdwFrequency);
14511498 }
14521499 HRESULT WINAPI glDirectDraw1::GetScanLine(LPDWORD lpdwScanLine)
14531500 {
 1501+ if(!this) return DDERR_INVALIDPARAMS;
14541502 return glDD7->GetScanLine(lpdwScanLine);
14551503 }
14561504 HRESULT WINAPI glDirectDraw1::GetVerticalBlankStatus(LPBOOL lpbIsInVB)
14571505 {
 1506+ if(!this) return DDERR_INVALIDPARAMS;
14581507 return glDD7->GetVerticalBlankStatus(lpbIsInVB);
14591508 }
14601509 HRESULT WINAPI glDirectDraw1::Initialize(GUID FAR *lpGUID)
14611510 {
 1511+ if(!this) return DDERR_INVALIDPARAMS;
14621512 return glDD7->Initialize(lpGUID);
14631513 }
14641514 HRESULT WINAPI glDirectDraw1::RestoreDisplayMode()
14651515 {
 1516+ if(!this) return DDERR_INVALIDPARAMS;
14661517 return glDD7->RestoreDisplayMode();
14671518 }
14681519 HRESULT WINAPI glDirectDraw1::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
14691520 {
 1521+ if(!this) return DDERR_INVALIDPARAMS;
14701522 return glDD7->SetCooperativeLevel(hWnd,dwFlags);
14711523 }
14721524 HRESULT WINAPI glDirectDraw1::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP)
14731525 {
 1526+ if(!this) return DDERR_INVALIDPARAMS;
14741527 return glDD7->SetDisplayMode(dwWidth,dwHeight,dwBPP,0,0);
14751528 }
14761529 HRESULT WINAPI glDirectDraw1::WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
14771530 {
 1531+ if(!this) return DDERR_INVALIDPARAMS;
14781532 return glDD7->WaitForVerticalBlank(dwFlags,hEvent);
14791533 }
14801534 // DDRAW2 wrapper
@@ -1489,15 +1543,18 @@
14901544 }
14911545 HRESULT WINAPI glDirectDraw2::QueryInterface(REFIID riid, void** ppvObj)
14921546 {
 1547+ if(!this) return DDERR_INVALIDPARAMS;
14931548 return glDD7->QueryInterface(riid,ppvObj);
14941549 }
14951550 ULONG WINAPI glDirectDraw2::AddRef()
14961551 {
 1552+ if(!this) return 0;
14971553 refcount++;
14981554 return refcount;
14991555 }
15001556 ULONG WINAPI glDirectDraw2::Release()
15011557 {
 1558+ if(!this) return 0;
15021559 ULONG ret;
15031560 refcount--;
15041561 ret = refcount;
@@ -1506,18 +1563,22 @@
15071564 }
15081565 HRESULT WINAPI glDirectDraw2::Compact()
15091566 {
 1567+ if(!this) return DDERR_INVALIDPARAMS;
15101568 return glDD7->Compact();
15111569 }
15121570 HRESULT WINAPI glDirectDraw2::CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
15131571 {
 1572+ if(!this) return DDERR_INVALIDPARAMS;
15141573 return glDD7->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter);
15151574 }
15161575 HRESULT WINAPI glDirectDraw2::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
15171576 {
 1577+ if(!this) return DDERR_INVALIDPARAMS;
15181578 return glDD7->CreatePalette(dwFlags,lpDDColorArray,lplpDDPalette,pUnkOuter);
15191579 }
15201580 HRESULT WINAPI glDirectDraw2::CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
15211581 {
 1582+ if(!this) return DDERR_INVALIDPARAMS;
15221583 if(!lplpDDSurface) return DDERR_INVALIDPARAMS;
15231584 LPDIRECTDRAWSURFACE7 lpDDS7;
15241585 HRESULT err = glDD7->CreateSurface((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter);
@@ -1531,73 +1592,90 @@
15321593 }
15331594 HRESULT WINAPI glDirectDraw2::DuplicateSurface(LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE FAR *lplpDupDDSurface)
15341595 {
 1596+ if(!this) return DDERR_INVALIDPARAMS;
15351597 FIXME("glDirectDraw2::DuplicateSurface: stub\n");
15361598 ERR(DDERR_GENERIC);
15371599 }
15381600 HRESULT WINAPI glDirectDraw2::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
15391601 {
 1602+ if(!this) return DDERR_INVALIDPARAMS;
15401603 return ::EnumDisplayModes(dwFlags,lpDDSurfaceDesc,lpContext,lpEnumModesCallback);
15411604 }
15421605 HRESULT WINAPI glDirectDraw2::EnumSurfaces(DWORD dwFlags, LPDDSURFACEDESC lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
15431606 {
 1607+ if(!this) return DDERR_INVALIDPARAMS;
15441608 FIXME("glDirectDraw2::EnumSurfaces: stub\n");
15451609 ERR(DDERR_GENERIC);
15461610 }
15471611 HRESULT WINAPI glDirectDraw2::FlipToGDISurface()
15481612 {
 1613+ if(!this) return DDERR_INVALIDPARAMS;
15491614 return glDD7->FlipToGDISurface();
15501615 }
15511616 HRESULT WINAPI glDirectDraw2::GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
15521617 {
 1618+ if(!this) return DDERR_INVALIDPARAMS;
15531619 return glDD7->GetCaps(lpDDDriverCaps,lpDDHELCaps);
15541620 }
15551621 HRESULT WINAPI glDirectDraw2::GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc)
15561622 {
 1623+ if(!this) return DDERR_INVALIDPARAMS;
15571624 return glDD7->GetDisplayMode((LPDDSURFACEDESC2)lpDDSurfaceDesc);
15581625 }
15591626 HRESULT WINAPI glDirectDraw2::GetFourCCCodes(LPDWORD lpNumCodes, LPDWORD lpCodes)
15601627 {
 1628+ if(!this) return DDERR_INVALIDPARAMS;
15611629 return glDD7->GetFourCCCodes(lpNumCodes,lpCodes);
15621630 }
15631631 HRESULT WINAPI glDirectDraw2::GetGDISurface(LPDIRECTDRAWSURFACE FAR *lplpGDIDDSurface)
15641632 {
 1633+ if(!this) return DDERR_INVALIDPARAMS;
15651634 FIXME("glDirectDraw2::GetGDISurface: stub\n");
15661635 ERR(DDERR_GENERIC);
15671636 }
15681637 HRESULT WINAPI glDirectDraw2::GetMonitorFrequency(LPDWORD lpdwFrequency)
15691638 {
 1639+ if(!this) return DDERR_INVALIDPARAMS;
15701640 return glDD7->GetMonitorFrequency(lpdwFrequency);
15711641 }
15721642 HRESULT WINAPI glDirectDraw2::GetScanLine(LPDWORD lpdwScanLine)
15731643 {
 1644+ if(!this) return DDERR_INVALIDPARAMS;
15741645 return glDD7->GetScanLine(lpdwScanLine);
15751646 }
15761647 HRESULT WINAPI glDirectDraw2::GetVerticalBlankStatus(LPBOOL lpbIsInVB)
15771648 {
 1649+ if(!this) return DDERR_INVALIDPARAMS;
15781650 return glDD7->GetVerticalBlankStatus(lpbIsInVB);
15791651 }
15801652 HRESULT WINAPI glDirectDraw2::Initialize(GUID FAR *lpGUID)
15811653 {
 1654+ if(!this) return DDERR_INVALIDPARAMS;
15821655 return glDD7->Initialize(lpGUID);
15831656 }
15841657 HRESULT WINAPI glDirectDraw2::RestoreDisplayMode()
15851658 {
 1659+ if(!this) return DDERR_INVALIDPARAMS;
15861660 return glDD7->RestoreDisplayMode();
15871661 }
15881662 HRESULT WINAPI glDirectDraw2::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
15891663 {
 1664+ if(!this) return DDERR_INVALIDPARAMS;
15901665 return glDD7->SetCooperativeLevel(hWnd,dwFlags);
15911666 }
15921667 HRESULT WINAPI glDirectDraw2::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
15931668 {
 1669+ if(!this) return DDERR_INVALIDPARAMS;
15941670 return glDD7->SetDisplayMode(dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags);
15951671 }
15961672 HRESULT WINAPI glDirectDraw2::WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
15971673 {
 1674+ if(!this) return DDERR_INVALIDPARAMS;
15981675 return glDD7->WaitForVerticalBlank(dwFlags,hEvent);
15991676 }
16001677 HRESULT WINAPI glDirectDraw2::GetAvailableVidMem(LPDDSCAPS lpDDSCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree)
16011678 {
 1679+ if(!this) return DDERR_INVALIDPARAMS;
16021680 MEMORYSTATUS memstatus;
16031681 memstatus.dwLength = sizeof(MEMORYSTATUS);
16041682 GlobalMemoryStatus(&memstatus);
@@ -1617,15 +1695,18 @@
16181696 }
16191697 HRESULT WINAPI glDirectDraw4::QueryInterface(REFIID riid, void** ppvObj)
16201698 {
 1699+ if(!this) return DDERR_INVALIDPARAMS;
16211700 return glDD7->QueryInterface(riid,ppvObj);
16221701 }
16231702 ULONG WINAPI glDirectDraw4::AddRef()
16241703 {
 1704+ if(!this) return 0;
16251705 refcount++;
16261706 return refcount;
16271707 }
16281708 ULONG WINAPI glDirectDraw4::Release()
16291709 {
 1710+ if(!this) return 0;
16301711 ULONG ret;
16311712 refcount--;
16321713 ret = refcount;
@@ -1634,18 +1715,22 @@
16351716 }
16361717 HRESULT WINAPI glDirectDraw4::Compact()
16371718 {
 1719+ if(!this) return DDERR_INVALIDPARAMS;
16381720 return glDD7->Compact();
16391721 }
16401722 HRESULT WINAPI glDirectDraw4::CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
16411723 {
 1724+ if(!this) return DDERR_INVALIDPARAMS;
16421725 return glDD7->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter);
16431726 }
16441727 HRESULT WINAPI glDirectDraw4::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
16451728 {
 1729+ if(!this) return DDERR_INVALIDPARAMS;
16461730 return glDD7->CreatePalette(dwFlags,lpDDColorArray,lplpDDPalette,pUnkOuter);
16471731 }
16481732 HRESULT WINAPI glDirectDraw4::CreateSurface(LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE4 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
16491733 {
 1734+ if(!this) return DDERR_INVALIDPARAMS;
16501735 LPDIRECTDRAWSURFACE7 lpDDS7;
16511736 HRESULT err = glDD7->CreateSurface((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter);
16521737 if(err == DD_OK)
@@ -1657,91 +1742,113 @@
16581743 return err;}
16591744 HRESULT WINAPI glDirectDraw4::DuplicateSurface(LPDIRECTDRAWSURFACE4 lpDDSurface, LPDIRECTDRAWSURFACE4 FAR *lplpDupDDSurface)
16601745 {
 1746+ if(!this) return DDERR_INVALIDPARAMS;
16611747 FIXME("glDirectDraw4::DuplicateSurface: stub\n");
16621748 ERR(DDERR_GENERIC);
16631749 }
16641750 HRESULT WINAPI glDirectDraw4::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback)
16651751 {
 1752+ if(!this) return DDERR_INVALIDPARAMS;
16661753 return ::EnumDisplayModes(dwFlags,lpDDSurfaceDesc,lpContext,lpEnumModesCallback);
16671754 }
16681755 HRESULT WINAPI glDirectDraw4::EnumSurfaces(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumSurfacesCallback)
16691756 {
 1757+ if(!this) return DDERR_INVALIDPARAMS;
16701758 FIXME("glDirectDraw4::EnumSurfaces: stub\n");
16711759 ERR(DDERR_GENERIC);
16721760 }
16731761 HRESULT WINAPI glDirectDraw4::FlipToGDISurface()
16741762 {
 1763+ if(!this) return DDERR_INVALIDPARAMS;
16751764 return glDD7->FlipToGDISurface();
16761765 }
16771766 HRESULT WINAPI glDirectDraw4::GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
16781767 {
 1768+ if(!this) return DDERR_INVALIDPARAMS;
16791769 return glDD7->GetCaps(lpDDDriverCaps,lpDDHELCaps);
16801770 }
16811771 HRESULT WINAPI glDirectDraw4::GetDisplayMode(LPDDSURFACEDESC2 lpDDSurfaceDesc2)
16821772 {
 1773+ if(!this) return DDERR_INVALIDPARAMS;
16831774 return glDD7->GetDisplayMode(lpDDSurfaceDesc2);
16841775 }
16851776 HRESULT WINAPI glDirectDraw4::GetFourCCCodes(LPDWORD lpNumCodes, LPDWORD lpCodes)
16861777 {
 1778+ if(!this) return DDERR_INVALIDPARAMS;
16871779 return glDD7->GetFourCCCodes(lpNumCodes,lpCodes);
16881780 }
16891781 HRESULT WINAPI glDirectDraw4::GetGDISurface(LPDIRECTDRAWSURFACE4 FAR *lplpGDIDDSurface)
16901782 {
 1783+ if(!this) return DDERR_INVALIDPARAMS;
16911784 FIXME("glDirectDraw4::GetGDISurface: stub\n");
16921785 ERR(DDERR_GENERIC);
16931786 }
16941787 HRESULT WINAPI glDirectDraw4::GetMonitorFrequency(LPDWORD lpdwFrequency)
16951788 {
 1789+ if(!this) return DDERR_INVALIDPARAMS;
16961790 return glDD7->GetMonitorFrequency(lpdwFrequency);
16971791 }
16981792 HRESULT WINAPI glDirectDraw4::GetScanLine(LPDWORD lpdwScanLine)
16991793 {
 1794+ if(!this) return DDERR_INVALIDPARAMS;
17001795 return glDD7->GetScanLine(lpdwScanLine);
17011796 }
17021797 HRESULT WINAPI glDirectDraw4::GetVerticalBlankStatus(LPBOOL lpbIsInVB)
17031798 {
 1799+ if(!this) return DDERR_INVALIDPARAMS;
17041800 return glDD7->GetVerticalBlankStatus(lpbIsInVB);
17051801 }
17061802 HRESULT WINAPI glDirectDraw4::Initialize(GUID FAR *lpGUID)
17071803 {
 1804+ if(!this) return DDERR_INVALIDPARAMS;
17081805 return glDD7->Initialize(lpGUID);
17091806 }
17101807 HRESULT WINAPI glDirectDraw4::RestoreDisplayMode()
17111808 {
 1809+ if(!this) return DDERR_INVALIDPARAMS;
17121810 return glDD7->RestoreDisplayMode();
17131811 }
17141812 HRESULT WINAPI glDirectDraw4::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
17151813 {
 1814+ if(!this) return DDERR_INVALIDPARAMS;
17161815 return glDD7->SetCooperativeLevel(hWnd,dwFlags);
17171816 }
17181817 HRESULT WINAPI glDirectDraw4::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
17191818 {
 1819+ if(!this) return DDERR_INVALIDPARAMS;
17201820 return glDD7->SetDisplayMode(dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags);
17211821 }
17221822 HRESULT WINAPI glDirectDraw4::WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
17231823 {
 1824+ if(!this) return DDERR_INVALIDPARAMS;
17241825 return glDD7->WaitForVerticalBlank(dwFlags,hEvent);
17251826 }
17261827 HRESULT WINAPI glDirectDraw4::GetAvailableVidMem(LPDDSCAPS2 lpDDSCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree)
17271828 {
 1829+ if(!this) return DDERR_INVALIDPARAMS;
17281830 FIXME("IDirectDraw4::GetAvailableVidMem: stub\n");
17291831 ERR(DDERR_GENERIC);
17301832 }
17311833 HRESULT WINAPI glDirectDraw4::GetSurfaceFromDC(HDC hdc, LPDIRECTDRAWSURFACE4 *lpDDS)
17321834 {
 1835+ if(!this) return DDERR_INVALIDPARAMS;
17331836 FIXME("IDirectDraw4::GetSurfaceFromDC: stub\n");
17341837 ERR(DDERR_GENERIC);
17351838 }
17361839 HRESULT WINAPI glDirectDraw4::RestoreAllSurfaces()
17371840 {
 1841+ if(!this) return DDERR_INVALIDPARAMS;
17381842 return glDD7->RestoreAllSurfaces();
17391843 }
17401844 HRESULT WINAPI glDirectDraw4::TestCooperativeLevel()
17411845 {
 1846+ if(!this) return DDERR_INVALIDPARAMS;
17421847 return glDD7->TestCooperativeLevel();
17431848 }
17441849 HRESULT WINAPI glDirectDraw4::GetDeviceIdentifier(LPDDDEVICEIDENTIFIER lpdddi, DWORD dwFlags)
17451850 {
 1851+ if(!this) return DDERR_INVALIDPARAMS;
 1852+ if(!lpdddi) return DDERR_INVALIDPARAMS;
17461853 devid.guidDeviceIdentifier = device_template;
17471854 memcpy(lpdddi,&devid,sizeof(DDDEVICEIDENTIFIER));
17481855 return DD_OK;
Index: ddraw/glDirectDrawClipper.cpp
@@ -35,6 +35,7 @@
3636 }
3737 HRESULT WINAPI glDirectDrawClipper::QueryInterface(REFIID riid, LPVOID* obp)
3838 {
 39+ if(!this) return DDERR_INVALIDPARAMS;
3940 if(riid == IID_IDirectDrawClipper)
4041 {
4142 *obp = this;
@@ -45,11 +46,13 @@
4647 }
4748 ULONG WINAPI glDirectDrawClipper::AddRef()
4849 {
 50+ if(!this) return 0;
4951 refcount++;
5052 return refcount;
5153 }
5254 ULONG WINAPI glDirectDrawClipper::Release()
5355 {
 56+ if(!this) return 0;
5457 ULONG ret;
5558 refcount--;
5659 ret = refcount;
@@ -58,11 +61,13 @@
5962 }
6063 HRESULT WINAPI glDirectDrawClipper::GetClipList(LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize)
6164 {
 65+ if(!this) return DDERR_INVALIDPARAMS;
6266 FIXME("IDirectDrawClipper::GetClipList: stub");
6367 ERR(DDERR_GENERIC);
6468 }
6569 HRESULT WINAPI glDirectDrawClipper::GetHWnd(HWND FAR *lphWnd)
6670 {
 71+ if(!this) return DDERR_INVALIDPARAMS;
6772 *lphWnd = hWnd;
6873 if(!hWnd) return DDERR_INVALIDOBJECT;
6974 return DD_OK;
@@ -69,6 +74,7 @@
7075 }
7176 HRESULT WINAPI glDirectDrawClipper::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags)
7277 {
 78+ if(!this) return DDERR_INVALIDPARAMS;
7379 if(initialized) return DDERR_ALREADYINITIALIZED;
7480 glDD7 = (glDirectDraw7*)lpDD;
7581 if(glDD7) hasparent = true;
@@ -80,16 +86,19 @@
8187 }
8288 HRESULT WINAPI glDirectDrawClipper::IsClipListChanged(BOOL FAR *lpbChanged)
8389 {
 90+ if(!this) return DDERR_INVALIDPARAMS;
8491 FIXME("IDirectDrawClipper::IsClipListChanged: stub");
8592 ERR(DDERR_GENERIC);
8693 }
8794 HRESULT WINAPI glDirectDrawClipper::SetClipList(LPRGNDATA lpClipList, DWORD dwFlags)
8895 {
 96+ if(!this) return DDERR_INVALIDPARAMS;
8997 FIXME("IDirectDrawClipper::SetClipList: stub");
9098 ERR(DDERR_GENERIC);
9199 }
92100 HRESULT WINAPI glDirectDrawClipper::SetHWnd(DWORD dwFlags, HWND hWnd)
93101 {
 102+ if(!this) return DDERR_INVALIDPARAMS;
94103 this->hWnd = hWnd;
95104 return DD_OK;
96105 }
Index: ddraw/glDirectDrawPalette.cpp
@@ -115,11 +115,13 @@
116116
117117 HRESULT WINAPI glDirectDrawPalette::QueryInterface(REFIID riid, void** ppvObj)
118118 {
 119+ if(!this) return DDERR_INVALIDPARAMS;
119120 ERR(E_NOINTERFACE);
120121 }
121122
122123 ULONG WINAPI glDirectDrawPalette::AddRef()
123124 {
 125+ if(!this) return 0;
124126 refcount++;
125127 return refcount;
126128 }
@@ -126,6 +128,7 @@
127129
128130 ULONG WINAPI glDirectDrawPalette::Release()
129131 {
 132+ if(!this) return 0;
130133 ULONG ret;
131134 refcount--;
132135 ret = refcount;
@@ -135,11 +138,13 @@
136139
137140 HRESULT WINAPI glDirectDrawPalette::GetCaps(LPDWORD lpdwCaps)
138141 {
 142+ if(!this) return DDERR_INVALIDPARAMS;
139143 return flags;
140144 }
141145
142146 HRESULT WINAPI glDirectDrawPalette::GetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries)
143147 {
 148+ if(!this) return DDERR_INVALIDPARAMS;
144149 DWORD allentries = 256;
145150 DWORD entrysize;
146151 if(flags & DDPCAPS_1BIT) allentries=2;
@@ -154,10 +159,12 @@
155160 }
156161 HRESULT WINAPI glDirectDrawPalette::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable)
157162 {
 163+ if(!this) return DDERR_INVALIDPARAMS;
158164 ERR(DDERR_ALREADYINITIALIZED);
159165 }
160166 HRESULT WINAPI glDirectDrawPalette::SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
161167 {
 168+ if(!this) return DDERR_INVALIDPARAMS;
162169 DWORD allentries = 256;
163170 DWORD entrysize;
164171 if(flags & DDPCAPS_1BIT) allentries=2;
Index: ddraw/glDirectDrawSurface.cpp
@@ -447,6 +447,7 @@
448448 }
449449 HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
450450 {
 451+ if(!this) return DDERR_INVALIDPARAMS;
451452 if(riid == IID_IDirectDrawSurface7)
452453 {
453454 this->AddRef();
@@ -521,11 +522,13 @@
522523 }
523524 ULONG WINAPI glDirectDrawSurface7::AddRef()
524525 {
 526+ if(!this) return 0;
525527 refcount++;
526528 return refcount;
527529 }
528530 ULONG WINAPI glDirectDrawSurface7::Release()
529531 {
 532+ if(!this) return 0;
530533 ULONG ret;
531534 refcount--;
532535 ret = refcount;
@@ -534,6 +537,7 @@
535538 }
536539 HRESULT WINAPI glDirectDrawSurface7::AddAttachedSurface(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
537540 {
 541+ if(!this) return DDERR_INVALIDPARAMS;
538542 if(zbuffer) ERR(DDERR_SURFACEALREADYATTACHED);
539543 glDirectDrawSurface7 *attached = (glDirectDrawSurface7 *)lpDDSAttachedSurface;
540544 DDSURFACEDESC2 ddsd;
@@ -549,11 +553,13 @@
550554 }
551555 HRESULT WINAPI glDirectDrawSurface7::AddOverlayDirtyRect(LPRECT lpRect)
552556 {
 557+ if(!this) return DDERR_INVALIDPARAMS;
553558 FIXME("glDirectDrawSurface7::AddOverlayDirtyRect: stub\n");
554559 ERR(DDERR_GENERIC);
555560 }
556561 HRESULT WINAPI glDirectDrawSurface7::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
557562 {
 563+ if(!this) return DDERR_INVALIDPARAMS;
558564 if((dwFlags & DDBLT_COLORFILL) && !lpDDBltFx) return DDERR_INVALIDPARAMS;
559565 glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
560566 if(dirty & 1)
@@ -575,11 +581,13 @@
576582 }
577583 HRESULT WINAPI glDirectDrawSurface7::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
578584 {
 585+ if(!this) return DDERR_INVALIDPARAMS;
579586 FIXME("glDirectDrawSurface7::BltBatch: stub\n");
580587 ERR(DDERR_GENERIC);
581588 }
582589 HRESULT WINAPI glDirectDrawSurface7::BltFast(DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans)
583590 {
 591+ if(!this) return DDERR_INVALIDPARAMS;
584592 DDSURFACEDESC2 ddsd;
585593 ddsd.dwSize = sizeof(DDSURFACEDESC2);
586594 lpDDSrcSurface->GetSurfaceDesc(&ddsd);
@@ -604,6 +612,7 @@
605613 }
606614 HRESULT WINAPI glDirectDrawSurface7::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
607615 {
 616+ if(!this) return DDERR_INVALIDPARAMS;
608617 if(lpDDSAttachedSurface == (LPDIRECTDRAWSURFACE7)zbuffer)
609618 {
610619 zbuffer->Release();
@@ -614,16 +623,19 @@
615624 }
616625 HRESULT WINAPI glDirectDrawSurface7::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback)
617626 {
 627+ if(!this) return DDERR_INVALIDPARAMS;
618628 FIXME("glDirectDrawSurface7::EnumAttachedSurfaces: stub\n");
619629 ERR(DDERR_GENERIC);
620630 }
621631 HRESULT WINAPI glDirectDrawSurface7::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpfnCallback)
622632 {
 633+ if(!this) return DDERR_INVALIDPARAMS;
623634 FIXME("glDirectDrawSurface7::EnumOverlayZOrders: stub\n");
624635 ERR(DDERR_GENERIC);
625636 }
626637 HRESULT WINAPI glDirectDrawSurface7::Flip(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
627638 {
 639+ if(!this) return DDERR_INVALIDPARAMS;
628640 HRESULT ret = Flip2(lpDDSurfaceTargetOverride,dwFlags);
629641 if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) RenderScreen(texture,this);
630642 return ret;
@@ -630,6 +642,7 @@
631643 }
632644 HRESULT glDirectDrawSurface7::Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
633645 {
 646+ if(!this) return DDERR_INVALIDPARAMS;
634647 DWORD i;
635648 glDirectDrawSurface7 *tmp;
636649 if(dwFlags & DDFLIP_NOVSYNC) swapinterval=0;
@@ -709,6 +722,7 @@
710723 }
711724 HRESULT WINAPI glDirectDrawSurface7::GetAttachedSurface(LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE7 FAR *lplpDDAttachedSurface)
712725 {
 726+ if(!this) return DDERR_INVALIDPARAMS;
713727 DDSCAPS2 ddsComp;
714728 backbuffer->GetCaps(&ddsComp);
715729 unsigned __int64 comp1,comp2;
@@ -736,21 +750,25 @@
737751 }
738752 HRESULT WINAPI glDirectDrawSurface7::GetBltStatus(DWORD dwFlags)
739753 {
 754+ if(!this) return DDERR_INVALIDPARAMS;
740755 FIXME("glDirectDrawSurface7::GetBltStatus: stub\n");
741756 ERR(DDERR_GENERIC);
742757 }
743758 HRESULT WINAPI glDirectDrawSurface7::GetCaps(LPDDSCAPS2 lpDDSCaps)
744759 {
 760+ if(!this) return DDERR_INVALIDPARAMS;
745761 memcpy(lpDDSCaps,&ddsd.ddsCaps,sizeof(DDSCAPS2));
746762 return DD_OK;
747763 }
748764 HRESULT WINAPI glDirectDrawSurface7::GetClipper(LPDIRECTDRAWCLIPPER FAR *lplpDDClipper)
749765 {
 766+ if(!this) return DDERR_INVALIDPARAMS;
750767 FIXME("glDirectDrawSurface7::GetClipper: stub\n");
751768 ERR(DDERR_GENERIC);
752769 }
753770 HRESULT WINAPI glDirectDrawSurface7::GetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
754771 {
 772+ if(!this) return DDERR_INVALIDPARAMS;
755773 if(dwFlags == DDCKEY_SRCBLT)
756774 {
757775 if(colorkey[0].enabled)
@@ -791,6 +809,7 @@
792810 }
793811 HRESULT WINAPI glDirectDrawSurface7::GetDC(HDC FAR *lphDC)
794812 {
 813+ if(!this) return DDERR_INVALIDPARAMS;
795814 if(hdc) ERR(DDERR_DCALREADYCREATED);
796815 DWORD colors[256];
797816 HRESULT error;
@@ -816,6 +835,7 @@
817836 }
818837 HRESULT WINAPI glDirectDrawSurface7::GetFlipStatus(DWORD dwFlags)
819838 {
 839+ if(!this) return DDERR_INVALIDPARAMS;
820840 return DD_OK;
821841 FIXME("glDirectDrawSurface7::GetFlipStatus: stub\n");
822842 ERR(DDERR_GENERIC);
@@ -822,11 +842,13 @@
823843 }
824844 HRESULT WINAPI glDirectDrawSurface7::GetOverlayPosition(LPLONG lplX, LPLONG lplY)
825845 {
 846+ if(!this) return DDERR_INVALIDPARAMS;
826847 FIXME("glDirectDrawSurface7::GetOverlayPosition: stub\n");
827848 ERR(DDERR_GENERIC);
828849 }
829850 HRESULT WINAPI glDirectDrawSurface7::GetPalette(LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
830851 {
 852+ if(!this) return DDERR_INVALIDPARAMS;
831853 HRESULT err;
832854 if(palette)
833855 {
@@ -843,11 +865,13 @@
844866 }
845867 HRESULT WINAPI glDirectDrawSurface7::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
846868 {
 869+ if(!this) return DDERR_INVALIDPARAMS;
847870 *lpDDPixelFormat = ddsd.ddpfPixelFormat;
848871 return DD_OK;
849872 }
850873 HRESULT WINAPI glDirectDrawSurface7::GetSurfaceDesc(LPDDSURFACEDESC2 lpDDSurfaceDesc)
851874 {
 875+ if(!this) return DDERR_INVALIDPARAMS;
852876 if(!lpDDSurfaceDesc) ERR(DDERR_INVALIDPARAMS);
853877 memcpy(lpDDSurfaceDesc,&ddsd,lpDDSurfaceDesc->dwSize);
854878 return DD_OK;
@@ -854,10 +878,12 @@
855879 }
856880 HRESULT WINAPI glDirectDrawSurface7::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC2 lpDDSurfaceDesc)
857881 {
 882+ if(!this) return DDERR_INVALIDPARAMS;
858883 return DDERR_ALREADYINITIALIZED;
859884 }
860885 HRESULT WINAPI glDirectDrawSurface7::IsLost()
861886 {
 887+ if(!this) return DDERR_INVALIDPARAMS;
862888 if(hRC == ddInterface->renderer->hRC) return DD_OK;
863889 else return DDERR_SURFACELOST;
864890 }
@@ -864,6 +890,7 @@
865891
866892 HRESULT WINAPI glDirectDrawSurface7::Lock(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
867893 {
 894+ if(!this) return DDERR_INVALIDPARAMS;
868895 if(locked) ERR(DDERR_SURFACEBUSY);
869896 dirty |= 1;
870897 retry:
@@ -899,6 +926,7 @@
900927 }
901928 HRESULT WINAPI glDirectDrawSurface7::ReleaseDC(HDC hDC)
902929 {
 930+ if(!this) return DDERR_INVALIDPARAMS;
903931 if(!hdc) return DDERR_INVALIDOBJECT;
904932 if(hDC != hdc) return DDERR_INVALIDOBJECT;
905933 GetDIBits(hDC,hbitmap,0,ddsd.dwHeight,ddsd.lpSurface,bitmapinfo,DIB_RGB_COLORS);
@@ -945,6 +973,7 @@
946974 }
947975 HRESULT WINAPI glDirectDrawSurface7::Restore()
948976 {
 977+ if(!this) return DDERR_INVALIDPARAMS;
949978 LONG sizes[6];
950979 if(!ddInterface->renderer) return DDERR_INVALIDOBJECT;
951980 if(hRC != ddInterface->renderer->hRC)
@@ -990,6 +1019,7 @@
9911020 }
9921021 HRESULT WINAPI glDirectDrawSurface7::SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper)
9931022 {
 1023+ if(!this) return DDERR_INVALIDPARAMS;
9941024 if(clipper) clipper->Release();
9951025 clipper = (glDirectDrawClipper *)lpDDClipper;
9961026 if(clipper)clipper->AddRef();
@@ -997,6 +1027,7 @@
9981028 }
9991029 HRESULT WINAPI glDirectDrawSurface7::SetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
10001030 {
 1031+ if(!this) return DDERR_INVALIDPARAMS;
10011032 CKEY key;
10021033 key.enabled = true;
10031034 if(dwFlags & DDCKEY_COLORSPACE) key.colorspace = true;
@@ -1010,11 +1041,13 @@
10111042 }
10121043 HRESULT WINAPI glDirectDrawSurface7::SetOverlayPosition(LONG lX, LONG lY)
10131044 {
 1045+ if(!this) return DDERR_INVALIDPARAMS;
10141046 FIXME("glDirectDrawSurface7::SetOverlayPosition: stub\n");
10151047 ERR(DDERR_GENERIC);
10161048 }
10171049 HRESULT WINAPI glDirectDrawSurface7::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
10181050 {
 1051+ if(!this) return DDERR_INVALIDPARAMS;
10191052 if(palette)
10201053 {
10211054 palette->Release();
@@ -1030,6 +1063,7 @@
10311064
10321065 HRESULT WINAPI glDirectDrawSurface7::Unlock(LPRECT lpRect)
10331066 {
 1067+ if(!this) return DDERR_INVALIDPARAMS;
10341068 if(!locked) return DDERR_NOTLOCKED;
10351069 locked--;
10361070 ddsd.lpSurface = NULL;
@@ -1041,16 +1075,19 @@
10421076 }
10431077 HRESULT WINAPI glDirectDrawSurface7::UpdateOverlay(LPRECT lpSrcRect, LPDIRECTDRAWSURFACE7 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx)
10441078 {
 1079+ if(!this) return DDERR_INVALIDPARAMS;
10451080 FIXME("glDirectDrawSurface7::UpdateOverlay: stub\n");
10461081 ERR(DDERR_GENERIC);
10471082 }
10481083 HRESULT WINAPI glDirectDrawSurface7::UpdateOverlayDisplay(DWORD dwFlags)
10491084 {
 1085+ if(!this) return DDERR_INVALIDPARAMS;
10501086 FIXME("glDirectDrawSurface7::UpdateOverlayDisplay: stub\n");
10511087 ERR(DDERR_GENERIC);
10521088 }
10531089 HRESULT WINAPI glDirectDrawSurface7::UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSReference)
10541090 {
 1091+ if(!this) return DDERR_INVALIDPARAMS;
10551092 FIXME("glDirectDrawSurface7::UpdateOverlayZOrder: stub\n");
10561093 ERR(DDERR_GENERIC);
10571094 }
@@ -1062,6 +1099,7 @@
10631100 // ddraw 2+ api
10641101 HRESULT WINAPI glDirectDrawSurface7::GetDDInterface(LPVOID FAR *lplpDD)
10651102 {
 1103+ if(!this) return DDERR_INVALIDPARAMS;
10661104 *lplpDD = ddInterface;
10671105 FIXME("glDirectDrawSurface7::GetDDInterface: stub\n");
10681106 ERR(DDERR_GENERIC);
@@ -1068,11 +1106,13 @@
10691107 }
10701108 HRESULT WINAPI glDirectDrawSurface7::PageLock(DWORD dwFlags)
10711109 {
 1110+ if(!this) return DDERR_INVALIDPARAMS;
10721111 pagelocked++;
10731112 return DD_OK;
10741113 }
10751114 HRESULT WINAPI glDirectDrawSurface7::PageUnlock(DWORD dwFlags)
10761115 {
 1116+ if(!this) return DDERR_INVALIDPARAMS;
10771117 if(!pagelocked) ERR(DDERR_NOTPAGELOCKED);
10781118 pagelocked--;
10791119 return DD_OK;
@@ -1080,6 +1120,7 @@
10811121 // ddraw 3+ api
10821122 HRESULT WINAPI glDirectDrawSurface7::SetSurfaceDesc(LPDDSURFACEDESC2 lpddsd2, DWORD dwFlags)
10831123 {
 1124+ if(!this) return DDERR_INVALIDPARAMS;
10841125 FIXME("glDirectDrawSurface7::SetSurfaceDesc: stub\n");
10851126 ERR(DDERR_GENERIC);
10861127 }
@@ -1086,26 +1127,31 @@
10871128 // ddraw 4+ api
10881129 HRESULT WINAPI glDirectDrawSurface7::SetPrivateData(REFGUID guidTag, LPVOID lpData, DWORD cbSize, DWORD dwFlags)
10891130 {
 1131+ if(!this) return DDERR_INVALIDPARAMS;
10901132 FIXME("glDirectDrawSurface7::SetPrivateData: stub\n");
10911133 ERR(DDERR_GENERIC);
10921134 }
10931135 HRESULT WINAPI glDirectDrawSurface7::GetPrivateData(REFGUID guidTag, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
10941136 {
 1137+ if(!this) return DDERR_INVALIDPARAMS;
10951138 FIXME("glDirectDrawSurface7::GetPrivateData: stub\n");
10961139 ERR(DDERR_GENERIC);
10971140 }
10981141 HRESULT WINAPI glDirectDrawSurface7::FreePrivateData(REFGUID guidTag)
10991142 {
 1143+ if(!this) return DDERR_INVALIDPARAMS;
11001144 FIXME("glDirectDrawSurface7::FreePrivateData: stub\n");
11011145 ERR(DDERR_GENERIC);
11021146 }
11031147 HRESULT WINAPI glDirectDrawSurface7::GetUniquenessValue(LPDWORD lpValue)
11041148 {
 1149+ if(!this) return DDERR_INVALIDPARAMS;
11051150 FIXME("glDirectDrawSurface7::GetUniquenessValue: stub\n");
11061151 ERR(DDERR_GENERIC);
11071152 }
11081153 HRESULT WINAPI glDirectDrawSurface7::ChangeUniquenessValue()
11091154 {
 1155+ if(!this) return DDERR_INVALIDPARAMS;
11101156 FIXME("glDirectDrawSurface7::ChangeUniquenessValue: stub\n");
11111157 ERR(DDERR_GENERIC);
11121158 }
@@ -1112,26 +1158,31 @@
11131159 // ddraw 7 api
11141160 HRESULT WINAPI glDirectDrawSurface7::SetPriority(DWORD dwPriority)
11151161 {
 1162+ if(!this) return DDERR_INVALIDPARAMS;
11161163 FIXME("glDirectDrawSurface7::SetPriority: stub\n");
11171164 ERR(DDERR_GENERIC);
11181165 }
11191166 HRESULT WINAPI glDirectDrawSurface7::GetPriority(LPDWORD lpdwPriority)
11201167 {
 1168+ if(!this) return DDERR_INVALIDPARAMS;
11211169 FIXME("glDirectDrawSurface7::GetPriority: stub\n");
11221170 ERR(DDERR_GENERIC);
11231171 }
11241172 HRESULT WINAPI glDirectDrawSurface7::SetLOD(DWORD dwMaxLOD)
11251173 {
 1174+ if(!this) return DDERR_INVALIDPARAMS;
11261175 FIXME("glDirectDrawSurface7::SetLOD: stub\n");
11271176 ERR(DDERR_GENERIC);
11281177 }
11291178 HRESULT WINAPI glDirectDrawSurface7::GetLOD(LPDWORD lpdwMaxLOD)
11301179 {
 1180+ if(!this) return DDERR_INVALIDPARAMS;
11311181 FIXME("glDirectDrawSurface7::GetLOD: stub\n");
11321182 ERR(DDERR_GENERIC);
11331183 }
11341184 HRESULT WINAPI glDirectDrawSurface7::Unlock2(LPVOID lpSurfaceData)
11351185 {
 1186+ if(!this) return DDERR_INVALIDPARAMS;
11361187 return Unlock((LPRECT)lpSurfaceData);
11371188 }
11381189
@@ -1148,15 +1199,18 @@
11491200 }
11501201 HRESULT WINAPI glDirectDrawSurface1::QueryInterface(REFIID riid, void** ppvObj)
11511202 {
 1203+ if(!this) return DDERR_INVALIDPARAMS;
11521204 return glDDS7->QueryInterface(riid,ppvObj);
11531205 }
11541206 ULONG WINAPI glDirectDrawSurface1::AddRef()
11551207 {
 1208+ if(!this) return 0;
11561209 refcount++;
11571210 return refcount;
11581211 }
11591212 ULONG WINAPI glDirectDrawSurface1::Release()
11601213 {
 1214+ if(!this) return 0;
11611215 ULONG ret;
11621216 refcount--;
11631217 ret = refcount;
@@ -1165,39 +1219,48 @@
11661220 }
11671221 HRESULT WINAPI glDirectDrawSurface1::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
11681222 {
 1223+ if(!this) return DDERR_INVALIDPARAMS;
11691224 return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
11701225 }
11711226 HRESULT WINAPI glDirectDrawSurface1::AddOverlayDirtyRect(LPRECT lpRect)
11721227 {
 1228+ if(!this) return DDERR_INVALIDPARAMS;
11731229 return glDDS7->AddOverlayDirtyRect(lpRect);
11741230 }
11751231 HRESULT WINAPI glDirectDrawSurface1::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
11761232 {
 1233+ if(!this) return DDERR_INVALIDPARAMS;
11771234 if(lpDDSrcSurface) return glDDS7->Blt(lpDestRect,((glDirectDrawSurface1*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx);
11781235 else return glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx);
11791236 }
11801237 HRESULT WINAPI glDirectDrawSurface1::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
11811238 {
 1239+ if(!this) return DDERR_INVALIDPARAMS;
11821240 return glDDS7->BltBatch(lpDDBltBatch,dwCount,dwFlags);
11831241 }
11841242 HRESULT WINAPI glDirectDrawSurface1::BltFast(DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans)
11851243 {
 1244+ if(!this) return DDERR_INVALIDPARAMS;
11861245 return glDDS7->BltFast(dwX,dwY,((glDirectDrawSurface1*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwTrans);
11871246 }
11881247 HRESULT WINAPI glDirectDrawSurface1::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
11891248 {
 1249+ if(!this) return DDERR_INVALIDPARAMS;
11901250 return glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
11911251 }
11921252 HRESULT WINAPI glDirectDrawSurface1::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
11931253 {
 1254+ if(!this) return DDERR_INVALIDPARAMS;
11941255 return glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback);
11951256 }
11961257 HRESULT WINAPI glDirectDrawSurface1::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
11971258 {
 1259+ if(!this) return DDERR_INVALIDPARAMS;
11981260 return glDDS7->EnumOverlayZOrders(dwFlags,lpContext,(LPDDENUMSURFACESCALLBACK7)lpfnCallback);
11991261 }
12001262 HRESULT WINAPI glDirectDrawSurface1::Flip(LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags)
12011263 {
 1264+ if(!this) return DDERR_INVALIDPARAMS;
12021265 if(lpDDSurfaceTargetOverride)
12031266 return glDDS7->Flip(((glDirectDrawSurface1*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
12041267 else return glDDS7->Flip(NULL,dwFlags);
@@ -1204,6 +1267,7 @@
12051268 }
12061269 HRESULT WINAPI glDirectDrawSurface1::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE FAR *lplpDDAttachedSurface)
12071270 {
 1271+ if(!this) return DDERR_INVALIDPARAMS;
12081272 HRESULT error;
12091273 glDirectDrawSurface7 *attachedsurface;
12101274 glDirectDrawSurface1 *attached1;
@@ -1221,10 +1285,12 @@
12221286 }
12231287 HRESULT WINAPI glDirectDrawSurface1::GetBltStatus(DWORD dwFlags)
12241288 {
 1289+ if(!this) return DDERR_INVALIDPARAMS;
12251290 return glDDS7->GetBltStatus(dwFlags);
12261291 }
12271292 HRESULT WINAPI glDirectDrawSurface1::GetCaps(LPDDSCAPS lpDDSCaps)
12281293 {
 1294+ if(!this) return DDERR_INVALIDPARAMS;
12291295 HRESULT error;
12301296 DDSCAPS2 ddsCaps1;
12311297 error = glDDS7->GetCaps(&ddsCaps1);
@@ -1234,86 +1300,107 @@
12351301 }
12361302 HRESULT WINAPI glDirectDrawSurface1::GetClipper(LPDIRECTDRAWCLIPPER FAR *lplpDDClipper)
12371303 {
 1304+ if(!this) return DDERR_INVALIDPARAMS;
12381305 return glDDS7->GetClipper(lplpDDClipper);
12391306 }
12401307 HRESULT WINAPI glDirectDrawSurface1::GetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
12411308 {
 1309+ if(!this) return DDERR_INVALIDPARAMS;
12421310 return glDDS7->GetColorKey(dwFlags,lpDDColorKey);
12431311 }
12441312 HRESULT WINAPI glDirectDrawSurface1::GetDC(HDC FAR *lphDC)
12451313 {
 1314+ if(!this) return DDERR_INVALIDPARAMS;
12461315 return glDDS7->GetDC(lphDC);
12471316 }
12481317 HRESULT WINAPI glDirectDrawSurface1::GetFlipStatus(DWORD dwFlags)
12491318 {
 1319+ if(!this) return DDERR_INVALIDPARAMS;
12501320 return glDDS7->GetFlipStatus(dwFlags);
12511321 }
12521322 HRESULT WINAPI glDirectDrawSurface1::GetOverlayPosition(LPLONG lplX, LPLONG lplY)
12531323 {
 1324+ if(!this) return DDERR_INVALIDPARAMS;
12541325 return glDDS7->GetOverlayPosition(lplX,lplY);
12551326 }
12561327 HRESULT WINAPI glDirectDrawSurface1::GetPalette(LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
12571328 {
 1329+ if(!this) return DDERR_INVALIDPARAMS;
12581330 return glDDS7->GetPalette(lplpDDPalette);
12591331 }
12601332 HRESULT WINAPI glDirectDrawSurface1::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
12611333 {
 1334+ if(!this) return DDERR_INVALIDPARAMS;
12621335 return glDDS7->GetPixelFormat(lpDDPixelFormat);
12631336 }
12641337 HRESULT WINAPI glDirectDrawSurface1::GetSurfaceDesc(LPDDSURFACEDESC lpDDSurfaceDesc)
12651338 {
 1339+ if(!this) return DDERR_INVALIDPARAMS;
12661340 return glDDS7->GetSurfaceDesc((LPDDSURFACEDESC2)lpDDSurfaceDesc);
12671341 }
12681342 HRESULT WINAPI glDirectDrawSurface1::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
12691343 {
 1344+ if(!this) return DDERR_INVALIDPARAMS;
12701345 return DDERR_ALREADYINITIALIZED;
12711346 }
12721347 HRESULT WINAPI glDirectDrawSurface1::IsLost()
12731348 {
 1349+ if(!this) return DDERR_INVALIDPARAMS;
12741350 return glDDS7->IsLost();
12751351 }
12761352 HRESULT WINAPI glDirectDrawSurface1::Lock(LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
12771353 {
 1354+ if(!this) return DDERR_INVALIDPARAMS;
12781355 return glDDS7->Lock(lpDestRect,(LPDDSURFACEDESC2)lpDDSurfaceDesc,dwFlags,hEvent);
12791356 }
12801357 HRESULT WINAPI glDirectDrawSurface1::ReleaseDC(HDC hDC)
12811358 {
 1359+ if(!this) return DDERR_INVALIDPARAMS;
12821360 return glDDS7->ReleaseDC(hDC);
12831361 }
12841362 HRESULT WINAPI glDirectDrawSurface1::Restore()
12851363 {
 1364+ if(!this) return DDERR_INVALIDPARAMS;
12861365 return glDDS7->Restore();
12871366 }
12881367 HRESULT WINAPI glDirectDrawSurface1::SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper)
12891368 {
 1369+ if(!this) return DDERR_INVALIDPARAMS;
12901370 return glDDS7->SetClipper(lpDDClipper);
12911371 }
12921372 HRESULT WINAPI glDirectDrawSurface1::SetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
12931373 {
 1374+ if(!this) return DDERR_INVALIDPARAMS;
12941375 return glDDS7->SetColorKey(dwFlags,lpDDColorKey);
12951376 }
12961377 HRESULT WINAPI glDirectDrawSurface1::SetOverlayPosition(LONG lX, LONG lY)
12971378 {
 1379+ if(!this) return DDERR_INVALIDPARAMS;
12981380 return glDDS7->SetOverlayPosition(lX,lY);
12991381 }
13001382 HRESULT WINAPI glDirectDrawSurface1::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
13011383 {
 1384+ if(!this) return DDERR_INVALIDPARAMS;
13021385 return glDDS7->SetPalette(lpDDPalette);
13031386 }
13041387 HRESULT WINAPI glDirectDrawSurface1::Unlock(LPVOID lpSurfaceData)
13051388 {
 1389+ if(!this) return DDERR_INVALIDPARAMS;
13061390 return glDDS7->Unlock2(lpSurfaceData);
13071391 }
13081392 HRESULT WINAPI glDirectDrawSurface1::UpdateOverlay(LPRECT lpSrcRect, LPDIRECTDRAWSURFACE lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx)
13091393 {
 1394+ if(!this) return DDERR_INVALIDPARAMS;
13101395 return glDDS7->UpdateOverlay(lpSrcRect,(LPDIRECTDRAWSURFACE7)lpDDDestSurface,lpDestRect,dwFlags,lpDDOverlayFx);
13111396 }
13121397 HRESULT WINAPI glDirectDrawSurface1::UpdateOverlayDisplay(DWORD dwFlags)
13131398 {
 1399+ if(!this) return DDERR_INVALIDPARAMS;
13141400 return glDDS7->UpdateOverlayDisplay(dwFlags);
13151401 }
13161402 HRESULT WINAPI glDirectDrawSurface1::UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSReference)
13171403 {
 1404+ if(!this) return DDERR_INVALIDPARAMS;
13181405 return glDDS7->UpdateOverlayZOrder(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSReference);
13191406 }
13201407
@@ -1330,15 +1417,18 @@
13311418 }
13321419 HRESULT WINAPI glDirectDrawSurface2::QueryInterface(REFIID riid, void** ppvObj)
13331420 {
 1421+ if(!this) return DDERR_INVALIDPARAMS;
13341422 return glDDS7->QueryInterface(riid,ppvObj);
13351423 }
13361424 ULONG WINAPI glDirectDrawSurface2::AddRef()
13371425 {
 1426+ if(!this) return 0;
13381427 refcount++;
13391428 return refcount;
13401429 }
13411430 ULONG WINAPI glDirectDrawSurface2::Release()
13421431 {
 1432+ if(!this) return 0;
13431433 ULONG ret;
13441434 refcount--;
13451435 ret = refcount;
@@ -1347,39 +1437,48 @@
13481438 }
13491439 HRESULT WINAPI glDirectDrawSurface2::AddAttachedSurface(LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface)
13501440 {
 1441+ if(!this) return DDERR_INVALIDPARAMS;
13511442 return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
13521443 }
13531444 HRESULT WINAPI glDirectDrawSurface2::AddOverlayDirtyRect(LPRECT lpRect)
13541445 {
 1446+ if(!this) return DDERR_INVALIDPARAMS;
13551447 return glDDS7->AddOverlayDirtyRect(lpRect);
13561448 }
13571449 HRESULT WINAPI glDirectDrawSurface2::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
13581450 {
 1451+ if(!this) return DDERR_INVALIDPARAMS;
13591452 if(lpDDSrcSurface) return glDDS7->Blt(lpDestRect,((glDirectDrawSurface2*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx);
13601453 else return glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx);
13611454 }
13621455 HRESULT WINAPI glDirectDrawSurface2::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
13631456 {
 1457+ if(!this) return DDERR_INVALIDPARAMS;
13641458 return glDDS7->BltBatch(lpDDBltBatch,dwCount,dwFlags);
13651459 }
13661460 HRESULT WINAPI glDirectDrawSurface2::BltFast(DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans)
13671461 {
 1462+ if(!this) return DDERR_INVALIDPARAMS;
13681463 return glDDS7->BltFast(dwX,dwY,((glDirectDrawSurface2*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwTrans);
13691464 }
13701465 HRESULT WINAPI glDirectDrawSurface2::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface)
13711466 {
 1467+ if(!this) return DDERR_INVALIDPARAMS;
13721468 return glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
13731469 }
13741470 HRESULT WINAPI glDirectDrawSurface2::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
13751471 {
 1472+ if(!this) return DDERR_INVALIDPARAMS;
13761473 return glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback);
13771474 }
13781475 HRESULT WINAPI glDirectDrawSurface2::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
13791476 {
 1477+ if(!this) return DDERR_INVALIDPARAMS;
13801478 return glDDS7->EnumOverlayZOrders(dwFlags,lpContext,(LPDDENUMSURFACESCALLBACK7)lpfnCallback);
13811479 }
13821480 HRESULT WINAPI glDirectDrawSurface2::Flip(LPDIRECTDRAWSURFACE2 lpDDSurfaceTargetOverride, DWORD dwFlags)
13831481 {
 1482+ if(!this) return DDERR_INVALIDPARAMS;
13841483 if(lpDDSurfaceTargetOverride)
13851484 return glDDS7->Flip(((glDirectDrawSurface2*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
13861485 else return glDDS7->Flip(NULL,dwFlags);
@@ -1386,6 +1485,7 @@
13871486 }
13881487 HRESULT WINAPI glDirectDrawSurface2::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE2 FAR *lplpDDAttachedSurface)
13891488 {
 1489+ if(!this) return DDERR_INVALIDPARAMS;
13901490 HRESULT error;
13911491 glDirectDrawSurface7 *attachedsurface;
13921492 glDirectDrawSurface2 *attached1;
@@ -1403,10 +1503,12 @@
14041504 }
14051505 HRESULT WINAPI glDirectDrawSurface2::GetBltStatus(DWORD dwFlags)
14061506 {
 1507+ if(!this) return DDERR_INVALIDPARAMS;
14071508 return glDDS7->GetBltStatus(dwFlags);
14081509 }
14091510 HRESULT WINAPI glDirectDrawSurface2::GetCaps(LPDDSCAPS lpDDSCaps)
14101511 {
 1512+ if(!this) return DDERR_INVALIDPARAMS;
14111513 HRESULT error;
14121514 DDSCAPS2 ddsCaps1;
14131515 error = glDDS7->GetCaps(&ddsCaps1);
@@ -1416,98 +1518,122 @@
14171519 }
14181520 HRESULT WINAPI glDirectDrawSurface2::GetClipper(LPDIRECTDRAWCLIPPER FAR *lplpDDClipper)
14191521 {
 1522+ if(!this) return DDERR_INVALIDPARAMS;
14201523 return glDDS7->GetClipper(lplpDDClipper);
14211524 }
14221525 HRESULT WINAPI glDirectDrawSurface2::GetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
14231526 {
 1527+ if(!this) return DDERR_INVALIDPARAMS;
14241528 return glDDS7->GetColorKey(dwFlags,lpDDColorKey);
14251529 }
14261530 HRESULT WINAPI glDirectDrawSurface2::GetDC(HDC FAR *lphDC)
14271531 {
 1532+ if(!this) return DDERR_INVALIDPARAMS;
14281533 return glDDS7->GetDC(lphDC);
14291534 }
14301535 HRESULT WINAPI glDirectDrawSurface2::GetFlipStatus(DWORD dwFlags)
14311536 {
 1537+ if(!this) return DDERR_INVALIDPARAMS;
14321538 return glDDS7->GetFlipStatus(dwFlags);
14331539 }
14341540 HRESULT WINAPI glDirectDrawSurface2::GetOverlayPosition(LPLONG lplX, LPLONG lplY)
14351541 {
 1542+ if(!this) return DDERR_INVALIDPARAMS;
14361543 return glDDS7->GetOverlayPosition(lplX,lplY);
14371544 }
14381545 HRESULT WINAPI glDirectDrawSurface2::GetPalette(LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
14391546 {
 1547+ if(!this) return DDERR_INVALIDPARAMS;
14401548 return glDDS7->GetPalette(lplpDDPalette);
14411549 }
14421550 HRESULT WINAPI glDirectDrawSurface2::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
14431551 {
 1552+ if(!this) return DDERR_INVALIDPARAMS;
14441553 return glDDS7->GetPixelFormat(lpDDPixelFormat);
14451554 }
14461555 HRESULT WINAPI glDirectDrawSurface2::GetSurfaceDesc(LPDDSURFACEDESC lpDDSurfaceDesc)
14471556 {
 1557+ if(!this) return DDERR_INVALIDPARAMS;
14481558 return glDDS7->GetSurfaceDesc((LPDDSURFACEDESC2)lpDDSurfaceDesc);
14491559 }
14501560 HRESULT WINAPI glDirectDrawSurface2::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
14511561 {
 1562+ if(!this) return DDERR_INVALIDPARAMS;
14521563 return DDERR_ALREADYINITIALIZED;
14531564 }
14541565 HRESULT WINAPI glDirectDrawSurface2::IsLost()
14551566 {
 1567+ if(!this) return DDERR_INVALIDPARAMS;
14561568 return glDDS7->IsLost();
14571569 }
14581570 HRESULT WINAPI glDirectDrawSurface2::Lock(LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
14591571 {
 1572+ if(!this) return DDERR_INVALIDPARAMS;
14601573 return glDDS7->Lock(lpDestRect,(LPDDSURFACEDESC2)lpDDSurfaceDesc,dwFlags,hEvent);
14611574 }
14621575 HRESULT WINAPI glDirectDrawSurface2::ReleaseDC(HDC hDC)
14631576 {
 1577+ if(!this) return DDERR_INVALIDPARAMS;
14641578 return glDDS7->ReleaseDC(hDC);
14651579 }
14661580 HRESULT WINAPI glDirectDrawSurface2::Restore()
14671581 {
 1582+ if(!this) return DDERR_INVALIDPARAMS;
14681583 return glDDS7->Restore();
14691584 }
14701585 HRESULT WINAPI glDirectDrawSurface2::SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper)
14711586 {
 1587+ if(!this) return DDERR_INVALIDPARAMS;
14721588 return glDDS7->SetClipper(lpDDClipper);
14731589 }
14741590 HRESULT WINAPI glDirectDrawSurface2::SetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
14751591 {
 1592+ if(!this) return DDERR_INVALIDPARAMS;
14761593 return glDDS7->SetColorKey(dwFlags,lpDDColorKey);
14771594 }
14781595 HRESULT WINAPI glDirectDrawSurface2::SetOverlayPosition(LONG lX, LONG lY)
14791596 {
 1597+ if(!this) return DDERR_INVALIDPARAMS;
14801598 return glDDS7->SetOverlayPosition(lX,lY);
14811599 }
14821600 HRESULT WINAPI glDirectDrawSurface2::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
14831601 {
 1602+ if(!this) return DDERR_INVALIDPARAMS;
14841603 return glDDS7->SetPalette(lpDDPalette);
14851604 }
14861605 HRESULT WINAPI glDirectDrawSurface2::Unlock(LPVOID lpSurfaceData)
14871606 {
 1607+ if(!this) return DDERR_INVALIDPARAMS;
14881608 return glDDS7->Unlock2(lpSurfaceData);
14891609 }
14901610 HRESULT WINAPI glDirectDrawSurface2::UpdateOverlay(LPRECT lpSrcRect, LPDIRECTDRAWSURFACE2 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx)
14911611 {
 1612+ if(!this) return DDERR_INVALIDPARAMS;
14921613 return glDDS7->UpdateOverlay(lpSrcRect,(LPDIRECTDRAWSURFACE7)lpDDDestSurface,lpDestRect,dwFlags,lpDDOverlayFx);
14931614 }
14941615 HRESULT WINAPI glDirectDrawSurface2::UpdateOverlayDisplay(DWORD dwFlags)
14951616 {
 1617+ if(!this) return DDERR_INVALIDPARAMS;
14961618 return glDDS7->UpdateOverlayDisplay(dwFlags);
14971619 }
14981620 HRESULT WINAPI glDirectDrawSurface2::UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE2 lpDDSReference)
14991621 {
 1622+ if(!this) return DDERR_INVALIDPARAMS;
15001623 return glDDS7->UpdateOverlayZOrder(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSReference);
15011624 }
15021625 HRESULT WINAPI glDirectDrawSurface2::GetDDInterface(LPVOID FAR *lplpDD)
15031626 {
 1627+ if(!this) return DDERR_INVALIDPARAMS;
15041628 return glDDS7->GetDDInterface(lplpDD);
15051629 }
15061630 HRESULT WINAPI glDirectDrawSurface2::PageLock(DWORD dwFlags)
15071631 {
 1632+ if(!this) return DDERR_INVALIDPARAMS;
15081633 return glDDS7->PageLock(dwFlags);
15091634 }
15101635 HRESULT WINAPI glDirectDrawSurface2::PageUnlock(DWORD dwFlags)
15111636 {
 1637+ if(!this) return DDERR_INVALIDPARAMS;
15121638 return glDDS7->PageUnlock(dwFlags);
15131639 }
15141640
@@ -1524,15 +1650,18 @@
15251651 }
15261652 HRESULT WINAPI glDirectDrawSurface3::QueryInterface(REFIID riid, void** ppvObj)
15271653 {
 1654+ if(!this) return DDERR_INVALIDPARAMS;
15281655 return glDDS7->QueryInterface(riid,ppvObj);
15291656 }
15301657 ULONG WINAPI glDirectDrawSurface3::AddRef()
15311658 {
 1659+ if(!this) return 0;
15321660 refcount++;
15331661 return refcount;
15341662 }
15351663 ULONG WINAPI glDirectDrawSurface3::Release()
15361664 {
 1665+ if(!this) return 0;
15371666 ULONG ret;
15381667 refcount--;
15391668 ret = refcount;
@@ -1541,39 +1670,48 @@
15421671 }
15431672 HRESULT WINAPI glDirectDrawSurface3::AddAttachedSurface(LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface)
15441673 {
 1674+ if(!this) return DDERR_INVALIDPARAMS;
15451675 return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
15461676 }
15471677 HRESULT WINAPI glDirectDrawSurface3::AddOverlayDirtyRect(LPRECT lpRect)
15481678 {
 1679+ if(!this) return DDERR_INVALIDPARAMS;
15491680 return glDDS7->AddOverlayDirtyRect(lpRect);
15501681 }
15511682 HRESULT WINAPI glDirectDrawSurface3::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
15521683 {
 1684+ if(!this) return DDERR_INVALIDPARAMS;
15531685 if(lpDDSrcSurface) return glDDS7->Blt(lpDestRect,((glDirectDrawSurface3*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx);
15541686 else return glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx);
15551687 }
15561688 HRESULT WINAPI glDirectDrawSurface3::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
15571689 {
 1690+ if(!this) return DDERR_INVALIDPARAMS;
15581691 return glDDS7->BltBatch(lpDDBltBatch,dwCount,dwFlags);
15591692 }
15601693 HRESULT WINAPI glDirectDrawSurface3::BltFast(DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans)
15611694 {
 1695+ if(!this) return DDERR_INVALIDPARAMS;
15621696 return glDDS7->BltFast(dwX,dwY,((glDirectDrawSurface3*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwTrans);
15631697 }
15641698 HRESULT WINAPI glDirectDrawSurface3::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface)
15651699 {
 1700+ if(!this) return DDERR_INVALIDPARAMS;
15661701 return glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
15671702 }
15681703 HRESULT WINAPI glDirectDrawSurface3::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
15691704 {
 1705+ if(!this) return DDERR_INVALIDPARAMS;
15701706 return glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback);
15711707 }
15721708 HRESULT WINAPI glDirectDrawSurface3::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
15731709 {
 1710+ if(!this) return DDERR_INVALIDPARAMS;
15741711 return glDDS7->EnumOverlayZOrders(dwFlags,lpContext,(LPDDENUMSURFACESCALLBACK7)lpfnCallback);
15751712 }
15761713 HRESULT WINAPI glDirectDrawSurface3::Flip(LPDIRECTDRAWSURFACE3 lpDDSurfaceTargetOverride, DWORD dwFlags)
15771714 {
 1715+ if(!this) return DDERR_INVALIDPARAMS;
15781716 if(lpDDSurfaceTargetOverride)
15791717 return glDDS7->Flip(((glDirectDrawSurface3*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
15801718 else return glDDS7->Flip(NULL,dwFlags);
@@ -1580,6 +1718,7 @@
15811719 }
15821720 HRESULT WINAPI glDirectDrawSurface3::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE3 FAR *lplpDDAttachedSurface)
15831721 {
 1722+ if(!this) return DDERR_INVALIDPARAMS;
15841723 HRESULT error;
15851724 glDirectDrawSurface7 *attachedsurface;
15861725 glDirectDrawSurface3 *attached1;
@@ -1597,10 +1736,12 @@
15981737 }
15991738 HRESULT WINAPI glDirectDrawSurface3::GetBltStatus(DWORD dwFlags)
16001739 {
 1740+ if(!this) return DDERR_INVALIDPARAMS;
16011741 return glDDS7->GetBltStatus(dwFlags);
16021742 }
16031743 HRESULT WINAPI glDirectDrawSurface3::GetCaps(LPDDSCAPS lpDDSCaps)
16041744 {
 1745+ if(!this) return DDERR_INVALIDPARAMS;
16051746 HRESULT error;
16061747 DDSCAPS2 ddsCaps1;
16071748 error = glDDS7->GetCaps(&ddsCaps1);
@@ -1610,102 +1751,127 @@
16111752 }
16121753 HRESULT WINAPI glDirectDrawSurface3::GetClipper(LPDIRECTDRAWCLIPPER FAR *lplpDDClipper)
16131754 {
 1755+ if(!this) return DDERR_INVALIDPARAMS;
16141756 return glDDS7->GetClipper(lplpDDClipper);
16151757 }
16161758 HRESULT WINAPI glDirectDrawSurface3::GetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
16171759 {
 1760+ if(!this) return DDERR_INVALIDPARAMS;
16181761 return glDDS7->GetColorKey(dwFlags,lpDDColorKey);
16191762 }
16201763 HRESULT WINAPI glDirectDrawSurface3::GetDC(HDC FAR *lphDC)
16211764 {
 1765+ if(!this) return DDERR_INVALIDPARAMS;
16221766 return glDDS7->GetDC(lphDC);
16231767 }
16241768 HRESULT WINAPI glDirectDrawSurface3::GetFlipStatus(DWORD dwFlags)
16251769 {
 1770+ if(!this) return DDERR_INVALIDPARAMS;
16261771 return glDDS7->GetFlipStatus(dwFlags);
16271772 }
16281773 HRESULT WINAPI glDirectDrawSurface3::GetOverlayPosition(LPLONG lplX, LPLONG lplY)
16291774 {
 1775+ if(!this) return DDERR_INVALIDPARAMS;
16301776 return glDDS7->GetOverlayPosition(lplX,lplY);
16311777 }
16321778 HRESULT WINAPI glDirectDrawSurface3::GetPalette(LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
16331779 {
 1780+ if(!this) return DDERR_INVALIDPARAMS;
16341781 return glDDS7->GetPalette(lplpDDPalette);
16351782 }
16361783 HRESULT WINAPI glDirectDrawSurface3::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
16371784 {
 1785+ if(!this) return DDERR_INVALIDPARAMS;
16381786 return glDDS7->GetPixelFormat(lpDDPixelFormat);
16391787 }
16401788 HRESULT WINAPI glDirectDrawSurface3::GetSurfaceDesc(LPDDSURFACEDESC lpDDSurfaceDesc)
16411789 {
 1790+ if(!this) return DDERR_INVALIDPARAMS;
16421791 return glDDS7->GetSurfaceDesc((LPDDSURFACEDESC2)lpDDSurfaceDesc);
16431792 }
16441793 HRESULT WINAPI glDirectDrawSurface3::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc)
16451794 {
 1795+ if(!this) return DDERR_INVALIDPARAMS;
16461796 return DDERR_ALREADYINITIALIZED;
16471797 }
16481798 HRESULT WINAPI glDirectDrawSurface3::IsLost()
16491799 {
 1800+ if(!this) return DDERR_INVALIDPARAMS;
16501801 return glDDS7->IsLost();
16511802 }
16521803 HRESULT WINAPI glDirectDrawSurface3::Lock(LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
16531804 {
 1805+ if(!this) return DDERR_INVALIDPARAMS;
16541806 return glDDS7->Lock(lpDestRect,(LPDDSURFACEDESC2)lpDDSurfaceDesc,dwFlags,hEvent);
16551807 }
16561808 HRESULT WINAPI glDirectDrawSurface3::ReleaseDC(HDC hDC)
16571809 {
 1810+ if(!this) return DDERR_INVALIDPARAMS;
16581811 return glDDS7->ReleaseDC(hDC);
16591812 }
16601813 HRESULT WINAPI glDirectDrawSurface3::Restore()
16611814 {
 1815+ if(!this) return DDERR_INVALIDPARAMS;
16621816 return glDDS7->Restore();
16631817 }
16641818 HRESULT WINAPI glDirectDrawSurface3::SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper)
16651819 {
 1820+ if(!this) return DDERR_INVALIDPARAMS;
16661821 return glDDS7->SetClipper(lpDDClipper);
16671822 }
16681823 HRESULT WINAPI glDirectDrawSurface3::SetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
16691824 {
 1825+ if(!this) return DDERR_INVALIDPARAMS;
16701826 return glDDS7->SetColorKey(dwFlags,lpDDColorKey);
16711827 }
16721828 HRESULT WINAPI glDirectDrawSurface3::SetOverlayPosition(LONG lX, LONG lY)
16731829 {
 1830+ if(!this) return DDERR_INVALIDPARAMS;
16741831 return glDDS7->SetOverlayPosition(lX,lY);
16751832 }
16761833 HRESULT WINAPI glDirectDrawSurface3::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
16771834 {
 1835+ if(!this) return DDERR_INVALIDPARAMS;
16781836 return glDDS7->SetPalette(lpDDPalette);
16791837 }
16801838 HRESULT WINAPI glDirectDrawSurface3::Unlock(LPVOID lpSurfaceData)
16811839 {
 1840+ if(!this) return DDERR_INVALIDPARAMS;
16821841 return glDDS7->Unlock2(lpSurfaceData);
16831842 }
16841843 HRESULT WINAPI glDirectDrawSurface3::UpdateOverlay(LPRECT lpSrcRect, LPDIRECTDRAWSURFACE3 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx)
16851844 {
 1845+ if(!this) return DDERR_INVALIDPARAMS;
16861846 return glDDS7->UpdateOverlay(lpSrcRect,(LPDIRECTDRAWSURFACE7)lpDDDestSurface,lpDestRect,dwFlags,lpDDOverlayFx);
16871847 }
16881848 HRESULT WINAPI glDirectDrawSurface3::UpdateOverlayDisplay(DWORD dwFlags)
16891849 {
 1850+ if(!this) return DDERR_INVALIDPARAMS;
16901851 return glDDS7->UpdateOverlayDisplay(dwFlags);
16911852 }
16921853 HRESULT WINAPI glDirectDrawSurface3::UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE3 lpDDSReference)
16931854 {
 1855+ if(!this) return DDERR_INVALIDPARAMS;
16941856 return glDDS7->UpdateOverlayZOrder(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSReference);
16951857 }
16961858 HRESULT WINAPI glDirectDrawSurface3::GetDDInterface(LPVOID FAR *lplpDD)
16971859 {
 1860+ if(!this) return DDERR_INVALIDPARAMS;
16981861 return glDDS7->GetDDInterface(lplpDD);
16991862 }
17001863 HRESULT WINAPI glDirectDrawSurface3::PageLock(DWORD dwFlags)
17011864 {
 1865+ if(!this) return DDERR_INVALIDPARAMS;
17021866 return glDDS7->PageLock(dwFlags);
17031867 }
17041868 HRESULT WINAPI glDirectDrawSurface3::PageUnlock(DWORD dwFlags)
17051869 {
 1870+ if(!this) return DDERR_INVALIDPARAMS;
17061871 return glDDS7->PageUnlock(dwFlags);
17071872 }
17081873 HRESULT WINAPI glDirectDrawSurface3::SetSurfaceDesc(LPDDSURFACEDESC lpddsd, DWORD dwFlags)
17091874 {
 1875+ if(!this) return DDERR_INVALIDPARAMS;
17101876 return glDDS7->SetSurfaceDesc((LPDDSURFACEDESC2)lpddsd,dwFlags);
17111877 }
17121878
@@ -1722,15 +1888,18 @@
17231889 }
17241890 HRESULT WINAPI glDirectDrawSurface4::QueryInterface(REFIID riid, void** ppvObj)
17251891 {
 1892+ if(!this) return DDERR_INVALIDPARAMS;
17261893 return glDDS7->QueryInterface(riid,ppvObj);
17271894 }
17281895 ULONG WINAPI glDirectDrawSurface4::AddRef()
17291896 {
 1897+ if(!this) return 0;
17301898 refcount++;
17311899 return refcount;
17321900 }
17331901 ULONG WINAPI glDirectDrawSurface4::Release()
17341902 {
 1903+ if(!this) return 0;
17351904 ULONG ret;
17361905 refcount--;
17371906 ret = refcount;
@@ -1739,39 +1908,48 @@
17401909 }
17411910 HRESULT WINAPI glDirectDrawSurface4::AddAttachedSurface(LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface)
17421911 {
 1912+ if(!this) return DDERR_INVALIDPARAMS;
17431913 return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
17441914 }
17451915 HRESULT WINAPI glDirectDrawSurface4::AddOverlayDirtyRect(LPRECT lpRect)
17461916 {
 1917+ if(!this) return DDERR_INVALIDPARAMS;
17471918 return glDDS7->AddOverlayDirtyRect(lpRect);
17481919 }
17491920 HRESULT WINAPI glDirectDrawSurface4::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
17501921 {
 1922+ if(!this) return DDERR_INVALIDPARAMS;
17511923 if(lpDDSrcSurface) return glDDS7->Blt(lpDestRect,((glDirectDrawSurface4*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx);
17521924 else return glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx);
17531925 }
17541926 HRESULT WINAPI glDirectDrawSurface4::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
17551927 {
 1928+ if(!this) return DDERR_INVALIDPARAMS;
17561929 return glDDS7->BltBatch(lpDDBltBatch,dwCount,dwFlags);
17571930 }
17581931 HRESULT WINAPI glDirectDrawSurface4::BltFast(DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans)
17591932 {
 1933+ if(!this) return DDERR_INVALIDPARAMS;
17601934 return glDDS7->BltFast(dwX,dwY,((glDirectDrawSurface4*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwTrans);
17611935 }
17621936 HRESULT WINAPI glDirectDrawSurface4::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface)
17631937 {
 1938+ if(!this) return DDERR_INVALIDPARAMS;
17641939 return glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
17651940 }
17661941 HRESULT WINAPI glDirectDrawSurface4::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumSurfacesCallback)
17671942 {
 1943+ if(!this) return DDERR_INVALIDPARAMS;
17681944 return glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback);
17691945 }
17701946 HRESULT WINAPI glDirectDrawSurface4::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpfnCallback)
17711947 {
 1948+ if(!this) return DDERR_INVALIDPARAMS;
17721949 return glDDS7->EnumOverlayZOrders(dwFlags,lpContext,(LPDDENUMSURFACESCALLBACK7)lpfnCallback);
17731950 }
17741951 HRESULT WINAPI glDirectDrawSurface4::Flip(LPDIRECTDRAWSURFACE4 lpDDSurfaceTargetOverride, DWORD dwFlags)
17751952 {
 1953+ if(!this) return DDERR_INVALIDPARAMS;
17761954 if(lpDDSurfaceTargetOverride)
17771955 return glDDS7->Flip(((glDirectDrawSurface4*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
17781956 else return glDDS7->Flip(NULL,dwFlags);
@@ -1778,6 +1956,7 @@
17791957 }
17801958 HRESULT WINAPI glDirectDrawSurface4::GetAttachedSurface(LPDDSCAPS2 lpDDSCaps2, LPDIRECTDRAWSURFACE4 FAR *lplpDDAttachedSurface)
17811959 {
 1960+ if(!this) return DDERR_INVALIDPARAMS;
17821961 HRESULT error;
17831962 glDirectDrawSurface7 *attachedsurface;
17841963 glDirectDrawSurface4 *attached1;
@@ -1792,129 +1971,161 @@
17931972 }
17941973 HRESULT WINAPI glDirectDrawSurface4::GetBltStatus(DWORD dwFlags)
17951974 {
 1975+ if(!this) return DDERR_INVALIDPARAMS;
17961976 return glDDS7->GetBltStatus(dwFlags);
17971977 }
17981978 HRESULT WINAPI glDirectDrawSurface4::GetCaps(LPDDSCAPS2 lpDDSCaps)
17991979 {
 1980+ if(!this) return DDERR_INVALIDPARAMS;
18001981 return glDDS7->GetCaps(lpDDSCaps);
18011982 }
18021983 HRESULT WINAPI glDirectDrawSurface4::GetClipper(LPDIRECTDRAWCLIPPER FAR *lplpDDClipper)
18031984 {
 1985+ if(!this) return DDERR_INVALIDPARAMS;
18041986 return glDDS7->GetClipper(lplpDDClipper);
18051987 }
18061988 HRESULT WINAPI glDirectDrawSurface4::GetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
18071989 {
 1990+ if(!this) return DDERR_INVALIDPARAMS;
18081991 return glDDS7->GetColorKey(dwFlags,lpDDColorKey);
18091992 }
18101993 HRESULT WINAPI glDirectDrawSurface4::GetDC(HDC FAR *lphDC)
18111994 {
 1995+ if(!this) return DDERR_INVALIDPARAMS;
18121996 return glDDS7->GetDC(lphDC);
18131997 }
18141998 HRESULT WINAPI glDirectDrawSurface4::GetFlipStatus(DWORD dwFlags)
18151999 {
 2000+ if(!this) return DDERR_INVALIDPARAMS;
18162001 return glDDS7->GetFlipStatus(dwFlags);
18172002 }
18182003 HRESULT WINAPI glDirectDrawSurface4::GetOverlayPosition(LPLONG lplX, LPLONG lplY)
18192004 {
 2005+ if(!this) return DDERR_INVALIDPARAMS;
18202006 return glDDS7->GetOverlayPosition(lplX,lplY);
18212007 }
18222008 HRESULT WINAPI glDirectDrawSurface4::GetPalette(LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
18232009 {
 2010+ if(!this) return DDERR_INVALIDPARAMS;
18242011 return glDDS7->GetPalette(lplpDDPalette);
18252012 }
18262013 HRESULT WINAPI glDirectDrawSurface4::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
18272014 {
 2015+ if(!this) return DDERR_INVALIDPARAMS;
18282016 return glDDS7->GetPixelFormat(lpDDPixelFormat);
18292017 }
18302018 HRESULT WINAPI glDirectDrawSurface4::GetSurfaceDesc(LPDDSURFACEDESC2 lpDDSurfaceDesc)
18312019 {
 2020+ if(!this) return DDERR_INVALIDPARAMS;
18322021 return glDDS7->GetSurfaceDesc(lpDDSurfaceDesc);
18332022 }
18342023 HRESULT WINAPI glDirectDrawSurface4::Initialize(LPDIRECTDRAW lpDD, LPDDSURFACEDESC2 lpDDSurfaceDesc)
18352024 {
 2025+ if(!this) return DDERR_INVALIDPARAMS;
18362026 return DDERR_ALREADYINITIALIZED;
18372027 }
18382028 HRESULT WINAPI glDirectDrawSurface4::IsLost()
18392029 {
 2030+ if(!this) return DDERR_INVALIDPARAMS;
18402031 return glDDS7->IsLost();
18412032 }
18422033 HRESULT WINAPI glDirectDrawSurface4::Lock(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
18432034 {
 2035+ if(!this) return DDERR_INVALIDPARAMS;
18442036 return glDDS7->Lock(lpDestRect,lpDDSurfaceDesc,dwFlags,hEvent);
18452037 }
18462038 HRESULT WINAPI glDirectDrawSurface4::ReleaseDC(HDC hDC)
18472039 {
 2040+ if(!this) return DDERR_INVALIDPARAMS;
18482041 return glDDS7->ReleaseDC(hDC);
18492042 }
18502043 HRESULT WINAPI glDirectDrawSurface4::Restore()
18512044 {
 2045+ if(!this) return DDERR_INVALIDPARAMS;
18522046 return glDDS7->Restore();
18532047 }
18542048 HRESULT WINAPI glDirectDrawSurface4::SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper)
18552049 {
 2050+ if(!this) return DDERR_INVALIDPARAMS;
18562051 return glDDS7->SetClipper(lpDDClipper);
18572052 }
18582053 HRESULT WINAPI glDirectDrawSurface4::SetColorKey(DWORD dwFlags, LPDDCOLORKEY lpDDColorKey)
18592054 {
 2055+ if(!this) return DDERR_INVALIDPARAMS;
18602056 return glDDS7->SetColorKey(dwFlags,lpDDColorKey);
18612057 }
18622058 HRESULT WINAPI glDirectDrawSurface4::SetOverlayPosition(LONG lX, LONG lY)
18632059 {
 2060+ if(!this) return DDERR_INVALIDPARAMS;
18642061 return glDDS7->SetOverlayPosition(lX,lY);
18652062 }
18662063 HRESULT WINAPI glDirectDrawSurface4::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
18672064 {
 2065+ if(!this) return DDERR_INVALIDPARAMS;
18682066 return glDDS7->SetPalette(lpDDPalette);
18692067 }
18702068 HRESULT WINAPI glDirectDrawSurface4::Unlock(LPRECT lpRect)
18712069 {
 2070+ if(!this) return DDERR_INVALIDPARAMS;
18722071 return glDDS7->Unlock2(lpRect);
18732072 }
18742073 HRESULT WINAPI glDirectDrawSurface4::UpdateOverlay(LPRECT lpSrcRect, LPDIRECTDRAWSURFACE4 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx)
18752074 {
 2075+ if(!this) return DDERR_INVALIDPARAMS;
18762076 return glDDS7->UpdateOverlay(lpSrcRect,(LPDIRECTDRAWSURFACE7)lpDDDestSurface,lpDestRect,dwFlags,lpDDOverlayFx);
18772077 }
18782078 HRESULT WINAPI glDirectDrawSurface4::UpdateOverlayDisplay(DWORD dwFlags)
18792079 {
 2080+ if(!this) return DDERR_INVALIDPARAMS;
18802081 return glDDS7->UpdateOverlayDisplay(dwFlags);
18812082 }
18822083 HRESULT WINAPI glDirectDrawSurface4::UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE4 lpDDSReference)
18832084 {
 2085+ if(!this) return DDERR_INVALIDPARAMS;
18842086 return glDDS7->UpdateOverlayZOrder(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSReference);
18852087 }
18862088 HRESULT WINAPI glDirectDrawSurface4::GetDDInterface(LPVOID FAR *lplpDD)
18872089 {
 2090+ if(!this) return DDERR_INVALIDPARAMS;
18882091 return glDDS7->GetDDInterface(lplpDD);
18892092 }
18902093 HRESULT WINAPI glDirectDrawSurface4::PageLock(DWORD dwFlags)
18912094 {
 2095+ if(!this) return DDERR_INVALIDPARAMS;
18922096 return glDDS7->PageLock(dwFlags);
18932097 }
18942098 HRESULT WINAPI glDirectDrawSurface4::PageUnlock(DWORD dwFlags)
18952099 {
 2100+ if(!this) return DDERR_INVALIDPARAMS;
18962101 return glDDS7->PageUnlock(dwFlags);
18972102 }
18982103 HRESULT WINAPI glDirectDrawSurface4::SetSurfaceDesc(LPDDSURFACEDESC2 lpddsd, DWORD dwFlags)
18992104 {
 2105+ if(!this) return DDERR_INVALIDPARAMS;
19002106 return glDDS7->SetSurfaceDesc(lpddsd,dwFlags);
19012107 }
19022108 HRESULT WINAPI glDirectDrawSurface4::SetPrivateData(REFGUID guidTag, LPVOID lpData, DWORD cbSize, DWORD dwFlags)
19032109 {
 2110+ if(!this) return DDERR_INVALIDPARAMS;
19042111 return glDDS7->SetPrivateData(guidTag,lpData,cbSize,dwFlags);
19052112 }
19062113 HRESULT WINAPI glDirectDrawSurface4::GetPrivateData(REFGUID guidTag, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
19072114 {
 2115+ if(!this) return DDERR_INVALIDPARAMS;
19082116 return glDDS7->GetPrivateData(guidTag,lpBuffer,lpcbBufferSize);
19092117 }
19102118 HRESULT WINAPI glDirectDrawSurface4::FreePrivateData(REFGUID guidTag)
19112119 {
 2120+ if(!this) return DDERR_INVALIDPARAMS;
19122121 return glDDS7->FreePrivateData(guidTag);
19132122 }
19142123 HRESULT WINAPI glDirectDrawSurface4::GetUniquenessValue(LPDWORD lpValue)
19152124 {
 2125+ if(!this) return DDERR_INVALIDPARAMS;
19162126 return glDDS7->GetUniquenessValue(lpValue);
19172127 }
19182128 HRESULT WINAPI glDirectDrawSurface4::ChangeUniquenessValue()
19192129 {
 2130+ if(!this) return DDERR_INVALIDPARAMS;
19202131 return glDDS7->ChangeUniquenessValue();
19212132 }