[CMAKE]
[reactos.git] / subsystems / win32 / win32k / ntuser / menu.c
index 9bdbe02..49e643e 100644 (file)
@@ -9,13 +9,13 @@
  */
 /* INCLUDES ******************************************************************/
 
-#include <w32k.h>
+#include <win32k.h>
 
 #define NDEBUG
 #include <debug.h>
 
 PMENU_OBJECT FASTCALL
-IntGetSystemMenu(PWINDOW_OBJECT Window, BOOL bRevert, BOOL RetMenu);
+IntGetSystemMenu(PWND Window, BOOL bRevert, BOOL RetMenu);
 
 
 
@@ -86,7 +86,9 @@ UserMenuInfo(
         ( ((r).bottom >=  y)) && \
         ( ((r).top <= y)) )
 
-NTSTATUS FASTCALL
+INIT_FUNCTION
+NTSTATUS
+NTAPI
 InitMenuImpl(VOID)
 {
    return(STATUS_SUCCESS);
@@ -253,7 +255,7 @@ IntDestroyMenuObject(PMENU_OBJECT Menu,
 {
    if(Menu)
    {
-      PWINDOW_OBJECT Window;
+      PWND Window;
       PWINSTATION_OBJECT WindowStation;
       NTSTATUS Status;
 
@@ -279,7 +281,7 @@ IntDestroyMenuObject(PMENU_OBJECT Menu,
             Window = UserGetWindowObject(Menu->MenuInfo.Wnd);
             if (Window)
             {
-               Window->Wnd->IDMenu = 0;
+               Window->IDMenu = 0;
             }
          }
 //         UserDereferenceObject(Menu);
@@ -959,7 +961,6 @@ DWORD FASTCALL
 IntBuildMenuItemList(PMENU_OBJECT MenuObject, PVOID Buffer, ULONG nMax)
 {
    DWORD res = 0;
-   UINT sz;
    ROSMENUITEMINFO mii;
    PVOID Buf;
    PMENU_ITEM CurItem = MenuObject->MenuItemList;
@@ -976,7 +977,6 @@ IntBuildMenuItemList(PMENU_OBJECT MenuObject, PVOID Buffer, ULONG nMax)
       StrOut = (PWCHAR)((char *) Buffer + MenuObject->MenuInfo.MenuItemCount
                         * sizeof(ROSMENUITEMINFO));
       nMax -= MenuObject->MenuInfo.MenuItemCount * sizeof(ROSMENUITEMINFO);
-      sz = sizeof(ROSMENUITEMINFO);
       Buf = Buffer;
       mii.cbSize = sizeof(ROSMENUITEMINFO);
       mii.fMask = 0;
@@ -1081,7 +1081,7 @@ IntCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck)
 }
 
 BOOL FASTCALL
-IntHiliteMenuItem(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject,
+IntHiliteMenuItem(PWND WindowObject, PMENU_OBJECT MenuObject,
                   UINT uItemHilite, UINT uHilite)
 {
    PMENU_ITEM MenuItem;
@@ -1209,39 +1209,39 @@ IntGetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT fByPos, UINT gmdiFlags,
 }
 
 VOID FASTCALL
-co_IntInitTracking(PWINDOW_OBJECT Window, PMENU_OBJECT Menu, BOOL Popup,
+co_IntInitTracking(PWND Window, PMENU_OBJECT Menu, BOOL Popup,
                    UINT Flags)
 {
    /* FIXME - hide caret */
 
    if(!(Flags & TPM_NONOTIFY))
-      co_IntSendMessage(Window->hSelf, WM_SETCURSOR, (WPARAM)Window->hSelf, HTCAPTION);
+      co_IntSendMessage(Window->head.h, WM_SETCURSOR, (WPARAM)Window->head.h, HTCAPTION);
 
    /* FIXME - send WM_SETCURSOR message */
 
    if(!(Flags & TPM_NONOTIFY))
-      co_IntSendMessage(Window->hSelf, WM_INITMENU, (WPARAM)Menu->MenuInfo.Self, 0);
+      co_IntSendMessage(Window->head.h, WM_INITMENU, (WPARAM)Menu->MenuInfo.Self, 0);
 }
 
 VOID FASTCALL
-co_IntExitTracking(PWINDOW_OBJECT Window, PMENU_OBJECT Menu, BOOL Popup,
+co_IntExitTracking(PWND Window, PMENU_OBJECT Menu, BOOL Popup,
                    UINT Flags)
 {
    if(!(Flags & TPM_NONOTIFY))
-      co_IntSendMessage(Window->hSelf, WM_EXITMENULOOP, 0 /* FIXME */, 0);
+      co_IntSendMessage(Window->head.h, WM_EXITMENULOOP, 0 /* FIXME */, 0);
 
    /* FIXME - Show caret again */
 }
 
 INT FASTCALL
-IntTrackMenu(PMENU_OBJECT Menu, PWINDOW_OBJECT Window, INT x, INT y,
+IntTrackMenu(PMENU_OBJECT Menu, PWND Window, INT x, INT y,
              RECTL lprect)
 {
    return 0;
 }
 
 BOOL FASTCALL
-co_IntTrackPopupMenu(PMENU_OBJECT Menu, PWINDOW_OBJECT Window,
+co_IntTrackPopupMenu(PMENU_OBJECT Menu, PWND Window,
                      UINT Flags, POINT *Pos, UINT MenuPos, RECTL *ExcludeRect)
 {
    co_IntInitTracking(Window, Menu, TRUE, Flags);
@@ -1296,17 +1296,8 @@ IntCleanupMenus(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
    return TRUE;
 }
 
-VOID APIENTRY
-co_InflateRect(RECTL *rect, int dx, int dy)
-{
-    rect->left -= dx;
-    rect->top -= dy;
-    rect->right += dx;
-    rect->bottom += dy;
-}
-
 BOOLEAN APIENTRY
-intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
+intGetTitleBarInfo(PWND pWindowObject, PTITLEBARINFO bti)
 {
 
     DWORD dwStyle = 0;
@@ -1319,13 +1310,13 @@ intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
 
         bti->rgstate[0] = STATE_SYSTEM_FOCUSABLE;
 
-        dwStyle = pWindowObject->Wnd->style;
-        dwExStyle = pWindowObject->Wnd->ExStyle;
+        dwStyle = pWindowObject->style;
+        dwExStyle = pWindowObject->ExStyle;
 
         bti->rcTitleBar.top  = 0;
         bti->rcTitleBar.left = 0;
-        bti->rcTitleBar.right  = pWindowObject->Wnd->rcWindow.right - pWindowObject->Wnd->rcWindow.left;
-        bti->rcTitleBar.bottom = pWindowObject->Wnd->rcWindow.bottom - pWindowObject->Wnd->rcWindow.top;
+        bti->rcTitleBar.right  = pWindowObject->rcWindow.right - pWindowObject->rcWindow.left;
+        bti->rcTitleBar.bottom = pWindowObject->rcWindow.bottom - pWindowObject->rcWindow.top;
 
         /* is it iconiced ? */ 
         if ((dwStyle & WS_ICONIC)!=WS_ICONIC)
@@ -1334,17 +1325,17 @@ intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
             if (HAS_THICKFRAME( dwStyle, dwExStyle ))
             {
                 /* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXFRAME) and UserGetSystemMetrics(SM_CYFRAME) */
-                co_InflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXFRAME), -UserGetSystemMetrics(SM_CYFRAME) );
+                RECTL_vInflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXFRAME), -UserGetSystemMetrics(SM_CYFRAME) );
             }
             else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
             {
                 /* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXDLGFRAME) and UserGetSystemMetrics(SM_CYDLGFRAME) */
-                co_InflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXDLGFRAME), -UserGetSystemMetrics(SM_CYDLGFRAME));
+                RECTL_vInflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXDLGFRAME), -UserGetSystemMetrics(SM_CYDLGFRAME));
             }
             else if (HAS_THINFRAME( dwStyle, dwExStyle))
             {
                 /* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
-                co_InflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER) );
+                RECTL_vInflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER) );
             }
 
             /* We have additional border information if the window
@@ -1355,20 +1346,20 @@ intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
                 if (dwExStyle & WS_EX_CLIENTEDGE)
                 {
                     /* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXEDGE) and UserGetSystemMetrics(SM_CYEDGE) */
-                    co_InflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXEDGE), -UserGetSystemMetrics(SM_CYEDGE));
+                    RECTL_vInflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXEDGE), -UserGetSystemMetrics(SM_CYEDGE));
                 }
 
                 if (dwExStyle & WS_EX_STATICEDGE)
                 {
                     /* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
-                    co_InflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER));
+                    RECTL_vInflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER));
                 }
             }
         }
 
-        bti->rcTitleBar.top += pWindowObject->Wnd->rcWindow.top;
-        bti->rcTitleBar.left += pWindowObject->Wnd->rcWindow.left;
-        bti->rcTitleBar.right += pWindowObject->Wnd->rcWindow.left;
+        bti->rcTitleBar.top += pWindowObject->rcWindow.top;
+        bti->rcTitleBar.left += pWindowObject->rcWindow.left;
+        bti->rcTitleBar.right += pWindowObject->rcWindow.left;
 
         bti->rcTitleBar.bottom = bti->rcTitleBar.top;
         if (dwExStyle & WS_EX_TOOLWINDOW)
@@ -1409,7 +1400,7 @@ intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
                 {
                     bti->rgstate[4] = STATE_SYSTEM_INVISIBLE;
                 }
-                if (pWindowObject->Wnd->pcls->style & CS_NOCLOSE)
+                if (pWindowObject->pcls->style & CS_NOCLOSE)
                 {
                     bti->rgstate[5] = STATE_SYSTEM_UNAVAILABLE;
                 }
@@ -1436,50 +1427,49 @@ intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
     return retValue;
 }
 
-/* FUNCTIONS *****************************************************************/
-
-
-/*
- * @implemented
- */
-DWORD
-APIENTRY
-NtUserBuildMenuItemList(
-   HMENU hMenu,
-   VOID* Buffer,
-   ULONG nBufSize,
-   DWORD Reserved)
+DWORD FASTCALL
+UserInsertMenuItem(
+   PMENU_OBJECT Menu,
+   UINT uItem,
+   BOOL fByPosition,
+   LPCMENUITEMINFOW UnsafeItemInfo)
 {
-   DWORD res = -1;
-   PMENU_OBJECT Menu;
-   DECLARE_RETURN(DWORD);
-
-   DPRINT("Enter NtUserBuildMenuItemList\n");
-   UserEnterExclusive();
+   NTSTATUS Status;
+   ROSMENUITEMINFO ItemInfo;
 
-   if(!(Menu = UserGetMenuObject(hMenu)))
+   /* Try to copy the whole MENUITEMINFOW structure */
+   Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
+   if (NT_SUCCESS(Status))
    {
-      RETURN( (DWORD)-1);
+      if (sizeof(MENUITEMINFOW) != ItemInfo.cbSize
+         && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return FALSE;
+      }
+      return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo);
    }
 
-   if(Buffer)
-   {
-      res = IntBuildMenuItemList(Menu, Buffer, nBufSize);
-   }
-   else
+   /* Try to copy without last field (not present in older versions) */
+   Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, FIELD_OFFSET(MENUITEMINFOW, hbmpItem));
+   if (NT_SUCCESS(Status))
    {
-      res = Menu->MenuInfo.MenuItemCount;
+      if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return FALSE;
+      }
+      ItemInfo.hbmpItem = (HBITMAP)0;
+      return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo);
    }
 
-   RETURN( res);
-
-CLEANUP:
-   DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_);
-   UserLeave();
-   END_CLEANUP;
+   SetLastNtError(Status);
+   return FALSE;
 }
 
 
+/* FUNCTIONS *****************************************************************/
+
 /*
  * @implemented
  */
@@ -1508,7 +1498,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 HMENU FASTCALL UserCreateMenu(BOOL PopupMenu)
 {
    PWINSTATION_OBJECT WinStaObject;
@@ -1548,7 +1537,6 @@ HMENU FASTCALL UserCreateMenu(BOOL PopupMenu)
    return (HMENU)Handle;
 }
 
-
 /*
  * @implemented
  */
@@ -1585,7 +1573,7 @@ NtUserGetTitleBarInfo(
     HWND hwnd,
     PTITLEBARINFO bti)
 {
-    PWINDOW_OBJECT WindowObject;
+    PWND WindowObject;
     TITLEBARINFO bartitleinfo;
     DECLARE_RETURN(BOOLEAN);
     BOOLEAN retValue = TRUE;
@@ -1644,8 +1632,6 @@ CLEANUP:
     END_CLEANUP;
 }
 
-
-
 /*
  * @implemented
  */
@@ -1699,7 +1685,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 /*
  * @implemented
  */
@@ -1728,66 +1713,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
-/*
- * @implemented
- */
-DWORD APIENTRY
-UserInsertMenuItem(
-   HMENU hMenu,
-   UINT uItem,
-   BOOL fByPosition,
-   LPCMENUITEMINFOW UnsafeItemInfo)
-{
-   PMENU_OBJECT Menu;
-   NTSTATUS Status;
-   ROSMENUITEMINFO ItemInfo;
-   DECLARE_RETURN(DWORD);
-
-   DPRINT("Enter UserInsertMenuItem\n");
-   UserEnterExclusive();
-
-   if(!(Menu = UserGetMenuObject(hMenu)))
-   {
-      RETURN( FALSE);
-   }
-
-   /* Try to copy the whole MENUITEMINFOW structure */
-   Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
-   if (NT_SUCCESS(Status))
-   {
-      if (sizeof(MENUITEMINFOW) != ItemInfo.cbSize
-         && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
-      {
-         SetLastWin32Error(ERROR_INVALID_PARAMETER);
-         RETURN( FALSE);
-      }
-      RETURN( IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo));
-   }
-
-   /* Try to copy without last field (not present in older versions) */
-   Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, FIELD_OFFSET(MENUITEMINFOW, hbmpItem));
-   if (NT_SUCCESS(Status))
-   {
-      if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
-      {
-         SetLastWin32Error(ERROR_INVALID_PARAMETER);
-         RETURN( FALSE);
-      }
-      ItemInfo.hbmpItem = (HBITMAP)0;
-      RETURN( IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo));
-   }
-
-   SetLastNtError(Status);
-   RETURN( FALSE);
-
-CLEANUP:
-   DPRINT("Leave UserInsertMenuItem, ret=%i\n",_ret_);
-   UserLeave();
-   END_CLEANUP;
-}
-
-
 /*
  * @unimplemented
  */
@@ -1799,37 +1724,6 @@ NtUserEndMenu(VOID)
    return 0;
 }
 
-
-/*
- * @implemented
- */
-UINT APIENTRY
-NtUserGetMenuDefaultItem(
-   HMENU hMenu,
-   UINT fByPos,
-   UINT gmdiFlags)
-{
-   PMENU_OBJECT Menu;
-   DWORD gismc = 0;
-   DECLARE_RETURN(UINT);
-
-   DPRINT("Enter NtUserGetMenuDefaultItem\n");
-   UserEnterExclusive();
-
-   if(!(Menu = UserGetMenuObject(hMenu)))
-   {
-      RETURN(-1);
-   }
-
-   RETURN( IntGetMenuDefaultItem(Menu, fByPos, gmdiFlags, &gismc));
-
-CLEANUP:
-   DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_);
-   UserLeave();
-   END_CLEANUP;
-}
-
-
 /*
  * @implemented
  */
@@ -1843,7 +1737,7 @@ NtUserGetMenuBarInfo(
    BOOL Res = TRUE;
    PMENU_OBJECT MenuObject;
    PMENU_ITEM mi;
-   PWINDOW_OBJECT WindowObject;
+   PWND WindowObject;
    HMENU hMenu;
    POINT Offset;
    RECTL Rect;
@@ -1859,7 +1753,7 @@ NtUserGetMenuBarInfo(
         RETURN(FALSE);
      }
 
-   hMenu = (HMENU)(DWORD_PTR)WindowObject->Wnd->IDMenu;
+   hMenu = (HMENU)(DWORD_PTR)WindowObject->IDMenu;
 
    if (!(MenuObject = UserGetMenuObject(hMenu)))
      {
@@ -1945,7 +1839,7 @@ NtUserGetMenuBarInfo(
            }
          else
            {
-              PWINDOW_OBJECT SubWinObj;
+              PWND SubWinObj;
               if (!(SubWinObj = UserGetWindowObject(SubMenuObject->MenuInfo.Wnd)))
                 {
                    Res = FALSE;
@@ -1995,7 +1889,7 @@ NtUserGetMenuBarInfo(
            }
          else
            {
-              PWINDOW_OBJECT SysWinObj;
+              PWND SysWinObj;
               if (!(SysWinObj = UserGetWindowObject(SysMenuObject->MenuInfo.Wnd)))
                 {
                    Res = FALSE;
@@ -2045,20 +1939,40 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 /*
- * @unimplemented
+ * @implemented
  */
 UINT APIENTRY
 NtUserGetMenuIndex(
    HMENU hMenu,
-   UINT wID)
+   HMENU hSubMenu)
 {
-   UNIMPLEMENTED
+   PMENU_OBJECT Menu, SubMenu;
+   PMENU_ITEM MenuItem;
+   DECLARE_RETURN(UINT);
 
-   return 0;
-}
+   DPRINT("Enter NtUserGetMenuIndex\n");
+   UserEnterShared();
+
+   if ( !(Menu = UserGetMenuObject(hMenu)) ||
+        !(SubMenu = UserGetMenuObject(hSubMenu)) )
+      RETURN(0xFFFFFFFF);
+
+   MenuItem = Menu->MenuItemList;
+   while(MenuItem)
+   {
+      if (MenuItem->hSubMenu == hSubMenu)
+         RETURN(MenuItem->wID);
+      MenuItem = MenuItem->Next;
+   }
 
+   RETURN(0xFFFFFFFF);
+
+CLEANUP:
+   DPRINT("Leave NtUserGetMenuIndex, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+}
 
 /*
  * @implemented
@@ -2071,7 +1985,7 @@ NtUserGetMenuItemRect(
    PRECTL lprcItem)
 {
    ROSMENUINFO mi;
-   PWINDOW_OBJECT ReferenceWnd;
+   PWND ReferenceWnd;
    LONG XMove, YMove;
    RECTL Rect;
    NTSTATUS Status;
@@ -2106,13 +2020,13 @@ NtUserGetMenuItemRect(
 
    if(MenuItem->fType & MF_POPUP)
    {
-     XMove = ReferenceWnd->Wnd->rcClient.left;
-     YMove = ReferenceWnd->Wnd->rcClient.top;
+     XMove = ReferenceWnd->rcClient.left;
+     YMove = ReferenceWnd->rcClient.top;
    }
    else
    {
-     XMove = ReferenceWnd->Wnd->rcWindow.left;
-     YMove = ReferenceWnd->Wnd->rcWindow.top;
+     XMove = ReferenceWnd->rcWindow.left;
+     YMove = ReferenceWnd->rcWindow.top;
    }
 
    Rect.left   += XMove;
@@ -2134,7 +2048,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 /*
  * @implemented
  */
@@ -2146,7 +2059,7 @@ NtUserHiliteMenuItem(
    UINT uHilite)
 {
    PMENU_OBJECT Menu;
-   PWINDOW_OBJECT Window;
+   PWND Window;
    DECLARE_RETURN(BOOLEAN);
 
    DPRINT("Enter NtUserHiliteMenuItem\n");
@@ -2162,7 +2075,7 @@ NtUserHiliteMenuItem(
       RETURN(FALSE);
    }
 
-   if(Window->Wnd->IDMenu == (UINT)(UINT_PTR)hMenu)
+   if(Window->IDMenu == (UINT)(UINT_PTR)hMenu)
    {
       RETURN( IntHiliteMenuItem(Window, Menu, uItemHilite, uHilite));
    }
@@ -2175,7 +2088,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 static
 BOOL FASTCALL
 UserMenuInfo(
@@ -2229,41 +2141,6 @@ UserMenuInfo(
    return( Res);
 }
 
-
-
-
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-NtUserMenuInfo(
-   HMENU hMenu,
-   PROSMENUINFO UnsafeMenuInfo,
-   BOOL SetOrGet)
-{
-   PMENU_OBJECT Menu;
-   DECLARE_RETURN(BOOL);
-
-   DPRINT("Enter NtUserMenuInfo\n");
-   UserEnterShared();
-
-   if (!(Menu = UserGetMenuObject(hMenu)))
-   {
-      RETURN(FALSE);
-   }
-
-   RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet));
-
-CLEANUP:
-   DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_);
-   UserLeave();
-   END_CLEANUP;
-}
-
-
-
 /*
  * @implemented
  */
@@ -2275,7 +2152,7 @@ NtUserMenuItemFromPoint(
    DWORD Y)
 {
    PMENU_OBJECT Menu;
-   PWINDOW_OBJECT Window = NULL;
+   PWND Window = NULL;
    PMENU_ITEM mi;
    int i;
    DECLARE_RETURN(int);
@@ -2293,8 +2170,8 @@ NtUserMenuItemFromPoint(
       RETURN( -1);
    }
 
-   X -= Window->Wnd->rcWindow.left;
-   Y -= Window->Wnd->rcWindow.top;
+   X -= Window->rcWindow.left;
+   Y -= Window->rcWindow.top;
 
    mi = Menu->MenuItemList;
    for (i = 0; NULL != mi; i++)
@@ -2314,8 +2191,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
-
 static
 BOOL FASTCALL
 UserMenuItemInfo(
@@ -2388,41 +2263,6 @@ UserMenuItemInfo(
    return( Ret);
 }
 
-
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-NtUserMenuItemInfo(
-   HMENU hMenu,
-   UINT Item,
-   BOOL ByPosition,
-   PROSMENUITEMINFO UnsafeItemInfo,
-   BOOL SetOrGet)
-{
-   PMENU_OBJECT Menu;
-   DECLARE_RETURN(BOOL);
-
-   DPRINT("Enter NtUserMenuItemInfo\n");
-   UserEnterExclusive();
-
-   if (!(Menu = UserGetMenuObject(hMenu)))
-   {
-      RETURN(FALSE);
-   }
-
-   RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet));
-
-CLEANUP:
-   DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_);
-   UserLeave();
-   END_CLEANUP;
-
-}
-
-
 /*
  * @implemented
  */
@@ -2452,7 +2292,6 @@ CLEANUP:
 
 }
 
-
 /*
  * @implemented
  */
@@ -2480,8 +2319,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
-
 /*
  * @implemented
  */
@@ -2510,7 +2347,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 /*
  * @implemented
  */
@@ -2537,25 +2373,37 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
 /*
- * @unimplemented
+ * @implemented
  */
-DWORD APIENTRY
+BOOL APIENTRY
 NtUserThunkedMenuInfo(
    HMENU hMenu,
    LPCMENUINFO lpcmi)
 {
-   UNIMPLEMENTED
-   /* This function seems just to call SetMenuInfo() */
-   return 0;
-}
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
 
+   DPRINT("Enter NtUserThunkedMenuInfo\n");
+   UserEnterExclusive();
+
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(FALSE);
+   }
+
+   RETURN(UserMenuInfo(Menu, (PROSMENUINFO)lpcmi, TRUE));
+
+CLEANUP:
+   DPRINT("Leave NtUserThunkedMenuInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+}
 
 /*
- * @unimplemented
+ * @implemented
  */
-DWORD APIENTRY
+BOOL APIENTRY
 NtUserThunkedMenuItemInfo(
    HMENU hMenu,
    UINT uItem,
@@ -2564,16 +2412,48 @@ NtUserThunkedMenuItemInfo(
    LPMENUITEMINFOW lpmii,
    PUNICODE_STRING lpszCaption)
 {
+   PMENU_OBJECT Menu;
+   NTSTATUS Status;
+   UNICODE_STRING lstrCaption;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserThunkedMenuItemInfo\n");
+   UserEnterExclusive();
 
    /* lpszCaption may be NULL, check for it and call RtlInitUnicodeString()
-      if bInsert == TRUE call NtUserInsertMenuItem() else NtUserSetMenuItemInfo()   */
+      if bInsert == TRUE call UserInsertMenuItem() else UserSetMenuItemInfo()   */
 
-   if (bInsert) return UserInsertMenuItem(hMenu, uItem, fByPosition, lpmii);
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(FALSE);
+   }
 
-   UNIMPLEMENTED
-   return 0;
-}
+   lstrCaption.Buffer = NULL;
+
+   /* Check if we got a Caption */
+   if (lpszCaption)
+   {
+      /* Copy the string to kernel mode */
+      Status = ProbeAndCaptureUnicodeString( &lstrCaption,
+                                                 UserMode,
+                                              lpszCaption);
+      if (!NT_SUCCESS(Status))
+      {
+         DPRINT1("Failed to capture MenuItem Caption (status 0x%08x)\n",Status);
+         SetLastNtError(Status);
+         RETURN(FALSE);
+      }       
+   }
+
+   if (bInsert) RETURN( UserInsertMenuItem(Menu, uItem, fByPosition, lpmii));
 
+   RETURN( UserMenuItemInfo(Menu, uItem, fByPosition, (PROSMENUITEMINFO)lpmii, TRUE));
+
+CLEANUP:
+   DPRINT("Leave NtUserThunkedMenuItemInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+}
 
 /*
  * @implemented
@@ -2594,4 +2474,135 @@ NtUserTrackPopupMenuEx(
 }
 
 
+////// ReactOS NtUserBad
+/*
+ * @implemented
+ */
+DWORD
+APIENTRY
+NtUserBuildMenuItemList(
+   HMENU hMenu,
+   VOID* Buffer,
+   ULONG nBufSize,
+   DWORD Reserved)
+{
+   DWORD res = -1;
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserBuildMenuItemList\n");
+   UserEnterExclusive();
+
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN( (DWORD)-1);
+   }
+
+   if(Buffer)
+   {
+      res = IntBuildMenuItemList(Menu, Buffer, nBufSize);
+   }
+   else
+   {
+      res = Menu->MenuInfo.MenuItemCount;
+   }
+
+   RETURN( res);
+
+CLEANUP:
+   DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+}
+
+/*
+ * @implemented
+ */
+UINT APIENTRY
+NtUserGetMenuDefaultItem(
+   HMENU hMenu,
+   UINT fByPos,
+   UINT gmdiFlags)
+{
+   PMENU_OBJECT Menu;
+   DWORD gismc = 0;
+   DECLARE_RETURN(UINT);
+
+   DPRINT("Enter NtUserGetMenuDefaultItem\n");
+   UserEnterExclusive();
+
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(-1);
+   }
+
+   RETURN( IntGetMenuDefaultItem(Menu, fByPos, gmdiFlags, &gismc));
+
+CLEANUP:
+   DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+APIENTRY
+NtUserMenuInfo(
+   HMENU hMenu,
+   PROSMENUINFO UnsafeMenuInfo,
+   BOOL SetOrGet)
+{
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserMenuInfo\n");
+   UserEnterShared();
+
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(FALSE);
+   }
+
+   RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet));
+
+CLEANUP:
+   DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+APIENTRY
+NtUserMenuItemInfo(
+   HMENU hMenu,
+   UINT Item,
+   BOOL ByPosition,
+   PROSMENUITEMINFO UnsafeItemInfo,
+   BOOL SetOrGet)
+{
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserMenuItemInfo\n");
+   UserEnterExclusive();
+
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(FALSE);
+   }
+
+   RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet));
+
+CLEANUP:
+   DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+
+}
+
 /* EOF */