[CMAKE]
[reactos.git] / subsystems / win32 / win32k / ntuser / ntstubs.c
index 1baaeb4..281fe71 100644 (file)
@@ -40,13 +40,13 @@ NtUserAttachThreadInput(
   Status = PsLookupThreadByThreadId((HANDLE)idAttach, &Thread);
   if (!NT_SUCCESS(Status))
   {
-     SetLastWin32Error(ERROR_INVALID_PARAMETER);
+     EngSetLastError(ERROR_INVALID_PARAMETER);
      goto Exit;
   }
   Status = PsLookupThreadByThreadId((HANDLE)idAttachTo, &ThreadTo);
   if (!NT_SUCCESS(Status))
   {
-     SetLastWin32Error(ERROR_INVALID_PARAMETER);
+     EngSetLastError(ERROR_INVALID_PARAMETER);
      ObDereferenceObject(Thread);
      goto Exit;
   }
@@ -84,11 +84,11 @@ NtUserBitBltSysBmp(
    Ret = NtGdiBitBlt( hdc,
                    nXDest,
                    nYDest,
-                   nWidth, 
-                  nHeight, 
+                   nWidth,
+                  nHeight,
                 hSystemBM,
-                    nXSrc, 
-                    nYSrc, 
+                    nXSrc,
+                    nYSrc,
                     dwRop,
                         0,
                         0);
@@ -255,7 +255,7 @@ HBRUSH
 APIENTRY
 NtUserGetControlColor(
    HWND hwndParent,
-   HWND hwnd, 
+   HWND hwnd,
    HDC hdc,
    UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush
 {
@@ -277,56 +277,6 @@ NtUserGetImeHotKey(
    return 0;
 }
 
-
-DWORD
-APIENTRY
-NtUserGetMouseMovePointsEx(
-   UINT cbSize,
-   LPMOUSEMOVEPOINT lppt,
-   LPMOUSEMOVEPOINT lpptBuf,
-   int nBufPoints,
-   DWORD resolution)
-{
-   UserEnterExclusive();
-
-   if ((cbSize != sizeof(MOUSEMOVEPOINT)) || (nBufPoints < 0) || (nBufPoints > 64))
-   {
-      UserLeave();
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return -1;
-   }
-
-   _SEH2_TRY
-   {
-      ProbeForRead(lppt, cbSize, 1);
-      ProbeForWrite(lpptBuf, cbSize, 1);
-   }
-   _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-   {
-       SetLastNtError(_SEH2_GetExceptionCode());
-       SetLastWin32Error(ERROR_NOACCESS);
-   }
-   _SEH2_END;
-
-/*
-   Call a subfunction of GetMouseMovePointsEx!
-   switch(resolution)
-   {
-     case GMMP_USE_DISPLAY_POINTS:
-     case GMMP_USE_HIGH_RESOLUTION_POINTS:
-          break;
-     default:
-        SetLastWin32Error(GMMP_ERR_POINT_NOT_FOUND);
-        return GMMP_ERR_POINT_NOT_FOUND;
-   }
-  */
-   UNIMPLEMENTED
-   UserLeave();
-   return -1;
-}
-
-
-
 BOOL
 APIENTRY
 NtUserImpersonateDdeClientWindow(
@@ -380,7 +330,7 @@ NtUserInitializeClientPfnArrays(
       DPRINT1("Failed reading Client Pfns from user space.\n");
       SetLastNtError(Status);
    }
-   
+
    UserLeave();
    return Status;
 }
@@ -538,36 +488,43 @@ NtUserSetSysColors(
    IN CONST COLORREF *lpaRgbValues,
    FLONG Flags)
 {
-  DWORD Ret = FALSE;
-  NTSTATUS Status = STATUS_SUCCESS;
-  UserEnterExclusive();
-  _SEH2_TRY
-  {
-     ProbeForRead(lpaElements,
-                   sizeof(INT),
-                   1);
-     ProbeForRead(lpaRgbValues,
-                   sizeof(INT),
-                   1);
-// Developers: We are thread locked and calling gdi.
-     Ret = IntSetSysColors(cElements, (INT*)lpaElements, (COLORREF*)lpaRgbValues);
-  }
-  _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-  {
-      Status = _SEH2_GetExceptionCode();
-  }
-  _SEH2_END;
-  if (!NT_SUCCESS(Status))
-  {
-      SetLastNtError(Status);
+   DWORD Ret = TRUE;
+
+   if (cElements == 0)
+      return TRUE;
+
+   /* We need this check to prevent overflow later */
+   if ((ULONG)cElements >= 0x40000000)
+   {
+      EngSetLastError(ERROR_NOACCESS);
+      return FALSE;
+   }
+
+   UserEnterExclusive();
+
+   _SEH2_TRY
+   {
+      ProbeForRead(lpaElements, cElements * sizeof(INT), 1);
+      ProbeForRead(lpaRgbValues, cElements * sizeof(COLORREF), 1);
+
+      IntSetSysColors(cElements, lpaElements, lpaRgbValues);
+   }
+   _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+   {
+      SetLastNtError(_SEH2_GetExceptionCode());
       Ret = FALSE;
-  }
-  if (Ret)
-  {
-     UserPostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
-  }
-  UserLeave();
-  return Ret;
+   }
+   _SEH2_END;
+
+   if (Ret)
+   {
+      UserSendNotifyMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
+
+      UserRedrawDesktop();
+   }
+
+   UserLeave();
+   return Ret;
 }
 
 DWORD
@@ -581,17 +538,6 @@ NtUserSetThreadState(
    return 0;
 }
 
-BOOL
-APIENTRY
-NtUserTrackMouseEvent(
-   LPTRACKMOUSEEVENT lpEventTrack)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
 DWORD
 APIENTRY
 NtUserUpdateInputContext(
@@ -817,8 +763,45 @@ NtUserMinMaximize(
     UINT cmd, // Wine SW_ commands
     BOOL Hide)
 {
-    UNIMPLEMENTED;
-    return 0;
+  RECTL NewPos;
+  UINT SwFlags;
+  PWND pWnd;
+
+  DPRINT("Enter NtUserMinMaximize\n");
+  UserEnterExclusive();
+
+  pWnd = UserGetWindowObject(hWnd);
+  if ( !pWnd ||                          // FIXME:
+        pWnd == IntGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP
+        pWnd == IntGetMessageWindow() )  // pWnd->fnid == FNID_MESSAGEWND
+  {
+     goto Exit;
+  }
+
+  if ( cmd > SW_MAX || pWnd->state2 & WNDS2_INDESTROY)
+  {
+     EngSetLastError(ERROR_INVALID_PARAMETER);
+     goto Exit;
+  }
+
+  co_WinPosMinMaximize(pWnd, cmd, &NewPos);
+
+  SwFlags = Hide ? SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED : SWP_NOZORDER|SWP_FRAMECHANGED;
+
+  co_WinPosSetWindowPos( pWnd,
+                         NULL,
+                         NewPos.left,
+                         NewPos.top,
+                         NewPos.right,
+                         NewPos.bottom,
+                         SwFlags);
+
+  co_WinPosShowWindow(pWnd, cmd);
+
+Exit:
+  DPRINT("Leave NtUserMinMaximize\n");
+  UserLeave();
+  return 0; // Always NULL?
 }
 
 DWORD
@@ -833,17 +816,6 @@ NtUserNotifyProcessCreate(
     return 0;
 }
 
-BOOL
-APIENTRY
-NtUserPrintWindow(
-    HWND hwnd,
-    HDC  hdcBlt,
-    UINT nFlags)
-{
-    UNIMPLEMENTED;
-    return 0;
-}
-
 NTSTATUS
 APIENTRY
 NtUserProcessConnect(
@@ -904,25 +876,25 @@ NtUserQueryInputContext(
     return 0;
 }
 
-DWORD
+BOOL
 APIENTRY
 NtUserRealInternalGetMessage(
-    DWORD dwUnknown1,
-    DWORD dwUnknown2,
-    DWORD dwUnknown3,
-    DWORD dwUnknown4,
-    DWORD dwUnknown5,
-    DWORD dwUnknown6)
+    LPMSG lpMsg,
+    HWND hWnd,
+    UINT wMsgFilterMin,
+    UINT wMsgFilterMax,
+    UINT wRemoveMsg,
+    BOOL bGMSG)
 {
     UNIMPLEMENTED;
     return 0;
 }
 
-DWORD
+BOOL
 APIENTRY
 NtUserRealWaitMessageEx(
-    DWORD dwUnknown1,
-    DWORD dwUnknown2)
+    DWORD dwWakeMask,
+    UINT uTimeout)
 {
     UNIMPLEMENTED;
     return 0;
@@ -1103,20 +1075,11 @@ NtUserValidateTimerCallback(
     LPARAM lParam)
 {
   BOOL Ret = FALSE;
-  PWINDOW_OBJECT Window = NULL;
 
   UserEnterShared();
 
-  if (hWnd)
-  {
-     Window = UserGetWindowObject(hWnd);
-     if (!Window || !Window->Wnd)
-        goto Exit;
-  }
-
-  Ret = ValidateTimerCallback(PsGetCurrentThreadWin32Thread(), Window, wParam, lParam);
+  Ret = ValidateTimerCallback(PsGetCurrentThreadWin32Thread(), lParam);
 
-Exit:
   UserLeave();
   return Ret;
 }
@@ -1171,5 +1134,283 @@ NtUserCtxDisplayIOCtl(
     return 0;
 }
 
+/*
+ * @unimplemented
+ */
+DWORD
+APIENTRY
+NtUserDrawMenuBarTemp(
+   HWND hWnd,
+   HDC hDC,
+   PRECT hRect,
+   HMENU hMenu,
+   HFONT hFont)
+{
+   /* we'll use this function just for caching the menu bar */
+   UNIMPLEMENTED
+   return 0;
+}
+
+/*
+ * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
+ */
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserFillWindow(HWND hWndPaint,
+                 HWND hWndPaint1,
+                 HDC  hDC,
+                 HBRUSH hBrush)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserFlashWindowEx(IN PFLASHWINFO pfwi)
+{
+   UNIMPLEMENTED
+
+   return 1;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserLockWindowUpdate(HWND hWnd)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+HWND APIENTRY
+NtUserRealChildWindowFromPoint(HWND Parent,
+                               LONG x,
+                               LONG y)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserSetImeOwnerWindow(DWORD Unknown0,
+                        DWORD Unknown1)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserSetInternalWindowPos(
+   HWND    hwnd,
+   UINT    showCmd,
+   LPRECT  rect,
+   LPPOINT pt)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserSetLayeredWindowAttributes(HWND hwnd,
+                          COLORREF crKey,
+                          BYTE bAlpha,
+                          DWORD dwFlags)
+{
+  UNIMPLEMENTED;
+  return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+APIENTRY
+NtUserUpdateLayeredWindow(
+   HWND hwnd,
+   HDC hdcDst,
+   POINT *pptDst,
+   SIZE *psize,
+   HDC hdcSrc,
+   POINT *pptSrc,
+   COLORREF crKey,
+   BLENDFUNCTION *pblend,
+   DWORD dwFlags,
+   RECT *prcDirty)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ *    @unimplemented
+ */
+HWND APIENTRY
+NtUserWindowFromPhysicalPoint(POINT Point)
+{
+   UNIMPLEMENTED
+
+   return NULL;
+}
+
+/*
+ * NtUserResolveDesktopForWOW
+ *
+ * Status
+ *    @unimplemented
+ */
+
+DWORD APIENTRY
+NtUserResolveDesktopForWOW(DWORD Unknown0)
+{
+   UNIMPLEMENTED
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserEndMenu(VOID)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @implemented
+ */
+/* NOTE: unused function */
+BOOL APIENTRY
+NtUserTrackPopupMenuEx(
+   HMENU hMenu,
+   UINT fuFlags,
+   int x,
+   int y,
+   HWND hWnd,
+   LPTPMPARAMS lptpm)
+{
+   UNIMPLEMENTED
+
+   return FALSE;
+}
+
+DWORD APIENTRY
+NtUserQuerySendMessage(DWORD Unknown0)
+{
+    UNIMPLEMENTED;
+
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserAlterWindowStyle(DWORD Unknown0,
+                       DWORD Unknown1,
+                       DWORD Unknown2)
+{
+   UNIMPLEMENTED
+
+   return(0);
+}
+
+/*
+ * NtUserSetWindowStationUser
+ *
+ * Status
+ *    @unimplemented
+ */
+
+DWORD APIENTRY
+NtUserSetWindowStationUser(
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+BOOL APIENTRY NtUserAddClipboardFormatListener(
+    HWND hwnd
+)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
+
+BOOL APIENTRY NtUserRemoveClipboardFormatListener(
+    HWND hwnd
+)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
+
+BOOL APIENTRY NtUserGetUpdatedClipboardFormats(
+    PUINT lpuiFormats,
+    UINT cFormats,
+    PUINT pcFormatsOut
+)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD
+APIENTRY
+NtUserGetCursorFrameInfo(
+    DWORD Unknown0,
+    DWORD Unknown1,
+    DWORD Unknown2,
+    DWORD Unknown3)
+{
+    UNIMPLEMENTED
+
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+APIENTRY
+NtUserSetSystemCursor(
+    HCURSOR hcur,
+    DWORD id)
+{
+    return FALSE;
+}
 
 /* EOF */