@@ -5577,8 +5577,8 @@ NtUserCalcMenuBar(
5577
5577
5578
5578
if (!(Window = UserGetWindowObject (hwnd )))
5579
5579
{
5580
- EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
5581
5580
UserLeave ();
5581
+ EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
5582
5582
return 0 ;
5583
5583
}
5584
5584
@@ -5599,7 +5599,6 @@ NtUserCalcMenuBar(
5599
5599
UserReleaseDC ( 0 , hdc , FALSE );
5600
5600
5601
5601
UserLeave ();
5602
-
5603
5602
return ret ;
5604
5603
}
5605
5604
@@ -5624,8 +5623,8 @@ NtUserCheckMenuItem(
5624
5623
Ret = IntCheckMenuItem (Menu , uIDCheckItem , uCheck );
5625
5624
}
5626
5625
5627
- TRACE ("Leave NtUserCheckMenuItem, ret=%lu\n" , Ret );
5628
5626
UserLeave ();
5627
+ TRACE ("Leave NtUserCheckMenuItem, ret=%lu\n" , Ret );
5629
5628
return Ret ;
5630
5629
}
5631
5630
@@ -5650,8 +5649,8 @@ NtUserDeleteMenu(
5650
5649
Ret = IntRemoveMenuItem (Menu , uPosition , uFlags , TRUE);
5651
5650
}
5652
5651
5653
- TRACE ("Leave NtUserDeleteMenu, ret=%i\n" , Ret );
5654
5652
UserLeave ();
5653
+ TRACE ("Leave NtUserDeleteMenu, ret=%i\n" , Ret );
5655
5654
return Ret ;
5656
5655
}
5657
5656
@@ -5705,8 +5704,8 @@ NtUserGetSystemMenu(HWND hWnd, BOOL bRevert)
5705
5704
Ret = UserHMGetHandle (Menu );
5706
5705
5707
5706
Exit :
5708
- TRACE ("Leave NtUserGetSystemMenu, ret=%p\n" , Ret );
5709
5707
UserLeave ();
5708
+ TRACE ("Leave NtUserGetSystemMenu, ret=%p\n" , Ret );
5710
5709
return Ret ;
5711
5710
}
5712
5711
@@ -5748,8 +5747,8 @@ NtUserSetSystemMenu(HWND hWnd, HMENU hMenu)
5748
5747
EngSetLastError (ERROR_INVALID_MENU_HANDLE );
5749
5748
5750
5749
Exit :
5751
- TRACE ("Leave NtUserSetSystemMenu, ret=%i\n" , Result );
5752
5750
UserLeave ();
5751
+ TRACE ("Leave NtUserSetSystemMenu, ret=%i\n" , Result );
5753
5752
return Result ;
5754
5753
}
5755
5754
@@ -5763,56 +5762,55 @@ NtUserGetTitleBarInfo(
5763
5762
{
5764
5763
PWND WindowObject ;
5765
5764
TITLEBARINFO bartitleinfo ;
5766
- BOOLEAN retValue = TRUE ;
5765
+ BOOLEAN retValue = FALSE ;
5767
5766
5768
5767
TRACE ("Enter NtUserGetTitleBarInfo\n" );
5769
5768
UserEnterExclusive ();
5770
5769
5771
- /* Vaildate the windows handle */
5770
+ /* Validate the window handle */
5772
5771
if (!(WindowObject = UserGetWindowObject (hwnd )))
5773
5772
{
5774
5773
EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
5775
- retValue = FALSE ;
5774
+ goto Exit ;
5776
5775
}
5777
5776
5777
+ /* Copy user mode buffer to local buffer */
5778
5778
_SEH2_TRY
5779
5779
{
5780
- /* Copy our usermode buffer bti to local buffer bartitleinfo */
5781
5780
ProbeForRead (bti , sizeof (TITLEBARINFO ), 1 );
5782
5781
RtlCopyMemory (& bartitleinfo , bti , sizeof (TITLEBARINFO ));
5783
5782
}
5784
5783
_SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER )
5785
5784
{
5786
- /* Fail copy the data */
5787
5785
EngSetLastError (ERROR_INVALID_PARAMETER );
5788
- retValue = FALSE ;
5786
+ _SEH2_YIELD ( goto Exit ) ;
5789
5787
}
5790
5788
_SEH2_END
5791
5789
5792
5790
/* Get the tile bar info */
5793
- if (retValue )
5791
+ retValue = intGetTitleBarInfo (WindowObject , & bartitleinfo );
5792
+ if (!retValue )
5794
5793
{
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 ;
5812
5796
}
5813
5797
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 :
5815
5812
UserLeave ();
5813
+ TRACE ("Leave NtUserGetTitleBarInfo, ret=%u\n" , retValue );
5816
5814
return retValue ;
5817
5815
}
5818
5816
@@ -5862,8 +5860,8 @@ NtUserDestroyMenu(
5862
5860
Ret = IntDestroyMenuObject (Menu , TRUE);
5863
5861
5864
5862
Exit :
5865
- TRACE ("Leave NtUserDestroyMenu, ret=%i\n" , Ret );
5866
5863
UserLeave ();
5864
+ TRACE ("Leave NtUserDestroyMenu, ret=%i\n" , Ret );
5867
5865
return Ret ;
5868
5866
}
5869
5867
@@ -5888,8 +5886,8 @@ NtUserEnableMenuItem(
5888
5886
Ret = IntEnableMenuItem (Menu , uIDEnableItem , uEnable );
5889
5887
}
5890
5888
5891
- TRACE ("Leave NtUserEnableMenuItem, ret=%u\n" , Ret );
5892
5889
UserLeave ();
5890
+ TRACE ("Leave NtUserEnableMenuItem, ret=%u\n" , Ret );
5893
5891
return Ret ;
5894
5892
}
5895
5893
@@ -6078,8 +6076,8 @@ NtUserGetMenuBarInfo(
6078
6076
6079
6077
Cleanup :
6080
6078
if (pWnd ) UserDerefObjectCo (pWnd );
6081
- TRACE ("Leave NtUserGetMenuBarInfo, ret=%i\n" , Ret );
6082
6079
UserLeave ();
6080
+ TRACE ("Leave NtUserGetMenuBarInfo, ret=%i\n" , Ret );
6083
6081
return Ret ;
6084
6082
}
6085
6083
@@ -6114,8 +6112,8 @@ NtUserGetMenuIndex(
6114
6112
}
6115
6113
6116
6114
Exit :
6117
- TRACE ("Leave NtUserGetMenuIndex, ret=%u\n" , Ret );
6118
6115
UserLeave ();
6116
+ TRACE ("Leave NtUserGetMenuIndex, ret=%u\n" , Ret );
6119
6117
return Ret ;
6120
6118
}
6121
6119
@@ -6200,8 +6198,8 @@ NtUserGetMenuItemRect(
6200
6198
Ret = TRUE;
6201
6199
6202
6200
Exit :
6203
- TRACE ("Leave NtUserGetMenuItemRect, ret=%i\n" , Ret );
6204
6201
UserLeave ();
6202
+ TRACE ("Leave NtUserGetMenuItemRect, ret=%i\n" , Ret );
6205
6203
return Ret ;
6206
6204
}
6207
6205
@@ -6237,8 +6235,8 @@ NtUserHiliteMenuItem(
6237
6235
Ret = IntHiliteMenuItem (Window , Menu , uItemHilite , uHilite );
6238
6236
6239
6237
Exit :
6240
- TRACE ("Leave NtUserHiliteMenuItem, ret=%i\n" , Ret );
6241
6238
UserLeave ();
6239
+ TRACE ("Leave NtUserHiliteMenuItem, ret=%i\n" , Ret );
6242
6240
return Ret ;
6243
6241
}
6244
6242
@@ -6295,8 +6293,8 @@ NtUserDrawMenuBarTemp(
6295
6293
Ret = IntDrawMenuBarTemp (Window , hDC , & Rect , Menu , hFont );
6296
6294
6297
6295
Exit :
6298
- ERR ("Leave NtUserDrawMenuBarTemp, ret=%lu\n" , Ret );
6299
6296
UserLeave ();
6297
+ ERR ("Leave NtUserDrawMenuBarTemp, ret=%lu\n" , Ret );
6300
6298
return Ret ;
6301
6299
}
6302
6300
@@ -6353,8 +6351,8 @@ NtUserMenuItemFromPoint(
6353
6351
Ret = (mi ? i : NO_SELECTED_ITEM );
6354
6352
6355
6353
Exit :
6356
- TRACE ("Leave NtUserMenuItemFromPoint, ret=%i\n" , Ret );
6357
6354
UserLeave ();
6355
+ TRACE ("Leave NtUserMenuItemFromPoint, ret=%i\n" , Ret );
6358
6356
return Ret ;
6359
6357
}
6360
6358
@@ -6377,8 +6375,8 @@ NtUserPaintMenuBar(
6377
6375
6378
6376
if (!(Window = UserGetWindowObject (hWnd )))
6379
6377
{
6380
- EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
6381
6378
UserLeave ();
6379
+ EngSetLastError (ERROR_INVALID_WINDOW_HANDLE );
6382
6380
return 0 ;
6383
6381
}
6384
6382
@@ -6390,7 +6388,6 @@ NtUserPaintMenuBar(
6390
6388
ret = MENU_DrawMenuBar (hDC , & Rect , Window , FALSE);
6391
6389
6392
6390
UserLeave ();
6393
-
6394
6391
return ret ;
6395
6392
}
6396
6393
@@ -6415,8 +6412,8 @@ NtUserRemoveMenu(
6415
6412
Ret = IntRemoveMenuItem (Menu , uPosition , uFlags , FALSE);
6416
6413
}
6417
6414
6418
- TRACE ("Leave NtUserRemoveMenu, ret=%i\n" , Ret );
6419
6415
UserLeave ();
6416
+ TRACE ("Leave NtUserRemoveMenu, ret=%i\n" , Ret );
6420
6417
return Ret ;
6421
6418
}
6422
6419
@@ -6458,8 +6455,8 @@ NtUserSetMenu(
6458
6455
Ret = TRUE;
6459
6456
6460
6457
Exit :
6461
- TRACE ("Leave NtUserSetMenu, ret=%i\n" , Ret );
6462
6458
UserLeave ();
6459
+ TRACE ("Leave NtUserSetMenu, ret=%i\n" , Ret );
6463
6460
return Ret ;
6464
6461
}
6465
6462
@@ -6483,8 +6480,8 @@ NtUserSetMenuContextHelpId(
6483
6480
Ret = IntSetMenuContextHelpId (Menu , dwContextHelpId );
6484
6481
}
6485
6482
6486
- TRACE ("Leave NtUserSetMenuContextHelpId, ret=%i\n" , Ret );
6487
6483
UserLeave ();
6484
+ TRACE ("Leave NtUserSetMenuContextHelpId, ret=%i\n" , Ret );
6488
6485
return Ret ;
6489
6486
}
6490
6487
@@ -6509,8 +6506,8 @@ NtUserSetMenuDefaultItem(
6509
6506
Ret = UserSetMenuDefaultItem (Menu , uItem , fByPos );
6510
6507
}
6511
6508
6512
- TRACE ("Leave NtUserSetMenuDefaultItem, ret=%i\n" , Ret );
6513
6509
UserLeave ();
6510
+ TRACE ("Leave NtUserSetMenuDefaultItem, ret=%i\n" , Ret );
6514
6511
return Ret ;
6515
6512
}
6516
6513
@@ -6533,8 +6530,8 @@ NtUserSetMenuFlagRtoL(
6533
6530
Ret = IntSetMenuFlagRtoL (Menu );
6534
6531
}
6535
6532
6536
- TRACE ("Leave NtUserSetMenuFlagRtoL, ret=%i\n" , Ret );
6537
6533
UserLeave ();
6534
+ TRACE ("Leave NtUserSetMenuFlagRtoL, ret=%i\n" , Ret );
6538
6535
return Ret ;
6539
6536
}
6540
6537
@@ -6558,8 +6555,8 @@ NtUserThunkedMenuInfo(
6558
6555
Ret = UserMenuInfo (Menu , (PROSMENUINFO )lpcmi , TRUE);
6559
6556
}
6560
6557
6561
- TRACE ("Leave NtUserThunkedMenuInfo, ret=%i\n" , Ret );
6562
6558
UserLeave ();
6559
+ TRACE ("Leave NtUserThunkedMenuInfo, ret=%i\n" , Ret );
6563
6560
return Ret ;
6564
6561
}
6565
6562
@@ -6577,16 +6574,12 @@ NtUserThunkedMenuItemInfo(
6577
6574
{
6578
6575
PMENU Menu ;
6579
6576
NTSTATUS Status ;
6580
- UNICODE_STRING lstrCaption ;
6577
+ UNICODE_STRING lstrCaption = { 0 } ;
6581
6578
BOOL Ret = FALSE;
6582
6579
6583
6580
TRACE ("Enter NtUserThunkedMenuItemInfo\n" );
6584
- UserEnterExclusive ();
6585
6581
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 ();
6590
6583
6591
6584
if (!(Menu = UserGetMenuObject (hMenu )))
6592
6585
{
@@ -6611,19 +6604,21 @@ NtUserThunkedMenuItemInfo(
6611
6604
if (bInsert )
6612
6605
{
6613
6606
Ret = UserInsertMenuItem (Menu , uItem , fByPosition , lpmii , & lstrCaption );
6614
- goto Cleanup ;
6615
6607
}
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
+ }
6618
6612
6619
6613
Cleanup :
6614
+ UserLeave ();
6615
+
6620
6616
if (lstrCaption .Buffer )
6621
6617
{
6622
6618
ReleaseCapturedUnicodeString (& lstrCaption , UserMode );
6623
6619
}
6624
6620
6625
6621
TRACE ("Leave NtUserThunkedMenuItemInfo, ret=%i\n" , Ret );
6626
- UserLeave ();
6627
6622
return Ret ;
6628
6623
}
6629
6624
@@ -6651,15 +6646,16 @@ NtUserTrackPopupMenuEx(
6651
6646
USER_REFERENCE_ENTRY WndRef , MenuRef ;
6652
6647
6653
6648
TRACE ("Enter NtUserTrackPopupMenuEx\n" );
6654
- UserEnterExclusive ();
6655
6649
6656
6650
if (fuFlags & ~VALID_TPM_FLAGS )
6657
6651
{
6658
6652
ERR ("TPME : Invalid flags 0x%X (valid flags are 0x%X)\n" , fuFlags , VALID_TPM_FLAGS );
6659
6653
EngSetLastError (ERROR_INVALID_FLAGS );
6660
- goto Exit ;
6654
+ goto Exit0 ;
6661
6655
}
6662
6656
6657
+ UserEnterExclusive ();
6658
+
6663
6659
/* Parameter check */
6664
6660
if (!(menu = UserGetMenuObject ( hMenu )))
6665
6661
{
@@ -6695,7 +6691,9 @@ NtUserTrackPopupMenuEx(
6695
6691
UserDerefObjectCo (pWnd );
6696
6692
6697
6693
Exit :
6698
- TRACE ("Leave NtUserTrackPopupMenuEx, ret=%i\n" ,Ret );
6699
6694
UserLeave ();
6695
+
6696
+ Exit0 :
6697
+ TRACE ("Leave NtUserTrackPopupMenuEx, ret=%i\n" , Ret );
6700
6698
return Ret ;
6701
6699
}
0 commit comments