From b07e61e478f5c23bc515fc1a589200643b213931 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 14 Apr 2014 05:43:02 +0000 Subject: [PATCH] [User32] - Patch by Victor Martinez Calvo : Fix Invalid parameter handling in GetMenuInfo and SetLastError. Modified handle validation by me. See CORE-8064. - Moved code and added a non-client create function ID. svn path=/trunk/; revision=62746 --- reactos/win32ss/user/user32/windows/menu.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/reactos/win32ss/user/user32/windows/menu.c b/reactos/win32ss/user/user32/windows/menu.c index 2446ae3ba64..c051f69dd44 100644 --- a/reactos/win32ss/user/user32/windows/menu.c +++ b/reactos/win32ss/user/user32/windows/menu.c @@ -1147,9 +1147,8 @@ static void FASTCALL MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND Wnd if ( (Wnd->style & WS_MINIMIZE)) { UserGetInsideRectNC(Wnd, &rect); - UserDrawSysMenuButton(hWnd, hdc, &rect, - lpitem->fState & (MF_HILITE | MF_MOUSESELECT)); - } + UserDrawSysMenuButton(hWnd, hdc, &rect, lpitem->fState & (MF_HILITE | MF_MOUSESELECT)); + } return; } @@ -1816,6 +1815,10 @@ LRESULT WINAPI PopupMenuWndProcA(HWND Wnd, UINT Message, WPARAM wParam, LPARAM l { if (!pWnd->fnid) { + if (Message != WM_NCCREATE) + { + return DefWindowProcA(Wnd, Message, wParam, lParam); + } NtUserSetWindowFNID(Wnd, FNID_MENU); } else @@ -4264,9 +4267,16 @@ GetMenuInfo(HMENU hmenu, { ROSMENUINFO mi; BOOL res = FALSE; + PVOID pMenu; - if(!lpcmi || (lpcmi->cbSize != sizeof(MENUINFO))) - return FALSE; + if (!(pMenu = ValidateHandle(hmenu, TYPE_MENU))) + return FALSE; + + if (!lpcmi || (lpcmi->cbSize != sizeof(MENUINFO))) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } RtlZeroMemory(&mi, sizeof(MENUINFO)); mi.cbSize = sizeof(MENUINFO); -- 2.17.1