- Fix class window procedure checks, prevents misbehaving applications from calling wrong class procs.
- Fixed callout for static control color brush.

svn path=/trunk/; revision=54249
This commit is contained in:
James Tabor 2011-10-24 14:47:59 +00:00
parent 3581e033d0
commit 519e75748d
7 changed files with 71 additions and 3 deletions

View file

@ -266,6 +266,14 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
{ {
NtUserSetWindowFNID(hWnd, FNID_BUTTON); NtUserSetWindowFNID(hWnd, FNID_BUTTON);
} }
else
{
if (pWnd->fnid != FNID_BUTTON)
{
ERR("Wrong window class for Button!\n");
return 0;
}
}
} }
#endif #endif

View file

@ -1843,6 +1843,14 @@ LRESULT WINAPI ComboWndProc_common( HWND hwnd, UINT message,
{ {
NtUserSetWindowFNID(hwnd, FNID_COMBOBOX); NtUserSetWindowFNID(hwnd, FNID_COMBOBOX);
} }
else
{
if (pWnd->fnid != FNID_COMBOBOX)
{
ERR("Wrong window class for ComboBox!\n");
return 0;
}
}
} }
#endif #endif

View file

@ -4477,6 +4477,14 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
{ {
NtUserSetWindowFNID(hwnd, FNID_EDIT); NtUserSetWindowFNID(hwnd, FNID_EDIT);
} }
else
{
if (pWnd->fnid != FNID_EDIT)
{
ERR("Wrong window class for Edit!\n");
return 0;
}
}
} }
#endif #endif

View file

@ -21,6 +21,7 @@
#include <user32.h> #include <user32.h>
#include <wine/debug.h> #include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(user32);
static BOOL bMultiLineTitle; static BOOL bMultiLineTitle;
static HFONT hIconTitleFont; static HFONT hIconTitleFont;
@ -198,6 +199,14 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
{ {
NtUserSetWindowFNID(hWnd, FNID_ICONTITLE); NtUserSetWindowFNID(hWnd, FNID_ICONTITLE);
} }
else
{
if (pWnd->fnid != FNID_ICONTITLE)
{
ERR("Wrong window class for IconTitle!\n");
return 0;
}
}
} }
#endif #endif

View file

@ -2584,6 +2584,14 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg,
{ {
NtUserSetWindowFNID(hwnd, FNID_LISTBOX); // Could be FNID_COMBOLBOX by class. NtUserSetWindowFNID(hwnd, FNID_LISTBOX); // Could be FNID_COMBOLBOX by class.
} }
else
{
if (pWnd->fnid != FNID_LISTBOX)
{
ERR("Wrong window class for listbox!\n");
return 0;
}
}
} }
#endif #endif

View file

@ -1253,6 +1253,14 @@ ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARA
{ {
NtUserSetWindowFNID(Wnd, FNID_SCROLLBAR); NtUserSetWindowFNID(Wnd, FNID_SCROLLBAR);
} }
else
{
if (pWnd->fnid != FNID_SCROLLBAR)
{
ERR("Wrong window class for Scrollbar!\n");
return 0;
}
}
} }
#endif #endif

View file

@ -324,15 +324,26 @@ static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
} }
} }
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj);
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc) static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
{ {
PWND pwnd;
HBRUSH hBrush; HBRUSH hBrush;
HWND parent = GetParent(hwnd); HWND parent = GetParent(hwnd);
if (!parent) parent = hwnd; if (!parent) parent = hwnd;
// ReactOS
pwnd = ValidateHwnd(parent);
if (pwnd && !TestWindowProcess(pwnd))
{
return (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd);
}
////
hBrush = (HBRUSH) SendMessageW( parent, hBrush = (HBRUSH) SendMessageW( parent,
WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd ); WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
if (!hBrush) /* did the app forget to call DefWindowProc ? */ if (!hBrush || /* did the app forget to call DefWindowProc ? */
!GdiValidateHandle(hBrush)) // ReactOS
{ {
/* FIXME: DefWindowProc should return different colors if a /* FIXME: DefWindowProc should return different colors if a
manifest is present */ manifest is present */
@ -388,6 +399,14 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
{ {
NtUserSetWindowFNID(hwnd, FNID_STATIC); NtUserSetWindowFNID(hwnd, FNID_STATIC);
} }
else
{
if (pWnd->fnid != FNID_STATIC)
{
ERR("Wrong window class for Static!\n");
return 0;
}
}
} }
#endif #endif
@ -505,10 +524,10 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
if (HIWORD(lParam)) if (HIWORD(lParam))
{ {
if(unicode) if(unicode)
lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam ); lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
else else
lResult = DefWindowProcA( hwnd, uMsg, wParam, lParam ); lResult = DefWindowProcA( hwnd, uMsg, wParam, lParam );
STATIC_TryPaintFcn( hwnd, full_style ); STATIC_TryPaintFcn( hwnd, full_style );
} }
} }
break; break;