Author: greatlrd
Date: Mon May 21 20:23:43 2007
New Revision: 26853
URL:
http://svn.reactos.org/svn/reactos?rev=26853&view=rev
Log:
fixing thread safe in GetFourCCCodes
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
Modified: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/dd…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c Mon May 21 20:23:43 2007
@@ -131,7 +131,7 @@
memcpy(&memdata.DDSCaps, ddscaps, sizeof(DDSCAPS2));
if
(This->lpLcl->lpDDCB->cbDDMiscellaneousCallbacks.GetAvailDriverMemory(&memdata)
== DDHAL_DRIVER_NOTHANDLED)
- return DDERR_NODIRECTDRAWHW;
+ return DDERR_NODIRECTDRAWHW;
if (dwTotal)
*dwTotal = memdata.dwTotal;
@@ -148,15 +148,20 @@
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace();
- if(!lpNumCodes)
- return DDERR_INVALIDPARAMS;
-
- if(lpCodes)
- memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)*(*lpNumCodes));
- else
- *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
-
- return DD_OK;
+ /* FIXME protect with SEH or something else if lpCodes or lpNumCodes for bad user
pointers */
+ EnterCriticalSection(&ddcs);
+
+ if(!lpNumCodes)
+ return DDERR_INVALIDPARAMS;
+
+ if(lpCodes)
+ memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC,
sizeof(DWORD)*(*lpNumCodes));
+ else
+ *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
+
+
+ LeaveCriticalSection(&ddcs);
+ return DD_OK;
}
HRESULT WINAPI