[ros-diffs] [greatlrd] 25018: fixed follow bugs 1. Fixed memory crash bug for linking two directdraw interface 2. Fixed meoory alloc does not being overwrite when it being linked

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sat Dec 2 19:59:06 CET 2006


Author: greatlrd
Date: Sat Dec  2 21:59:05 2006
New Revision: 25018

URL: http://svn.reactos.org/svn/reactos?rev=25018&view=rev
Log:
fixed follow bugs
1. Fixed memory crash bug for linking two directdraw interface
2. Fixed meoory alloc does not being overwrite when it being linked

Modified:
    trunk/reactos/dll/directx/ddraw/startup.c

Modified: trunk/reactos/dll/directx/ddraw/startup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/startup.c?rev=25018&r1=25017&r2=25018&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ddraw/startup.c (original)
+++ trunk/reactos/dll/directx/ddraw/startup.c Sat Dec  2 21:59:05 2006
@@ -33,27 +33,45 @@
     
     DX_WINDBG_trace();
 	  
-	RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
+
+	if (This->lpLink == NULL)
+	{
+		RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
+	    
+		if (ddgbl.lpDDCBtmp == NULL)
+		{
+			ddgbl.lpDDCBtmp = (LPDDHAL_CALLBACKS) DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));  
+			if (ddgbl.lpDDCBtmp == NULL)
+			{
+				DX_STUB_str("Out of memmory");
+				return DD_FALSE;
+			}
+		}
+		
+		
+	}
+
+	/* 
+	   Visual studio think this code is a break point if we call 
+	   second time to this function, press on continue in visual
+	   studio the program will work. No real bug. gcc 3.4.5 genreate 
+	   code that look like MS visual studio break point. 
+     */
+
+	This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp;
+
+    /* Same for HEL and HAL */
+
+	if (ddgbl.lpModeInfo == NULL)
+	{
+		ddgbl.lpModeInfo = (DDHALMODEINFO*) DxHeapMemAlloc(1 * sizeof(DDHALMODEINFO));  
+		if (ddgbl.lpModeInfo == NULL)
+		{
+			DX_STUB_str("DD_FALSE");
+			return DD_FALSE;
+		}		   
+	}
     
-	ddgbl.lpDDCBtmp = (LPDDHAL_CALLBACKS) DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));  
-	if (ddgbl.lpDDCBtmp == NULL)
-	{
-	   DX_STUB_str("Out of memmory");
-       return DD_FALSE;
-	}	
-
-	This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp;
-	
-	
-    /* Same for HEL and HAL */
-    This->lpLcl->lpGbl->lpModeInfo = (DDHALMODEINFO*) DxHeapMemAlloc(1 * sizeof(DDHALMODEINFO));  
-	
-    if (This->lpLcl->lpGbl->lpModeInfo == NULL)
-    {
-	   DX_STUB_str("DD_FALSE");
-       return DD_FALSE;
-    }
-
     EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
 
     This->lpLcl->lpGbl->lpModeInfo[0].dwWidth      = devmode.dmPelsWidth;
@@ -62,7 +80,6 @@
     This->lpLcl->lpGbl->lpModeInfo[0].lPitch       = (devmode.dmPelsWidth*devmode.dmBitsPerPel)/8;
     This->lpLcl->lpGbl->lpModeInfo[0].wRefreshRate = (WORD)devmode.dmDisplayFrequency;
    
-
 	if (lpGuid == NULL) 
 	{
 		devicetypes = 1;
@@ -156,15 +173,10 @@
 	
 	This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;	  
 	This->lpLcl->dwProcessId = GetCurrentProcessId();
-
-    
-    
     
     hel_ret = StartDirectDrawHel(iface);
 	hal_ret = StartDirectDrawHal(iface);
 
-	
-
     if ((hal_ret!=DD_OK) &&  (hel_ret!=DD_OK))
     {
 		DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT");
@@ -172,7 +184,6 @@
     }
 
 	This->lpLcl->hDD = This->lpLcl->lpGbl->hDD;
-
 
 	/* Mix the DDCALLBACKS */	
 	This->lpLcl->lpDDCB->cbDDCallbacks.dwSize = sizeof(This->lpLcl->lpDDCB->cbDDCallbacks);
@@ -929,7 +940,7 @@
 	{		
 		return DDERR_INVALIDPARAMS;
 	}
-		
+	
 	if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID) == DD_OK);
     {
 




More information about the Ros-diffs mailing list