Author: greatlrd
Date: Tue Jul 25 20:04:10 2006
New Revision: 23286
URL:
http://svn.reactos.org/svn/reactos?rev=23286&view=rev
Log:
fixing bsod in GetAttachSurface when pointer is NULL
Modified:
trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
trunk/reactos/dll/directx/ddraw/main/surface_main.c
trunk/reactos/dll/directx/ddraw/rosdraw.h
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddr…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Tue Jul 25 20:04:10 2006
@@ -297,6 +297,8 @@
// FIXME Free memmory at exit
return E_OUTOFMEMORY;
}
+ ZeroMemory(surf, sizeof(DxSurf));
+
That->lpVtbl = &DirectDrawSurface7_Vtable;
Modified: trunk/reactos/dll/directx/ddraw/main/surface_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/sur…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/surface_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/surface_main.c Tue Jul 25 20:04:10 2006
@@ -235,7 +235,7 @@
LPDIRECTDRAWSURFACE7* ppSurface)
{
IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
- IDirectDrawSurfaceImpl *surf;
+ IDirectDrawSurfaceImpl *surf;
DDSCAPS2 our_caps;
DX_WINDBG_trace();
@@ -246,7 +246,7 @@
*/
our_caps = *pCaps;
-
+
/*
FIXME adding version check
Earlier dx apps put garbage into these members, clear them
@@ -255,32 +255,43 @@
our_caps.dwCaps3 = 0;
our_caps.dwCaps4 = 0;
- surf = This;
- while( (surf = surf->Surf->next_complex) )
- {
- if (((surf->Surf->mddsdPrimary.ddsCaps.dwCaps & our_caps.dwCaps) ==
our_caps.dwCaps) &&
- ((surf->Surf->mddsdPrimary.ddsCaps.dwCaps2 & our_caps.dwCaps2) ==
our_caps.dwCaps2))
- {
- *ppSurface = (LPDIRECTDRAWSURFACE7)surf;
- Main_DDrawSurface_AddRef(*ppSurface);
- return DD_OK;
- }
- }
-
- /* Next, look at the attachment chain */
- surf = This;
-
- while( (surf = surf->Surf->next_attached) )
- {
- if (((surf->Surf->mddsdPrimary.ddsCaps.dwCaps & our_caps.dwCaps) ==
our_caps.dwCaps) &&
- ((surf->Surf->mddsdPrimary.ddsCaps.dwCaps2 & our_caps.dwCaps2) ==
our_caps.dwCaps2))
- {
- *ppSurface = (LPDIRECTDRAWSURFACE7)surf;
- Main_DDrawSurface_AddRef(*ppSurface);
- return DD_OK;
- }
- }
-
+ //surf = (IDirectDrawSurfaceImpl*)This->Surf->next_complex;
+ if (This->Surf->next_complex != NULL)
+ {
+ surf = (IDirectDrawSurfaceImpl*)This->Surf->next_complex;
+ while( surf != NULL )
+ {
+ if (((surf->Surf->mddsdPrimary.ddsCaps.dwCaps & our_caps.dwCaps) ==
our_caps.dwCaps) &&
+ ((surf->Surf->mddsdPrimary.ddsCaps.dwCaps2 & our_caps.dwCaps2) ==
our_caps.dwCaps2))
+ {
+ *ppSurface = (LPDIRECTDRAWSURFACE7)surf;
+ Main_DDrawSurface_AddRef(*ppSurface);
+ DX_STUB_str("surf->Surf->next_complex ok");
+ return DD_OK;
+ }
+ surf = (IDirectDrawSurfaceImpl*)This->Surf->next_complex;
+ }
+ }
+
+ if (This->Surf->next_attached != NULL)
+ {
+ surf = (IDirectDrawSurfaceImpl*)This->Surf->next_attached;
+
+ while(surf != NULL)
+ {
+ if (((surf->Surf->mddsdPrimary.ddsCaps.dwCaps & our_caps.dwCaps) ==
our_caps.dwCaps) &&
+ ((surf->Surf->mddsdPrimary.ddsCaps.dwCaps2 & our_caps.dwCaps2) ==
our_caps.dwCaps2))
+ {
+ *ppSurface = (LPDIRECTDRAWSURFACE7)surf;
+ Main_DDrawSurface_AddRef(*ppSurface);
+ DX_STUB_str("surf->Surf->next_attached ok");
+ return DD_OK;
+ }
+ surf = (IDirectDrawSurfaceImpl*)This->Surf->next_attached;
+ }
+ }
+
+ DX_STUB_str("Fail");
return DDERR_NOTFOUND;
}
Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/rosdraw.h (original)
+++ trunk/reactos/dll/directx/ddraw/rosdraw.h Tue Jul 25 20:04:10 2006
@@ -128,12 +128,12 @@
wine desgin for it
type IDirectDrawSurfaceImpl;
*/
- LPVOID next_attached;
- LPVOID first_attached;
- LPVOID next_complex;
- LPVOID first_complex;
- LPVOID next;
- LPVOID prev;
+ DWORD* next_attached;
+ DWORD* first_attached;
+ DWORD* next_complex;
+ DWORD* first_complex;
+ DWORD* next;
+ DWORD* prev;
/* Need be delete later */
DDRAWI_DDRAWSURFACE_GBL mSurfGlobal;