From 189da79a18bcb7baabcd50de36bf2a6ba818b79d Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 15 Apr 2022 00:42:16 +0200 Subject: [PATCH] win32u: Move NtUserDeleteMenu implementation from user32. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/user32/mdi.c | 6 +++--- dlls/user32/menu.c | 26 +++----------------------- dlls/user32/user32.spec | 2 +- dlls/win32u/menu.c | 19 +++++++++++++++++++ dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 9 +++++++++ include/ntuser.h | 1 + 9 files changed, 39 insertions(+), 28 deletions(-) diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c index b856f054247..1b06143d4cf 100644 --- a/dlls/user32/mdi.c +++ b/dlls/user32/mdi.c @@ -945,11 +945,11 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild ) } /* close */ - DeleteMenu(menu, SC_CLOSE, MF_BYCOMMAND); + NtUserDeleteMenu( menu, SC_CLOSE, MF_BYCOMMAND ); /* restore */ - DeleteMenu(menu, SC_RESTORE, MF_BYCOMMAND); + NtUserDeleteMenu( menu, SC_RESTORE, MF_BYCOMMAND ); /* minimize */ - DeleteMenu(menu, SC_MINIMIZE, MF_BYCOMMAND); + NtUserDeleteMenu( menu, SC_MINIMIZE, MF_BYCOMMAND ); DrawMenuBar(frame); diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 669d838bf61..761718182b5 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -410,7 +410,7 @@ static HMENU MENU_GetSysMenu( HWND hWnd, HMENU hPopupMenu ) if (hPopupMenu) { if (GetClassLongW(hWnd, GCL_STYLE) & CS_NOCLOSE) - DeleteMenu(hPopupMenu, SC_CLOSE, MF_BYCOMMAND); + NtUserDeleteMenu( hPopupMenu, SC_CLOSE, MF_BYCOMMAND ); InsertMenuW( hMenu, -1, MF_SYSMENU | MF_POPUP | MF_BYPOSITION, (UINT_PTR)hPopupMenu, NULL ); @@ -3540,7 +3540,7 @@ BOOL WINAPI ChangeMenuA( HMENU hMenu, UINT pos, LPCSTR data, TRACE("menu=%p pos=%d data=%p id=%08x flags=%08x\n", hMenu, pos, data, id, flags ); if (flags & MF_APPEND) return AppendMenuA( hMenu, flags & ~MF_APPEND, id, data ); - if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE); + if (flags & MF_DELETE) return NtUserDeleteMenu( hMenu, pos, flags & ~MF_DELETE ); if (flags & MF_CHANGE) return ModifyMenuA(hMenu, pos, flags & ~MF_CHANGE, id, data ); if (flags & MF_REMOVE) return NtUserRemoveMenu( hMenu, @@ -3560,7 +3560,7 @@ BOOL WINAPI ChangeMenuW( HMENU hMenu, UINT pos, LPCWSTR data, TRACE("menu=%p pos=%d data=%p id=%08x flags=%08x\n", hMenu, pos, data, id, flags ); if (flags & MF_APPEND) return AppendMenuW( hMenu, flags & ~MF_APPEND, id, data ); - if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE); + if (flags & MF_DELETE) return NtUserDeleteMenu( hMenu, pos, flags & ~MF_DELETE ); if (flags & MF_CHANGE) return ModifyMenuW(hMenu, pos, flags & ~MF_CHANGE, id, data ); if (flags & MF_REMOVE) return NtUserRemoveMenu( hMenu, @@ -3825,26 +3825,6 @@ BOOL WINAPI AppendMenuW( HMENU hMenu, UINT flags, } -/********************************************************************** - * DeleteMenu (USER32.@) - */ -BOOL WINAPI DeleteMenu( HMENU hMenu, UINT id, UINT flags ) -{ - POPUPMENU *menu; - UINT pos; - - if (!(menu = find_menu_item(hMenu, id, flags, &pos))) - return FALSE; - - if (menu->items[pos].fType & MF_POPUP) - NtUserDestroyMenu( menu->items[pos].hSubMenu ); - - NtUserRemoveMenu( menu->obj.handle, pos, flags | MF_BYPOSITION ); - release_menu_ptr(menu); - return TRUE; -} - - /******************************************************************* * ModifyMenuW (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 26f2d1caf45..0697bcfa841 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -153,7 +153,7 @@ @ stdcall DefWindowProcA(long long long long) @ stdcall DefWindowProcW(long long long long) @ stdcall DeferWindowPos(long long long long long long long long) -@ stdcall DeleteMenu(long long long) +@ stdcall DeleteMenu(long long long) NtUserDeleteMenu @ stdcall DeregisterShellHookWindow (long) @ stdcall DestroyAcceleratorTable(long) NtUserDestroyAcceleratorTable @ stdcall DestroyCaret() diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c index d41aba956f2..67abac37037 100644 --- a/dlls/win32u/menu.c +++ b/dlls/win32u/menu.c @@ -976,6 +976,25 @@ BOOL WINAPI NtUserRemoveMenu( HMENU handle, UINT id, UINT flags ) return TRUE; } +/********************************************************************** + * NtUserDeleteMenu (win32u.@) + */ +BOOL WINAPI NtUserDeleteMenu( HMENU handle, UINT id, UINT flags ) +{ + POPUPMENU *menu; + UINT pos; + + if (!(menu = find_menu_item( handle, id, flags, &pos ))) + return FALSE; + + if (menu->items[pos].fType & MF_POPUP) + NtUserDestroyMenu( menu->items[pos].hSubMenu ); + + NtUserRemoveMenu( menu->obj.handle, pos, flags | MF_BYPOSITION ); + release_menu_ptr( menu ); + return TRUE; +} + /********************************************************************** * NtUserSetMenuContextHelpId (win32u.@) */ diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index f585e90bd4a..488056ef439 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -114,6 +114,7 @@ static void * const syscalls[] = NtUserCreateAcceleratorTable, NtUserCreateDesktopEx, NtUserCreateWindowStation, + NtUserDeleteMenu, NtUserDestroyAcceleratorTable, NtUserFindExistingCursorIcon, NtUserFindWindowEx, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 483b3d52289..43db8421bb8 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -824,7 +824,7 @@ @ stdcall NtUserDeferWindowPosAndBand(long long long long long long long long long long) @ stub NtUserDelegateCapturePointers @ stub NtUserDelegateInput -@ stub NtUserDeleteMenu +@ stdcall -syscall NtUserDeleteMenu(long long long) @ stub NtUserDeleteWindowGroup @ stdcall -syscall NtUserDestroyAcceleratorTable(long) @ stub NtUserDestroyActivationGroup diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index 776a7e671f6..27ba163408b 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -101,6 +101,7 @@ SYSCALL_ENTRY( NtUserCreateAcceleratorTable ) \ SYSCALL_ENTRY( NtUserCreateDesktopEx ) \ SYSCALL_ENTRY( NtUserCreateWindowStation ) \ + SYSCALL_ENTRY( NtUserDeleteMenu ) \ SYSCALL_ENTRY( NtUserDestroyAcceleratorTable ) \ SYSCALL_ENTRY( NtUserFindExistingCursorIcon ) \ SYSCALL_ENTRY( NtUserFindWindowEx ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 1f287c7631c..d90c4ec2f99 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -669,6 +669,15 @@ NTSTATUS WINAPI wow64_NtUserCheckMenuItem( UINT *args ) return NtUserCheckMenuItem( handle, id, flags ); } +NTSTATUS WINAPI wow64_NtUserDeleteMenu( UINT *args ) +{ + HMENU menu = get_handle( &args ); + UINT id = get_ulong( &args ); + UINT flags = get_ulong( &args ); + + return NtUserDeleteMenu( menu, id, flags ); +} + NTSTATUS WINAPI wow64_NtUserGetMenuItemRect( UINT *args ) { HWND hwnd = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 1876b32c84b..dfa9f53a187 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -487,6 +487,7 @@ HWINSTA WINAPI NtUserCreateWindowStation( OBJECT_ATTRIBUTES *attr, ACCESS_MASK m ULONG arg4, ULONG arg5, ULONG arg6, ULONG arg7 ); HDWP WINAPI NtUserDeferWindowPosAndBand( HDWP hdwp, HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags, UINT unk1, UINT unk2 ); +BOOL WINAPI NtUserDeleteMenu( HMENU menu, UINT id, UINT flags ); BOOL WINAPI NtUserDestroyAcceleratorTable( HACCEL handle ); BOOL WINAPI NtUserDestroyCursor( HCURSOR cursor, ULONG arg ); BOOL WINAPI NtUserDestroyMenu( HMENU menu );