Window stations and desktops
authorCasper Hornstrup <chorns@users.sourceforge.net>
Tue, 12 Jun 2001 17:51:51 +0000 (17:51 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Tue, 12 Jun 2001 17:51:51 +0000 (17:51 +0000)
svn path=/trunk/; revision=1965

42 files changed:
reactos/iface/addsys/w32ksvc.db
reactos/include/napi/teb.h
reactos/include/win32k/ntuser.h
reactos/lib/user32/include/debug.h [new file with mode: 0644]
reactos/lib/user32/include/user32.h [new file with mode: 0644]
reactos/lib/user32/include/window.h [new file with mode: 0644]
reactos/lib/user32/include/winsta.h [new file with mode: 0644]
reactos/lib/user32/misc/desktop.c [new file with mode: 0644]
reactos/lib/user32/misc/winsta.c [new file with mode: 0644]
reactos/lib/user32/windows/class.c [new file with mode: 0644]
reactos/lib/user32/windows/message.c [new file with mode: 0644]
reactos/lib/user32/windows/window.c [new file with mode: 0644]
reactos/ntoskrnl/Makefile
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/ex/win32k.c [new file with mode: 0644]
reactos/ntoskrnl/include/internal/ex.h
reactos/ntoskrnl/ob/object.c
reactos/ntoskrnl/ps/process.c
reactos/ntoskrnl/rtl/atom.c
reactos/subsys/smss/init.c
reactos/subsys/system/winlogon/makefile
reactos/subsys/system/winlogon/winlogon.c
reactos/subsys/win32k/include/class.h [new file with mode: 0644]
reactos/subsys/win32k/include/error.h [new file with mode: 0644]
reactos/subsys/win32k/include/guicheck.h [new file with mode: 0644]
reactos/subsys/win32k/include/msgqueue.h [new file with mode: 0644]
reactos/subsys/win32k/include/object.h [new file with mode: 0644]
reactos/subsys/win32k/include/window.h [new file with mode: 0644]
reactos/subsys/win32k/include/winsta.h [new file with mode: 0644]
reactos/subsys/win32k/main/dllmain.c
reactos/subsys/win32k/makefile
reactos/subsys/win32k/misc/error.c [new file with mode: 0644]
reactos/subsys/win32k/misc/object.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/class.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/guicheck.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/hook.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/message.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/msgqueue.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/stubs.c
reactos/subsys/win32k/ntuser/window.c [new file with mode: 0644]
reactos/subsys/win32k/ntuser/winsta.c [new file with mode: 0644]
reactos/subsys/win32k/objects/gdiobj.c

index 3008dd0..9586fb1 100644 (file)
@@ -439,6 +439,7 @@ NtUserQueryUserCounters                 5
 NtUserQueryWindow                       2
 NtUserRealChildWindowFromPoint          3
 NtUserRedrawWindow                      4
+NtUserRegisterClassExWOW                6
 NtUserRegisterHotKey                    4
 NtUserRegisterTasklist                  1
 NtUserRegisterWindowMessage             1
@@ -475,6 +476,7 @@ NtUserSetMenuDefaultItem                3
 NtUserSetMenuFlagRtoL                   1
 NtUserSetObjectInformation              4
 NtUserSetParent                         2
+NtUserSetProcessWindowStation           1
 NtUserSetProp                           3
 NtUserSetRipFlags                       2
 NtUserSetScrollInfo                     4
index 0d2b650..5b2afa4 100644 (file)
@@ -131,6 +131,8 @@ typedef struct _PEB
    ULONG ImageSubSystemMajorVersion;                // B8h
    ULONG ImageSubSystemMinorVersion;                // C0h
    ULONG GdiHandleBuffer[0x22];                     // C4h
+
+   PVOID ProcessWindowStation;                      // ???
 } PEB, *PPEB;
 
 
@@ -215,6 +217,8 @@ typedef struct _NT_TEB
    PVOID StackCommit;                  // F88h
    PVOID StackCommitMax;               // F8Ch
    PVOID StackReserve;                 // F90h
+
+   PVOID MessageQueue;                 // ???
 } NT_TEB, *PNT_TEB;
 
 #define PEB_STARTUPINFO (0xb0003000)
index 45c02e9..b375509 100644 (file)
@@ -174,15 +174,15 @@ DWORD
 STDCALL
 NtUserCloseClipboard(VOID);
 
-DWORD
+BOOL
 STDCALL
 NtUserCloseDesktop(
-  DWORD Unknown0);
+  HDESK hDesktop);
 
-DWORD
+BOOL
 STDCALL
 NtUserCloseWindowStation(
-  DWORD Unknown0);
+  HWINSTA hWinSta);
 
 DWORD
 STDCALL
@@ -215,14 +215,14 @@ NtUserCreateCaret(
   DWORD Unknown2,
   DWORD Unknown3);
 
-DWORD
+HDESK
 STDCALL
 NtUserCreateDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4);
+  PUNICODE_STRING lpszDesktopName,
+  DWORD dwFlags,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpSecurity,
+  HWINSTA hWindowStation);
 
 DWORD
 STDCALL
@@ -232,29 +232,29 @@ NtUserCreateLocalMemHandle(
   DWORD Unknown2,
   DWORD Unknown3);
 
-DWORD
+HWND
 STDCALL
 NtUserCreateWindowEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7,
-  DWORD Unknown8,
-  DWORD Unknown9,
-  DWORD Unknown10,
-  DWORD Unknown11,
+  DWORD dwExStyle,
+  PUNICODE_STRING lpClassName,
+  PUNICODE_STRING lpWindowName,
+  DWORD dwStyle,
+  LONG x,
+  LONG y,
+  LONG nWidth,
+  LONG nHeight,
+  HWND hWndParent,
+  HMENU hMenu,
+  HINSTANCE hInstance,
+  LPVOID lpParam,
   DWORD Unknown12);
 
-DWORD
+HWINSTA
 STDCALL
 NtUserCreateWindowStation(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
+  PUNICODE_STRING lpszWindowStationName,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpSecurity,
   DWORD Unknown3,
   DWORD Unknown4,
   DWORD Unknown5);
@@ -328,10 +328,10 @@ STDCALL
 NtUserDestroyWindow(
   DWORD Unknown0);
 
-DWORD
+LRESULT
 STDCALL
 NtUserDispatchMessage(
-  DWORD Unknown0);
+  LPMSG lpmsg);
 
 DWORD
 STDCALL
@@ -735,13 +735,13 @@ NtUserGetMenuItemRect(
   DWORD Unknown2,
   DWORD Unknown3);
 
-DWORD
+BOOL
 STDCALL
 NtUserGetMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3);
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax);
 
 DWORD
 STDCALL
@@ -752,14 +752,14 @@ NtUserGetMouseMovePointsEx(
   DWORD Unknown3,
   DWORD Unknown4);
 
-DWORD
+BOOL
 STDCALL
 NtUserGetObjectInformation(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4);
+  HANDLE hObject,
+  DWORD nIndex,
+  PVOID pvInformation,
+  DWORD nLength,
+  PDWORD nLengthNeeded);
 
 DWORD
 STDCALL
@@ -771,7 +771,7 @@ NtUserGetPriorityClipboardFormat(
   DWORD Unknown0,
   DWORD Unknown1);
 
-DWORD
+HWINSTA
 STDCALL
 NtUserGetProcessWindowStation(VOID);
 
@@ -788,10 +788,10 @@ NtUserGetSystemMenu(
   DWORD Unknown0,
   DWORD Unknown1);
 
-DWORD
+HDESK
 STDCALL
 NtUserGetThreadDesktop(
-  DWORD Unknown0,
+  DWORD dwThreadId,
   DWORD Unknown1);
 
 DWORD
@@ -920,10 +920,10 @@ NtUserLoadKeyboardLayoutEx(
   DWORD Unknown4,
   DWORD Unknown5);
 
-DWORD
+BOOL
 STDCALL
 NtUserLockWindowStation(
-  DWORD Unknown0);
+  HWINSTA hWindowStation);
 
 DWORD
 STDCALL
@@ -1015,55 +1015,55 @@ NtUserOpenClipboard(
   DWORD Unknown0,
   DWORD Unknown1);
 
-DWORD
+HDESK
 STDCALL
 NtUserOpenDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2);
+  PUNICODE_STRING lpszDesktopName,
+  DWORD dwFlags,
+  ACCESS_MASK dwDesiredAccess);
 
-DWORD
+HDESK
 STDCALL
 NtUserOpenInputDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2);
+  DWORD dwFlags,
+  BOOL fInherit,
+  ACCESS_MASK dwDesiredAccess);
 
-DWORD
+HWINSTA
 STDCALL
 NtUserOpenWindowStation(
-  DWORD Unknown0,
-  DWORD Unknown1);
+  PUNICODE_STRING lpszWindowStationName,
+  ACCESS_MASK dwDesiredAccess);
 
-DWORD
+BOOL
 STDCALL
 NtUserPaintDesktop(
-  DWORD Unknown0);
+  HDC hDC);
 
-DWORD
+BOOL
 STDCALL
 NtUserPeekMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4);
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax,
+  UINT wRemoveMsg);
 
-DWORD
+BOOL
 STDCALL
 NtUserPostMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3);
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam);
 
-DWORD
+BOOL
 STDCALL
 NtUserPostThreadMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3);
+  DWORD idThread,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam);
 
 DWORD
 STDCALL
@@ -1100,6 +1100,16 @@ NtUserRedrawWindow(
   DWORD Unknown2,
   DWORD Unknown3);
 
+RTL_ATOM
+STDCALL
+NtUserRegisterClassExWOW(
+  LPWNDCLASSEX lpwcx,
+  BOOL bUnicodeClass,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5);
+
 DWORD
 STDCALL
 NtUserRegisterHotKey(
@@ -1174,23 +1184,23 @@ NtUserSendInput(
   DWORD Unknown1,
   DWORD Unknown2);
 
-DWORD
+BOOL
 STDCALL
 NtUserSendMessageCallback(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5);
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam,
+  SENDASYNCPROC lpCallBack,
+  ULONG_PTR dwData);
 
-DWORD
+BOOL
 STDCALL
 NtUserSendNotifyMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3);
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam);
 
 DWORD
 STDCALL
@@ -1331,13 +1341,13 @@ STDCALL
 NtUserSetMenuFlagRtoL(
   DWORD Unknown0);
 
-DWORD
+BOOL
 STDCALL
 NtUserSetObjectInformation(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3);
+  HANDLE hObject,
+  DWORD nIndex,
+  PVOID pvInformation,
+  DWORD nLength);
 
 DWORD
 STDCALL
@@ -1345,6 +1355,11 @@ NtUserSetParent(
   DWORD Unknown0,
   DWORD Unknown1);
 
+BOOL
+STDCALL
+NtUserSetProcessWindowStation(
+  HWINSTA hWindowStation);
+
 DWORD
 STDCALL
 NtUserSetProp(
@@ -1400,10 +1415,10 @@ NtUserSetSystemTimer(
   DWORD Unknown2,
   DWORD Unknown3);
 
-DWORD
+BOOL
 STDCALL
 NtUserSetThreadDesktop(
-  DWORD Unknown0);
+  HDESK hDesktop);
 
 DWORD
 STDCALL
@@ -1513,11 +1528,11 @@ NtUserShowScrollBar(
   DWORD Unknown1,
   DWORD Unknown2);
 
-DWORD
+BOOL
 STDCALL
 NtUserShowWindow(
-  DWORD Unknown0,
-  DWORD Unknown1);
+  HWND hWnd,
+  LONG nCmdShow);
 
 DWORD
 STDCALL
@@ -1525,10 +1540,10 @@ NtUserShowWindowAsync(
   DWORD Unknown0,
   DWORD Unknown1);
 
-DWORD
+BOOL
 STDCALL
 NtUserSwitchDesktop(
-  DWORD Unknown0);
+  HDESK hDesktop);
 
 DWORD
 STDCALL
@@ -1587,10 +1602,10 @@ NtUserTranslateAccelerator(
   DWORD Unknown1,
   DWORD Unknown2);
 
-DWORD
+BOOL
 STDCALL
 NtUserTranslateMessage(
-  DWORD Unknown0,
+  LPMSG lpMsg,
   DWORD Unknown1);
 
 DWORD
@@ -1608,10 +1623,10 @@ STDCALL
 NtUserUnloadKeyboardLayout(
   DWORD Unknown0);
 
-DWORD
+BOOL
 STDCALL
 NtUserUnlockWindowStation(
-  DWORD Unknown0);
+  HWINSTA hWindowStation);
 
 DWORD
 STDCALL
@@ -1696,7 +1711,7 @@ STDCALL
 NtUserWaitForMsgAndEvent(
   DWORD Unknown0);
 
-DWORD
+BOOL
 STDCALL
 NtUserWaitMessage(VOID);
 
diff --git a/reactos/lib/user32/include/debug.h b/reactos/lib/user32/include/debug.h
new file mode 100644 (file)
index 0000000..9eab7d6
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS user32.dll
+ * FILE:        include/debug.h
+ * PURPOSE:     Debugging support macros
+ * DEFINES:     DBG     - Enable debug output
+ *              NASSERT - Disable assertions
+ */
+#ifndef __DEBUG_H
+#define __DEBUG_H
+
+#define NORMAL_MASK    0x000000FF
+#define SPECIAL_MASK   0xFFFFFF00
+#define MIN_TRACE      0x00000001
+#define MID_TRACE      0x00000002
+#define MAX_TRACE      0x00000003
+
+#define DEBUG_CHECK    0x00000100
+#define DEBUG_OBJECT   0x00000200
+#define DEBUG_WINDOW   0x00000400
+#define DEBUG_ULTRA    0xFFFFFFFF
+
+#ifdef DBG
+
+extern DWORD DebugTraceLevel;
+
+#define D(_t_, _x_) \
+    if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
+        ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
+        DbgPrint("(%hS:%d)(%hS) ", __FILE__, __LINE__, __FUNCTION__); \
+                   DbgPrint _x_; \
+    }
+
+#ifdef ASSERT
+#undef ASSERT
+#endif
+
+#ifdef NASSERT
+#define ASSERT(x)
+#else /* NASSERT */
+#define ASSERT(x) if (!(x)) { D(MIN_TRACE, ("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__)); KeBugCheck(0); }
+#endif /* NASSERT */
+
+#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
+
+#else /* DBG */
+
+#define D(_t_, _x_)
+
+#define ASSERT_IRQL(x)
+#define ASSERT(x)
+
+#endif /* DBG */
+
+
+#define assert(x) ASSERT(x)
+#define assert_irql(x) ASSERT_IRQL(x)
+
+
+#define UNIMPLEMENTED \
+    D(MIN_TRACE, ("is unimplemented, please try again later.\n"));
+
+#define CHECKPOINT \
+    D(DEBUG_CHECK, ("\n"));
+
+#define CP CHECKPOINT
+
+#endif /* __DEBUG_H */
+
+/* EOF */
diff --git a/reactos/lib/user32/include/user32.h b/reactos/lib/user32/include/user32.h
new file mode 100644 (file)
index 0000000..ea10654
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS user32.dll
+ * FILE:        include/user32.h
+ * PURPOSE:     Global user32 definitions
+ */
+#include <windows.h>
+#include <win32k/win32k.h>
+
+extern HANDLE ProcessHeap;
diff --git a/reactos/lib/user32/include/window.h b/reactos/lib/user32/include/window.h
new file mode 100644 (file)
index 0000000..87ef77e
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS user32.dll
+ * FILE:        include/window.h
+ * PURPOSE:     Window management definitions
+ */
+#include <windows.h>
+
+#define IS_ATOM(x) \
+  (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
diff --git a/reactos/lib/user32/include/winsta.h b/reactos/lib/user32/include/winsta.h
new file mode 100644 (file)
index 0000000..0271481
--- /dev/null
@@ -0,0 +1,6 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS user32.dll
+ * FILE:        include/winsta.h
+ * PURPOSE:     Window stations
+ */
diff --git a/reactos/lib/user32/misc/desktop.c b/reactos/lib/user32/misc/desktop.c
new file mode 100644 (file)
index 0000000..baaae27
--- /dev/null
@@ -0,0 +1,209 @@
+/* $Id: desktop.c,v 1.1 2001/06/12 17:50:27 chorns Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS user32.dll
+ * FILE:            lib/user32/misc/desktop.c
+ * PURPOSE:         Desktops
+ * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *      06-06-2001  CSH  Created
+ */
+#include <windows.h>
+#include <user32.h>
+#include <debug.h>
+
+
+WINBOOL
+STDCALL
+CloseDesktop(
+  HDESK hDesktop)
+{
+  return NtUserCloseDesktop(hDesktop);
+}
+
+HDESK
+STDCALL
+CreateDesktopA(
+  LPCSTR lpszDesktop,
+  LPCSTR lpszDevice,
+  LPDEVMODE pDevmode,
+  DWORD dwFlags,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpsa)
+{
+  ANSI_STRING DesktopNameA;
+  UNICODE_STRING DesktopNameU;
+  HDESK hDesktop;
+
+       if (lpszDesktop != NULL) {
+               RtlInitAnsiString(&DesktopNameA, (LPSTR)lpszDesktop);
+               RtlAnsiStringToUnicodeString(&DesktopNameU, &DesktopNameA, TRUE);
+  } else {
+    RtlInitUnicodeString(&DesktopNameU, NULL);
+  }
+
+  hDesktop = CreateDesktopW(
+    DesktopNameU.Buffer,
+    NULL,
+    pDevmode,
+    dwFlags,
+    dwDesiredAccess,
+    lpsa);
+
+       RtlFreeUnicodeString(&DesktopNameU);
+
+  return hDesktop;
+}
+
+HDESK
+STDCALL
+CreateDesktopW(
+  LPCWSTR lpszDesktop,
+  LPCWSTR lpszDevice,
+  LPDEVMODE pDevmode,
+  DWORD dwFlags,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpsa)
+{
+  UNICODE_STRING DesktopName;
+  HWINSTA hWinSta;
+  HDESK hDesktop;
+
+  hWinSta = NtUserGetProcessWindowStation();
+
+  RtlInitUnicodeString(&DesktopName, lpszDesktop);
+
+  hDesktop = NtUserCreateDesktop(
+    &DesktopName,
+    dwFlags,
+    dwDesiredAccess,
+    lpsa,
+    hWinSta);
+
+  return hDesktop;
+}
+
+WINBOOL
+STDCALL
+EnumDesktopWindows(
+  HDESK hDesktop,
+  ENUMWINDOWSPROC lpfn,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EnumDesktopsA(
+  HWINSTA hwinsta,
+  DESKTOPENUMPROC lpEnumFunc,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EnumDesktopsW(
+  HWINSTA hwinsta,
+  DESKTOPENUMPROC lpEnumFunc,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+HDESK
+STDCALL
+GetThreadDesktop(
+  DWORD dwThreadId)
+{
+  return NtUserGetThreadDesktop(dwThreadId, 0);
+}
+
+HDESK
+STDCALL
+OpenDesktopA(
+  LPSTR lpszDesktop,
+  DWORD dwFlags,
+  WINBOOL fInherit,
+  ACCESS_MASK dwDesiredAccess)
+{
+  ANSI_STRING DesktopNameA;
+  UNICODE_STRING DesktopNameU;
+  HDESK hDesktop;
+
+       if (lpszDesktop != NULL) {
+               RtlInitAnsiString(&DesktopNameA, lpszDesktop);
+               RtlAnsiStringToUnicodeString(&DesktopNameU, &DesktopNameA, TRUE);
+  } else {
+    RtlInitUnicodeString(&DesktopNameU, NULL);
+  }
+
+  hDesktop = OpenDesktopW(
+    DesktopNameU.Buffer,
+    dwFlags,
+    fInherit,
+    dwDesiredAccess);
+
+       RtlFreeUnicodeString(&DesktopNameU);
+
+  return hDesktop;
+}
+
+HDESK
+STDCALL
+OpenDesktopW(
+  LPWSTR lpszDesktop,
+  DWORD dwFlags,
+  WINBOOL fInherit,
+  ACCESS_MASK dwDesiredAccess)
+{
+  UNICODE_STRING DesktopName;
+
+  RtlInitUnicodeString(&DesktopName, lpszDesktop);
+
+  return NtUserOpenDesktop(
+    &DesktopName,
+    dwFlags,
+    dwDesiredAccess);
+}
+
+HDESK
+STDCALL
+OpenInputDesktop(
+  DWORD dwFlags,
+  WINBOOL fInherit,
+  ACCESS_MASK dwDesiredAccess)
+{
+  return NtUserOpenInputDesktop(
+    dwFlags,
+    fInherit,
+    dwDesiredAccess);
+}
+
+WINBOOL
+STDCALL
+PaintDesktop(
+  HDC hdc)
+{
+  return NtUserPaintDesktop(hdc);
+}
+
+WINBOOL
+STDCALL
+SetThreadDesktop(
+  HDESK hDesktop)
+{
+  return NtUserSetThreadDesktop(hDesktop);
+}
+
+WINBOOL
+STDCALL
+SwitchDesktop(
+  HDESK hDesktop)
+{
+  return NtUserSwitchDesktop(hDesktop);
+}
+
+/* EOF */
diff --git a/reactos/lib/user32/misc/winsta.c b/reactos/lib/user32/misc/winsta.c
new file mode 100644 (file)
index 0000000..fff1391
--- /dev/null
@@ -0,0 +1,147 @@
+/* $Id: winsta.c,v 1.1 2001/06/12 17:50:27 chorns Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS user32.dll
+ * FILE:            lib/user32/misc/winsta.c
+ * PURPOSE:         Window stations
+ * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *      04-06-2001  CSH  Created
+ */
+#include <windows.h>
+#include <user32.h>
+#include <debug.h>
+
+
+WINBOOL
+STDCALL
+CloseWindowStation(
+  HWINSTA hWinSta)
+{
+  return NtUserCloseWindowStation(hWinSta);
+}
+
+HWINSTA
+STDCALL
+CreateWindowStationA(
+  LPSTR lpwinsta,
+  DWORD dwReserved,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpsa)
+{
+  ANSI_STRING WindowStationNameA;
+  UNICODE_STRING WindowStationNameU;
+  HWINSTA hWinSta;
+
+       if (lpwinsta != NULL) {
+               RtlInitAnsiString(&WindowStationNameA, lpwinsta);
+               RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA, TRUE);
+  } else {
+    RtlInitUnicodeString(&WindowStationNameU, NULL);
+  }
+
+  hWinSta = CreateWindowStationW(
+    WindowStationNameU.Buffer,
+    dwReserved,
+    dwDesiredAccess,
+    lpsa);
+
+       RtlFreeUnicodeString(&WindowStationNameU);
+
+  return hWinSta;
+}
+
+HWINSTA
+STDCALL
+CreateWindowStationW(
+  LPWSTR lpwinsta,
+  DWORD dwReserved,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpsa)
+{
+  UNICODE_STRING WindowStationName;
+
+  RtlInitAnsiString(&WindowStationName, lpwinsta);
+
+  return NtUserCreateWindowStation(
+    &WindowStationName,
+    dwDesiredAccess,
+    lpsa, 0, 0, 0);
+}
+
+WINBOOL
+STDCALL
+EnumWindowStationsA(
+  ENUMWINDOWSTATIONPROC lpEnumFunc,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EnumWindowStationsW(
+  ENUMWINDOWSTATIONPROC lpEnumFunc,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+HWINSTA
+STDCALL
+GetProcessWindowStation(VOID)
+{
+  return NtUserGetProcessWindowStation();
+}
+
+HWINSTA
+STDCALL
+OpenWindowStationA(
+  LPSTR lpszWinSta,
+  WINBOOL fInherit,
+  ACCESS_MASK dwDesiredAccess)
+{
+  ANSI_STRING WindowStationNameA;
+  UNICODE_STRING WindowStationNameU;
+  HWINSTA hWinSta;
+
+       if (lpszWinSta != NULL) {
+               RtlInitAnsiString(&WindowStationNameA, lpszWinSta);
+               RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA, TRUE);
+  } else {
+    RtlInitUnicodeString(&WindowStationNameU, NULL);
+  }
+
+  hWinSta = OpenWindowStationW(
+    WindowStationNameU.Buffer,
+    fInherit,
+    dwDesiredAccess);
+
+       RtlFreeUnicodeString(&WindowStationNameU);
+
+  return hWinSta;
+}
+
+HWINSTA
+STDCALL
+OpenWindowStationW(
+  LPWSTR lpszWinSta,
+  WINBOOL fInherit,
+  ACCESS_MASK dwDesiredAccess)
+{
+  UNICODE_STRING WindowStationName;
+
+  RtlInitAnsiString(&WindowStationName, lpszWinSta);
+
+  return NtUserOpenWindowStation(&WindowStationName, dwDesiredAccess);
+}
+
+WINBOOL
+STDCALL
+SetProcessWindowStation(
+  HWINSTA hWinSta)
+{
+  return NtUserSetProcessWindowStation(hWinSta);
+}
+
+/* EOF */
diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c
new file mode 100644 (file)
index 0000000..bb7c5d9
--- /dev/null
@@ -0,0 +1,311 @@
+/* $Id: class.c,v 1.9 2001/06/12 17:50:27 chorns Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS user32.dll
+ * FILE:            lib/user32/windows/class.c
+ * PURPOSE:         Window classes
+ * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *      09-05-2001  CSH  Created
+ */
+#include <windows.h>
+#include <user32.h>
+#include <debug.h>
+
+
+WINBOOL
+STDCALL
+GetClassInfoA(
+  HINSTANCE hInstance,
+  LPCSTR lpClassName,
+  LPWNDCLASS lpWndClass)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetClassInfoExA(
+  HINSTANCE hinst,
+  LPCSTR lpszClass,
+  LPWNDCLASSEX lpwcx)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetClassInfoExW(
+  HINSTANCE hinst,
+  LPCWSTR lpszClass,
+  LPWNDCLASSEX lpwcx)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetClassInfoW(
+  HINSTANCE hInstance,
+  LPCWSTR lpClassName,
+  LPWNDCLASS lpWndClass)
+{
+  return FALSE;
+}
+
+DWORD
+STDCALL
+GetClassLongA(
+  HWND hWnd,
+  int nIndex)
+{
+  return 0;
+}
+
+DWORD
+STDCALL
+GetClassLongW(
+  HWND hWnd,
+  int nIndex)
+{
+  return 0;
+}
+
+int
+STDCALL
+GetClassNameA(
+  HWND hWnd,
+  LPSTR lpClassName,
+  int nMaxCount)
+{
+  return 0;
+}
+
+int
+STDCALL
+GetClassNameW(
+  HWND hWnd,
+  LPWSTR lpClassName,
+  int nMaxCount)
+{
+  return 0;
+}
+
+WORD
+STDCALL
+GetClassWord(
+  HWND hWnd,
+  int nIndex)
+/*
+ * NOTE: Obsoleted in 32-bit windows
+ */
+{
+  return 0;
+}
+
+LONG
+STDCALL
+GetWindowLongA(
+  HWND hWnd,
+  int nIndex)
+{
+  return 0;
+}
+
+LONG
+STDCALL
+GetWindowLongW(
+  HWND hWnd,
+  int nIndex)
+{
+  return 0;
+}
+
+UINT
+STDCALL
+RealGetWindowClass(
+  HWND  hwnd,
+  LPSTR pszType,
+  UINT  cchType)
+{
+  return 0;
+}
+
+UINT
+STDCALL
+RealGetWindowClassA(
+  HWND  hwnd,
+  LPSTR pszType,
+  UINT  cchType)
+{
+  return 0;
+}
+
+UINT
+STDCALL
+RealGetWindowClassW(
+  HWND  hwnd,
+  LPWSTR pszType,
+  UINT  cchType)
+{
+  return 0;
+}
+
+ATOM
+STDCALL
+RegisterClassA(
+  CONST WNDCLASS *lpWndClass)
+{
+  WNDCLASSEX Class;
+
+  RtlMoveMemory(&Class.style, lpWndClass, sizeof(WNDCLASS));
+  Class.cbSize = sizeof(WNDCLASSEX);
+  Class.hIconSm = INVALID_HANDLE_VALUE;
+  return RegisterClassExA(&Class);
+}
+
+ATOM
+STDCALL
+RegisterClassExA(
+  CONST WNDCLASSEX *lpwcx)
+{
+  UNICODE_STRING MenuName;
+  UNICODE_STRING ClassName;
+  WNDCLASSEX Class;
+  RTL_ATOM Atom;
+
+  if (!RtlCreateUnicodeStringFromAsciiz(&MenuName, (PCSZ)lpwcx->lpszMenuName))
+  {
+    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+    return (ATOM)0;
+  }
+
+  if (!RtlCreateUnicodeStringFromAsciiz(&ClassName, (PCSZ)lpwcx->lpszMenuName))
+  {
+    RtlFreeUnicodeString(&MenuName);
+    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+    return (ATOM)0;
+  }
+
+  RtlMoveMemory(&Class, lpwcx, sizeof(WNDCLASSEX));
+  Class.lpszMenuName = (LPCTSTR)MenuName.Buffer;
+  Class.lpszClassName = (LPCTSTR)ClassName.Buffer;
+
+  Atom = NtUserRegisterClassExWOW(
+    (WNDCLASSEX*)lpwcx,
+    FALSE,
+    0,
+    0,
+    0,
+    0);
+
+  RtlFreeUnicodeString(&ClassName);
+
+  RtlFreeUnicodeString(&MenuName);
+
+  return (ATOM)Atom;
+}
+
+ATOM
+STDCALL
+RegisterClassExW(
+  CONST WNDCLASSEX *lpwcx)
+{
+  RTL_ATOM Atom;
+
+  Atom = NtUserRegisterClassExWOW(
+    (WNDCLASSEX*)lpwcx,
+    TRUE,
+    0,
+    0,
+    0,
+    0);
+
+  return (ATOM)Atom;
+}
+
+ATOM
+STDCALL
+RegisterClassW(
+  CONST WNDCLASS *lpWndClass)
+{
+  WNDCLASSEX Class;
+
+  RtlMoveMemory(&Class.style, lpWndClass, sizeof(WNDCLASS));
+  Class.cbSize = sizeof(WNDCLASSEX);
+  Class.hIconSm = INVALID_HANDLE_VALUE;
+  return RegisterClassExW(&Class);
+}
+
+DWORD
+STDCALL
+SetClassLongA(
+  HWND hWnd,
+  int nIndex,
+  LONG dwNewLong)
+{
+  return 0;
+}
+
+DWORD
+STDCALL
+SetClassLongW(
+  HWND hWnd,
+  int nIndex,
+  LONG dwNewLong)
+{
+  return 0;
+}
+
+WORD
+STDCALL
+SetClassWord(
+  HWND hWnd,
+  int nIndex,
+  WORD wNewWord)
+/*
+ * NOTE: Obsoleted in 32-bit windows
+ */
+{
+  return 0;
+}
+
+LONG
+STDCALL
+SetWindowLongA(
+  HWND hWnd,
+  int nIndex,
+  LONG dwNewLong)
+{
+  return 0;
+}
+
+LONG
+STDCALL
+SetWindowLongW(
+  HWND hWnd,
+  int nIndex,
+  LONG dwNewLong)
+{
+  return 0;
+}
+
+WINBOOL
+STDCALL
+UnregisterClassA(
+  LPCSTR lpClassName,
+  HINSTANCE hInstance)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+UnregisterClassW(
+  LPCWSTR lpClassName,
+  HINSTANCE hInstance)
+{
+  return FALSE;
+}
+
+/* EOF */
diff --git a/reactos/lib/user32/windows/message.c b/reactos/lib/user32/windows/message.c
new file mode 100644 (file)
index 0000000..918dcc5
--- /dev/null
@@ -0,0 +1,269 @@
+/* $Id: message.c,v 1.4 2001/06/12 17:50:27 chorns Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS user32.dll
+ * FILE:            lib/user32/windows/message.c
+ * PURPOSE:         Messages
+ * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *      06-06-2001  CSH  Created
+ */
+#include <windows.h>
+#include <user32.h>
+#include <debug.h>
+
+
+LPMSG
+MsgiAnsiToUnicodeMessage(
+  LPMSG AnsiMsg,
+  LPMSG UnicodeMsg)
+{
+  /* FIXME: Convert */
+  RtlMoveMemory(UnicodeMsg, AnsiMsg, sizeof(MSG));
+
+  return UnicodeMsg;
+}
+
+
+LRESULT
+STDCALL
+DispatchMessageA(
+  CONST MSG *lpmsg)
+{
+  MSG Msg;
+
+  return NtUserDispatchMessage(MsgiAnsiToUnicodeMessage((LPMSG)lpmsg, &Msg));
+}
+
+LRESULT
+STDCALL
+DispatchMessageW(
+  CONST MSG *lpmsg)
+{
+  return NtUserDispatchMessage((LPMSG)lpmsg);
+}
+
+WINBOOL
+STDCALL
+GetMessageA(
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax)
+{
+  return NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+}
+
+WINBOOL
+STDCALL
+GetMessageW(
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax)
+{
+  return NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+}
+
+WINBOOL
+STDCALL
+PeekMessageA(
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax,
+  UINT wRemoveMsg)
+{
+  return NtUserPeekMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
+}
+
+WINBOOL
+STDCALL
+PeekMessageW(
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax,
+  UINT wRemoveMsg)
+{
+  return NtUserPeekMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
+}
+
+WINBOOL
+STDCALL
+PostMessageA(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return NtUserPostMessage(hWnd, Msg, wParam, lParam);
+}
+
+WINBOOL
+STDCALL
+PostMessageW(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return NtUserPostMessage(hWnd, Msg, wParam, lParam);
+}
+
+VOID
+STDCALL
+PostQuitMessage(
+  int nExitCode)
+{
+}
+
+WINBOOL
+STDCALL
+PostThreadMessageA(
+  DWORD idThread,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return NtUserPostThreadMessage(idThread, Msg, wParam, lParam);
+}
+
+WINBOOL
+STDCALL
+PostThreadMessageW(
+  DWORD idThread,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return NtUserPostThreadMessage(idThread, Msg, wParam, lParam);
+}
+
+LRESULT
+STDCALL
+SendMessageA(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return (LRESULT)0;
+}
+
+WINBOOL
+STDCALL
+SendMessageCallbackA(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam,
+  SENDASYNCPROC lpCallBack,
+  ULONG_PTR dwData)
+{
+  return NtUserSendMessageCallback(
+    hWnd,
+    Msg,
+    wParam,
+    lParam,
+    lpCallBack,
+    dwData);
+}
+
+WINBOOL
+STDCALL
+SendMessageCallbackW(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam,
+  SENDASYNCPROC lpCallBack,
+  ULONG_PTR dwData)
+{
+  return NtUserSendMessageCallback(
+    hWnd,
+    Msg,
+    wParam,
+    lParam,
+    lpCallBack,
+    dwData);
+}
+
+LRESULT
+STDCALL
+SendMessageTimeoutA(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam,
+  UINT fuFlags,
+  UINT uTimeout,
+  PDWORD_PTR lpdwResult)
+{
+  return (LRESULT)0;
+}
+
+LRESULT
+STDCALL
+SendMessageTimeoutW(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam,
+  UINT fuFlags,
+  UINT uTimeout,
+  PDWORD_PTR lpdwResult)
+{
+  return (LRESULT)0;
+}
+
+
+LRESULT
+STDCALL
+SendMessageW(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return (LRESULT)0;
+}
+
+WINBOOL
+STDCALL
+SendNotifyMessageA(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+SendNotifyMessageW(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+TranslateMessage(
+  CONST MSG *lpMsg)
+{
+  return NtUserTranslateMessage((LPMSG)lpMsg, 0);
+}
+
+WINBOOL
+STDCALL
+WaitMessage(VOID)
+{
+  return FALSE;
+}
+
+/* EOF */
diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c
new file mode 100644 (file)
index 0000000..18a9b9a
--- /dev/null
@@ -0,0 +1,827 @@
+/* $Id: window.c,v 1.1 2001/06/12 17:50:27 chorns Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS user32.dll
+ * FILE:            lib/user32/windows/window.c
+ * PURPOSE:         Window management
+ * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *      06-06-2001  CSH  Created
+ */
+#include <windows.h>
+#include <user32.h>
+#include <window.h>
+#include <debug.h>
+
+
+WINBOOL
+STDCALL
+AdjustWindowRect(
+  LPRECT lpRect,
+  DWORD dwStyle,
+  WINBOOL bMenu)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+AdjustWindowRectEx(
+  LPRECT lpRect, 
+  DWORD dwStyle, 
+  WINBOOL bMenu, 
+  DWORD dwExStyle)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+AllowSetForegroundWindow(
+  DWORD dwProcessId)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+AnimateWindow(
+  HWND hwnd,
+  DWORD dwTime,
+  DWORD dwFlags)
+{
+  return FALSE;
+}
+
+UINT
+STDCALL
+ArrangeIconicWindows(
+  HWND hWnd)
+{
+  return 0;
+}
+
+HDWP
+STDCALL
+BeginDeferWindowPos(
+  int nNumWindows)
+{
+  return (HDWP)0;
+}
+
+WINBOOL
+STDCALL
+BringWindowToTop(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WORD
+STDCALL
+CascadeWindows(
+  HWND hwndParent,
+  UINT wHow,
+  CONST RECT *lpRect,
+  UINT cKids,
+  const HWND *lpKids)
+{
+  return 0;
+}
+
+HWND
+STDCALL
+ChildWindowFromPoint(
+  HWND hWndParent,
+  POINT Point)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+ChildWindowFromPointEx(
+  HWND hwndParent,
+  POINT pt,
+  UINT uFlags)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+CloseWindow(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+CreateWindowExA(
+  DWORD dwExStyle,
+  LPCSTR lpClassName,
+  LPCSTR lpWindowName,
+  DWORD dwStyle,
+  int x,
+  int y,
+  int nWidth,
+  int nHeight,
+  HWND hWndParent,
+  HMENU hMenu,
+  HINSTANCE hInstance,
+  LPVOID lpParam)
+{
+  UNICODE_STRING WindowName;
+  UNICODE_STRING ClassName;
+  HWND Handle;
+
+  if (IS_ATOM(lpClassName)) {
+    RtlInitUnicodeString(&ClassName, NULL);
+    ClassName.Buffer = (LPWSTR)lpClassName;
+  } else {
+    if (!RtlCreateUnicodeStringFromAsciiz(&(ClassName), (PCSZ)lpClassName)) {
+      SetLastError(ERROR_OUTOFMEMORY);
+      return (HWND)0;
+    }
+  }
+
+  if (!RtlCreateUnicodeStringFromAsciiz(&WindowName, (PCSZ)lpWindowName)) {
+    if (!IS_ATOM(lpClassName)) {
+      RtlFreeUnicodeString(&ClassName);
+    }
+    SetLastError(ERROR_OUTOFMEMORY);
+    return (HWND)0;
+  }
+
+  Handle = NtUserCreateWindowEx(
+    dwExStyle,
+    &ClassName,
+    &WindowName,
+    dwStyle,
+    x,
+    y,
+    nWidth,
+    nHeight,
+    hWndParent,
+    hMenu,
+    hInstance,
+    lpParam,
+    0);
+
+  RtlFreeUnicodeString(&WindowName);
+
+  if (!IS_ATOM(lpClassName)) {
+    RtlFreeUnicodeString(&ClassName);
+  }
+
+  return Handle;
+}
+
+HWND
+STDCALL
+CreateWindowExW(
+  DWORD dwExStyle,
+  LPCWSTR lpClassName,
+  LPCWSTR lpWindowName,
+  DWORD dwStyle,
+  int x,
+  int y,
+  int nWidth,
+  int nHeight,
+  HWND hWndParent,
+  HMENU hMenu,
+  HINSTANCE hInstance,
+  LPVOID lpParam)
+{
+  UNICODE_STRING WindowName;
+  UNICODE_STRING ClassName;
+  HANDLE Handle;
+
+  if (IS_ATOM(lpClassName)) {
+    RtlInitUnicodeString(&ClassName, NULL);
+    ClassName.Buffer = (LPWSTR)lpClassName;
+  } else {
+    RtlInitUnicodeString(&ClassName, lpClassName);
+  }
+
+  RtlInitUnicodeString(&WindowName, lpWindowName);
+
+  Handle = NtUserCreateWindowEx(
+    dwExStyle,
+    &ClassName,
+    &WindowName,
+    dwStyle,
+    x,
+    y,
+    nWidth,
+    nHeight,
+    hWndParent,
+    hMenu,
+    hInstance,
+    lpParam,
+    0);
+
+  return (HWND)Handle;
+}
+
+HDWP
+STDCALL
+DeferWindowPos(
+  HDWP hWinPosInfo,
+  HWND hWnd,
+  HWND hWndInsertAfter,
+  int x,
+  int y,
+  int cx,
+  int cy,
+  UINT uFlags)
+{
+  return (HDWP)0;
+}
+
+LRESULT
+STDCALL
+DefWindowProcA(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  switch (Msg)
+  { 
+    case WM_CREATE:
+      return 0;
+
+    case WM_DESTROY:
+      return 0;
+
+    default:
+      return 0;
+  }
+
+  return 0;
+}
+
+LRESULT
+STDCALL
+DefWindowProcW(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  return (LRESULT)0;
+}
+
+WINBOOL
+STDCALL
+DestroyWindow(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EndDeferWindowPos(
+  HDWP hWinPosInfo)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EnumChildWindows(
+  HWND hWndParent,
+  ENUMWINDOWSPROC lpEnumFunc,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EnumThreadWindows(
+  DWORD dwThreadId,
+  ENUMWINDOWSPROC lpfn,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+EnumWindows(
+  ENUMWINDOWSPROC lpEnumFunc,
+  LPARAM lParam)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+FindWindowA(
+  LPCSTR lpClassName,
+  LPCSTR lpWindowName)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+FindWindowExA(
+  HWND hwndParent,
+  HWND hwndChildAfter,
+  LPCSTR lpszClass,
+  LPCSTR lpszWindow)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+FindWindowExW(
+  HWND hwndParent,
+  HWND hwndChildAfter,
+  LPCWSTR lpszClass,
+  LPCWSTR lpszWindow)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+FindWindowW(
+  LPCWSTR lpClassName,
+  LPCWSTR lpWindowName)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+GetAltTabInfo(
+  HWND hwnd,
+  int iItem,
+  PALTTABINFO pati,
+  LPTSTR pszItemText,
+  UINT cchItemText)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetAltTabInfoA(
+  HWND hwnd,
+  int iItem,
+  PALTTABINFO pati,
+  LPSTR pszItemText,
+  UINT cchItemText)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetAltTabInfoW(
+  HWND hwnd,
+  int iItem,
+  PALTTABINFO pati,
+  LPWSTR pszItemText,
+  UINT cchItemText)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+GetAncestor(
+  HWND hwnd,
+  UINT gaFlags)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+GetClientRect(
+  HWND hWnd,
+  LPRECT lpRect)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+GetDesktopWindow(VOID)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+GetForegroundWindow(VOID)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+GetGUIThreadInfo(
+  DWORD idThread,
+  LPGUITHREADINFO lpgui)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+GetLastActivePopup(
+  HWND hWnd)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+GetParent(
+  HWND hWnd)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+GetProcessDefaultLayout(
+  DWORD *pdwDefaultLayout)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetTitleBarInfo(
+  HWND hwnd,
+  PTITLEBARINFO pti)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+GetTopWindow(
+  HWND hWnd)
+{
+  return (HWND)0;
+}
+
+HWND
+STDCALL
+GetWindow(
+  HWND hWnd,
+  UINT uCmd)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+GetWindowInfo(
+  HWND hwnd,
+  PWINDOWINFO pwi)
+{
+  return FALSE;
+}
+
+UINT
+STDCALL
+GetWindowModuleFileName(
+  HWND hwnd,
+  LPSTR lpszFileName,
+  UINT cchFileNameMax)
+{
+  return 0;
+}
+
+UINT
+STDCALL
+GetWindowModuleFileNameA(
+  HWND hwnd,
+  LPSTR lpszFileName,
+  UINT cchFileNameMax)
+{
+  return 0;
+}
+
+UINT
+STDCALL
+GetWindowModuleFileNameW(
+  HWND hwnd,
+  LPWSTR lpszFileName,
+  UINT cchFileNameMax)
+{
+  return 0;
+}
+
+WINBOOL
+STDCALL
+GetWindowPlacement(
+  HWND hWnd,
+  WINDOWPLACEMENT *lpwndpl)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+GetWindowRect(
+  HWND hWnd,
+  LPRECT lpRect)
+{
+  return FALSE;
+}
+
+int
+STDCALL
+GetWindowTextA(
+  HWND hWnd,
+  LPSTR lpString,
+  int nMaxCount)
+{
+  return 0;
+}
+
+int
+STDCALL
+GetWindowTextLengthA(
+  HWND hWnd)
+{
+  return 0;
+}
+
+int
+STDCALL
+GetWindowTextLengthW(
+  HWND hWnd)
+{
+  return 0;
+}
+
+int
+STDCALL
+GetWindowTextW(
+  HWND hWnd,
+  LPWSTR lpString,
+  int nMaxCount)
+{
+  return 0;
+}
+
+DWORD
+STDCALL
+GetWindowThreadProcessId(
+  HWND hWnd,
+  LPDWORD lpdwProcessId)
+{
+  return 0;
+}
+
+WINBOOL
+STDCALL
+IsChild(
+  HWND hWndParent,
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+IsIconic(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+IsWindow(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+IsWindowUnicode(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+IsWindowVisible(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+IsZoomed(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+LockSetForegroundWindow(
+  UINT uLockCode)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+MoveWindow(
+  HWND hWnd,
+  int X,
+  int Y,
+  int nWidth,
+  int nHeight,
+  WINBOOL bRepaint)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+OpenIcon(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+RealChildWindowFromPoint(
+  HWND hwndParent,
+  POINT ptParentClientCoords)
+{
+  return (HWND)0;
+}
+
+UINT
+RealGetWindowClass(
+  HWND  hwnd,
+  LPTSTR pszType,
+  UINT  cchType)
+{
+  return 0;
+}
+
+WINBOOL
+STDCALL
+SetForegroundWindow(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+SetLayeredWindowAttributes(
+  HWND hwnd,
+  COLORREF crKey,
+  BYTE bAlpha,
+  DWORD dwFlags)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+SetParent(
+  HWND hWndChild,
+  HWND hWndNewParent)
+{
+  return (HWND)0;
+}
+
+WINBOOL
+STDCALL
+SetProcessDefaultLayout(
+  DWORD dwDefaultLayout)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+SetWindowPlacement(
+  HWND hWnd,
+  CONST WINDOWPLACEMENT *lpwndpl)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+SetWindowPos(
+  HWND hWnd,
+  HWND hWndInsertAfter,
+  int X,
+  int Y,
+  int cx,
+  int cy,
+  UINT uFlags)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+SetWindowTextA(
+  HWND hWnd,
+  LPCSTR lpString)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+SetWindowTextW(
+  HWND hWnd,
+  LPCWSTR lpString)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+ShowOwnedPopups(
+  HWND hWnd,
+  WINBOOL fShow)
+{
+  return FALSE;
+}
+
+WINBOOL
+STDCALL
+ShowWindow(
+  HWND hWnd,
+  int nCmdShow)
+{
+  return NtUserShowWindow(hWnd, nCmdShow);
+}
+
+WINBOOL
+STDCALL
+ShowWindowAsync(
+  HWND hWnd,
+  int nCmdShow)
+{
+  return FALSE;
+}
+
+WORD
+STDCALL
+TileWindows(
+  HWND hwndParent,
+  UINT wHow,
+  CONST RECT *lpRect,
+  UINT cKids,
+  const HWND *lpKids)
+{
+  return 0;
+}
+
+WINBOOL
+STDCALL
+UpdateLayeredWindow(
+  HWND hwnd,
+  HDC hdcDst,
+  POINT *pptDst,
+  SIZE *psize,
+  HDC hdcSrc,
+  POINT *pptSrc,
+  COLORREF crKey,
+  BLENDFUNCTION *pblend,
+  DWORD dwFlags)
+{
+  return FALSE;
+}
+
+HWND
+STDCALL
+WindowFromPoint(
+  POINT Point)
+{
+  return (HWND)0;
+}
+
+/* EOF */
index b9e7eb6..b2e82a6 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.42 2001/06/01 17:14:40 ekohl Exp $
+# $Id: Makefile,v 1.43 2001/06/12 17:50:27 chorns Exp $
 #
 # ReactOS Operating System
 #
@@ -237,6 +237,7 @@ OBJECTS_EX = \
        ex/resource.o \
        ex/time.o \
        ex/sysinfo.o \
+       ex/win32k.o \
        ex/work.o \
        ex/zone.o
 
index dfb89d0..08217c0 100644 (file)
 #include <ddk/ntddk.h>
 #include <internal/ex.h>
 
-/* DATA **********************************************************************/
-
-POBJECT_TYPE EXPORTED ExDesktopObjectType = NULL;
-POBJECT_TYPE EXPORTED ExWindowStationObjectType = NULL;
+#define NDEBUG
+#include <internal/debug.h>
 
+/* DATA **********************************************************************/
 
 /* FUNCTIONS ****************************************************************/
 
@@ -42,6 +41,7 @@ ExInit (VOID)
 {
   ExInitTimeZoneInfo();
   ExInitializeWorkerThreads();
+  ExpWin32kInit();
 }
 
 
diff --git a/reactos/ntoskrnl/ex/win32k.c b/reactos/ntoskrnl/ex/win32k.c
new file mode 100644 (file)
index 0000000..09468eb
--- /dev/null
@@ -0,0 +1,341 @@
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*
+ * PROJECT:         ReactOS kernel
+ * FILE:            kernel/ex/win32k.c
+ * PURPOSE:         Executive Win32 subsystem support
+ * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *      04-06-2001  CSH  Created
+ */
+#include <limits.h>
+#include <ddk/ntddk.h>
+#include <internal/ex.h>
+#include <internal/ob.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+/* DATA **********************************************************************/
+
+POBJECT_TYPE EXPORTED ExWindowStationObjectType = NULL;
+POBJECT_TYPE EXPORTED ExDesktopObjectType = NULL;
+
+static GENERIC_MAPPING ExpWindowStationMapping = {
+    FILE_GENERIC_READ,
+         FILE_GENERIC_WRITE,
+         FILE_GENERIC_EXECUTE,
+         FILE_ALL_ACCESS };
+
+static GENERIC_MAPPING ExpDesktopMapping = {
+    FILE_GENERIC_READ,
+         FILE_GENERIC_WRITE,
+         FILE_GENERIC_EXECUTE,
+         FILE_ALL_ACCESS };
+
+/* FUNCTIONS ****************************************************************/
+
+
+NTSTATUS
+ExpWinStaObjectCreate(
+  PVOID ObjectBody,
+       PVOID Parent,
+       PWSTR RemainingPath,
+       struct _OBJECT_ATTRIBUTES* ObjectAttributes)
+{
+  PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
+  UNICODE_STRING UnicodeString;
+  NTSTATUS Status;
+
+  if (RemainingPath == NULL)
+       {
+               return STATUS_SUCCESS;
+       }
+
+  if (wcschr((RemainingPath + 1), '\\') != NULL)
+       {
+               return STATUS_UNSUCCESSFUL;
+       }
+
+  RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
+
+  DPRINT("Creating window station (0x%X)  Name (%wZ)\n", WinSta, &UnicodeString);
+
+  Status = RtlCreateUnicodeString(&WinSta->Name, UnicodeString.Buffer);
+  if (!NT_SUCCESS(Status))
+  {
+    return Status;
+  }
+
+  KeInitializeSpinLock(&WinSta->Lock);
+
+  InitializeListHead(&WinSta->DesktopListHead);
+
+#if 1
+  WinSta->AtomTable = NULL;
+#endif
+
+  Status = RtlCreateAtomTable(37, &WinSta->AtomTable);
+  if (!NT_SUCCESS(Status))
+  {
+    RtlFreeUnicodeString(&WinSta->Name);
+    return Status;
+  }
+
+       Status = ObReferenceObjectByPointer(
+         Parent,
+               STANDARD_RIGHTS_REQUIRED,
+               ObDirectoryType,
+               UserMode);
+       if (!NT_SUCCESS(Status))
+       {
+    RtlDestroyAtomTable(WinSta->AtomTable);
+    RtlFreeUnicodeString(&WinSta->Name);
+               return Status;
+       }
+
+       ObAddEntryDirectory(
+    Parent,
+               ObjectBody,
+               (RemainingPath + 1));
+  ObDereferenceObject(Parent);
+
+  DPRINT("Window station successfully created. Name (%wZ)\n", &WinSta->Name);
+
+  return STATUS_SUCCESS;
+}
+
+VOID
+ExpWinStaObjectDelete(
+  PVOID DeletedObject)
+{
+  PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeletedObject;
+
+  DPRINT("Deleting window station (0x%X)\n", WinSta);
+
+  RtlDestroyAtomTable(WinSta->AtomTable);
+
+  RtlFreeUnicodeString(&WinSta->Name);
+}
+
+PVOID
+ExpWinStaObjectFind(
+  PWINSTATION_OBJECT WinStaObject,
+       PWSTR Name,
+  ULONG Attributes)
+{
+  PLIST_ENTRY Current;
+  PDESKTOP_OBJECT CurrentObject;
+
+  DPRINT("WinStaObject (0x%X)  Name (%wS)\n", WinStaObject, Name);
+
+  if (Name[0] == 0)
+  {
+    return NULL;
+  }
+
+  Current = WinStaObject->DesktopListHead.Flink;
+  while (Current != &WinStaObject->DesktopListHead)
+  {
+    CurrentObject = CONTAINING_RECORD(Current, DESKTOP_OBJECT, ListEntry);
+    DPRINT("Scanning %wZ for %wS\n", &CurrentObject->Name, Name);
+    if (Attributes & OBJ_CASE_INSENSITIVE)
+    {
+      if (_wcsicmp(CurrentObject->Name.Buffer, Name) == 0)
+      {
+        DPRINT("Found desktop at (0x%X)\n", CurrentObject);
+        return CurrentObject;
+      }
+    }
+    else
+    {
+      if (wcscmp(CurrentObject->Name.Buffer, Name) == 0)
+      {
+        DPRINT("Found desktop at (0x%X)\n", CurrentObject);
+        return CurrentObject;
+      }
+    }
+    Current = Current->Flink;
+  }
+
+  DPRINT("Returning NULL\n");
+
+  return NULL;
+}
+
+NTSTATUS
+ExpWinStaObjectParse(
+  PVOID Object,
+       PVOID *NextObject,
+       PUNICODE_STRING FullPath,
+       PWSTR *Path,
+       POBJECT_TYPE ObjectType,
+       ULONG Attributes)
+{
+  PVOID FoundObject;
+  NTSTATUS Status;
+  PWSTR End;
+
+  DPRINT("Object (0x%X)  Path (0x%X)  *Path (%wS)\n", Object, Path, *Path);
+
+  *NextObject = NULL;
+
+  if ((Path == NULL) || ((*Path) == NULL))
+  {
+    return STATUS_SUCCESS;
+  }
+
+  End = wcschr((*Path) + 1, '\\');
+  if (End != NULL)
+  {
+    DPRINT("Name contains illegal characters\n");
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  FoundObject = ExpWinStaObjectFind(Object, (*Path) + 1, Attributes);
+  if (FoundObject == NULL)
+  {
+    DPRINT("Name was not found\n");
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  Status = ObReferenceObjectByPointer(
+    FoundObject,
+    STANDARD_RIGHTS_REQUIRED,
+    NULL,
+    UserMode);
+
+  *Path = NULL;
+
+  return Status;
+}
+
+NTSTATUS
+ExpDesktopObjectCreate(
+  PVOID ObjectBody,
+       PVOID Parent,
+       PWSTR RemainingPath,
+       struct _OBJECT_ATTRIBUTES* ObjectAttributes)
+{
+  PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)ObjectBody;
+  UNICODE_STRING UnicodeString;
+
+  if (RemainingPath == NULL)
+       {
+               return STATUS_SUCCESS;
+       }
+
+  if (wcschr((RemainingPath + 1), '\\') != NULL)
+       {
+               return STATUS_UNSUCCESSFUL;
+       }
+
+  RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
+
+  DPRINT("Creating desktop (0x%X)  Name (%wZ)\n", Desktop, &UnicodeString);
+
+  KeInitializeSpinLock(&Desktop->Lock);
+
+  Desktop->WindowStation = (PWINSTATION_OBJECT)Parent;
+
+  /* Put the desktop on the window station's list of associcated desktops */
+  ExInterlockedInsertTailList(
+    &Desktop->WindowStation->DesktopListHead,
+    &Desktop->ListEntry,
+    &Desktop->WindowStation->Lock);
+
+  return RtlCreateUnicodeString(&Desktop->Name, UnicodeString.Buffer);
+}
+
+VOID
+ExpDesktopObjectDelete(
+  PVOID DeletedObject)
+{
+  PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)DeletedObject;
+  KIRQL OldIrql;
+
+  DPRINT("Deleting desktop (0x%X)\n", Desktop);
+
+  /* Remove the desktop from the window station's list of associcated desktops */
+  KeAcquireSpinLock(&Desktop->WindowStation->Lock, &OldIrql);
+  RemoveEntryList(&Desktop->ListEntry);
+  KeReleaseSpinLock(&Desktop->WindowStation->Lock, OldIrql);
+
+  RtlFreeUnicodeString(&Desktop->Name);
+}
+
+VOID
+ExpWin32kInit(VOID)
+{
+  /* Create window station object type */
+  ExWindowStationObjectType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
+  if (ExWindowStationObjectType == NULL)
+  {
+    CPRINT("Could not create window station object type\n");
+    KeBugCheck(0);
+  }
+
+  ExWindowStationObjectType->Tag = TAG('W', 'I', 'N', 'S');
+  ExWindowStationObjectType->TotalObjects = 0;
+  ExWindowStationObjectType->TotalHandles = 0;
+  ExWindowStationObjectType->MaxObjects = ULONG_MAX;
+  ExWindowStationObjectType->MaxHandles = ULONG_MAX;
+  ExWindowStationObjectType->PagedPoolCharge = 0;
+  ExWindowStationObjectType->NonpagedPoolCharge = sizeof(WINSTATION_OBJECT);
+  ExWindowStationObjectType->Mapping = &ExpWindowStationMapping;
+  ExWindowStationObjectType->Dump = NULL;
+  ExWindowStationObjectType->Open = NULL;
+  ExWindowStationObjectType->Close = NULL;
+  ExWindowStationObjectType->Delete = ExpWinStaObjectDelete;
+  ExWindowStationObjectType->Parse = ExpWinStaObjectParse;
+  ExWindowStationObjectType->Security = NULL;
+  ExWindowStationObjectType->QueryName = NULL;
+  ExWindowStationObjectType->OkayToClose = NULL;
+  ExWindowStationObjectType->Create = ExpWinStaObjectCreate;
+  RtlInitUnicodeString(&ExWindowStationObjectType->TypeName, L"WindowStation");
+
+  /* Create desktop object type */
+  ExDesktopObjectType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
+  if (ExDesktopObjectType == NULL)
+  {
+    CPRINT("Could not create desktop object type\n");
+    KeBugCheck(0);
+  }
+
+  ExDesktopObjectType->Tag = TAG('D', 'E', 'S', 'K');
+  ExDesktopObjectType->TotalObjects = 0;
+  ExDesktopObjectType->TotalHandles = 0;
+  ExDesktopObjectType->MaxObjects = ULONG_MAX;
+  ExDesktopObjectType->MaxHandles = ULONG_MAX;
+  ExDesktopObjectType->PagedPoolCharge = 0;
+  ExDesktopObjectType->NonpagedPoolCharge = sizeof(DESKTOP_OBJECT);
+  ExDesktopObjectType->Mapping = &ExpDesktopMapping;
+  ExDesktopObjectType->Dump = NULL;
+  ExDesktopObjectType->Open = NULL;
+  ExDesktopObjectType->Close = NULL;
+  ExDesktopObjectType->Delete = ExpDesktopObjectDelete;
+  ExDesktopObjectType->Parse = NULL;
+  ExDesktopObjectType->Security = NULL;
+  ExDesktopObjectType->QueryName = NULL;
+  ExDesktopObjectType->OkayToClose = NULL;
+  ExDesktopObjectType->Create = ExpDesktopObjectCreate;
+  RtlInitUnicodeString(&ExDesktopObjectType->TypeName, L"Desktop");
+}
+
+/* EOF */
index 525439f..6f354b1 100644 (file)
@@ -8,12 +8,39 @@
 #include <ddk/ntddk.h>
 #include <ntos/time.h>
 
+typedef struct _WINSTATION_OBJECT
+{   
+   CSHORT Type;
+   CSHORT Size;
+
+   KSPIN_LOCK Lock;
+   UNICODE_STRING Name;
+   LIST_ENTRY DesktopListHead;
+   PRTL_ATOM_TABLE AtomTable;
+   PVOID HandleTable;
+   /* FIXME: Clipboard */
+} WINSTATION_OBJECT, *PWINSTATION_OBJECT;
+
+typedef struct _DESKTOP_OBJECT
+{   
+   CSHORT Type;
+   CSHORT Size;
+
+   LIST_ENTRY ListEntry;
+   KSPIN_LOCK Lock;
+   UNICODE_STRING Name;
+   struct _WINSTATION_OBJECT *WindowStation;
+} DESKTOP_OBJECT, *PDESKTOP_OBJECT;
+
 /* GLOBAL VARIABLES *********************************************************/
 
 TIME_ZONE_INFORMATION SystemTimeZoneInfo;
 
 /* INITIALIZATION FUNCTIONS *************************************************/
 
+VOID
+ExpWin32kInit(VOID);
+
 VOID 
 ExInit (VOID);
 VOID 
index a212a10..cf49af2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: object.c,v 1.37 2001/05/05 09:33:16 ekohl Exp $
+/* $Id: object.c,v 1.38 2001/06/12 17:50:27 chorns Exp $
  * 
  * COPYRIGHT:     See COPYING in the top level directory
  * PROJECT:       ReactOS kernel
@@ -324,12 +324,12 @@ ObReferenceObjectByPointer(PVOID ObjectBody,
    
    if (ObjectType != NULL && ObjectHeader->ObjectType != ObjectType)
      {
-       DPRINT("Failed %x (type was %x %S) should %x\n",
+       DPRINT("Failed %x (type was %x %S) should be %x %S\n",
                ObjectHeader,
                ObjectHeader->ObjectType,
                ObjectHeader->ObjectType->TypeName.Buffer,
-               ObjectType);
-       KeBugCheck(0);
+               ObjectType,
+    ObjectType->TypeName.Buffer);
        return(STATUS_UNSUCCESSFUL);
      }
    if (ObjectHeader->ObjectType == PsProcessType)
index a6a76c9..413965e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.63 2001/04/21 12:39:05 ekohl Exp $
+/* $Id: process.c,v 1.64 2001/06/12 17:50:28 chorns Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS kernel
@@ -246,7 +246,7 @@ VOID PiDeleteProcess(PVOID ObjectBody)
 {
    KIRQL oldIrql;
    
-   DPRINT1("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
+   DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
    
    KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
    RemoveEntryList(&((PEPROCESS)ObjectBody)->ProcessListEntry);
index 9b9cd59..373c155 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: atom.c,v 1.1 2001/05/27 11:16:09 ekohl Exp $
+/* $Id: atom.c,v 1.2 2001/06/12 17:50:28 chorns Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -15,7 +15,7 @@
 #include <internal/handle.h>
 #include <internal/pool.h>
 
-//#define NDEBUG
+#define NDEBUG
 #include <internal/debug.h>
 
 
index 45e82c5..f8d1506 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.24 2001/05/01 23:06:25 phreak Exp $
+/* $Id: init.c,v 1.25 2001/06/12 17:50:28 chorns Exp $
  *
  * init.c - Session Manager initialization
  * 
@@ -239,11 +239,41 @@ BOOL InitSessionManager (HANDLE   Children[])
    PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
    RTL_PROCESS_INFO ProcessInfo;
    HANDLE CsrssInitEvent;
-
+   HANDLE      WindowsDirectory;
    WCHAR UnicodeBuffer[MAX_PATH];
    PKUSER_SHARED_DATA SharedUserData = 
        (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
-   
+
+   /*
+    * FIXME: The '\Windows' directory is created by csrss.exe but
+    *        win32k.sys needs it at intialization and it is loaded
+    *        before csrss.exe
+    */
+
+   /*
+         * Create the '\Windows' directory
+         */
+   RtlInitUnicodeString(
+      &UnicodeString,
+      L"\\Windows");
+
+        InitializeObjectAttributes(
+                 &ObjectAttributes,
+                 &UnicodeString,
+                 0,
+                 NULL,
+                 NULL);
+
+   Status = ZwCreateDirectoryObject(
+                 &WindowsDirectory,
+                 0,
+                 &ObjectAttributes);
+   if (!NT_SUCCESS(Status))
+     {
+   DisplayString (L"SM: Could not create \\Windows directory!\n");
+   return FALSE;
+     }
+
    /* Create the "\SmApiPort" object (LPC) */
    RtlInitUnicodeString (&UnicodeString,
                         L"\\SmApiPort");
index 84032b1..1a79dc9 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.2 2001/02/06 03:58:34 phreak Exp $
+# $Id: makefile,v 1.3 2001/06/12 17:50:26 chorns Exp $
 #
 # Logon/login Application
 #
@@ -13,7 +13,9 @@ BASE_CFLAGS = -I../../include
 
 OBJECTS = winlogon.o $(TARGET).coff
 
-LIBS = ../../../lib/kernel32/kernel32.a ../../../lib/ntdll/ntdll.a
+LIBS = $(PATH_TO_TOP)/lib/kernel32/kernel32.a \
+       $(PATH_TO_TOP)/lib/ntdll/ntdll.a \
+       $(PATH_TO_TOP)/lib/user32/user32.a
 
 all: $(TARGET).exe
 
index 277d537..5392a42 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: winlogon.c,v 1.5 2001/04/26 01:36:32 phreak Exp $
+/* $Id: winlogon.c,v 1.6 2001/06/12 17:50:26 chorns Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 
 /* GLOBALS ******************************************************************/
 
+HWINSTA InteractiveWindowStation;   /* WinSta0 */
+HDESK ApplicationDesktop;           /* WinSta0\Default */
+HDESK WinlogonDesktop;              /* WinSta0\Winlogon */
+HDESK ScreenSaverDesktop;           /* WinSta0\Screen-Saver */
+
 /* FUNCTIONS *****************************************************************/
 
 void PrintString (char* fmt,...)
@@ -221,12 +226,68 @@ WinMain(HINSTANCE hInstance,
    DWORD Result;
    CHAR LoginName[255];
    CHAR Password[255];
+   BOOL Success;
    ULONG i;
-   
-   /* 
-    * FIXME: Create WindowStations here. At the moment lsass and services
-    * share ours. Create a new console intead.
+
+   /*
+    * FIXME: Create a security descriptor with
+    *        one ACE containing the Winlogon SID
+    */
+
+   /*
+    * Create the interactive window station
     */
+   InteractiveWindowStation = CreateWindowStationW(
+      L"WinSta0", 0, GENERIC_ALL, NULL);
+
+   /*
+    * Set the process window station
+    */
+   SetProcessWindowStation(InteractiveWindowStation);
+
+   /*
+    * Create the application desktop
+    */
+   ApplicationDesktop = CreateDesktopW(
+      L"Default",
+      NULL,
+      NULL,
+      0,      /* FIXME: Set some flags */
+      GENERIC_ALL,
+      NULL);  /* FIXME: Create security descriptor (access to all) */
+
+   /*
+    * Create the winlogon desktop
+    */
+   WinlogonDesktop = CreateDesktopW(
+      L"Winlogon",
+      NULL,
+      NULL,
+      0,      /* FIXME: Set some flags */
+      GENERIC_ALL,
+      NULL);  /* FIXME: Create security descriptor (access for winlogon only) */
+
+   /*
+    * Create the screen saver desktop
+    */
+   ScreenSaverDesktop = CreateDesktopW(
+      L"Screen-Saver",
+      NULL,
+      NULL,
+      0,      /* FIXME: Set some flags */
+      GENERIC_ALL,
+      NULL);  /* FIXME: Create security descriptor (access to all) */
+
+   /*
+    * Switch to winlogon desktop
+    */
+   Success = SwitchDesktop(WinlogonDesktop);
+   if (!Success)
+   {
+      DbgPrint("Cannot switch to Winlogon desktop (0x%X)\n", GetLastError());
+   }
+
+
    AllocConsole();
    
    /* start system processes (services.exe & lsass.exe) */
@@ -246,6 +307,12 @@ WinMain(HINSTANCE hInstance,
      }
 #endif
    
+   /* FIXME: Create a window class and associate a Winlogon
+    *        window procedure with it.
+    *        Register SAS with the window.
+    *        Register for logoff notification
+    */
+
    /* Main loop */
    for (;;)
      {
diff --git a/reactos/subsys/win32k/include/class.h b/reactos/subsys/win32k/include/class.h
new file mode 100644 (file)
index 0000000..51565a5
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef __WIN32K_CLASS_H
+#define __WIN32K_CLASS_H
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+
+#define IS_ATOM(x) \
+  (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
+
+
+typedef struct _WNDCLASS_OBJECT
+{
+  WNDCLASSEX Class;
+  BOOL Unicode;
+  LIST_ENTRY ListEntry;
+} WNDCLASS_OBJECT, *PWNDCLASS_OBJECT;
+
+
+NTSTATUS
+InitClassImpl(VOID);
+
+NTSTATUS
+CleanupClassImpl(VOID);
+
+NTSTATUS
+ClassReferenceClassByName(
+  PWNDCLASS_OBJECT *Class,
+  LPWSTR ClassName);
+
+NTSTATUS
+ClassReferenceClassByAtom(
+  PWNDCLASS_OBJECT *Class,
+  RTL_ATOM ClassAtom);
+
+NTSTATUS
+ClassReferenceClassByNameOrAtom(
+  PWNDCLASS_OBJECT *Class,
+  LPWSTR ClassNameOrAtom);
+
+#endif /* __WIN32K_CLASS_H */
+
+/* EOF */
diff --git a/reactos/subsys/win32k/include/error.h b/reactos/subsys/win32k/include/error.h
new file mode 100644 (file)
index 0000000..2ef7d83
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __WIN32K_ERROR_H
+#define __WIN32K_ERROR_H
+
+VOID
+SetLastNtError(
+  NTSTATUS Status);
+
+VOID
+SetLastWin32Error(
+  DWORD Status);
+
+#endif /* __WIN32K_ERROR_H */
+
+/* EOF */
diff --git a/reactos/subsys/win32k/include/guicheck.h b/reactos/subsys/win32k/include/guicheck.h
new file mode 100644 (file)
index 0000000..9eca860
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __WIN32K_GUICHECK_H
+#define __WIN32K_GUICHECK_H
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+
+VOID
+GuiCheck(VOID);
+
+#endif /* __WIN32K_GUICHECK_H */
+
+/* EOF */
diff --git a/reactos/subsys/win32k/include/msgqueue.h b/reactos/subsys/win32k/include/msgqueue.h
new file mode 100644 (file)
index 0000000..9e34e46
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __WIN32K_MSGQUEUE_H
+#define __WIN32K_MSGQUEUE_H
+
+#include <windows.h>
+
+typedef struct _USER_MESSAGE
+{
+  LIST_ENTRY ListEntry;
+  MSG Msg;
+} USER_MESSAGE, *PUSER_MESSAGE;
+
+typedef struct _USER_MESSAGE_QUEUE
+{
+   LIST_ENTRY ListHead;
+   PFAST_MUTEX ListLock;
+} USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;
+
+
+VOID
+MsqInitializeMessage(
+  PUSER_MESSAGE Message,
+  LPMSG Msg);
+
+PUSER_MESSAGE
+MsqCreateMessage(
+  LPMSG Msg);
+
+VOID
+MsqDestroyMessage(
+  PUSER_MESSAGE Message);
+
+VOID
+MsqPostMessage(
+  PUSER_MESSAGE_QUEUE MessageQueue,
+  PUSER_MESSAGE Message);
+
+BOOL
+MsqRetrieveMessage(
+  PUSER_MESSAGE_QUEUE MessageQueue,
+  PUSER_MESSAGE *Message);
+
+VOID
+MsqInitializeMessageQueue(
+  PUSER_MESSAGE_QUEUE MessageQueue);
+
+VOID
+MsqFreeMessageQueue(
+  PUSER_MESSAGE_QUEUE MessageQueue);
+
+PUSER_MESSAGE_QUEUE
+MsqCreateMessageQueue(VOID);
+
+VOID
+MsqDestroyMessageQueue(
+  PUSER_MESSAGE_QUEUE MessageQueue);
+
+#endif /* __WIN32K_MSGQUEUE_H */
+
+/* EOF */
diff --git a/reactos/subsys/win32k/include/object.h b/reactos/subsys/win32k/include/object.h
new file mode 100644 (file)
index 0000000..c70a070
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef __WIN32K_OBJECT_H
+#define __WIN32K_OBJECT_H
+
+#include <windows.h>
+
+typedef enum {
+  otUnknown = 0,
+  otClass,
+  otWindow
+} USER_OBJECT_TYPE;
+
+typedef struct _USER_OBJECT_HEADER
+/*
+ * Header for user object
+ */
+{
+  USER_OBJECT_TYPE Type;
+  LONG HandleCount;
+  LONG RefCount;
+  CSHORT Size;
+} USER_OBJECT_HEADER, *PUSER_OBJECT_HEADER;
+
+
+typedef struct _USER_HANDLE
+{
+  PVOID ObjectBody;
+} USER_HANDLE, *PUSER_HANDLE;
+
+#define HANDLE_BLOCK_ENTRIES ((PAGESIZE-sizeof(LIST_ENTRY))/sizeof(USER_HANDLE))
+
+typedef struct _USER_HANDLE_BLOCK
+{
+  LIST_ENTRY ListEntry;
+  USER_HANDLE Handles[HANDLE_BLOCK_ENTRIES];
+} USER_HANDLE_BLOCK, *PUSER_HANDLE_BLOCK;
+
+typedef struct _USER_HANDLE_TABLE
+{
+   LIST_ENTRY ListHead;
+   PFAST_MUTEX ListLock;
+} USER_HANDLE_TABLE, *PUSER_HANDLE_TABLE;
+
+
+ULONG
+ObmGetReferenceCount(
+  PVOID ObjectBody);
+
+ULONG
+ObmGetHandleCount(
+  PVOID ObjectBody);
+
+VOID
+ObmReferenceObject(
+  PVOID ObjectBody);
+
+VOID
+ObmDereferenceObject(
+  PVOID ObjectBody);
+
+NTSTATUS
+ObmReferenceObjectByPointer(
+  PVOID ObjectBody,
+  USER_OBJECT_TYPE ObjectType);
+
+PVOID
+ObmCreateObject(
+  PUSER_HANDLE_TABLE HandleTable,
+  PHANDLE Handle,
+       USER_OBJECT_TYPE ObjectType,
+  ULONG ObjectSize);
+
+NTSTATUS
+ObmCreateHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  PVOID ObjectBody,
+       PHANDLE HandleReturn);
+
+NTSTATUS
+ObmReferenceObjectByHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  HANDLE Handle,
+       USER_OBJECT_TYPE ObjectType,
+       PVOID* Object);
+
+NTSTATUS
+ObmCloseHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  HANDLE Handle);
+
+VOID
+ObmInitializeHandleTable(
+  PUSER_HANDLE_TABLE HandleTable);
+
+VOID
+ObmFreeHandleTable(
+  PUSER_HANDLE_TABLE HandleTable);
+
+PUSER_HANDLE_TABLE
+ObmCreateHandleTable(VOID);
+
+VOID
+ObmDestroyHandleTable(
+  PUSER_HANDLE_TABLE HandleTable);
+
+#endif /* __WIN32K_OBJECT_H */
+
+/* EOF */
diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h
new file mode 100644 (file)
index 0000000..96d09ad
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef __WIN32K_WINDOW_H
+#define __WIN32K_WINDOW_H
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+#include <include/class.h>
+
+typedef struct _WINDOW_OBJECT
+{
+  PWNDCLASS_OBJECT Class;
+  DWORD ExStyle;
+  UNICODE_STRING WindowName;
+  DWORD Style;
+  int x;
+  int y;
+  int Width;
+  int Height;
+  HWND Parent;
+  HMENU Menu;
+  HINSTANCE Instance;
+  LPVOID Parameters;
+  LIST_ENTRY ListEntry;
+} WINDOW_OBJECT, *PWINDOW_OBJECT;
+
+
+NTSTATUS
+InitWindowImpl(VOID);
+
+NTSTATUS
+CleanupWindowImpl(VOID);
+
+#endif /* __WIN32K_WINDOW_H */
+
+/* EOF */
diff --git a/reactos/subsys/win32k/include/winsta.h b/reactos/subsys/win32k/include/winsta.h
new file mode 100644 (file)
index 0000000..1e39ed9
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef __WIN32K_WINSTA_H
+#define __WIN32K_WINSTA_H
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+#include <../ntoskrnl/include/internal/ex.h>
+
+/*
+* FIXME: NtCurrentPeb() does not work (returns 0)
+#define PROCESS_WINDOW_STATION() \
+  (HWINSTA)(NtCurrentPeb()->ProcessWindowStation);
+
+#define SET_PROCESS_WINDOW_STATION(WinSta) \
+  (NtCurrentPeb()->ProcessWindowStation = (PVOID)(WinSta));
+*/
+
+#define PROCESS_WINDOW_STATION() \
+  ((HWINSTA)(((PPEB)PEB_BASE)->ProcessWindowStation))
+
+#define SET_PROCESS_WINDOW_STATION(WinSta) \
+  (((PPEB)PEB_BASE)->ProcessWindowStation = (PVOID)(WinSta))
+
+
+NTSTATUS
+InitWindowStationImpl(VOID);
+
+NTSTATUS
+CleanupWindowStationImpl(VOID);
+
+NTSTATUS
+ValidateWindowStationHandle(
+  HWINSTA WindowStation,
+  KPROCESSOR_MODE AccessMode,
+  ACCESS_MASK DesiredAccess,
+  PWINSTATION_OBJECT *Object);
+
+NTSTATUS
+ValidateDesktopHandle(
+  HDESK Desktop,
+  KPROCESSOR_MODE AccessMode,
+  ACCESS_MASK DesiredAccess,
+  PDESKTOP_OBJECT *Object);
+
+#endif /* __WIN32K_WINSTA_H */
+
+/* EOF */
index c4162d2..f23604c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dllmain.c,v 1.19 2001/05/02 12:33:42 jfilby Exp $
+/* $Id: dllmain.c,v 1.20 2001/06/12 17:50:29 chorns Exp $
  * 
  *  Entry Point for win32k.sys
  */
 
 #include <win32k/win32k.h>
 
+#include <include/winsta.h>
+#include <include/class.h>
+#include <include/window.h>
+
 /*
  * NOTE: the table is actually in the file ./svctab.c,
  * generated by iface/addsys/mktab.c + w32ksvc.db
@@ -28,6 +32,7 @@ DllMain (
   IN   PDRIVER_OBJECT  DriverObject,
   IN   PUNICODE_STRING RegistryPath)
 {
+  NTSTATUS Status;
   BOOLEAN Result;
 
   DbgPrint("Win32 kernel mode driver\n");
@@ -44,6 +49,28 @@ DllMain (
   }
 
   DbgPrint("System services added successfully!\n");
+
+  Status = InitWindowStationImpl();
+  if (!NT_SUCCESS(Status))
+  {
+    DbgPrint("Failed to initialize window station implementation!\n");
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  Status = InitClassImpl();
+  if (!NT_SUCCESS(Status))
+  {
+    DbgPrint("Failed to initialize window class implementation!\n");
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  Status = InitWindowImpl();
+  if (!NT_SUCCESS(Status))
+  {
+    DbgPrint("Failed to initialize window implementation!\n");
+    return STATUS_UNSUCCESSFUL;
+  }
+
   return STATUS_SUCCESS;
 }
 
index f542dde..63c398a 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.32 2001/06/04 14:39:43 chorns Exp $
+# $Id: makefile,v 1.33 2001/06/12 17:50:28 chorns Exp $
 #
 # WIN32K.SYS build spec
 #
@@ -9,7 +9,7 @@ TARGET=win32k
 # from atheos appserver makefile
 COPTS   = -pipe -O3 -I./freetype/include -c -Wall
 
-CFLAGS = -I.
+CFLAGS = -I. -DUNICODE
 
 #define FT_FLAT_COMPILE
 
@@ -17,9 +17,11 @@ ENG_OBJECTS= eng/debug.o eng/mem.o eng/brush.o eng/bitblt.o eng/clip.o eng/copyb
                 eng/device.o eng/handle.o eng/lineto.o eng/paint.o eng/palette.o \
                eng/surface.o eng/xlate.o eng/transblt.o eng/mouse.o
 MAIN_OBJECTS = main/dllmain.o
-MISC_OBJECTS = misc/driver.o misc/math.o
+MISC_OBJECTS = misc/driver.o misc/error.o misc/math.o misc/object.o
 LDR_OBJECTS = ldr/loader.o
-NTUSER_OBJECTS = ntuser/stubs.o
+NTUSER_OBJECTS = ntuser/class.o ntuser/guicheck.o ntuser/hook.o \
+                 ntuser/message.o ntuser/msgqueue.o ntuser/stubs.o \
+                 ntuser/window.o ntuser/winsta.o
 OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o  \
                   objects/color.o objects/coord.o objects/dc.o  \
                   objects/fillshap.o objects/gdiobj.o objects/icm.o  \
diff --git a/reactos/subsys/win32k/misc/error.c b/reactos/subsys/win32k/misc/error.c
new file mode 100644 (file)
index 0000000..d58ddd7
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Errors
+ * FILE:             subsys/win32k/misc/error.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <include/error.h>
+
+
+VOID
+SetLastNtError(
+  NTSTATUS Status)
+{
+  SetLastWin32Error(RtlNtStatusToDosError(Status));
+}
+
+VOID
+SetLastWin32Error(
+  DWORD Status)
+{
+  PNT_TEB Teb = NtCurrentTeb();
+
+       if (NULL != Teb)
+       {
+               Teb->LastErrorValue = Status;
+       }
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/misc/object.c b/reactos/subsys/win32k/misc/object.c
new file mode 100644 (file)
index 0000000..74f3c33
--- /dev/null
@@ -0,0 +1,537 @@
+/* $Id: object.c,v 1.1 2001/06/12 17:51:51 chorns Exp $
+ *
+ * COPYRIGHT:      See COPYING in the top level directory
+ * PROJECT:        ReactOS kernel
+ * PURPOSE:        User object manager
+ * FILE:           subsys/win32k/misc/object.c
+ * PROGRAMMERS:    David Welch (welch@cwcom.net)
+ *                 Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * UPDATE HISTORY:
+ *     06-06-2001  CSH  Ported kernel object manager
+ */
+#include <ddk/ntddk.h>
+#include <include/object.h>
+
+#define NDEBUG
+#include <debug.h>
+
+PVOID
+HEADER_TO_BODY(
+  PUSER_OBJECT_HEADER ObjectHeader)
+{
+   return (((PUSER_OBJECT_HEADER)ObjectHeader) + 1);
+}
+
+PUSER_OBJECT_HEADER BODY_TO_HEADER(
+  PVOID ObjectBody)
+{
+  return (((PUSER_OBJECT_HEADER)ObjectBody) - 1);
+}
+
+static VOID
+ObmpLockHandleTable(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+//   ExAcquireFastMutex(HandleTable->ListLock);
+}
+
+static VOID
+ObmpUnlockHandleTable(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+//   ExReleaseFastMutex(AtomTable->ListLock);
+}
+
+VOID
+ObmpPerformRetentionChecks(
+  PUSER_OBJECT_HEADER ObjectHeader)
+{
+  if (ObjectHeader->RefCount < 0)
+  {
+    DbgPrint("ObjectHeader 0x%X has invalid reference count (%d)\n",
+                 ObjectHeader, ObjectHeader->RefCount);
+  }
+
+  if (ObjectHeader->HandleCount < 0)
+  {
+    DbgPrint("Object 0x%X has invalid handle count (%d)\n",
+      ObjectHeader, ObjectHeader->HandleCount);
+  }
+
+  if ((ObjectHeader->RefCount == 0) && (ObjectHeader->HandleCount == 0))
+  {
+    ExFreePool(ObjectHeader);
+  }
+}
+
+PUSER_HANDLE
+ObmpGetObjectByHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  HANDLE Handle)
+/*
+ * FUNCTION: Get the data structure for a handle
+ * ARGUMENTS:
+ *   HandleTable = Table to search
+ *   Handle      = Handle to get data structure for
+ * RETURNS:
+ *   Pointer to the data structure identified by the handle on success,
+ *   NULL on failure
+ */
+{
+  ULONG Count = ((ULONG)Handle / HANDLE_BLOCK_ENTRIES);
+  ULONG Index = (((ULONG)Handle) - 1) >> 2;
+  PUSER_HANDLE_BLOCK Block = NULL;
+  PLIST_ENTRY Current;
+  ULONG i;
+
+  Current = HandleTable->ListHead.Flink;
+
+  for (i = 0; i < Count; i++)
+  {
+    Current = Current->Flink;
+    if (Current == &(HandleTable->ListHead))
+    {
+      return NULL;
+    }
+  }
+
+  Block = CONTAINING_RECORD(Current, USER_HANDLE_BLOCK, ListEntry);
+  return &(Block->Handles[Index % HANDLE_BLOCK_ENTRIES]);
+}
+
+VOID
+ObmpCloseAllHandles(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+  PLIST_ENTRY CurrentEntry;
+  PUSER_HANDLE_BLOCK Current;
+  PVOID ObjectBody;
+  ULONG i;
+
+  ObmpLockHandleTable(HandleTable);
+
+  CurrentEntry = HandleTable->ListHead.Flink;
+
+  while (CurrentEntry != &HandleTable->ListHead)
+  {
+    Current = CONTAINING_RECORD(CurrentEntry, USER_HANDLE_BLOCK, ListEntry);
+
+    for (i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
+    {
+      ObjectBody = Current->Handles[i].ObjectBody;
+
+      if (ObjectBody != NULL)
+      {
+        PUSER_OBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+        ObmReferenceObjectByPointer(ObjectBody, otUnknown);
+        ObjectHeader->HandleCount--;
+                   Current->Handles[i].ObjectBody = NULL;
+
+                   ObmpUnlockHandleTable(HandleTable);
+
+        ObmDereferenceObject(ObjectBody);
+
+        ObmpLockHandleTable(HandleTable);
+                   CurrentEntry = &HandleTable->ListHead;
+                   break;
+      }
+    }
+
+    CurrentEntry = CurrentEntry->Flink;
+  }
+
+  ObmpUnlockHandleTable(HandleTable);
+}
+
+VOID
+ObmpDeleteHandleTable(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+  PUSER_HANDLE_BLOCK Current;
+  PLIST_ENTRY CurrentEntry;
+
+  ObmpCloseAllHandles(HandleTable);
+
+  CurrentEntry = RemoveHeadList(&HandleTable->ListHead);
+
+  while (CurrentEntry != &HandleTable->ListHead)
+  {
+    Current = CONTAINING_RECORD(CurrentEntry,
+      USER_HANDLE_BLOCK,
+       ListEntry);
+
+    ExFreePool(Current);
+
+         CurrentEntry = RemoveHeadList(&HandleTable->ListHead);
+  }
+}
+
+PVOID
+ObmpDeleteHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  HANDLE Handle)
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
+  PUSER_HANDLE Entry;
+  PVOID ObjectBody;
+
+  ObmpLockHandleTable(HandleTable);
+
+  Entry = ObmpGetObjectByHandle(HandleTable, Handle);
+  if (Entry == NULL)
+  {
+    ObmpUnlockHandleTable(HandleTable);
+    return NULL;
+  }
+
+  ObjectBody = Entry->ObjectBody;
+
+  if (ObjectBody != NULL)
+  {
+    ObjectHeader = BODY_TO_HEADER(ObjectBody);
+         ObjectHeader->HandleCount--;
+         ObmReferenceObjectByPointer(ObjectBody, otUnknown);
+    Entry->ObjectBody = NULL;
+  }
+
+  ObmpUnlockHandleTable(HandleTable);
+
+  return ObjectBody;
+}
+
+NTSTATUS
+ObmpInitializeObject(
+  PUSER_HANDLE_TABLE HandleTable,
+  PUSER_OBJECT_HEADER ObjectHeader,
+  PHANDLE Handle,
+  USER_OBJECT_TYPE ObjectType,
+  ULONG ObjectSize)
+{
+  DWORD Status = STATUS_SUCCESS;
+
+  ObjectHeader->Type = ObjectType;
+  ObjectHeader->HandleCount = 0;
+  ObjectHeader->RefCount = 1;
+  ObjectHeader->Size = ObjectSize;
+
+  if (Handle != NULL)
+  {
+    Status = ObmCreateHandle(
+      HandleTable,
+      HEADER_TO_BODY(ObjectHeader),
+           Handle);
+  }
+
+  return Status;
+}
+
+
+ULONG
+ObmGetReferenceCount(
+  PVOID ObjectBody)
+{
+  PUSER_OBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+  return ObjectHeader->RefCount;
+}
+
+ULONG
+ObmGetHandleCount(
+  PVOID ObjectBody)
+{
+  PUSER_OBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+  return ObjectHeader->HandleCount;
+}
+
+VOID
+ObmReferenceObject(
+  PVOID ObjectBody)
+/*
+ * FUNCTION: Increments a given object's reference count and performs
+ *           retention checks
+ * ARGUMENTS:
+ *   ObjectBody = Body of the object
+ */
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
+
+  if (!ObjectBody)
+  {
+    return;
+  }
+
+  ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+  ObjectHeader->RefCount++;
+
+  ObmpPerformRetentionChecks(ObjectHeader);
+}
+
+VOID
+ObmDereferenceObject(
+  PVOID ObjectBody)
+/*
+ * FUNCTION: Decrements a given object's reference count and performs
+ *           retention checks
+ * ARGUMENTS:
+ *   ObjectBody = Body of the object
+ */
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
+
+  if (!ObjectBody)
+  {
+    return;
+  }
+
+  ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+  ObjectHeader->RefCount--;
+
+  ObmpPerformRetentionChecks(ObjectHeader);
+}
+
+NTSTATUS
+ObmReferenceObjectByPointer(
+  PVOID ObjectBody,
+  USER_OBJECT_TYPE ObjectType)
+/*
+ * FUNCTION: Increments the pointer reference count for a given object
+ * ARGUMENTS:
+ *         ObjectBody = Object's body
+ *         ObjectType = Object type
+ * RETURNS: Status
+ */
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
+
+  ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+  if ((ObjectType != otUnknown) && (ObjectHeader->Type != ObjectType))
+  {
+    return STATUS_INVALID_PARAMETER;
+  }
+
+  ObjectHeader->RefCount++;
+
+  return STATUS_SUCCESS;
+}
+
+PVOID
+ObmCreateObject(
+  PUSER_HANDLE_TABLE HandleTable,
+  PHANDLE Handle,
+       USER_OBJECT_TYPE ObjectType,
+  ULONG ObjectSize)
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
+  PVOID ObjectBody;
+  DWORD Status;
+
+  ObjectHeader = (PUSER_OBJECT_HEADER)ExAllocatePool(
+    NonPagedPool, ObjectSize + sizeof(USER_OBJECT_HEADER));
+  if (!ObjectHeader)
+  {
+    return NULL;
+  }
+
+  ObjectBody = HEADER_TO_BODY(ObjectHeader);
+
+  RtlZeroMemory(ObjectBody, ObjectSize);
+
+  Status = ObmpInitializeObject(
+    HandleTable,
+    ObjectHeader,
+    Handle,
+               ObjectType,
+    ObjectSize);
+
+  if (!NT_SUCCESS(Status))
+  {
+    ExFreePool(ObjectHeader);
+    return NULL;
+  }
+
+  return ObjectBody;
+}
+
+NTSTATUS
+ObmCreateHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  PVOID ObjectBody,
+       PHANDLE HandleReturn)
+/*
+ * FUNCTION: Add a handle referencing an object
+ * ARGUMENTS:
+ *   HandleTable = Table to put handle in
+ *   ObjectBody  = Object body that the handle should refer to
+ * RETURNS: The created handle
+ */
+{
+  PUSER_HANDLE_BLOCK NewBlock;
+  PLIST_ENTRY Current;
+  ULONG Handle;
+  ULONG i;
+
+  if (ObjectBody != NULL) {
+    BODY_TO_HEADER(ObjectBody)->HandleCount++;
+  }
+
+  ObmpLockHandleTable(HandleTable);
+
+  Current = HandleTable->ListHead.Flink;
+  /*
+   * Scan through the currently allocated Handle blocks looking for a free
+   * slot
+   */
+  while (Current != &(HandleTable->ListHead))
+  {
+    PUSER_HANDLE_BLOCK Block = CONTAINING_RECORD(
+      Current, USER_HANDLE_BLOCK, ListEntry);
+
+    Handle = 1;
+    for (i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
+    {
+      if (!Block->Handles[i].ObjectBody)
+      {
+        Block->Handles[i].ObjectBody = ObjectBody;
+        ObmpUnlockHandleTable(HandleTable);
+        *HandleReturn = (HANDLE)((Handle + i) << 2);
+        return ERROR_SUCCESS;
+      }
+    }
+
+    Handle = Handle + HANDLE_BLOCK_ENTRIES;
+    Current = Current->Flink;
+  }
+
+  /*
+   * Add a new Handle block to the end of the list
+   */
+  NewBlock = (PUSER_HANDLE_BLOCK)ExAllocatePool(
+    NonPagedPool, sizeof(USER_HANDLE_BLOCK));
+  if (!NewBlock)
+  {
+    *HandleReturn = (PHANDLE)NULL;
+    return STATUS_INSUFFICIENT_RESOURCES;
+  }
+
+  RtlZeroMemory(NewBlock, sizeof(USER_HANDLE_BLOCK));
+  NewBlock->Handles[0].ObjectBody = ObjectBody;
+  InsertTailList(&HandleTable->ListHead, &NewBlock->ListEntry);
+  ObmpUnlockHandleTable(HandleTable);
+  *HandleReturn = (HANDLE)(Handle << 2);
+
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+ObmReferenceObjectByHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  HANDLE Handle,
+       USER_OBJECT_TYPE ObjectType,
+       PVOID* Object)
+/*
+ * FUNCTION: Increments the reference count for an object and returns a
+ *           pointer to its body
+ * ARGUMENTS:
+ *         HandleTable = Table to search
+ *         Handle = Handle for the object
+ *         ObjectType = Type of object
+ *         Object (OUT) = Points to the object body on return
+ * RETURNS: Status
+ */
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
+  PUSER_HANDLE UserHandle;
+  PVOID ObjectBody;
+
+  ObmpLockHandleTable(HandleTable);
+
+  UserHandle = ObmpGetObjectByHandle(HandleTable, Handle);
+
+  if ((UserHandle == NULL) || (UserHandle->ObjectBody == NULL))
+  {
+    ObmpUnlockHandleTable(HandleTable);
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  ObjectBody = UserHandle->ObjectBody;
+  ObmReferenceObjectByPointer(ObjectBody, ObjectType);
+
+  ObmpUnlockHandleTable(HandleTable);
+
+  ObjectHeader = BODY_TO_HEADER(ObjectBody);
+
+  if ((ObjectType != otUnknown) && (ObjectHeader->Type != ObjectType))
+  {
+         return STATUS_UNSUCCESSFUL;
+  }
+
+  *Object = ObjectBody;
+
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+ObmCloseHandle(
+  PUSER_HANDLE_TABLE HandleTable,
+  HANDLE Handle)
+{
+  PVOID ObjectBody;
+
+  ObjectBody = ObmpDeleteHandle(HandleTable, Handle);
+  if (ObjectBody == NULL)
+  {
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  ObmDereferenceObject(ObjectBody);
+
+  return STATUS_SUCCESS;
+}
+
+
+VOID
+ObmInitializeHandleTable(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+  InitializeListHead(&HandleTable->ListHead);
+  //ExInitializeFastMutex(HandleTable->ListLock);
+}
+
+VOID
+ObmFreeHandleTable(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+  ObmpDeleteHandleTable(HandleTable);
+}
+
+PUSER_HANDLE_TABLE
+ObmCreateHandleTable(VOID)
+{
+  PUSER_HANDLE_TABLE HandleTable;
+
+  HandleTable = (PUSER_HANDLE_TABLE)ExAllocatePool(
+    NonPagedPool, sizeof(USER_HANDLE_TABLE));
+  if (!HandleTable)
+  {
+    return NULL;
+  }
+
+  ObmInitializeHandleTable(HandleTable);
+
+  return HandleTable;
+}
+
+VOID
+ObmDestroyHandleTable(
+  PUSER_HANDLE_TABLE HandleTable)
+{
+  ObmFreeHandleTable(HandleTable);
+  ExFreePool(HandleTable);
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/ntuser/class.c b/reactos/subsys/win32k/ntuser/class.c
new file mode 100644 (file)
index 0000000..0570d97
--- /dev/null
@@ -0,0 +1,354 @@
+/* $Id: class.c,v 1.1 2001/06/12 17:50:29 chorns Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Window classes
+ * FILE:             subsys/win32k/ntuser/class.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+#include <include/class.h>
+#include <include/error.h>
+#include <include/object.h>
+#include <include/winsta.h>
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* List of system classes */
+LIST_ENTRY SystemClassListHead;
+FAST_MUTEX SystemClassListLock;
+
+
+NTSTATUS
+InitClassImpl(VOID)
+{
+  InitializeListHead(&SystemClassListHead);
+  //ExInitializeFastMutex(&SystemClassListLock);
+
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+CleanupClassImpl(VOID)
+{
+  //ExReleaseFastMutex(&SystemClassListLock);
+
+  return STATUS_SUCCESS;
+}
+
+
+DWORD
+CliFindClassByName(
+  PWNDCLASS_OBJECT *Class,
+  LPWSTR ClassName,
+  PLIST_ENTRY ListHead)
+{
+  PWNDCLASS_OBJECT Current;
+  PLIST_ENTRY CurrentEntry;
+
+  CurrentEntry = ListHead->Flink;
+  while (CurrentEntry != ListHead)
+  {
+    Current = CONTAINING_RECORD(CurrentEntry, WNDCLASS_OBJECT, ListEntry);
+
+    if (_wcsicmp(ClassName, Current->Class.lpszClassName) == 0)
+    {
+      *Class = Current;
+      ObmReferenceObject(Current);
+      return STATUS_SUCCESS;
+    }
+
+    CurrentEntry = CurrentEntry->Flink;
+  }
+
+  return STATUS_NOT_FOUND;
+}
+
+NTSTATUS
+CliReferenceClassByNameWinSta(
+  PWINSTATION_OBJECT WinStaObject,
+  PWNDCLASS_OBJECT *Class,
+  LPWSTR ClassName)
+{
+/*
+  if (NT_SUCCESS(CliFindClassByName(Class, ClassName, &LocalClassListHead)))
+  {
+    return STATUS_SUCCESS;
+  }
+
+  if (NT_SUCCESS(CliFindClassByName(Class, ClassName, &GlobalClassListHead)))
+  {
+    return STATUS_SUCCESS;
+  }
+*/
+  return CliFindClassByName(Class, ClassName, &SystemClassListHead);
+}
+
+NTSTATUS
+ClassReferenceClassByName(
+  PWNDCLASS_OBJECT *Class,
+  LPWSTR ClassName)
+{
+  PWINSTATION_OBJECT WinStaObject;
+  NTSTATUS Status;
+
+  if (!ClassName)
+  {
+    return STATUS_INVALID_PARAMETER;
+  }
+
+  Status = ValidateWindowStationHandle(
+    PROCESS_WINDOW_STATION(),
+    KernelMode,
+    0,
+    &WinStaObject);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT("Validation of window station handle (0x%X) failed\n",
+      PROCESS_WINDOW_STATION());
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  Status = CliReferenceClassByNameWinSta(
+    WinStaObject,
+    Class,
+    ClassName);
+
+  ObDereferenceObject(WinStaObject);
+
+  return Status;
+}
+
+NTSTATUS
+ClassReferenceClassByAtom(
+  PWNDCLASS_OBJECT *Class,
+  RTL_ATOM ClassAtom)
+{
+  PWINSTATION_OBJECT WinStaObject;
+  ULONG ClassNameLength;
+  WCHAR ClassName[256];
+  NTSTATUS Status;
+
+  if (!ClassAtom)
+  {
+    return STATUS_INVALID_PARAMETER;
+  }
+
+  Status = ValidateWindowStationHandle(
+    PROCESS_WINDOW_STATION(),
+    KernelMode,
+    0,
+    &WinStaObject);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT("Validation of window station handle (0x%X) failed\n",
+      PROCESS_WINDOW_STATION());
+    return STATUS_UNSUCCESSFUL;
+  }
+
+  ClassNameLength = sizeof(ClassName);
+  Status = RtlQueryAtomInAtomTable(
+    WinStaObject->AtomTable,
+    ClassAtom,
+    NULL,
+    NULL,
+    &ClassName[0],
+    &ClassNameLength);
+
+  Status = CliReferenceClassByNameWinSta(
+    WinStaObject,
+    Class,
+    &ClassName[0]);
+
+  ObDereferenceObject(WinStaObject);
+
+  return Status;
+}
+
+NTSTATUS
+ClassReferenceClassByNameOrAtom(
+  PWNDCLASS_OBJECT *Class,
+  LPWSTR ClassNameOrAtom)
+{
+  NTSTATUS Status;
+
+  if (IS_ATOM(ClassNameOrAtom))
+  {
+    Status = ClassReferenceClassByAtom(Class, (RTL_ATOM)((ULONG_PTR)ClassNameOrAtom));
+  }
+  else
+  {
+    Status = ClassReferenceClassByName(Class, ClassNameOrAtom);
+  }
+
+  if (!NT_SUCCESS(Status))
+  {
+    SetLastNtError(Status);
+  }
+
+  return Status;
+}
+
+
+DWORD
+STDCALL
+NtUserGetClassInfo(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetClassName(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetWOWClass(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+/*
+ * FUNCTION:
+ *   Registers a new class with the window manager
+ * ARGUMENTS:
+ *   lpcx          = Win32 extended window class structure
+ *   bUnicodeClass = Wether to send ANSI or unicode strings
+ *                   to window procedures
+ * RETURNS:
+ *   Atom identifying the new class
+ */
+RTL_ATOM
+STDCALL
+NtUserRegisterClassExWOW(
+  LPWNDCLASSEX lpwcx,
+  BOOL bUnicodeClass,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5)
+{
+  PWINSTATION_OBJECT WinStaObject;
+  PWNDCLASS_OBJECT ClassObject;
+  NTSTATUS Status;
+  RTL_ATOM Atom;
+
+  DPRINT("About to open window station handle (0x%X)\n", PROCESS_WINDOW_STATION());
+
+  Status = ValidateWindowStationHandle(
+    PROCESS_WINDOW_STATION(),
+    KernelMode,
+    0,
+    &WinStaObject);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT("Validation of window station handle (0x%X) failed\n",
+      PROCESS_WINDOW_STATION());
+    return (RTL_ATOM)0;
+  }
+
+  Status = RtlAddAtomToAtomTable(
+    WinStaObject->AtomTable,
+    (LPWSTR)lpwcx->lpszClassName,
+    &Atom);
+  if (!NT_SUCCESS(Status))
+  {
+    ObDereferenceObject(WinStaObject);
+    DPRINT("Failed adding class name (%wS) to atom table\n",
+      lpwcx->lpszClassName);
+    SetLastNtError(Status);
+    return (RTL_ATOM)0;
+  }
+
+  ClassObject = ObmCreateObject(
+    WinStaObject->HandleTable,
+    NULL,
+    otClass,
+    sizeof(WNDCLASS_OBJECT));
+  if (!ClassObject)
+  {
+    RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
+    ObDereferenceObject(WinStaObject);
+    DPRINT("Failed creating window class object\n");
+    SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
+    return (ATOM)0;
+  }
+
+  if (ClassObject->Class.style & CS_GLOBALCLASS)
+  {
+    /* FIXME: Put on global list */
+    InsertTailList(&SystemClassListHead, &ClassObject->ListEntry);
+  }
+  else
+  {
+    /* FIXME: Put on local list */
+    InsertTailList(&SystemClassListHead, &ClassObject->ListEntry);
+  }
+
+  ObDereferenceObject(WinStaObject);
+
+  return (RTL_ATOM)0;
+}
+
+DWORD
+STDCALL
+NtUserSetClassLong(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetClassWord(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserUnregisterClass(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/ntuser/guicheck.c b/reactos/subsys/win32k/ntuser/guicheck.c
new file mode 100644 (file)
index 0000000..7aee984
--- /dev/null
@@ -0,0 +1,33 @@
+/* $Id: guicheck.c,v 1.1 2001/06/12 17:50:29 chorns Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          GUI state check
+ * FILE:             subsys/win32k/ntuser/guicheck.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * NOTES:            The GuiCheck() function performs a few delayed operations:
+ *                   1) A GUI process is assigned a window station
+ *                   2) A message queue is created for a GUI thread before use
+ *                   3) The system window classes are registered for a process
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+#include <include/guicheck.h>
+#include <include/msgqueue.h>
+
+#define NDEBUG
+#include <debug.h>
+
+
+VOID
+GuiCheck(VOID)
+{
+  if (NtCurrentTeb()->MessageQueue)
+    return;
+
+  NtCurrentTeb()->MessageQueue = MsqCreateMessageQueue();
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/ntuser/hook.c b/reactos/subsys/win32k/ntuser/hook.c
new file mode 100644 (file)
index 0000000..031a875
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Window hooks
+ * FILE:             subsys/win32k/ntuser/hook.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+
+#define NDEBUG
+#include <debug.h>
+
+DWORD
+STDCALL
+NtUserCallNextHookEx(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowsHookAW(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowsHookEx(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWinEventHook(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6,
+  DWORD Unknown7)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserUnhookWindowsHookEx(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserUnhookWinEvent(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/ntuser/message.c b/reactos/subsys/win32k/ntuser/message.c
new file mode 100644 (file)
index 0000000..fedb7d3
--- /dev/null
@@ -0,0 +1,173 @@
+/* $Id: message.c,v 1.1 2001/06/12 17:50:29 chorns Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Messages
+ * FILE:             subsys/win32k/ntuser/message.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+#include <include/window.h>
+#include <include/class.h>
+#include <include/error.h>
+#include <include/object.h>
+#include <include/winsta.h>
+
+#define NDEBUG
+#include <debug.h>
+
+
+NTSTATUS
+InitMessageImpl(VOID)
+{
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+CleanupMessageImpl(VOID)
+{
+  return STATUS_SUCCESS;
+}
+
+
+LRESULT
+STDCALL
+NtUserDispatchMessage(
+  LPMSG lpmsg)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserGetMessage(
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax)
+{
+  UNIMPLEMENTED
+
+  return FALSE;
+}
+
+DWORD
+STDCALL
+NtUserMessageCall(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserPeekMessage(
+  LPMSG lpMsg,
+  HWND hWnd,
+  UINT wMsgFilterMin,
+  UINT wMsgFilterMax,
+  UINT wRemoveMsg)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserPostMessage(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserPostThreadMessage(
+  DWORD idThread,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserQuerySendMessage(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserSendMessageCallback(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam,
+  SENDASYNCPROC lpCallBack,
+  ULONG_PTR dwData)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserSendNotifyMessage(
+  HWND hWnd,
+  UINT Msg,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserTranslateMessage(
+  LPMSG lpMsg,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserWaitMessage(VOID)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c
new file mode 100644 (file)
index 0000000..e13b7c3
--- /dev/null
@@ -0,0 +1,128 @@
+/* $Id: msgqueue.c,v 1.1 2001/06/12 17:50:29 chorns Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Message queues
+ * FILE:             subsys/win32k/ntuser/msgqueue.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+#include <include/msgqueue.h>
+
+#define NDEBUG
+#include <debug.h>
+
+
+VOID
+MsqInitializeMessage(
+  PUSER_MESSAGE Message,
+  LPMSG Msg)
+{
+  RtlMoveMemory(&Message->Msg, Msg, sizeof(MSG));
+}
+
+PUSER_MESSAGE
+MsqCreateMessage(
+  LPMSG Msg)
+{
+  PUSER_MESSAGE Message;
+
+  Message = (PUSER_MESSAGE)ExAllocatePool(
+    PagedPool, sizeof(USER_MESSAGE));
+  if (!Message)
+  {
+    return NULL;
+  }
+
+  MsqInitializeMessage(Message, Msg);
+
+  return Message;
+}
+
+VOID
+MsqDestroyMessage(
+  PUSER_MESSAGE Message)
+{
+  ExFreePool(Message);
+}
+
+VOID
+MsqPostMessage(
+  PUSER_MESSAGE_QUEUE MessageQueue,
+  PUSER_MESSAGE Message)
+{
+  // FIXME: Grab lock
+  InsertTailList(&MessageQueue->ListHead, &Message->ListEntry);
+}
+
+BOOL
+MsqRetrieveMessage(
+  PUSER_MESSAGE_QUEUE MessageQueue,
+  PUSER_MESSAGE *Message)
+{
+  PLIST_ENTRY CurrentEntry;
+
+  // FIXME: Grab lock
+  if (!IsListEmpty(&MessageQueue->ListHead))
+  {
+    CurrentEntry = RemoveHeadList(&MessageQueue->ListHead);
+    *Message = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
+    return TRUE;
+  }
+  else
+  {
+    return FALSE;
+  }
+}
+
+
+VOID
+MsqInitializeMessageQueue(
+  PUSER_MESSAGE_QUEUE MessageQueue)
+{
+  InitializeListHead(&MessageQueue->ListHead);
+  ExInitializeFastMutex(MessageQueue->ListLock);
+}
+
+VOID
+MsqFreeMessageQueue(
+  PUSER_MESSAGE_QUEUE MessageQueue)
+{
+  PUSER_MESSAGE Message;
+
+  // FIXME: Grab lock
+  while (MsqRetrieveMessage(MessageQueue, &Message))
+  {
+    ExFreePool(Message);
+  }
+}
+
+PUSER_MESSAGE_QUEUE
+MsqCreateMessageQueue(VOID)
+{
+  PUSER_MESSAGE_QUEUE MessageQueue;
+
+  MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePool(
+    PagedPool, sizeof(USER_MESSAGE_QUEUE));
+  if (!MessageQueue)
+  {
+    return NULL;
+  }
+
+  MsqInitializeMessageQueue(MessageQueue);
+
+  return MessageQueue;
+}
+
+VOID
+MsqDestroyMessageQueue(
+  PUSER_MESSAGE_QUEUE MessageQueue)
+{
+  MsqFreeMessageQueue(MessageQueue);
+  ExFreePool(MessageQueue);
+}
+
+/* EOF */
index e8108bd..0b30632 100644 (file)
@@ -24,18 +24,6 @@ NtUserActivateKeyboardLayout(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserAlterWindowStyle(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserAttachThreadInput(
@@ -196,19 +184,6 @@ NtUserCallMsgFilter(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserCallNextHookEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserCallNoParam(
@@ -279,19 +254,6 @@ NtUserCheckMenuItem(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserChildWindowFromPointEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserClipCursor(
@@ -311,26 +273,6 @@ NtUserCloseClipboard(VOID)
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserCloseDesktop(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserCloseWindowStation(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserConvertMemHandle(
@@ -387,20 +329,6 @@ NtUserCreateCaret(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserCreateDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserCreateLocalMemHandle(
@@ -414,43 +342,6 @@ NtUserCreateLocalMemHandle(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserCreateWindowEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7,
-  DWORD Unknown8,
-  DWORD Unknown9,
-  DWORD Unknown10,
-  DWORD Unknown11,
-  DWORD Unknown12)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserCreateWindowStation(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserDdeGetQualityOfService(
@@ -489,23 +380,6 @@ NtUserDdeSetQualityOfService(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserDeferWindowPos(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserDefSetText(
@@ -560,26 +434,6 @@ NtUserDestroyMenu(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserDestroyWindow(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserDispatchMessage(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserDragDetect(
@@ -715,17 +569,6 @@ NtUserEnableScrollBar(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserEndDeferWindowPosEx(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserEndMenu(VOID)
@@ -806,19 +649,6 @@ NtUserExcludeUpdateRgn(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserFillWindow(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserFindExistingCursorIcon(
@@ -831,30 +661,6 @@ NtUserFindExistingCursorIcon(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserFindWindowEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserFlashWindowEx(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserGetAltTabInfo(
@@ -910,32 +716,6 @@ NtUserGetCaretPos(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserGetClassInfo(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetClassName(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserGetClipboardData(
@@ -1098,15 +878,6 @@ NtUserGetDoubleClickTime(VOID)
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserGetForegroundWindow(VOID)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserGetGuiResources(
@@ -1170,18 +941,6 @@ NtUserGetImeHotKey(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserGetInternalWindowPos(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserGetKeyboardLayoutList(
@@ -1284,11 +1043,12 @@ NtUserGetMenuItemRect(
 
 DWORD
 STDCALL
-NtUserGetMessage(
+NtUserGetMouseMovePointsEx(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2,
-  DWORD Unknown3)
+  DWORD Unknown3,
+  DWORD Unknown4)
 {
   UNIMPLEMENTED
 
@@ -1297,12 +1057,9 @@ NtUserGetMessage(
 
 DWORD
 STDCALL
-NtUserGetMouseMovePointsEx(
+NtUserGetPriorityClipboardFormat(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -1311,12 +1068,10 @@ NtUserGetMouseMovePointsEx(
 
 DWORD
 STDCALL
-NtUserGetObjectInformation(
+NtUserGetScrollBarInfo(
   DWORD Unknown0,
   DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -1325,7 +1080,9 @@ NtUserGetObjectInformation(
 
 DWORD
 STDCALL
-NtUserGetOpenClipboardWindow(VOID)
+NtUserGetSystemMenu(
+  DWORD Unknown0,
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -1334,9 +1091,8 @@ NtUserGetOpenClipboardWindow(VOID)
 
 DWORD
 STDCALL
-NtUserGetPriorityClipboardFormat(
-  DWORD Unknown0,
-  DWORD Unknown1)
+NtUserGetThreadState(
+  DWORD Unknown0)
 {
   UNIMPLEMENTED
 
@@ -1345,7 +1101,9 @@ NtUserGetPriorityClipboardFormat(
 
 DWORD
 STDCALL
-NtUserGetProcessWindowStation(VOID)
+NtUserGetTitleBarInfo(
+  DWORD Unknown0,
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -1354,7 +1112,7 @@ NtUserGetProcessWindowStation(VOID)
 
 DWORD
 STDCALL
-NtUserGetScrollBarInfo(
+NtUserGetUpdateRect(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2)
@@ -1366,97 +1124,10 @@ NtUserGetScrollBarInfo(
 
 DWORD
 STDCALL
-NtUserGetSystemMenu(
+NtUserGetUpdateRgn(
   DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetThreadDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetThreadState(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetTitleBarInfo(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetUpdateRect(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetUpdateRgn(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetWindowDC(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetWindowPlacement(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserGetWOWClass(
-  DWORD Unknown0,
-  DWORD Unknown1)
+  DWORD Unknown1,
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -1530,18 +1201,6 @@ NtUserInitTask(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserInternalGetWindowText(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserInvalidateRect(
@@ -1602,26 +1261,6 @@ NtUserLoadKeyboardLayoutEx(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserLockWindowStation(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserLockWindowUpdate(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserLockWorkStation(VOID)
@@ -1657,22 +1296,6 @@ NtUserMenuItemFromPoint(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserMessageCall(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserMinMaximize(
@@ -1718,493 +1341,10 @@ NtUserModifyUserStartupInfoFlags(
 
 DWORD
 STDCALL
-NtUserMoveWindow(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserNotifyIMEStatus(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserNotifyWinEvent(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserOpenClipboard(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserOpenDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserOpenInputDesktop(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserOpenWindowStation(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserPaintDesktop(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserPeekMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserPostMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserPostThreadMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserQuerySendMessage(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserQueryUserCounters(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserQueryWindow(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRealChildWindowFromPoint(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRedrawWindow(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRegisterHotKey(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRegisterTasklist(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRegisterWindowMessage(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRemoveMenu(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserRemoveProp(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserResolveDesktopForWOW(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSBGetParms(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserScrollDC(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserScrollWindowEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSendInput(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSendMessageCallback(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSendNotifyMessage(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetActiveWindow(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetCapture(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetClassLong(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetClassWord(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetClipboardData(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetClipboardViewer(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetConsoleReserveKeys(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetCursor(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetCursorContents(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetCursorIconData(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetDbgTag(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetFocus(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetImeHotKey(
+NtUserNotifyIMEStatus(
   DWORD Unknown0,
   DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -2213,9 +1353,11 @@ NtUserSetImeHotKey(
 
 DWORD
 STDCALL
-NtUserSetImeOwnerWindow(
+NtUserNotifyWinEvent(
   DWORD Unknown0,
-  DWORD Unknown1)
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
 {
   UNIMPLEMENTED
 
@@ -2224,11 +1366,9 @@ NtUserSetImeOwnerWindow(
 
 DWORD
 STDCALL
-NtUserSetInternalWindowPos(
+NtUserOpenClipboard(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -2237,8 +1377,12 @@ NtUserSetInternalWindowPos(
 
 DWORD
 STDCALL
-NtUserSetKeyboardState(
-  DWORD Unknown0)
+NtUserQueryUserCounters(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4)
 {
   UNIMPLEMENTED
 
@@ -2247,7 +1391,7 @@ NtUserSetKeyboardState(
 
 DWORD
 STDCALL
-NtUserSetLayeredWindowAttributes(
+NtUserRegisterHotKey(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2,
@@ -2260,7 +1404,7 @@ NtUserSetLayeredWindowAttributes(
 
 DWORD
 STDCALL
-NtUserSetLogonNotifyWindow(
+NtUserRegisterTasklist(
   DWORD Unknown0)
 {
   UNIMPLEMENTED
@@ -2270,7 +1414,7 @@ NtUserSetLogonNotifyWindow(
 
 DWORD
 STDCALL
-NtUserSetMenu(
+NtUserRemoveMenu(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2)
@@ -2282,7 +1426,7 @@ NtUserSetMenu(
 
 DWORD
 STDCALL
-NtUserSetMenuContextHelpId(
+NtUserRemoveProp(
   DWORD Unknown0,
   DWORD Unknown1)
 {
@@ -2293,10 +1437,11 @@ NtUserSetMenuContextHelpId(
 
 DWORD
 STDCALL
-NtUserSetMenuDefaultItem(
+NtUserSBGetParms(
   DWORD Unknown0,
   DWORD Unknown1,
-  DWORD Unknown2)
+  DWORD Unknown2,
+  DWORD Unknown3)
 {
   UNIMPLEMENTED
 
@@ -2305,8 +1450,14 @@ NtUserSetMenuDefaultItem(
 
 DWORD
 STDCALL
-NtUserSetMenuFlagRtoL(
-  DWORD Unknown0)
+NtUserScrollDC(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6)
 {
   UNIMPLEMENTED
 
@@ -2315,11 +1466,10 @@ NtUserSetMenuFlagRtoL(
 
 DWORD
 STDCALL
-NtUserSetObjectInformation(
+NtUserSendInput(
   DWORD Unknown0,
   DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -2328,9 +1478,8 @@ NtUserSetObjectInformation(
 
 DWORD
 STDCALL
-NtUserSetParent(
-  DWORD Unknown0,
-  DWORD Unknown1)
+NtUserSetCapture(
+  DWORD Unknown0)
 {
   UNIMPLEMENTED
 
@@ -2339,7 +1488,7 @@ NtUserSetParent(
 
 DWORD
 STDCALL
-NtUserSetProp(
+NtUserSetClipboardData(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2)
@@ -2351,7 +1500,17 @@ NtUserSetProp(
 
 DWORD
 STDCALL
-NtUserSetRipFlags(
+NtUserSetClipboardViewer(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetConsoleReserveKeys(
   DWORD Unknown0,
   DWORD Unknown1)
 {
@@ -2362,11 +1521,8 @@ NtUserSetRipFlags(
 
 DWORD
 STDCALL
-NtUserSetScrollInfo(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+NtUserSetCursor(
+  DWORD Unknown0)
 {
   UNIMPLEMENTED
 
@@ -2375,7 +1531,7 @@ NtUserSetScrollInfo(
 
 DWORD
 STDCALL
-NtUserSetShellWindowEx(
+NtUserSetCursorContents(
   DWORD Unknown0,
   DWORD Unknown1)
 {
@@ -2386,7 +1542,7 @@ NtUserSetShellWindowEx(
 
 DWORD
 STDCALL
-NtUserSetSysColors(
+NtUserSetCursorIconData(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2,
@@ -2399,7 +1555,7 @@ NtUserSetSysColors(
 
 DWORD
 STDCALL
-NtUserSetSystemCursor(
+NtUserSetDbgTag(
   DWORD Unknown0,
   DWORD Unknown1)
 {
@@ -2410,9 +1566,8 @@ NtUserSetSystemCursor(
 
 DWORD
 STDCALL
-NtUserSetSystemMenu(
-  DWORD Unknown0,
-  DWORD Unknown1)
+NtUserSetFocus(
+  DWORD Unknown0)
 {
   UNIMPLEMENTED
 
@@ -2421,11 +1576,12 @@ NtUserSetSystemMenu(
 
 DWORD
 STDCALL
-NtUserSetSystemTimer(
+NtUserSetImeHotKey(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2,
-  DWORD Unknown3)
+  DWORD Unknown3,
+  DWORD Unknown4)
 {
   UNIMPLEMENTED
 
@@ -2434,7 +1590,7 @@ NtUserSetSystemTimer(
 
 DWORD
 STDCALL
-NtUserSetThreadDesktop(
+NtUserSetKeyboardState(
   DWORD Unknown0)
 {
   UNIMPLEMENTED
@@ -2444,22 +1600,10 @@ NtUserSetThreadDesktop(
 
 DWORD
 STDCALL
-NtUserSetThreadState(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetTimer(
+NtUserSetMenu(
   DWORD Unknown0,
   DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -2468,7 +1612,7 @@ NtUserSetTimer(
 
 DWORD
 STDCALL
-NtUserSetWindowFNID(
+NtUserSetMenuContextHelpId(
   DWORD Unknown0,
   DWORD Unknown1)
 {
@@ -2479,11 +1623,10 @@ NtUserSetWindowFNID(
 
 DWORD
 STDCALL
-NtUserSetWindowLong(
+NtUserSetMenuDefaultItem(
   DWORD Unknown0,
   DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -2492,9 +1635,8 @@ NtUserSetWindowLong(
 
 DWORD
 STDCALL
-NtUserSetWindowPlacement(
-  DWORD Unknown0,
-  DWORD Unknown1)
+NtUserSetMenuFlagRtoL(
+  DWORD Unknown0)
 {
   UNIMPLEMENTED
 
@@ -2503,14 +1645,9 @@ NtUserSetWindowPlacement(
 
 DWORD
 STDCALL
-NtUserSetWindowPos(
+NtUserSetParent(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -2519,7 +1656,7 @@ NtUserSetWindowPos(
 
 DWORD
 STDCALL
-NtUserSetWindowRgn(
+NtUserSetProp(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2)
@@ -2531,10 +1668,9 @@ NtUserSetWindowRgn(
 
 DWORD
 STDCALL
-NtUserSetWindowsHookAW(
+NtUserSetRipFlags(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -2543,13 +1679,11 @@ NtUserSetWindowsHookAW(
 
 DWORD
 STDCALL
-NtUserSetWindowsHookEx(
+NtUserSetScrollInfo(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
+  DWORD Unknown3)
 {
   UNIMPLEMENTED
 
@@ -2558,7 +1692,7 @@ NtUserSetWindowsHookEx(
 
 DWORD
 STDCALL
-NtUserSetWindowStationUser(
+NtUserSetSysColors(
   DWORD Unknown0,
   DWORD Unknown1,
   DWORD Unknown2,
@@ -2571,10 +1705,9 @@ NtUserSetWindowStationUser(
 
 DWORD
 STDCALL
-NtUserSetWindowWord(
+NtUserSetSystemCursor(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -2583,15 +1716,9 @@ NtUserSetWindowWord(
 
 DWORD
 STDCALL
-NtUserSetWinEventHook(
+NtUserSetSystemMenu(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -2600,8 +1727,11 @@ NtUserSetWinEventHook(
 
 DWORD
 STDCALL
-NtUserShowCaret(
-  DWORD Unknown0)
+NtUserSetSystemTimer(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
 {
   UNIMPLEMENTED
 
@@ -2610,10 +1740,9 @@ NtUserShowCaret(
 
 DWORD
 STDCALL
-NtUserShowScrollBar(
+NtUserSetThreadState(
   DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+  DWORD Unknown1)
 {
   UNIMPLEMENTED
 
@@ -2622,9 +1751,11 @@ NtUserShowScrollBar(
 
 DWORD
 STDCALL
-NtUserShowWindow(
+NtUserSetTimer(
   DWORD Unknown0,
-  DWORD Unknown1)
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
 {
   UNIMPLEMENTED
 
@@ -2633,9 +1764,8 @@ NtUserShowWindow(
 
 DWORD
 STDCALL
-NtUserShowWindowAsync(
-  DWORD Unknown0,
-  DWORD Unknown1)
+NtUserShowCaret(
+  DWORD Unknown0)
 {
   UNIMPLEMENTED
 
@@ -2644,8 +1774,10 @@ NtUserShowWindowAsync(
 
 DWORD
 STDCALL
-NtUserSwitchDesktop(
-  DWORD Unknown0)
+NtUserShowScrollBar(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
 {
   UNIMPLEMENTED
 
@@ -2744,37 +1876,6 @@ NtUserTranslateAccelerator(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserTranslateMessage(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserUnhookWindowsHookEx(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserUnhookWinEvent(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserUnloadKeyboardLayout(
@@ -2785,28 +1886,6 @@ NtUserUnloadKeyboardLayout(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserUnlockWindowStation(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserUnregisterClass(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserUnregisterHotKey(
@@ -2842,24 +1921,6 @@ NtUserUpdateInstance(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserUpdateLayeredWindow(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7,
-  DWORD Unknown8)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserUpdatePerUserSystemParameters(
@@ -2938,15 +1999,6 @@ NtUserWaitForMsgAndEvent(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserWaitMessage(VOID)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserWin32PoolAllocationStats(
@@ -2962,17 +2014,6 @@ NtUserWin32PoolAllocationStats(
   return 0;
 }
 
-DWORD
-STDCALL
-NtUserWindowFromPoint(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
 DWORD
 STDCALL
 NtUserYieldTask(VOID)
diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c
new file mode 100644 (file)
index 0000000..42e4ca0
--- /dev/null
@@ -0,0 +1,580 @@
+/* $Id: window.c,v 1.1 2001/06/12 17:50:29 chorns Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Windows
+ * FILE:             subsys/win32k/ntuser/window.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+#include <include/guicheck.h>
+#include <include/window.h>
+#include <include/class.h>
+#include <include/error.h>
+#include <include/object.h>
+#include <include/winsta.h>
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* List of windows created by the process */
+LIST_ENTRY WindowListHead;
+FAST_MUTEX WindowListLock;
+
+
+NTSTATUS
+InitWindowImpl(VOID)
+{
+  InitializeListHead(&WindowListHead);
+  //ExInitializeFastMutex(&WindowListLock);
+
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+CleanupWindowImpl(VOID)
+{
+  //ExReleaseFastMutex(&WindowListLock);
+
+  return STATUS_SUCCESS;
+}
+
+
+DWORD
+STDCALL
+NtUserAlterWindowStyle(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserChildWindowFromPointEx(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+HWND
+STDCALL
+NtUserCreateWindowEx(
+  DWORD dwExStyle,
+  PUNICODE_STRING lpClassName,
+  PUNICODE_STRING lpWindowName,
+  DWORD dwStyle,
+  LONG x,
+  LONG y,
+  LONG nWidth,
+  LONG nHeight,
+  HWND hWndParent,
+  HMENU hMenu,
+  HINSTANCE hInstance,
+  LPVOID lpParam,
+  DWORD Unknown12)
+{
+  PWINSTATION_OBJECT WinStaObject;
+  PWNDCLASS_OBJECT ClassObject;
+  PWINDOW_OBJECT WindowObject;
+  UNICODE_STRING WindowName;
+  NTSTATUS Status;
+  HANDLE Handle;
+
+  GuiCheck();
+
+  Status = ClassReferenceClassByNameOrAtom(&ClassObject, lpClassName->Buffer);
+  if (!NT_SUCCESS(Status))
+  {
+    return (HWND)0;
+  }
+
+  if (!RtlCreateUnicodeString(&WindowName, lpWindowName->Buffer))
+  {
+    ObmDereferenceObject(ClassObject);
+    SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
+    return (HWND)0;
+  }
+
+  Status = ValidateWindowStationHandle(
+    PROCESS_WINDOW_STATION(),
+    KernelMode,
+    0,
+    &WinStaObject);
+  if (!NT_SUCCESS(Status))
+  {
+    RtlFreeUnicodeString(&WindowName);
+    ObmDereferenceObject(ClassObject);
+    DPRINT("Validation of window station handle (0x%X) failed\n",
+      PROCESS_WINDOW_STATION());
+    return (HWND)0;
+  }
+
+  WindowObject = ObmCreateObject(
+    WinStaObject->HandleTable,
+    &Handle,
+    otWindow,
+    sizeof(WINDOW_OBJECT));
+  if (!WindowObject) {
+    ObDereferenceObject(WinStaObject);
+    ObmDereferenceObject(ClassObject);
+    RtlFreeUnicodeString(&WindowName);
+    SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
+    return (HWND)0;
+  }
+
+  ObDereferenceObject(WinStaObject);
+
+  WindowObject->Class = ClassObject;
+  WindowObject->ExStyle = dwExStyle;
+  WindowObject->Style = dwStyle;
+  WindowObject->x = x;
+  WindowObject->y = y;
+  WindowObject->Width = nWidth;
+  WindowObject->Height = nHeight;
+  WindowObject->Parent = hWndParent;
+  WindowObject->Menu = hMenu;
+  WindowObject->Instance = hInstance;
+  WindowObject->Parameters = lpParam;
+
+  RtlInitUnicodeString(&WindowObject->WindowName, WindowName.Buffer);
+
+  //FIXME: Grab lock
+  InsertTailList(&WindowListHead, &WindowObject->ListEntry);
+
+  return (HWND)Handle;
+}
+
+DWORD
+STDCALL
+NtUserDeferWindowPos(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6,
+  DWORD Unknown7)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserDestroyWindow(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserEndDeferWindowPosEx(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserFillWindow(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserFindWindowEx(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserFlashWindowEx(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetForegroundWindow(VOID)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetInternalWindowPos(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetOpenClipboardWindow(VOID)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetWindowDC(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserGetWindowPlacement(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserInternalGetWindowText(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserLockWindowUpdate(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserMoveWindow(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserQueryWindow(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserRealChildWindowFromPoint(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserRedrawWindow(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserRegisterWindowMessage(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserScrollWindowEx(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6,
+  DWORD Unknown7)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetActiveWindow(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetImeOwnerWindow(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetInternalWindowPos(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetLayeredWindowAttributes(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetLogonNotifyWindow(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetShellWindowEx(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowFNID(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowLong(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowPlacement(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowPos(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowRgn(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowWord(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserShowWindow(
+  HWND hWnd,
+  LONG nCmdShow)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserShowWindowAsync(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserUpdateLayeredWindow(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6,
+  DWORD Unknown7,
+  DWORD Unknown8)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+DWORD
+STDCALL
+NtUserWindowFromPoint(
+  DWORD Unknown0,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+/* EOF */
diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c
new file mode 100644 (file)
index 0000000..9ee9e6c
--- /dev/null
@@ -0,0 +1,783 @@
+/* $Id: winsta.c,v 1.1 2001/06/12 17:50:29 chorns Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Window stations and desktops
+ * FILE:             subsys/win32k/ntuser/winsta.c
+ * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISION HISTORY:
+ *       06-06-2001  CSH  Created
+ * NOTES:            Exported functions set the Win32 last error value
+ *                   on errors. The value can be retrieved with the Win32
+ *                   function GetLastError().
+ * TODO:             The process window station is created on
+ *                   the first USER32/GDI32 call not related
+ *                   to window station/desktop handling
+ */
+#include <ddk/ntddk.h>
+#include <win32k/win32k.h>
+#include <include/winsta.h>
+#include <include/object.h>
+
+#define NDEBUG
+#include <debug.h>
+
+#define WINSTA_ROOT_NAME L"\\Windows\\WindowStations"
+
+
+HDESK InputDesktop; /* Currently active desktop */
+
+
+NTSTATUS
+InitWindowStationImpl(VOID)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  HANDLE WindowStationsDirectory;
+  UNICODE_STRING UnicodeString;
+  NTSTATUS Status;
+
+  /*
+        * Create the '\Windows\WindowStations' directory
+        */
+  RtlInitUnicodeString(
+    &UnicodeString,
+    WINSTA_ROOT_NAME);
+
+  InitializeObjectAttributes(
+    &ObjectAttributes,
+    &UnicodeString,
+    0,
+    NULL,
+    NULL);
+
+  Status = ZwCreateDirectoryObject(
+         &WindowStationsDirectory,
+    0,
+    &ObjectAttributes);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT("Could not create \\Windows\\WindowStations directory (Status 0x%X)\n", Status);
+    return Status;
+  }
+
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+CleanupWindowStationImpl(VOID)
+{
+  return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+ValidateWindowStationHandle(
+  HWINSTA WindowStation,
+  KPROCESSOR_MODE AccessMode,
+  ACCESS_MASK DesiredAccess,
+  PWINSTATION_OBJECT *Object)
+{
+  NTSTATUS Status;
+
+  Status = ObReferenceObjectByHandle(
+    WindowStation,
+    DesiredAccess,
+    ExWindowStationObjectType,
+    AccessMode,
+    (PVOID*)Object,
+    NULL);
+  if (!NT_SUCCESS(Status)) {
+    SetLastNtError(Status);
+  }
+
+  return Status;
+}
+
+NTSTATUS
+ValidateDesktopHandle(
+  HDESK Desktop,
+  KPROCESSOR_MODE AccessMode,
+  ACCESS_MASK DesiredAccess,
+  PDESKTOP_OBJECT *Object)
+{
+  NTSTATUS Status;
+
+  Status = ObReferenceObjectByHandle(
+    Desktop,
+    DesiredAccess,
+    ExDesktopObjectType,
+    AccessMode,
+    (PVOID*)Object,
+    NULL);
+  if (!NT_SUCCESS(Status)) {
+    SetLastNtError(Status);
+  }
+
+  return Status;
+}
+
+/*
+ * FUNCTION:
+ *   Closes a window station handle
+ * ARGUMENTS:
+ *   hWinSta = Handle to the window station 
+ * RETURNS:
+ *   Status
+ * NOTES:
+ *   The window station handle can be created with
+ *   NtUserCreateWindowStation() or NtUserOpenWindowStation().
+ *   Attemps to close a handle to the window station assigned
+ *   to the calling process will fail
+ */
+BOOL
+STDCALL
+NtUserCloseWindowStation(
+  HWINSTA hWinSta)
+{
+  PWINSTATION_OBJECT Object;
+  NTSTATUS Status;
+
+  DPRINT("About to close window station handle (0x%X)\n", hWinSta);
+
+  Status = ValidateWindowStationHandle(
+    hWinSta,
+    KernelMode,
+    0,
+    &Object);
+  if (!NT_SUCCESS(Status)) {
+    DPRINT("Validation of window station handle (0x%X) failed\n", hWinSta);
+    return FALSE;
+  }
+
+  ObDereferenceObject(Object);
+
+  DPRINT("Closing window station handle (0x%X)\n", hWinSta);
+
+  Status = ZwClose(hWinSta);
+  if (!NT_SUCCESS(Status)) {
+    SetLastNtError(Status);
+    return FALSE;
+  } else {
+    return TRUE;
+  }
+}
+
+/*
+ * FUNCTION:
+ *   Creates a new window station
+ * ARGUMENTS:
+ *   lpszWindowStationName = Name of the new window station
+ *   dwDesiredAccess       = Requested type of access
+ *   lpSecurity            = Security descriptor
+ *   Unknown3              = Unused
+ *   Unknown4              = Unused
+ *   Unknown5              = Unused
+ * RETURNS:
+ *   Handle to the new window station that can be closed with
+ *   NtUserCloseWindowStation()
+ *   Zero on failure
+ */
+HWINSTA
+STDCALL
+NtUserCreateWindowStation(
+  PUNICODE_STRING lpszWindowStationName,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpSecurity,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  UNICODE_STRING WindowStationName;
+  PWINSTATION_OBJECT WinStaObject;
+  WCHAR NameBuffer[MAX_PATH];
+  NTSTATUS Status;
+  HWINSTA WinSta;
+
+  wcscpy(NameBuffer, WINSTA_ROOT_NAME);
+  wcscat(NameBuffer, L"\\");
+  wcscat(NameBuffer, lpszWindowStationName->Buffer);
+  RtlInitUnicodeString(&WindowStationName, NameBuffer);
+
+  DPRINT("Trying to open window station (%wZ)\n", &WindowStationName);
+
+  /* Initialize ObjectAttributes for the window station object */
+  InitializeObjectAttributes(
+    &ObjectAttributes,
+    &WindowStationName,
+    0,
+    NULL,
+    NULL);
+
+  Status = ObOpenObjectByName(
+    &ObjectAttributes,
+    ExWindowStationObjectType,
+    NULL,
+    UserMode,
+    dwDesiredAccess,
+    NULL,
+    &WinSta);
+  if (NT_SUCCESS(Status))
+  {
+    DPRINT("Successfully opened window station (%wZ)\n", WindowStationName);
+    return (HWINSTA)WinSta;
+  }
+
+  DPRINT("Creating window station (%wZ)\n", &WindowStationName);
+
+  WinStaObject = (PWINSTATION_OBJECT)ObCreateObject(
+    &WinSta,
+    STANDARD_RIGHTS_REQUIRED,
+    &ObjectAttributes,
+    ExWindowStationObjectType);
+  if (!WinStaObject)
+  {
+    DPRINT("Failed creating window station (%wZ)\n", &WindowStationName);
+    SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
+    return (HWINSTA)0;
+  }
+
+  WinStaObject->HandleTable = ObmCreateHandleTable();
+  if (!WinStaObject->HandleTable)
+  {
+    DPRINT("Failed creating handle table\n");
+    ObDereferenceObject(WinStaObject);
+    SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
+    return (HWINSTA)0;
+  }
+
+  DPRINT("Window station successfully created (%wZ)\n", &WindowStationName);
+
+  return (HWINSTA)WinSta;
+}
+
+BOOL
+STDCALL
+NtUserGetObjectInformation(
+  HANDLE hObject,
+  DWORD nIndex,
+  PVOID pvInformation,
+  DWORD nLength,
+  PDWORD nLengthNeeded)
+{
+  return FALSE;
+}
+
+/*
+ * FUNCTION:
+ *   Returns a handle to the current process window station
+ * ARGUMENTS:
+ *   None
+ * RETURNS:
+ *   Handle to the window station assigned to the current process
+ *   Zero on failure
+ * NOTES:
+ *   The handle need not be closed by the caller
+ */
+HWINSTA
+STDCALL
+NtUserGetProcessWindowStation(VOID)
+{
+  return PROCESS_WINDOW_STATION();
+}
+
+BOOL
+STDCALL
+NtUserLockWindowStation(
+  HWINSTA hWindowStation)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+/*
+ * FUNCTION:
+ *   Opens an existing window station
+ * ARGUMENTS:
+ *   lpszWindowStationName = Name of the existing window station
+ *   dwDesiredAccess       = Requested type of access
+ * RETURNS:
+ *   Handle to the window station
+ *   Zero on failure
+ * NOTES:
+ *   The returned handle can be closed with NtUserCloseWindowStation()
+ */
+HWINSTA
+STDCALL
+NtUserOpenWindowStation(
+  PUNICODE_STRING lpszWindowStationName,
+  ACCESS_MASK dwDesiredAccess)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  UNICODE_STRING WindowStationName;
+  PWINSTATION_OBJECT WinStaObject;
+  WCHAR NameBuffer[MAX_PATH];
+  NTSTATUS Status;
+  HWINSTA WinSta;
+
+  wcscpy(NameBuffer, WINSTA_ROOT_NAME);
+  wcscat(NameBuffer, L"\\");
+  wcscat(NameBuffer, lpszWindowStationName->Buffer);
+  RtlInitUnicodeString(&WindowStationName, NameBuffer);
+
+  DPRINT("Trying to open window station (%wZ)\n", &WindowStationName);
+
+  /* Initialize ObjectAttributes for the window station object */
+  InitializeObjectAttributes(
+    &ObjectAttributes,
+    &WindowStationName,
+    0,
+    NULL,
+    NULL);
+
+  Status = ObOpenObjectByName(
+    &ObjectAttributes,
+    ExDesktopObjectType,
+    NULL,
+    UserMode,
+    dwDesiredAccess,
+    NULL,
+    &WinSta);
+  if (NT_SUCCESS(Status))
+  {
+    DPRINT("Successfully opened window station (%wZ)\n", &WindowStationName);
+    return (HWINSTA)WinSta;
+  }
+
+  SetLastNtError(Status);
+  return (HWINSTA)0;
+}
+
+BOOL
+STDCALL
+NtUserSetObjectInformation(
+  HANDLE hObject,
+  DWORD nIndex,
+  PVOID pvInformation,
+  DWORD nLength)
+{
+  /* FIXME: ZwQueryObject */
+  /* FIXME: ZwSetInformationObject */
+  SetLastNtError(STATUS_UNSUCCESSFUL);
+  return FALSE;
+}
+
+/*
+ * FUNCTION:
+ *   Assigns a window station to the current process
+ * ARGUMENTS:
+ *   hWinSta = Handle to the window station
+ * RETURNS:
+ *   Status
+ */
+BOOL
+STDCALL
+NtUserSetProcessWindowStation(
+  HWINSTA hWindowStation)
+{
+  PWINSTATION_OBJECT Object;
+  NTSTATUS Status;
+
+  DPRINT("About to set process window station with handle (0x%X)\n", hWindowStation);
+
+  Status = ValidateWindowStationHandle(
+    hWindowStation,
+    KernelMode,
+    0,
+    &Object);
+  if (!NT_SUCCESS(Status)) {
+    DPRINT("Validation of window station handle (0x%X) failed\n", hWindowStation);
+    return FALSE;
+  }
+
+  ObDereferenceObject(Object);
+
+  SET_PROCESS_WINDOW_STATION(hWindowStation);
+
+  return TRUE;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowStationUser(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserUnlockWindowStation(
+  HWINSTA hWindowStation)
+{
+  UNIMPLEMENTED
+
+  return FALSE;
+}
+
+
+/*
+ * FUNCTION:
+ *   Closes a desktop handle
+ * ARGUMENTS:
+ *   hDesktop = Handle to the desktop
+ * RETURNS:
+ *   Status
+ * NOTES:
+ *   The desktop handle can be created with NtUserCreateDesktop() or
+ *   NtUserOpenDesktop().
+ *   The function will fail if any thread in the calling process is using the
+ *   specified desktop handle or if the handle refers to the initial desktop
+ *   of the calling process
+ */
+BOOL
+STDCALL
+NtUserCloseDesktop(
+  HDESK hDesktop)
+{
+  PDESKTOP_OBJECT Object;
+  NTSTATUS Status;
+
+  DPRINT("About to close desktop handle (0x%X)\n", hDesktop);
+
+  Status = ValidateDesktopHandle(
+    hDesktop,
+    KernelMode,
+    0,
+    &Object);
+  if (!NT_SUCCESS(Status)) {
+    DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop);
+    return FALSE;
+  }
+
+  ObDereferenceObject(Object);
+
+  DPRINT("Closing desktop handle (0x%X)\n", hDesktop);
+
+  Status = ZwClose(hDesktop);
+  if (!NT_SUCCESS(Status)) {
+    SetLastNtError(Status);
+    return FALSE;
+  } else {
+    return TRUE;
+  }
+}
+
+/*
+ * FUNCTION:
+ *   Creates a new desktop
+ * ARGUMENTS:
+ *   lpszDesktopName = Name of the new desktop
+ *   dwFlags         = Interaction flags
+ *   dwDesiredAccess = Requested type of access
+ *   lpSecurity      = Security descriptor
+ *   hWindowStation  = Handle to window station on which to create the desktop
+ * RETURNS:
+ *   Handle to the new desktop that can be closed with NtUserCloseDesktop()
+ *   Zero on failure
+ */
+HDESK
+STDCALL
+NtUserCreateDesktop(
+  PUNICODE_STRING lpszDesktopName,
+  DWORD dwFlags,
+  ACCESS_MASK dwDesiredAccess,
+  LPSECURITY_ATTRIBUTES lpSecurity,
+  HWINSTA hWindowStation)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  PWINSTATION_OBJECT WinStaObject;
+  PDESKTOP_OBJECT DesktopObject;
+  UNICODE_STRING DesktopName;
+  WCHAR NameBuffer[MAX_PATH];
+  NTSTATUS Status;
+  HDESK Desktop;
+
+  Status = ValidateWindowStationHandle(
+    hWindowStation,
+    KernelMode,
+    0,
+    &WinStaObject);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT("Failed validation of window station handle (0x%X)\n", hWindowStation);
+    return (HDESK)0;
+  }
+
+  wcscpy(NameBuffer, WINSTA_ROOT_NAME);
+  wcscat(NameBuffer, L"\\");
+  wcscat(NameBuffer, WinStaObject->Name.Buffer);
+  wcscat(NameBuffer, L"\\");
+  wcscat(NameBuffer, lpszDesktopName->Buffer);
+  RtlInitUnicodeString(&DesktopName, NameBuffer);
+
+  ObDereferenceObject(WinStaObject);
+
+  DPRINT("Trying to open desktop (%wZ)\n", &DesktopName);
+
+  /* Initialize ObjectAttributes for the desktop object */
+  InitializeObjectAttributes(
+    &ObjectAttributes,
+    &DesktopName,
+    0,
+    NULL,
+    NULL);
+
+  Status = ObOpenObjectByName(
+    &ObjectAttributes,
+    ExDesktopObjectType,
+    NULL,
+    UserMode,
+    dwDesiredAccess,
+    NULL,
+    &Desktop);
+  if (NT_SUCCESS(Status))
+  {
+    DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName);
+    return (HDESK)Desktop;
+  }
+
+  DPRINT("Status for open operation (0x%X)\n", Status);
+
+  DesktopObject = (PDESKTOP_OBJECT)ObCreateObject(
+    &Desktop,
+    STANDARD_RIGHTS_REQUIRED,
+    &ObjectAttributes,
+    ExDesktopObjectType);
+  if (!DesktopObject)
+  {
+    DPRINT("Failed creating desktop (%wZ)\n", &DesktopName);
+    SetLastNtError(STATUS_UNSUCCESSFUL);
+    return (HDESK)0;
+  }
+
+  return (HDESK)Desktop;
+}
+
+HDESK
+STDCALL
+NtUserGetThreadDesktop(
+  DWORD dwThreadId,
+  DWORD Unknown1)
+{
+  UNIMPLEMENTED
+
+  return (HDESK)0;
+}
+
+/*
+ * FUNCTION:
+ *   Opens an existing desktop
+ * ARGUMENTS:
+ *   lpszDesktopName = Name of the existing desktop
+ *   dwFlags         = Interaction flags
+ *   dwDesiredAccess = Requested type of access
+ * RETURNS:
+ *   Handle to the desktop
+ *   Zero on failure
+ * NOTES:
+ *   The returned handle can be closed with NtUserCloseDesktop()
+ */
+HDESK
+STDCALL
+NtUserOpenDesktop(
+  PUNICODE_STRING lpszDesktopName,
+  DWORD dwFlags,
+  ACCESS_MASK dwDesiredAccess)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  PWINSTATION_OBJECT WinStaObject;
+  UNICODE_STRING DesktopName;
+  WCHAR NameBuffer[MAX_PATH];
+  NTSTATUS Status;
+  HDESK Desktop;
+
+  /* Validate the window station handle and
+     compose the fully qualified desktop name */
+
+  Status = ValidateWindowStationHandle(
+    PROCESS_WINDOW_STATION(),
+    KernelMode,
+    0,
+    &WinStaObject);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT("Failed validation of window station handle (0x%X)\n",
+      PROCESS_WINDOW_STATION());
+    return (HDESK)0;
+  }
+
+  wcscpy(NameBuffer, WINSTA_ROOT_NAME);
+  wcscat(NameBuffer, L"\\");
+  wcscat(NameBuffer, WinStaObject->Name.Buffer);
+  wcscat(NameBuffer, L"\\");
+  wcscat(NameBuffer, lpszDesktopName->Buffer);
+  RtlInitUnicodeString(&DesktopName, NameBuffer);
+
+  ObDereferenceObject(WinStaObject);
+
+
+  DPRINT("Trying to open desktop station (%wZ)\n", &DesktopName);
+
+  /* Initialize ObjectAttributes for the desktop object */
+  InitializeObjectAttributes(
+    &ObjectAttributes,
+    &DesktopName,
+    0,
+    NULL,
+    NULL);
+
+  Status = ObOpenObjectByName(
+    &ObjectAttributes,
+    ExDesktopObjectType,
+    NULL,
+    UserMode,
+    dwDesiredAccess,
+    NULL,
+    &Desktop);
+  if (NT_SUCCESS(Status))
+  {
+    DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName);
+    return (HDESK)Desktop;
+  }
+
+  SetLastNtError(Status);
+  return (HDESK)0;
+}
+
+/*
+ * FUNCTION:
+ *   Opens the input (interactive) desktop
+ * ARGUMENTS:
+ *   dwFlags         = Interaction flags
+ *   fInherit        = Inheritance option
+ *   dwDesiredAccess = Requested type of access
+ * RETURNS:
+ *   Handle to the input desktop
+ *   Zero on failure
+ * NOTES:
+ *   The returned handle can be closed with NtUserCloseDesktop()
+ */
+HDESK
+STDCALL
+NtUserOpenInputDesktop(
+  DWORD dwFlags,
+  BOOL fInherit,
+  ACCESS_MASK dwDesiredAccess)
+{
+  PDESKTOP_OBJECT Object;
+  NTSTATUS Status;
+  HDESK Desktop;
+
+  DPRINT("About to open input desktop\n");
+
+  /* Get a pointer to the desktop object */
+
+  Status = ValidateDesktopHandle(
+    InputDesktop,
+    KernelMode,
+    0,
+    &Object);
+  if (!NT_SUCCESS(Status)) {
+    DPRINT("Validation of input desktop handle (0x%X) failed\n", InputDesktop);
+    return (HDESK)0;
+  }
+
+  /* Create a new handle to the object */
+
+  Status = ObOpenObjectByPointer(
+    Object,
+    0,
+    NULL,
+    dwDesiredAccess,
+    ExDesktopObjectType,
+    UserMode,
+    &Desktop);
+
+  ObDereferenceObject(Object);
+
+  if (NT_SUCCESS(Status))
+  {
+    DPRINT("Successfully opened input desktop\n");
+    return (HDESK)Desktop;
+  }
+
+  SetLastNtError(Status);
+  return (HDESK)0;
+}
+
+BOOL
+STDCALL
+NtUserPaintDesktop(
+  HDC hDC)
+{
+  UNIMPLEMENTED
+
+  return FALSE;
+}
+
+DWORD
+STDCALL
+NtUserResolveDesktopForWOW(
+  DWORD Unknown0)
+{
+  UNIMPLEMENTED
+
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserSetThreadDesktop(
+  HDESK hDesktop)
+{
+  UNIMPLEMENTED
+
+  return FALSE;
+}
+
+/*
+ * FUNCTION:
+ *   Sets the current input (interactive) desktop
+ * ARGUMENTS:
+ *   hDesktop = Handle to desktop
+ * RETURNS:
+ *   Status
+ */
+BOOL
+STDCALL
+NtUserSwitchDesktop(
+  HDESK hDesktop)
+{
+  PDESKTOP_OBJECT Object;
+  NTSTATUS Status;
+
+  DPRINT("About to switch desktop (0x%X)\n", hDesktop);
+
+  Status = ValidateDesktopHandle(
+    hDesktop,
+    KernelMode,
+    0,
+    &Object);
+  if (!NT_SUCCESS(Status)) {
+    DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop);
+    return FALSE;
+  }
+
+  ObDereferenceObject(Object);
+
+  /* FIXME: Fail if the desktop belong to an invisible window station */
+  /* FIXME: Fail if the process is associated with a secured
+            desktop such as Winlogon or Screen-Saver */
+
+  /* FIXME: Connect to input device */
+  return TRUE;
+}
+
+/* EOF */
index a412933..3730725 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * GDIOBJ.C - GDI object manipulation routines
  *
- * $Id: gdiobj.c,v 1.8 2001/06/04 14:54:40 jfilby Exp $
+ * $Id: gdiobj.c,v 1.9 2001/06/12 17:50:29 chorns Exp $
  *
  */
 
@@ -48,7 +48,7 @@ static LOGPEN NullPen =
 
 static LOGFONT OEMFixedFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
-  0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" };
+  0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" };
 
 /* Filler to make the location counter dword aligned again.  This is necessary
    since (a) LOGFONT is packed, (b) gcc places initialised variables in the code
@@ -57,38 +57,38 @@ static UINT align_OEMFixedFont = 1;
 
 static LOGFONT AnsiFixedFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-  0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" };
+  0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" };
 
 static UINT align_AnsiFixedFont = 1;
 
 static LOGFONT AnsiVarFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" };
+  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" };
 
 static UINT align_AnsiVarFont = 1;
 
 static LOGFONT SystemFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "System" };
+  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System" };
 
 static UINT align_SystemFont = 1;
 
 static LOGFONT DeviceDefaultFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "" };
+  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"" };
 
 static UINT align_DeviceDefaultFont = 1;
 
 static LOGFONT SystemFixedFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-  0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" };
+  0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" };
 
 static UINT align_SystemFixedFont = 1;
 
 /* FIXME: Is this correct? */
 static LOGFONT DefaultGuiFont =
 { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" };
+  0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" };
 
 static UINT align_DefaultGuiFont = 1;