implemented RegisterLogonProcess(), LockWindowStation() and UnlockWindowStation()
authorThomas Bluemel <thomas@reactsoft.com>
Sat, 1 May 2004 16:43:15 +0000 (16:43 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Sat, 1 May 2004 16:43:15 +0000 (16:43 +0000)
svn path=/trunk/; revision=9267

reactos/include/funcs.h
reactos/include/win32k/ntuser.h
reactos/lib/user32/include/user32.h
reactos/lib/user32/misc/misc.c
reactos/lib/user32/misc/stubs.c
reactos/ntoskrnl/include/internal/ex.h
reactos/subsys/win32k/include/winsta.h
reactos/subsys/win32k/main/dllmain.c
reactos/subsys/win32k/ntuser/desktop.c
reactos/subsys/win32k/ntuser/misc.c

index 8c5acbb..7c8423d 100644 (file)
@@ -4624,7 +4624,7 @@ RegisterSystemThread(
                     DWORD reserved
                     );
 
-DWORD
+BOOL
 STDCALL
 RegisterLogonProcess(
                     HANDLE hprocess,
index 3ab2b90..835e144 100644 (file)
@@ -206,6 +206,7 @@ NtUserCallOneParam(
 #define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58
 #define TWOPARAM_ROUTINE_SETCARETPOS        0x60
 #define TWOPARAM_ROUTINE_GETWINDOWINFO      0x61
+#define TWOPARAM_ROUTINE_REGISTERLOGONPROC  0x62
 DWORD
 STDCALL
 NtUserCallTwoParam(
index 25f0fa8..8853a44 100644 (file)
@@ -52,6 +52,9 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);
 #define NtUserGetWindowInfo(hwnd, pwi) \
   (BOOL)NtUserCallTwoParam((DWORD)hwnd, (DWORD)pwi, TWOPARAM_ROUTINE_GETWINDOWINFO)
 
+#define NtUserRegisterLogonProcess(hproc, x) \
+  (BOOL)NtUserCallTwoParam((DWORD)hproc, (DWORD)x, TWOPARAM_ROUTINE_REGISTERLOGONPROC)
+
 #define NtUserSetCaretBlinkTime(uMSeconds) \
   (BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
 
index 1a7a938..1550383 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: misc.c,v 1.3 2003/12/07 23:02:57 gvg Exp $
+/* $Id: misc.c,v 1.4 2004/05/01 16:43:14 weiden Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/misc/misc.c
@@ -56,3 +56,13 @@ PrivateCsrssManualGuiCheck(LONG Check)
 {
   NtUserManualGuiCheck(Check);
 }
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+RegisterLogonProcess ( HANDLE hprocess, BOOL x )
+{
+  return NtUserRegisterLogonProcess(hprocess, x);
+}
index f58ef74..1209780 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.59 2004/04/29 20:26:35 weiden Exp $
+/* $Id: stubs.c,v 1.60 2004/05/01 16:43:14 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -372,17 +372,6 @@ RegisterSystemThread ( DWORD flags, DWORD reserved )
   UNIMPLEMENTED;
 }
 
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
-RegisterLogonProcess ( HANDLE hprocess, BOOL x )
-{
-  UNIMPLEMENTED;
-  return FALSE;
-}
-
 /*
  * @unimplemented
  */
index 0775fc4..091ae13 100644 (file)
@@ -59,7 +59,7 @@ typedef struct _WINSTATION_OBJECT
   UINT CaretBlinkRate;
   HANDLE ShellWindow;
   HANDLE ShellListView;
-  BOOL DesktopLocked;
+  ULONG Flags;
   struct _DESKTOP_OBJECT* ActiveDesktop;
   /* FIXME: Clipboard */
   LIST_ENTRY HotKeyListHead;
index d51d691..c0e2fff 100644 (file)
 #define WINSTA_ROOT_NAME       L"\\Windows\\WindowStations"
 #define WINSTA_ROOT_NAME_LENGTH        23
 
+/* Window Station Status Flags */
+#define WSS_LOCKED     (1)
+#define WSS_NOINTERACTIVE      (2)
+
 extern WINSTATION_OBJECT *InputWindowStation;
+extern PW32PROCESS LogonProcess;
 
 NTSTATUS FASTCALL
 InitWindowStationImpl(VOID);
index 6acaadc..275e793 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dllmain.c,v 1.69 2004/04/29 20:26:35 weiden Exp $
+/* $Id: dllmain.c,v 1.70 2004/05/01 16:43:14 weiden Exp $
  *
  *  Entry Point for win32k.sys
  */
@@ -138,6 +138,14 @@ Win32kProcessCallback (struct _EPROCESS *Process,
       CleanupForProcess(Process, Process->UniqueProcessId);
 
       IntGraphicsCheck(FALSE);
+      
+      /*
+       * Deregister logon application automatically
+       */
+      if(LogonProcess == Win32Process)
+      {
+        LogonProcess = NULL;
+      }
     }
 
   return STATUS_SUCCESS;
index f0f5a02..5d8132d 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- *  $Id: desktop.c,v 1.10 2004/04/09 20:03:19 navaraf Exp $
+ *  $Id: desktop.c,v 1.11 2004/05/01 16:43:15 weiden Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -719,7 +719,19 @@ NtUserSwitchDesktop(HDESK hDesktop)
       DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop);
       return FALSE;
    }
-
+   
+   /*
+    * Don't allow applications switch the desktop if it's locked, unless the caller
+    * is the logon application itself
+    */
+   if((DesktopObject->WindowStation->Flags & WSS_LOCKED) &&
+      LogonProcess != NULL && LogonProcess != PsGetWin32Process())
+   {
+      ObDereferenceObject(DesktopObject);
+      DPRINT1("Switching desktop 0x%x denied because the work station is locked!\n", hDesktop);
+      return FALSE;
+   }
+   
    /* 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 */
index 99e3ffe..8209a50 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.66 2004/05/01 11:38:28 weiden Exp $
+/* $Id: misc.c,v 1.67 2004/05/01 16:43:15 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -36,6 +36,9 @@
 #define NDEBUG
 #include <debug.h>
 
+/* registered Logon process */
+PW32PROCESS LogonProcess = NULL;
+
 /* FIXME - not yet defined in w32api :( */
 #define SPI_GETFOCUSBORDERWIDTH        (8206)
 #define SPI_SETFOCUSBORDERWIDTH        (8207)
@@ -61,6 +64,43 @@ PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() {
   return pmPrimitiveMessageQueue;
 }
 
+BOOL FASTCALL
+IntRegisterLogonProcess(HANDLE hProcess, BOOL x)
+{
+  PEPROCESS Process;
+  NTSTATUS Status;
+  
+  if(LogonProcess != NULL && LogonProcess != PsGetWin32Process())
+  {
+    SetLastWin32Error(ERROR_ACCESS_DENIED);
+    return FALSE;
+  }
+  
+  if(hProcess)
+  {
+    Status = ObReferenceObjectByHandle(hProcess,
+                                       PROCESS_QUERY_INFORMATION,
+                                       PsProcessType,
+                                       ExGetPreviousMode(),
+                                       (PVOID*)&Process,
+                                       NULL);
+    if(!NT_SUCCESS(Status))
+    {
+      SetLastNtError(Status);
+      return 0;
+    }
+  
+    LogonProcess = Process->Win32Process;
+    ObDereferenceObject(Process);
+  }
+  else
+  {
+    /* deregister the logon process */
+    LogonProcess = NULL;
+  }
+  return TRUE;
+}
+
 /*
  * @unimplemented
  */
@@ -94,7 +134,7 @@ NtUserCallNoParam(DWORD Routine)
       break;
 
     default:
-      DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam\n");
+      DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n");
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       break;
   }
@@ -223,7 +263,7 @@ NtUserCallOneParam(
       return (DWORD)TRUE;
     }
   }
-  DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam()\n Param=0x%x\n", 
+  DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n", 
           Routine, Param);
   SetLastWin32Error(ERROR_INVALID_PARAMETER);
   return 0;
@@ -394,8 +434,12 @@ NtUserCallTwoParam(
       IntReleaseWindowObject(WindowObject);
       return Ret;
     }
+    
+    case TWOPARAM_ROUTINE_REGISTERLOGONPROC:
+      return (DWORD)IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2);
+    
   }
-  DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam()\n Param1=0x%x Parm2=0x%x\n",
+  DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
           Routine, Param1, Param2);
   SetLastWin32Error(ERROR_INVALID_PARAMETER);
   return 0;