Fix broke SVN after me, thx to it I found wrong ref was release in different place fixed
Modified: trunk/reactos/lib/ddraw/main/clipper_main.c
Modified: trunk/reactos/lib/ddraw/main/color_main.c
Modified: trunk/reactos/lib/ddraw/main/gamma_main.c
Modified: trunk/reactos/lib/ddraw/main/palette_main.c
Modified: trunk/reactos/lib/ddraw/main/surface_main.c
Modified: trunk/reactos/lib/ddraw/rosdraw.h

Modified: trunk/reactos/lib/ddraw/main/clipper_main.c
--- trunk/reactos/lib/ddraw/main/clipper_main.c	2005-10-30 15:45:40 UTC (rev 18886)
+++ trunk/reactos/lib/ddraw/main/clipper_main.c	2005-10-30 16:14:42 UTC (rev 18887)
@@ -13,8 +13,8 @@
 
 ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) 
 {
-    IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-    ULONG ref = InterlockedDecrement(&This->ref);
+    IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+    ULONG ref = InterlockedDecrement(&This->DirectDrawGlobal.dwRefCnt);
     
     if (ref == 0)
 		HeapFree(GetProcessHeap(), 0, This);

Modified: trunk/reactos/lib/ddraw/main/color_main.c
--- trunk/reactos/lib/ddraw/main/color_main.c	2005-10-30 15:45:40 UTC (rev 18886)
+++ trunk/reactos/lib/ddraw/main/color_main.c	2005-10-30 16:14:42 UTC (rev 18887)
@@ -22,8 +22,8 @@
 ULONG WINAPI
 Main_DirectDrawColorControl_Release(LPDIRECTDRAWCOLORCONTROL iface)
 {
-    IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-    ULONG ref = InterlockedDecrement(&This->ref);
+    IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+    ULONG ref = InterlockedDecrement(&This->DirectDrawGlobal.dwRefCnt);
     
     if (ref == 0)
 		HeapFree(GetProcessHeap(), 0, This);

Modified: trunk/reactos/lib/ddraw/main/gamma_main.c
--- trunk/reactos/lib/ddraw/main/gamma_main.c	2005-10-30 15:45:40 UTC (rev 18886)
+++ trunk/reactos/lib/ddraw/main/gamma_main.c	2005-10-30 16:14:42 UTC (rev 18887)
@@ -22,8 +22,8 @@
 ULONG WINAPI
 Main_DirectDrawGammaControl_Release(LPDIRECTDRAWGAMMACONTROL iface)
 {
-    IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-    ULONG ref = InterlockedDecrement(&This->ref);
+    IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+    ULONG ref = InterlockedDecrement(&This->DirectDrawGlobal.dwRefCnt);
     
     if (ref == 0)
 		HeapFree(GetProcessHeap(), 0, This);

Modified: trunk/reactos/lib/ddraw/main/palette_main.c
--- trunk/reactos/lib/ddraw/main/palette_main.c	2005-10-30 15:45:40 UTC (rev 18886)
+++ trunk/reactos/lib/ddraw/main/palette_main.c	2005-10-30 16:14:42 UTC (rev 18887)
@@ -21,8 +21,8 @@
 
 ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface) 
 {
-    IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-    ULONG ref = InterlockedDecrement(&This->ref);
+    IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+    ULONG ref = InterlockedDecrement(&This->DirectDrawGlobal.dwRefCnt);
     
     if (ref == 0)
 		HeapFree(GetProcessHeap(), 0, This);

Modified: trunk/reactos/lib/ddraw/main/surface_main.c
--- trunk/reactos/lib/ddraw/main/surface_main.c	2005-10-30 15:45:40 UTC (rev 18886)
+++ trunk/reactos/lib/ddraw/main/surface_main.c	2005-10-30 16:14:42 UTC (rev 18887)
@@ -94,13 +94,14 @@
 ULONG WINAPI Main_DDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface)
 {
     IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-    return InterlockedIncrement(&This->ref);
+	
+    return InterlockedIncrement(&This->owner->DirectDrawGlobal.dsList->dwIntRefCnt);
 }
 
 ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface)
 {
     IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-    ULONG ref = InterlockedDecrement(&This->ref);
+    ULONG ref = InterlockedDecrement(&This->owner->DirectDrawGlobal.dsList->dwIntRefCnt);
     
     if (ref == 0)
 		HeapFree(GetProcessHeap(), 0, This);

Modified: trunk/reactos/lib/ddraw/rosdraw.h
--- trunk/reactos/lib/ddraw/rosdraw.h	2005-10-30 15:45:40 UTC (rev 18886)
+++ trunk/reactos/lib/ddraw/rosdraw.h	2005-10-30 16:14:42 UTC (rev 18887)
@@ -41,6 +41,10 @@
    
     IDirectDrawImpl* owner;
 
+	DDRAWI_DDRAWSURFACE_GBL Global; 
+	DDRAWI_DDRAWSURFACE_MORE More; 
+	DDRAWI_DDRAWSURFACE_LCL Local;
+
 } IDirectDrawSurfaceImpl;
 
 /******** Clipper Object ********/