Fix some crach in ddraw.dll startup process for surface, we still got crach and surfa...
authorMagnus Olsen <magnus@greatlord.com>
Mon, 31 Oct 2005 01:22:19 +0000 (01:22 +0000)
committerMagnus Olsen <magnus@greatlord.com>
Mon, 31 Oct 2005 01:22:19 +0000 (01:22 +0000)
svn path=/trunk/; revision=18908

reactos/lib/ddraw/hal/surface_hal.c
reactos/lib/ddraw/main/ddraw_main.c
reactos/lib/ddraw/main/surface_main.c

index 335addd..d815ee0 100644 (file)
@@ -13,7 +13,8 @@
 HRESULT Hal_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rDest,
                          LPDIRECTDRAWSURFACE7 src, LPRECT rSrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
 {
-    IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
+    
+       IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
     IDirectDrawSurfaceImpl* That = (IDirectDrawSurfaceImpl*)src;
        
        if (!(This->owner->DirectDrawGlobal.lpDDCBtmp->HALDDSurface.dwFlags  & DDHAL_SURFCB32_BLT)) 
index e064ce2..49e84a3 100644 (file)
@@ -38,7 +38,8 @@ HRESULT WINAPI Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
        // ... then overwrite with hal
        if((ret = Hel_DirectDraw_Initialize (iface)) != DD_OK)
                return ret;
-
+       
+   
        return DD_OK;
 }
 
@@ -165,22 +166,30 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
                return DDERR_UNSUPPORTED;
 
        // the nasty com stuff
+       IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+
        IDirectDrawSurfaceImpl* That; 
 
        That = (IDirectDrawSurfaceImpl*)HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectDrawSurfaceImpl));
-
+       
        if (That == NULL) 
                return E_OUTOFMEMORY;
 
        ZeroMemory(That, sizeof(IDirectDrawSurfaceImpl));
-
+       
        That->lpVtbl = &DirectDrawSurface7_Vtable;
        That->lpVtbl_v3 = &DDRAW_IDDS3_Thunk_VTable;
-       
+
+       This->DirectDrawGlobal.dsList = (LPDDRAWI_DDRAWSURFACE_INT)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
+                                                                                   sizeof(DDRAWI_DDRAWSURFACE_INT));           
+
+       That->owner = (IDirectDrawImpl *)This;
+
        That->owner->DirectDrawGlobal.dsList->dwIntRefCnt =1;
 
        /* we alwasy set to use the DirectDrawSurface7_Vtable as internel */
        That->owner->DirectDrawGlobal.dsList->lpVtbl = (PVOID) &DirectDrawSurface7_Vtable;
+       
 
        *ppSurf = (LPDIRECTDRAWSURFACE7)That;
 
index 6939eb5..c8d28d8 100644 (file)
 HRESULT WINAPI Main_DDrawSurface_Initialize (LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD)
 {
     IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-
-       if (This->owner)
-               return DDERR_ALREADYINITIALIZED;
-
+       
        if(sizeof(DDSURFACEDESC2) != pDDSD->dwSize)
                return DDERR_UNSUPPORTED;
 
        if(!(pDDSD->dwFlags & DDSD_CAPS))
                return DDERR_INVALIDPARAMS;
 
-       This->owner = (IDirectDrawImpl*)pDD;
+       This->owner = (IDirectDrawImpl*)pDD;    
    
        if (This->owner->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CANCREATESURFACE)
        {