Fix RegisterLogonProcess().
authorEric Kohl <eric.kohl@reactos.org>
Thu, 8 Jul 2004 14:36:18 +0000 (14:36 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 8 Jul 2004 14:36:18 +0000 (14:36 +0000)
svn path=/trunk/; revision=10036

reactos/include/funcs.h
reactos/lib/user32/misc/misc.c
reactos/subsys/win32k/ntuser/misc.c
reactos/w32api/include/winuser.h

index 763a63f..de16fc1 100644 (file)
@@ -4604,8 +4604,8 @@ RegisterSystemThread(
 BOOL
 STDCALL
 RegisterLogonProcess(
-                    HANDLE hprocess,
-                    BOOL x
+                    DWORD dwPprocessId,
+                    BOOL bRegister
                     );
 
 WINBOOL
index 9f33932..1ad07af 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.5 2004/05/28 21:33:41 gvg Exp $
+/* $Id: misc.c,v 1.6 2004/07/08 14:35:10 ekohl Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/misc/misc.c
@@ -59,17 +59,20 @@ PrivateCsrssManualGuiCheck(LONG Check)
 
 VOID
 STDCALL
-PrivateCsrssInitialized()
+PrivateCsrssInitialized(VOID)
 {
   NtUserCallNoParam(NOPARAM_ROUTINE_CSRSS_INITIALIZED);
 }
 
+
 /*
  * @implemented
  */
 BOOL
 STDCALL
-RegisterLogonProcess ( HANDLE hprocess, BOOL x )
+RegisterLogonProcess(DWORD dwProcessId, BOOL bRegister)
 {
-  return NtUserRegisterLogonProcess(hprocess, x);
+  return NtUserCallTwoParam(dwProcessId,
+                           (DWORD)bRegister,
+                           TWOPARAM_ROUTINE_REGISTERLOGONPROC);
 }
index edab919..e786c0b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.81 2004/07/03 13:55:36 navaraf Exp $
+/* $Id: misc.c,v 1.82 2004/07/08 14:36:18 ekohl Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -37,39 +37,44 @@ PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() {
 }
 
 BOOL FASTCALL
-IntRegisterLogonProcess(HANDLE hProcess, BOOL x)
+IntRegisterLogonProcess(DWORD dwProcessId, BOOL bRegister)
 {
   PEPROCESS Process;
   NTSTATUS Status;
-  
-  if(LogonProcess != NULL && LogonProcess != PsGetWin32Process())
+
+  Status = PsLookupProcessByProcessId((PVOID)dwProcessId,
+                                     &Process);
+  if (!NT_SUCCESS(Status))
   {
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
+    SetLastWin32Error(RtlNtStatusToDosError(Status));
     return FALSE;
   }
-  
-  if(hProcess)
+
+  if (bRegister)
   {
-    Status = ObReferenceObjectByHandle(hProcess,
-                                       PROCESS_QUERY_INFORMATION,
-                                       PsProcessType,
-                                       ExGetPreviousMode(),
-                                       (PVOID*)&Process,
-                                       NULL);
-    if(!NT_SUCCESS(Status))
+    /* Register the logon process */
+    if (LogonProcess != NULL)
     {
-      SetLastNtError(Status);
-      return 0;
+      ObDereferenceObject(Process);
+      return FALSE;
     }
-  
+
     LogonProcess = Process->Win32Process;
-    ObDereferenceObject(Process);
   }
   else
   {
-    /* deregister the logon process */
+    /* Deregister the logon process */
+    if (LogonProcess != Process->Win32Process)
+    {
+      ObDereferenceObject(Process);
+      return FALSE;
+    }
+
     LogonProcess = NULL;
   }
+
+  ObDereferenceObject(Process);
+
   return TRUE;
 }
 
@@ -489,7 +494,7 @@ NtUserCallTwoParam(
     }
     
     case TWOPARAM_ROUTINE_REGISTERLOGONPROC:
-      return (DWORD)IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2);
+      return (DWORD)IntRegisterLogonProcess(Param1, (BOOL)Param2);
     
   }
   DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
@@ -532,7 +537,7 @@ NtUserCallHwndLock(
          /* FIXME */
          break;
 
-      case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW:         
+      case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW:
          Ret = IntSetForegroundWindow(Window);
          break;
 
index bb7c528..c8a02f9 100644 (file)
@@ -3704,6 +3704,7 @@ HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE,LPVOID,DWORD);
 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE,LPVOID,DWORD);
 #endif
 BOOL WINAPI RegisterHotKey(HWND,int,UINT,UINT);
+BOOL WINAPI RegisterLogonProcess(DWORD,BOOL);
 #if (_WIN32_WINNT >= 0x0501)
 BOOL WINAPI RegisterRawInputDevices(PCRAWINPUTDEVICE,UINT,UINT);
 #endif