[ros-diffs] [greatlrd] 31402: Fixing smaller bugs in ddraw.dll GetCaps 1. GetCaps should not call get avail memory for hel 2. add ddcaps size check 3. add Enter/leave CriticalSection GetDeviceIdentifier 1. add Enter/leave CriticalSection

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sat Dec 22 21:33:11 CET 2007


Author: greatlrd
Date: Sat Dec 22 23:33:11 2007
New Revision: 31402

URL: http://svn.reactos.org/svn/reactos?rev=31402&view=rev
Log:
Fixing smaller bugs in ddraw.dll
GetCaps
1. GetCaps should not call get avail memory for hel
2. add ddcaps size check 
3. add Enter/leave CriticalSection

GetDeviceIdentifier
1. add Enter/leave CriticalSection

Modified:
    trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c
    trunk/reactos/dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c

Modified: trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c?rev=31402&r1=31401&r2=31402&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c Sat Dec 22 23:33:11 2007
@@ -32,9 +32,39 @@
 
     DX_WINDBG_trace();
 
-        _SEH_TRY
+    EnterCriticalSection( &ddcs );
+
+    _SEH_TRY
     {
         if ((!pDriverCaps) && (!pHELCaps))
+        {
+                retVal = DDERR_INVALIDPARAMS;
+                _SEH_LEAVE;
+        }
+
+        /*
+         * DDCAPS_DX6 and DDCAPS_DX7 have same size so
+         * we do not need check both only one of them
+         */
+        if ( (pDriverCaps) &&
+             (pDriverCaps->dwSize != sizeof(DDCAPS_DX1) ) &&
+             (pDriverCaps->dwSize != sizeof(DDCAPS_DX3) ) &&
+             (pDriverCaps->dwSize != sizeof(DDCAPS_DX5) ) &&
+             (pDriverCaps->dwSize !=  sizeof(DDCAPS_DX7 )) )
+        {
+                retVal = DDERR_INVALIDPARAMS;
+                _SEH_LEAVE;
+        }
+
+        /*
+         * DDCAPS_DX6 and DDCAPS_DX7 have same size so
+         * we do not need check both only one of them
+         */
+        if ( (pHELCaps) &&
+             (pHELCaps->dwSize != sizeof(DDCAPS_DX1) ) &&
+             (pHELCaps->dwSize != sizeof(DDCAPS_DX3) ) &&
+             (pHELCaps->dwSize != sizeof(DDCAPS_DX5) ) &&
+             (pHELCaps->dwSize != sizeof(DDCAPS_DX7 )) )
         {
                 retVal = DDERR_INVALIDPARAMS;
                 _SEH_LEAVE;
@@ -153,13 +183,10 @@
         if (pHELCaps)
         {
             /* Setup software caps */
-            DDSCAPS2 ddscaps = { 0 };
             LPDDCORECAPS CoreCaps = (LPDDCORECAPS)&This->lpLcl->lpGbl->ddHELCaps;
 
             DWORD dwTotal = 0;
             DWORD dwFree = 0;
-
-            Main_DirectDraw_GetAvailableVidMem4(This, &ddscaps, &dwTotal, &dwFree);
 
             switch (pHELCaps->dwSize)
             {
@@ -259,7 +286,6 @@
                     break;
             }
         }
-
 
     }
     _SEH_HANDLE
@@ -268,6 +294,7 @@
     }
     _SEH_END;
 
-     return  retVal;
+    LeaveCriticalSection( &ddcs );
+    return  retVal;
 }
 

Modified: trunk/reactos/dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c?rev=31402&r1=31401&r2=31402&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c Sat Dec 22 23:33:11 2007
@@ -74,6 +74,8 @@
     long *lpdata;
 
     DX_WINDBG_trace();
+
+    EnterCriticalSection( &ddcs );
 
     _SEH_TRY
     {
@@ -184,5 +186,6 @@
     }
     _SEH_END;
 
+    LeaveCriticalSection( &ddcs );
     return retVal;
 }




More information about the Ros-diffs mailing list