mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 00:50:23 +00:00
adding more seh protection to the code
svn path=/trunk/; revision=27036
This commit is contained in:
parent
958b55cf2c
commit
8d0428bfbd
1 changed files with 144 additions and 117 deletions
|
@ -10,10 +10,12 @@
|
||||||
|
|
||||||
#include "rosdraw.h"
|
#include "rosdraw.h"
|
||||||
|
|
||||||
|
/* PSEH for SEH Support */
|
||||||
|
#include <pseh/pseh.h>
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel)
|
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
|
* Code from wine, this functions have been cut and paste from wine 0.9.35
|
||||||
|
@ -21,27 +23,37 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
|
||||||
* msdn document struct and flags
|
* msdn document struct and flags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
HRESULT retVal = DD_OK;
|
||||||
HWND window;
|
HWND window;
|
||||||
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||||
|
|
||||||
|
DX_WINDBG_trace();
|
||||||
|
|
||||||
|
_SEH_TRY
|
||||||
|
{
|
||||||
/* Get the old window */
|
/* Get the old window */
|
||||||
window = (HWND) This->lpLcl->hWnd;
|
window = (HWND) This->lpLcl->hWnd;
|
||||||
#if 0 // this check is totally invalid if you ask me - mbosma
|
#if 0 // this check is totally invalid if you ask me - mbosma
|
||||||
if(!window)
|
if(!window)
|
||||||
{
|
{
|
||||||
return DDERR_NOHWND;
|
retVal = DDERR_NOHWND;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(hwnd && !IsWindow(hwnd))
|
if(hwnd && !IsWindow(hwnd))
|
||||||
return DDERR_INVALIDPARAMS;
|
{
|
||||||
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
_SEH_LEAVE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tests suggest that we need one of them: */
|
/* Tests suggest that we need one of them: */
|
||||||
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
|
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
|
||||||
DDSCL_NORMAL |
|
DDSCL_NORMAL |
|
||||||
DDSCL_EXCLUSIVE )))
|
DDSCL_EXCLUSIVE )))
|
||||||
{
|
{
|
||||||
return DDERR_INVALIDPARAMS;
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle those levels first which set various hwnds */
|
/* Handle those levels first which set various hwnds */
|
||||||
|
@ -58,16 +70,19 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
|
||||||
DDSCL_EXCLUSIVE |
|
DDSCL_EXCLUSIVE |
|
||||||
DDSCL_FULLSCREEN ) )
|
DDSCL_FULLSCREEN ) )
|
||||||
{
|
{
|
||||||
return DDERR_INVALIDPARAMS;
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(This->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED)
|
else if(This->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED)
|
||||||
{
|
{
|
||||||
return DDERR_HWNDALREADYSET;
|
retVal = DDERR_HWNDALREADYSET;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
else if( (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) && window)
|
else if( (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) && window)
|
||||||
{
|
{
|
||||||
return DDERR_HWNDALREADYSET;
|
retVal = DDERR_HWNDALREADYSET;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd;
|
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 */
|
/* Can't coexist with fullscreen or exclusive */
|
||||||
if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
|
if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
|
||||||
return DDERR_INVALIDPARAMS;
|
{
|
||||||
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
_SEH_LEAVE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Switching from fullscreen? */
|
/* Switching from fullscreen? */
|
||||||
if(This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN)
|
if(This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN)
|
||||||
|
@ -118,7 +135,10 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
|
||||||
{
|
{
|
||||||
/* Needs DDSCL_EXCLUSIVE */
|
/* Needs DDSCL_EXCLUSIVE */
|
||||||
if(!(cooplevel & DDSCL_EXCLUSIVE) )
|
if(!(cooplevel & DDSCL_EXCLUSIVE) )
|
||||||
return DDERR_INVALIDPARAMS;
|
{
|
||||||
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
_SEH_LEAVE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Switch from normal to full screen mode? */
|
/* Switch from normal to full screen mode? */
|
||||||
if (!(This->lpLcl->dwLocalFlags & DDRAWILCL_HASEXCLUSIVEMODE))
|
if (!(This->lpLcl->dwLocalFlags & DDRAWILCL_HASEXCLUSIVEMODE))
|
||||||
|
@ -140,7 +160,8 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
|
||||||
}
|
}
|
||||||
else if(cooplevel & DDSCL_EXCLUSIVE)
|
else if(cooplevel & DDSCL_EXCLUSIVE)
|
||||||
{
|
{
|
||||||
return DDERR_INVALIDPARAMS;
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
|
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
|
||||||
|
@ -174,6 +195,12 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl
|
||||||
/* FIXME GL
|
/* FIXME GL
|
||||||
* This->cooperative_level |= cooplevel;
|
* This->cooperative_level |= cooplevel;
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
return DD_OK;
|
_SEH_HANDLE
|
||||||
|
{
|
||||||
|
}
|
||||||
|
_SEH_END;
|
||||||
|
|
||||||
|
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue