Author: greatlrd
Date: Tue May 22 14:46:17 2007
New Revision: 26864
URL:
http://svn.reactos.org/svn/reactos?rev=26864&view=rev
Log:
Fixing another memory crash bug this time for GetFourCCCodes
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
trunk/reactos/dll/directx/ddraw/ddraw.rbuild
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 Tue May 22 14:46:17 2007
@@ -11,6 +11,9 @@
#include "rosdraw.h"
+/* PSEH for SEH Support */
+#include <pseh/pseh.h>
+
HRESULT WINAPI
Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
REFIID id,
@@ -150,26 +153,33 @@
DX_WINDBG_trace();
- /* FIXME protect with SEH or something else if lpCodes or lpNumCodes for bad user
pointers */
- EnterCriticalSection(&ddcs);
-
- if(!lpNumCodes)
- {
- retVal = DDERR_INVALIDPARAMS;
- }
- else
- {
- if ((lpCodes) && (*lpCodes))
- {
- memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)*
min(This->lpLcl->lpGbl->dwNumFourCC, *lpNumCodes));
- }
- else
- {
- *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
- }
- }
-
- LeaveCriticalSection(&ddcs);
+
+ // EnterCriticalSection(&ddcs);
+
+ _SEH_TRY
+ {
+ if(IsBadWritePtr(lpNumCodes,sizeof(LPDWORD)))
+ {
+ retVal = DDERR_INVALIDPARAMS;
+ }
+ else
+ {
+ if(!IsBadWritePtr(lpCodes,sizeof(LPDWORD)))
+ {
+ memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)*
min(This->lpLcl->lpGbl->dwNumFourCC, *lpNumCodes));
+ }
+ else
+ {
+ *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
+ }
+ }
+ }
+ _SEH_HANDLE
+ {
+ }
+ _SEH_END;
+
+ //LeaveCriticalSection(&ddcs);
return retVal;
}
Modified: trunk/reactos/dll/directx/ddraw/ddraw.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/ddraw.rb…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/ddraw.rbuild (original)
+++ trunk/reactos/dll/directx/ddraw/ddraw.rbuild Tue May 22 14:46:17 2007
@@ -16,6 +16,7 @@
<library>user32</library>
<library>advapi32</library>
<library>msvcrt</library>
+ <library>pseh</library>
<file>ddraw.rc</file>
<file>main.c</file>