@@ -5577,8 +5577,8 @@ NtUserCalcMenuBar(
55775577
55785578 if (!(Window = UserGetWindowObject (hwnd )))
55795579 {
5580- EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
55815580 UserLeave ();
5581+ EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
55825582 return 0 ;
55835583 }
55845584
@@ -5599,7 +5599,6 @@ NtUserCalcMenuBar(
55995599 UserReleaseDC ( 0 , hdc , FALSE );
56005600
56015601 UserLeave ();
5602-
56035602 return ret ;
56045603}
56055604
@@ -5624,8 +5623,8 @@ NtUserCheckMenuItem(
56245623 Ret = IntCheckMenuItem (Menu , uIDCheckItem , uCheck );
56255624 }
56265625
5627- TRACE ("Leave NtUserCheckMenuItem, ret=%lu\n" , Ret );
56285626 UserLeave ();
5627+ TRACE ("Leave NtUserCheckMenuItem, ret=%lu\n" , Ret );
56295628 return Ret ;
56305629}
56315630
@@ -5650,8 +5649,8 @@ NtUserDeleteMenu(
56505649 Ret = IntRemoveMenuItem (Menu , uPosition , uFlags , TRUE);
56515650 }
56525651
5653- TRACE ("Leave NtUserDeleteMenu, ret=%i\n" , Ret );
56545652 UserLeave ();
5653+ TRACE ("Leave NtUserDeleteMenu, ret=%i\n" , Ret );
56555654 return Ret ;
56565655}
56575656
@@ -5705,8 +5704,8 @@ NtUserGetSystemMenu(HWND hWnd, BOOL bRevert)
57055704 Ret = UserHMGetHandle (Menu );
57065705
57075706Exit :
5708- TRACE ("Leave NtUserGetSystemMenu, ret=%p\n" , Ret );
57095707 UserLeave ();
5708+ TRACE ("Leave NtUserGetSystemMenu, ret=%p\n" , Ret );
57105709 return Ret ;
57115710}
57125711
@@ -5748,8 +5747,8 @@ NtUserSetSystemMenu(HWND hWnd, HMENU hMenu)
57485747 EngSetLastError (ERROR_INVALID_MENU_HANDLE );
57495748
57505749Exit :
5751- TRACE ("Leave NtUserSetSystemMenu, ret=%i\n" , Result );
57525750 UserLeave ();
5751+ TRACE ("Leave NtUserSetSystemMenu, ret=%i\n" , Result );
57535752 return Result ;
57545753}
57555754
@@ -5763,56 +5762,55 @@ NtUserGetTitleBarInfo(
57635762{
57645763 PWND WindowObject ;
57655764 TITLEBARINFO bartitleinfo ;
5766- BOOLEAN retValue = TRUE ;
5765+ BOOLEAN retValue = FALSE ;
57675766
57685767 TRACE ("Enter NtUserGetTitleBarInfo\n" );
57695768 UserEnterExclusive ();
57705769
5771- /* Vaildate the windows handle */
5770+ /* Validate the window handle */
57725771 if (!(WindowObject = UserGetWindowObject (hwnd )))
57735772 {
57745773 EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
5775- retValue = FALSE ;
5774+ goto Exit ;
57765775 }
57775776
5777+ /* Copy user mode buffer to local buffer */
57785778 _SEH2_TRY
57795779 {
5780- /* Copy our usermode buffer bti to local buffer bartitleinfo */
57815780 ProbeForRead (bti , sizeof (TITLEBARINFO ), 1 );
57825781 RtlCopyMemory (& bartitleinfo , bti , sizeof (TITLEBARINFO ));
57835782 }
57845783 _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER )
57855784 {
5786- /* Fail copy the data */
57875785 EngSetLastError (ERROR_INVALID_PARAMETER );
5788- retValue = FALSE ;
5786+ _SEH2_YIELD ( goto Exit ) ;
57895787 }
57905788 _SEH2_END
57915789
57925790 /* Get the tile bar info */
5793- if (retValue )
5791+ retValue = intGetTitleBarInfo (WindowObject , & bartitleinfo );
5792+ if (!retValue )
57945793 {
5795- retValue = intGetTitleBarInfo (WindowObject , & bartitleinfo );
5796- if (retValue )
5797- {
5798- _SEH2_TRY
5799- {
5800- /* Copy our buffer to user mode buffer bti */
5801- ProbeForWrite (bti , sizeof (TITLEBARINFO ), 1 );
5802- RtlCopyMemory (bti , & bartitleinfo , sizeof (TITLEBARINFO ));
5803- }
5804- _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER )
5805- {
5806- /* Fail copy the data */
5807- EngSetLastError (ERROR_INVALID_PARAMETER );
5808- retValue = FALSE;
5809- }
5810- _SEH2_END
5811- }
5794+ // intGetTitleBarInfo() set LastError.
5795+ goto Exit ;
58125796 }
58135797
5814- TRACE ("Leave NtUserGetTitleBarInfo, ret=%u\n" , retValue );
5798+ /* Copy local buffer back to user mode buffer */
5799+ _SEH2_TRY
5800+ {
5801+ ProbeForWrite (bti , sizeof (TITLEBARINFO ), 1 );
5802+ RtlCopyMemory (bti , & bartitleinfo , sizeof (TITLEBARINFO ));
5803+ }
5804+ _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER )
5805+ {
5806+ EngSetLastError (ERROR_INVALID_PARAMETER );
5807+ retValue = FALSE;
5808+ }
5809+ _SEH2_END ;
5810+
5811+ Exit :
58155812 UserLeave ();
5813+ TRACE ("Leave NtUserGetTitleBarInfo, ret=%u\n" , retValue );
58165814 return retValue ;
58175815}
58185816
@@ -5862,8 +5860,8 @@ NtUserDestroyMenu(
58625860 Ret = IntDestroyMenuObject (Menu , TRUE);
58635861
58645862Exit :
5865- TRACE ("Leave NtUserDestroyMenu, ret=%i\n" , Ret );
58665863 UserLeave ();
5864+ TRACE ("Leave NtUserDestroyMenu, ret=%i\n" , Ret );
58675865 return Ret ;
58685866}
58695867
@@ -5888,8 +5886,8 @@ NtUserEnableMenuItem(
58885886 Ret = IntEnableMenuItem (Menu , uIDEnableItem , uEnable );
58895887 }
58905888
5891- TRACE ("Leave NtUserEnableMenuItem, ret=%u\n" , Ret );
58925889 UserLeave ();
5890+ TRACE ("Leave NtUserEnableMenuItem, ret=%u\n" , Ret );
58935891 return Ret ;
58945892}
58955893
@@ -6078,8 +6076,8 @@ NtUserGetMenuBarInfo(
60786076
60796077Cleanup :
60806078 if (pWnd ) UserDerefObjectCo (pWnd );
6081- TRACE ("Leave NtUserGetMenuBarInfo, ret=%i\n" , Ret );
60826079 UserLeave ();
6080+ TRACE ("Leave NtUserGetMenuBarInfo, ret=%i\n" , Ret );
60836081 return Ret ;
60846082}
60856083
@@ -6114,8 +6112,8 @@ NtUserGetMenuIndex(
61146112 }
61156113
61166114Exit :
6117- TRACE ("Leave NtUserGetMenuIndex, ret=%u\n" , Ret );
61186115 UserLeave ();
6116+ TRACE ("Leave NtUserGetMenuIndex, ret=%u\n" , Ret );
61196117 return Ret ;
61206118}
61216119
@@ -6200,8 +6198,8 @@ NtUserGetMenuItemRect(
62006198 Ret = TRUE;
62016199
62026200Exit :
6203- TRACE ("Leave NtUserGetMenuItemRect, ret=%i\n" , Ret );
62046201 UserLeave ();
6202+ TRACE ("Leave NtUserGetMenuItemRect, ret=%i\n" , Ret );
62056203 return Ret ;
62066204}
62076205
@@ -6237,8 +6235,8 @@ NtUserHiliteMenuItem(
62376235 Ret = IntHiliteMenuItem (Window , Menu , uItemHilite , uHilite );
62386236
62396237Exit :
6240- TRACE ("Leave NtUserHiliteMenuItem, ret=%i\n" , Ret );
62416238 UserLeave ();
6239+ TRACE ("Leave NtUserHiliteMenuItem, ret=%i\n" , Ret );
62426240 return Ret ;
62436241}
62446242
@@ -6295,8 +6293,8 @@ NtUserDrawMenuBarTemp(
62956293 Ret = IntDrawMenuBarTemp (Window , hDC , & Rect , Menu , hFont );
62966294
62976295Exit :
6298- ERR ("Leave NtUserDrawMenuBarTemp, ret=%lu\n" , Ret );
62996296 UserLeave ();
6297+ ERR ("Leave NtUserDrawMenuBarTemp, ret=%lu\n" , Ret );
63006298 return Ret ;
63016299}
63026300
@@ -6353,8 +6351,8 @@ NtUserMenuItemFromPoint(
63536351 Ret = (mi ? i : NO_SELECTED_ITEM );
63546352
63556353Exit :
6356- TRACE ("Leave NtUserMenuItemFromPoint, ret=%i\n" , Ret );
63576354 UserLeave ();
6355+ TRACE ("Leave NtUserMenuItemFromPoint, ret=%i\n" , Ret );
63586356 return Ret ;
63596357}
63606358
@@ -6377,8 +6375,8 @@ NtUserPaintMenuBar(
63776375
63786376 if (!(Window = UserGetWindowObject (hWnd )))
63796377 {
6380- EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
63816378 UserLeave ();
6379+ EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
63826380 return 0 ;
63836381 }
63846382
@@ -6390,7 +6388,6 @@ NtUserPaintMenuBar(
63906388 ret = MENU_DrawMenuBar (hDC , & Rect , Window , FALSE);
63916389
63926390 UserLeave ();
6393-
63946391 return ret ;
63956392}
63966393
@@ -6415,8 +6412,8 @@ NtUserRemoveMenu(
64156412 Ret = IntRemoveMenuItem (Menu , uPosition , uFlags , FALSE);
64166413 }
64176414
6418- TRACE ("Leave NtUserRemoveMenu, ret=%i\n" , Ret );
64196415 UserLeave ();
6416+ TRACE ("Leave NtUserRemoveMenu, ret=%i\n" , Ret );
64206417 return Ret ;
64216418}
64226419
@@ -6458,8 +6455,8 @@ NtUserSetMenu(
64586455 Ret = TRUE;
64596456
64606457Exit :
6461- TRACE ("Leave NtUserSetMenu, ret=%i\n" , Ret );
64626458 UserLeave ();
6459+ TRACE ("Leave NtUserSetMenu, ret=%i\n" , Ret );
64636460 return Ret ;
64646461}
64656462
@@ -6483,8 +6480,8 @@ NtUserSetMenuContextHelpId(
64836480 Ret = IntSetMenuContextHelpId (Menu , dwContextHelpId );
64846481 }
64856482
6486- TRACE ("Leave NtUserSetMenuContextHelpId, ret=%i\n" , Ret );
64876483 UserLeave ();
6484+ TRACE ("Leave NtUserSetMenuContextHelpId, ret=%i\n" , Ret );
64886485 return Ret ;
64896486}
64906487
@@ -6509,8 +6506,8 @@ NtUserSetMenuDefaultItem(
65096506 Ret = UserSetMenuDefaultItem (Menu , uItem , fByPos );
65106507 }
65116508
6512- TRACE ("Leave NtUserSetMenuDefaultItem, ret=%i\n" , Ret );
65136509 UserLeave ();
6510+ TRACE ("Leave NtUserSetMenuDefaultItem, ret=%i\n" , Ret );
65146511 return Ret ;
65156512}
65166513
@@ -6533,8 +6530,8 @@ NtUserSetMenuFlagRtoL(
65336530 Ret = IntSetMenuFlagRtoL (Menu );
65346531 }
65356532
6536- TRACE ("Leave NtUserSetMenuFlagRtoL, ret=%i\n" , Ret );
65376533 UserLeave ();
6534+ TRACE ("Leave NtUserSetMenuFlagRtoL, ret=%i\n" , Ret );
65386535 return Ret ;
65396536}
65406537
@@ -6558,8 +6555,8 @@ NtUserThunkedMenuInfo(
65586555 Ret = UserMenuInfo (Menu , (PROSMENUINFO )lpcmi , TRUE);
65596556 }
65606557
6561- TRACE ("Leave NtUserThunkedMenuInfo, ret=%i\n" , Ret );
65626558 UserLeave ();
6559+ TRACE ("Leave NtUserThunkedMenuInfo, ret=%i\n" , Ret );
65636560 return Ret ;
65646561}
65656562
@@ -6577,16 +6574,12 @@ NtUserThunkedMenuItemInfo(
65776574{
65786575 PMENU Menu ;
65796576 NTSTATUS Status ;
6580- UNICODE_STRING lstrCaption ;
6577+ UNICODE_STRING lstrCaption = { 0 } ;
65816578 BOOL Ret = FALSE;
65826579
65836580 TRACE ("Enter NtUserThunkedMenuItemInfo\n" );
6584- UserEnterExclusive ();
65856581
6586- /* lpszCaption may be NULL, check for it and call RtlInitUnicodeString()
6587- if bInsert == TRUE call UserInsertMenuItem() else UserSetMenuItemInfo() */
6588-
6589- RtlInitEmptyUnicodeString (& lstrCaption , NULL , 0 );
6582+ UserEnterExclusive ();
65906583
65916584 if (!(Menu = UserGetMenuObject (hMenu )))
65926585 {
@@ -6611,19 +6604,21 @@ NtUserThunkedMenuItemInfo(
66116604 if (bInsert )
66126605 {
66136606 Ret = UserInsertMenuItem (Menu , uItem , fByPosition , lpmii , & lstrCaption );
6614- goto Cleanup ;
66156607 }
6616-
6617- Ret = UserMenuItemInfo (Menu , uItem , fByPosition , (PROSMENUITEMINFO )lpmii , TRUE, & lstrCaption );
6608+ else
6609+ {
6610+ Ret = UserMenuItemInfo (Menu , uItem , fByPosition , (PROSMENUITEMINFO )lpmii , TRUE, & lstrCaption );
6611+ }
66186612
66196613Cleanup :
6614+ UserLeave ();
6615+
66206616 if (lstrCaption .Buffer )
66216617 {
66226618 ReleaseCapturedUnicodeString (& lstrCaption , UserMode );
66236619 }
66246620
66256621 TRACE ("Leave NtUserThunkedMenuItemInfo, ret=%i\n" , Ret );
6626- UserLeave ();
66276622 return Ret ;
66286623}
66296624
@@ -6651,15 +6646,16 @@ NtUserTrackPopupMenuEx(
66516646 USER_REFERENCE_ENTRY WndRef , MenuRef ;
66526647
66536648 TRACE ("Enter NtUserTrackPopupMenuEx\n" );
6654- UserEnterExclusive ();
66556649
66566650 if (fuFlags & ~VALID_TPM_FLAGS )
66576651 {
66586652 ERR ("TPME : Invalid flags 0x%X (valid flags are 0x%X)\n" , fuFlags , VALID_TPM_FLAGS );
66596653 EngSetLastError (ERROR_INVALID_FLAGS );
6660- goto Exit ;
6654+ goto Exit0 ;
66616655 }
66626656
6657+ UserEnterExclusive ();
6658+
66636659 /* Parameter check */
66646660 if (!(menu = UserGetMenuObject ( hMenu )))
66656661 {
@@ -6695,7 +6691,9 @@ NtUserTrackPopupMenuEx(
66956691 UserDerefObjectCo (pWnd );
66966692
66976693Exit :
6698- TRACE ("Leave NtUserTrackPopupMenuEx, ret=%i\n" ,Ret );
66996694 UserLeave ();
6695+
6696+ Exit0 :
6697+ TRACE ("Leave NtUserTrackPopupMenuEx, ret=%i\n" , Ret );
67006698 return Ret ;
67016699}
0 commit comments