[BASESRV]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 9 Nov 2012 23:39:45 +0000 (23:39 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 9 Nov 2012 23:39:45 +0000 (23:39 +0000)
- Remove the unneeded CallProcessCreated function since the same functionality is programmed and executed in CSRSRV when CsrInsertProcess is called via a call of CsrCreateProcess.
- Remove some hacks in process creation.
- In BaseSrvExitProcess, use the 'Reply = 2' value instead of the old hack 'ApiMessage->ApiNumber = 0xBABE'.

[USER32/WINSRV]
- Make SetLogonNotifyWindow call our 'RosSetLogonNotifyWindow' hack and explicitely mark it as a hack.
- CsrSetLogonNotifyWindow --> RosSetLogonNotifyWindow to emphasize that it is a ReactOS-specific hack.

svn path=/branches/ros-csrss/; revision=57694

include/reactos/subsys/win/winmsg.h
subsystems/win/basesrv/server.c
win32ss/user/user32/misc/misc.c
win32ss/user/winsrv/init.c
win32ss/user/winsrv/shutdown.c
win32ss/user/winsrv/winsrv.h

index 94bc8eb..d9ff9a7 100644 (file)
@@ -33,6 +33,9 @@ typedef enum _USERSRV_API_NUMBER
     // UserpConsoleHandleOperation,      // Added in Win7
     // UserpGetSetShutdownBlockReason,   // Added in Vista
 
+    /// HACK: ReactOS-specific
+    UserpRosSetLogonNotifyWindow,
+
     UserpMaxApiNumber
 } USERSRV_API_NUMBER, *PUSERSRV_API_NUMBER;
 
@@ -54,6 +57,7 @@ typedef struct
     BOOL Register;
 } CSRSS_REGISTER_LOGON_PROCESS, *PCSRSS_REGISTER_LOGON_PROCESS;
 
+/// HACK: ReactOS-specific
 typedef struct
 {
     HWND LogonNotifyWindow;
@@ -73,6 +77,8 @@ typedef struct _USER_API_MESSAGE
         CSRSS_EXIT_REACTOS ExitReactosRequest;
         CSRSS_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest;
         CSRSS_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest;
+
+        /// HACK: ReactOS-specific
         CSRSS_SET_LOGON_NOTIFY_WINDOW SetLogonNotifyWindowRequest;
     } Data;
 } USER_API_MESSAGE, *PUSER_API_MESSAGE;
index 7fcfc47..ec567b0 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
-
-// extern NTSTATUS CallProcessCreated(PCSR_PROCESS, PCSR_PROCESS); // TODO: Import it from csrsrv/init.c
-// Remove it and correct csrsrv instead...
-#if 0
-NTSTATUS
-CallProcessCreated(IN PCSR_PROCESS SourceProcessData,
-                   IN PCSR_PROCESS TargetProcessData)
-{
-    NTSTATUS Status = STATUS_SUCCESS;
-    ULONG i;
-    PCSR_SERVER_DLL ServerDll;
-
-    DPRINT("CSR: %s called\n", __FUNCTION__);
-
-    /* Notify the Server DLLs */
-    for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
-    {
-        /* Get the current Server DLL */
-        ServerDll = CsrLoadedServerDll[i];
-
-        /* Make sure it's valid and that it has callback */
-        if ((ServerDll) && (ServerDll->NewProcessCallback))
-        {
-            Status = ServerDll->NewProcessCallback(SourceProcessData, TargetProcessData);
-        }
-    }
-
-    return Status;
-}
-#endif
-
 CSR_API(BaseSrvCreateProcess)
 {
     NTSTATUS Status;
     PBASE_CREATE_PROCESS CreateProcessRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CreateProcessRequest;
     HANDLE ProcessHandle, ThreadHandle;
     PCSR_THREAD CsrThread;
-    PCSR_PROCESS Process; // , NewProcess;
-    ULONG /* Flags, */ VdmPower = 0, DebugFlags = 0;
+    PCSR_PROCESS Process;
+    ULONG Flags = 0, VdmPower = 0, DebugFlags = 0;
 
     /* Get the current client thread */
     CsrThread = CsrGetClientThread();
@@ -58,7 +27,7 @@ CSR_API(BaseSrvCreateProcess)
     Process = CsrThread->Process;
 
     /* Extract the flags out of the process handle */
-    // Flags = (ULONG_PTR)CreateProcessRequest->ProcessHandle & 3;
+    Flags = (ULONG_PTR)CreateProcessRequest->ProcessHandle & 3;
     CreateProcessRequest->ProcessHandle = (HANDLE)((ULONG_PTR)CreateProcessRequest->ProcessHandle & ~3);
 
     /* Duplicate the process handle */
@@ -107,7 +76,7 @@ CSR_API(BaseSrvCreateProcess)
         }
     }
 
-    /* Convert some flags. FIXME: More need conversion */
+    /* Flags conversion. FIXME: More need conversion */
     if (CreateProcessRequest->CreationFlags & CREATE_NEW_PROCESS_GROUP)
     {
         DebugFlags |= CsrProcessCreateNewGroup;
@@ -139,20 +108,6 @@ CSR_API(BaseSrvCreateProcess)
 
     /* FIXME: VDM vodoo */
 
-    /* ReactOS Compatibility */
-#if 0
-    Status = CsrLockProcessByClientId(CreateProcessRequest->ClientId.UniqueProcess, &NewProcess);
-    ASSERT(Status == STATUS_SUCCESS);
-    if (!(CreateProcessRequest->CreationFlags & (CREATE_NEW_CONSOLE | DETACHED_PROCESS)))
-    {
-        NewProcess->ParentConsole = Process->Console;
-        NewProcess->bInheritHandles = CreateProcessRequest->bInheritHandles;
-    }
-    RtlInitializeCriticalSection(&NewProcess->HandleTableLock);
-    CallProcessCreated(Process, NewProcess);
-    CsrUnlockProcess(NewProcess);
-#endif
-
     /* Return the result of this operation */
     return Status;
 }
@@ -206,7 +161,8 @@ CSR_API(BaseSrvCreateThread)
         /* Call CSRSRV to tell it about the new thread */
         Status = CsrCreateThread(CsrProcess,
                                  ThreadHandle,
-                                 &CreateThreadRequest->ClientId);
+                                 &CreateThreadRequest->ClientId,
+                                 TRUE);
     }
 
     /* Unlock the process and return */
@@ -232,8 +188,8 @@ CSR_API(BaseSrvExitProcess)
     PCSR_THREAD CsrThread = CsrGetClientThread();
     ASSERT(CsrThread != NULL);
 
-    /* Set magic flag so we don't reply this message back */
-    ApiMessage->ApiNumber = 0xBABE;
+    /* Set the special reply value so we don't reply this message back */
+    *Reply = 2;
 
     /* Remove the CSR_THREADs and CSR_PROCESS */
     return CsrDestroyProcess(&CsrThread->ClientId,
index 899c080..d211bb1 100644 (file)
@@ -74,26 +74,25 @@ BOOL
 WINAPI
 SetLogonNotifyWindow(HWND Wnd, HWINSTA WinSta)
 {
-#if 0
+/// HACK: Windows does not do this !! ReactOS-specific
     /* Maybe we should call NtUserSetLogonNotifyWindow and let that one inform CSRSS??? */
-    CSR_API_MESSAGE Request;
+    USER_API_MESSAGE Request;
     NTSTATUS Status;
 
     Request.Data.SetLogonNotifyWindowRequest.LogonNotifyWindow = Wnd;
 
-    Status = CsrClientCallServer(&Request,
+    Status = CsrClientCallServer((PCSR_API_MESSAGE)&Request,
                                  NULL,
-                                 CSR_CREATE_API_NUMBER(CSR_GUI, SET_LOGON_NOTIFY_WINDOW),
-                                 sizeof(CSR_API_MESSAGE));
+                                 CSR_CREATE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpRosSetLogonNotifyWindow),
+                                 sizeof(CSRSS_SET_LOGON_NOTIFY_WINDOW));
     if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
     {
         SetLastError(RtlNtStatusToDosError(Status));
         return FALSE;
     }
+/// END HACK
 
     return NtUserSetLogonNotifyWindow(Wnd);
-#endif
-    return TRUE;
 }
 
 /*
index 957df9a..90384ea 100644 (file)
@@ -40,6 +40,9 @@ PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber] =
     // SrvCancelShutdown,              // Added in Vista
     // SrvConsoleHandleOperation,      // Added in Win7
     // SrvGetSetShutdownBlockReason,   // Added in Vista
+
+    /// HACK: ReactOS-specific
+    RosSetLogonNotifyWindow
 };
 
 BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber] =
@@ -58,6 +61,9 @@ BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber] =
     // FALSE,   // SrvConsoleHandleOperation
     // FALSE,   // SrvGetSetShutdownBlockReason
 
+    /// HACK: ReactOS-specific
+    FALSE,   // RosSetLogonNotifyWindow
+
     // FALSE
 };
 
@@ -77,6 +83,9 @@ PCHAR UserServerApiNameTable[UserpMaxApiNumber] =
     // "SrvConsoleHandleOperation",
     // "SrvGetSetShutdownBlockReason",
 
+    /// HACK: ReactOS-specific
+    "RosSetLogonNotifyWindow",
+
     // NULL
 };
 
index b1904df..27e4944 100644 (file)
@@ -56,7 +56,8 @@ CSR_API(SrvRegisterLogonProcess)
     return STATUS_SUCCESS;
 }
 
-CSR_API(CsrSetLogonNotifyWindow)
+/// HACK: ReactOS-specific
+CSR_API(RosSetLogonNotifyWindow)
 {
     PCSRSS_SET_LOGON_NOTIFY_WINDOW SetLogonNotifyWindowRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.SetLogonNotifyWindowRequest;
     DWORD WindowCreator;
index 88e8a3b..0d11a04 100644 (file)
@@ -53,11 +53,12 @@ Win32CsrHardError(IN PCSR_THREAD ThreadData,
 
 /* shutdown.c */
 CSR_API(SrvExitWindowsEx);
-CSR_API(CsrSetLogonNotifyWindow);
-CSR_API(SrvRegisterLogonProcess);
 // CSR_API(CsrRegisterSystemClasses);
-
 CSR_API(SrvRegisterServicesProcess);
+CSR_API(SrvRegisterLogonProcess);
+
+/// HACK: ReactOS-specific
+CSR_API(RosSetLogonNotifyWindow);
 
 
 /*****************************