[WIN32K:NTUSER]
[reactos.git] / reactos / win32ss / user / winsrv / usersrv / init.c
index fc199b9..2e9ac5a 100644 (file)
@@ -102,7 +102,7 @@ NTAPI
 CreateSystemThreads(PVOID pParam)
 {
     NtUserCallOneParam((DWORD)pParam, ONEPARAM_ROUTINE_CREATESYSTEMTHREADS);
-    DPRINT1("This thread should not terminate!\n");
+    RtlExitUserThread(0);
     return 0;
 }
 
@@ -137,6 +137,23 @@ CSR_API(SrvDeviceEvent)
     return STATUS_NOT_IMPLEMENTED;
 }
 
+CSR_API(SrvLogon)
+{
+    PUSER_LOGON LogonRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.LogonRequest;
+
+    DPRINT1("We are logged %s\n", LogonRequest->IsLogon ? "on" : "off");
+
+    /* Impersonate the caller in order to retrieve settings in its context */
+    if (!CsrImpersonateClient(NULL))
+        return STATUS_UNSUCCESSFUL;
+
+    GetTimeouts(&ShutdownSettings);
+
+    /* We are done */
+    CsrRevertToSelf();
+    return STATUS_SUCCESS;
+}
+
 NTSTATUS
 NTAPI
 UserClientConnect(IN PCSR_PROCESS CsrProcess,
@@ -147,7 +164,7 @@ UserClientConnect(IN PCSR_PROCESS CsrProcess,
     // PUSERCONNECT
     PUSERSRV_API_CONNECTINFO ConnectInfo = (PUSERSRV_API_CONNECTINFO)ConnectionInfo;
 
-    DPRINT1("UserClientConnect\n");
+    DPRINT("UserClientConnect\n");
 
     /* Check if we don't have an API port yet */
     if (CsrApiPort == NULL)
@@ -191,12 +208,7 @@ UserClientConnect(IN PCSR_PROCESS CsrProcess,
 
 CSR_SERVER_DLL_INIT(UserServerDllInitialization)
 {
-/*** From win32csr... ***/
-    HANDLE ServerThread;
-    CLIENT_ID ClientId;
     NTSTATUS Status;
-    UINT i;
-/*** END - From win32csr... ***/
 
     /* Initialize the memory */
     UserServerHeap = RtlGetProcessHeap();
@@ -217,26 +229,6 @@ CSR_SERVER_DLL_INIT(UserServerDllInitialization)
 
     UserServerDllInstance = LoadedServerDll->ServerHandle;
 
-/*** From win32csr... See r54125 ***/
-    /* Start the Raw Input Thread and the Desktop Thread */
-    for (i = 0; i < 2; ++i)
-    {
-        Status = RtlCreateUserThread(NtCurrentProcess(),
-                                     NULL, TRUE, 0, 0, 0,
-                                     CreateSystemThreads,
-                                     (PVOID)i, &ServerThread, &ClientId);
-        if (NT_SUCCESS(Status))
-        {
-            NtResumeThread(ServerThread, NULL);
-            NtClose(ServerThread);
-        }
-        else
-        {
-            DPRINT1("Cannot start Raw Input Thread!\n");
-        }
-    }
-/*** END - From win32csr... ***/
-
     /* Create the power request event */
     Status = NtCreateEvent(&ghPowerRequestEvent,
                            EVENT_ALL_ACCESS,
@@ -261,6 +253,9 @@ CSR_SERVER_DLL_INIT(UserServerDllInitialization)
         return Status;
     }
 
+    /* Set the process creation notify routine for BASE */
+    BaseSetProcessCreateNotify(NtUserNotifyProcessCreate);
+
     /* Initialize the kernel mode subsystem */
     Status = NtUserInitialize(USER_VERSION,
                               ghPowerRequestEvent,
@@ -271,6 +266,32 @@ CSR_SERVER_DLL_INIT(UserServerDllInitialization)
         return Status;
     }
 
+/*** From win32csr... See r54125 ***/
+    {
+        HANDLE ServerThread;
+        CLIENT_ID ClientId;
+        UINT i;
+
+        /* Start the Raw Input Thread and the Desktop Thread */
+        for (i = 0; i < 2; ++i)
+        {
+            Status = RtlCreateUserThread(NtCurrentProcess(),
+                                         NULL, TRUE, 0, 0, 0,
+                                         CreateSystemThreads,
+                                         (PVOID)i, &ServerThread, &ClientId);
+            if (NT_SUCCESS(Status))
+            {
+                NtResumeThread(ServerThread, NULL);
+                NtClose(ServerThread);
+            }
+            else
+            {
+                DPRINT1("Cannot start Raw Input Thread!\n");
+            }
+        }
+    }
+/*** END - From win32csr... ***/
+
     /* All done */
     return STATUS_SUCCESS;
 }