adding more seh protection to the code

svn path=/trunk/; revision=27036
This commit is contained in:
Magnus Olsen 2007-06-07 08:46:33 +00:00
parent 958b55cf2c
commit 8d0428bfbd

View file

@ -10,38 +10,50 @@
#include "rosdraw.h"
/* PSEH for SEH Support */
#include <pseh/pseh.h>
HRESULT WINAPI
Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel)
{
DX_WINDBG_trace();
/*
/*
* Code from wine, this functions have been cut and paste from wine 0.9.35
* and have been modify allot and are still in devloping so it match with
* msdn document struct and flags
*/
HRESULT retVal = DD_OK;
HWND window;
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace();
_SEH_TRY
{
/* Get the old window */
window = (HWND) This->lpLcl->hWnd;
#if 0 // this check is totally invalid if you ask me - mbosma
if(!window)
{
return DDERR_NOHWND;
retVal = DDERR_NOHWND;
_SEH_LEAVE;
}
#endif
if(hwnd && !IsWindow(hwnd))
return DDERR_INVALIDPARAMS;
{
retVal = DDERR_INVALIDPARAMS;
_SEH_LEAVE;
}
/* Tests suggest that we need one of them: */
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
DDSCL_NORMAL |
DDSCL_EXCLUSIVE )))
{
return DDERR_INVALIDPARAMS;
retVal = DDERR_INVALIDPARAMS;
_SEH_LEAVE;
}
/* Handle those levels first which set various hwnds */
@ -58,16 +70,19 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN ) )
{
return DDERR_INVALIDPARAMS;
retVal = DDERR_INVALIDPARAMS;
_SEH_LEAVE;
}
else if(This->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED)
{
return DDERR_HWNDALREADYSET;
retVal = DDERR_HWNDALREADYSET;
_SEH_LEAVE;
}
else if( (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) && window)
{
return DDERR_HWNDALREADYSET;
retVal = DDERR_HWNDALREADYSET;
_SEH_LEAVE;
}
This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd;
@ -86,8 +101,10 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
{
/* Can't coexist with fullscreen or exclusive */
if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
return DDERR_INVALIDPARAMS;
{
retVal = DDERR_INVALIDPARAMS;
_SEH_LEAVE;
}
/* Switching from fullscreen? */
if(This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN)
@ -118,7 +135,10 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
{
/* Needs DDSCL_EXCLUSIVE */
if(!(cooplevel & DDSCL_EXCLUSIVE) )
return DDERR_INVALIDPARAMS;
{
retVal = DDERR_INVALIDPARAMS;
_SEH_LEAVE;
}
/* Switch from normal to full screen mode? */
if (!(This->lpLcl->dwLocalFlags & DDRAWILCL_HASEXCLUSIVEMODE))
@ -140,7 +160,8 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
}
else if(cooplevel & DDSCL_EXCLUSIVE)
{
return DDERR_INVALIDPARAMS;
retVal = DDERR_INVALIDPARAMS;
_SEH_LEAVE;
}
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
@ -174,6 +195,12 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
/* FIXME GL
* This->cooperative_level |= cooplevel;
*/
}
_SEH_HANDLE
{
}
_SEH_END;
return DD_OK;
return retVal;
}