[LSALIB]
authorEric Kohl <eric.kohl@reactos.org>
Wed, 21 Sep 2016 10:27:06 +0000 (10:27 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 21 Sep 2016 10:27:06 +0000 (10:27 +0000)
- LsaRegisterLogonProcess: Wait for the LSA_AUTHENTICATION_INITIALIZED event.
- LsaDeregisterLogonProcess: Use ZwClose to close the port handle.

svn path=/trunk/; revision=72756

reactos/sdk/lib/lsalib/lsa.c

index 935f32b..26ea320 100644 (file)
@@ -209,17 +209,14 @@ LsaRegisterLogonProcess(IN PLSA_STRING LogonProcessName,
                         OUT PHANDLE LsaHandle,
                         OUT PLSA_OPERATIONAL_MODE OperationalMode)
 {
                         OUT PHANDLE LsaHandle,
                         OUT PLSA_OPERATIONAL_MODE OperationalMode)
 {
-    NTSTATUS Status;
-#if 0
-    HANDLE EventHandle;
-#endif
-    UNICODE_STRING PortName; // = RTL_CONSTANT_STRING(L"\\LsaAuthenticationPort");
-#if 0
-    OBJECT_ATTRIBUTES ObjectAttributes;
-#endif
     SECURITY_QUALITY_OF_SERVICE SecurityQos;
     LSA_CONNECTION_INFO ConnectInfo;
     ULONG ConnectInfoLength = sizeof(ConnectInfo);
     SECURITY_QUALITY_OF_SERVICE SecurityQos;
     LSA_CONNECTION_INFO ConnectInfo;
     ULONG ConnectInfoLength = sizeof(ConnectInfo);
+    UNICODE_STRING PortName;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    UNICODE_STRING EventName;
+    HANDLE EventHandle;
+    NTSTATUS Status;
 
     DPRINT("LsaRegisterLogonProcess()\n");
 
 
     DPRINT("LsaRegisterLogonProcess()\n");
 
@@ -227,36 +224,46 @@ LsaRegisterLogonProcess(IN PLSA_STRING LogonProcessName,
     if (LogonProcessName->Length > LSASS_MAX_LOGON_PROCESS_NAME_LENGTH)
         return STATUS_NAME_TOO_LONG;
 
     if (LogonProcessName->Length > LSASS_MAX_LOGON_PROCESS_NAME_LENGTH)
         return STATUS_NAME_TOO_LONG;
 
-#if 0
-    /*
-     * First check whether the LSA server is ready:
-     * open the LSA event and wait on it.
-     */
-    // Note that we just reuse the 'PortName' variable here.
-    RtlInitUnicodeString(&PortName, L"\\SECURITY\\LSA_AUTHENTICATION_INITIALIZED");
+    /* Wait for the LSA authentication thread */
+    RtlInitUnicodeString(&EventName,
+                         L"\\SECURITY\\LSA_AUTHENTICATION_INITIALIZED");
     InitializeObjectAttributes(&ObjectAttributes,
     InitializeObjectAttributes(&ObjectAttributes,
-                               &PortName,
-                               OBJ_CASE_INSENSITIVE,
+                               &EventName,
+                               OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
                                NULL,
                                NULL);
                                NULL,
                                NULL);
-    Status = NtOpenEvent(&EventHandle, SYNCHRONIZE, &ObjectAttributes);
+    Status = ZwOpenEvent(&EventHandle,
+                         SYNCHRONIZE,
+                         &ObjectAttributes);
     if (!NT_SUCCESS(Status))
     {
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("NtOpenEvent failed (Status 0x%08lx)\n", Status);
-        return Status;
+        DPRINT"NtOpenEvent failed (Status 0x%08lx)\n", Status);
+
+        Status = ZwCreateEvent(&EventHandle,
+                               SYNCHRONIZE,
+                               &ObjectAttributes,
+                               NotificationEvent,
+                               FALSE);
+        if (!NT_SUCCESS(Status))
+        {
+            DPRINT1("NtCreateEvent failed (Status 0x%08lx)\n", Status);
+            return Status;
+        }
     }
 
     }
 
-    Status = NtWaitForSingleObject(EventHandle, TRUE, NULL);
-    NtClose(EventHandle);
+    Status = ZwWaitForSingleObject(EventHandle,
+                                   TRUE,
+                                   NULL);
+    ZwClose(EventHandle);
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("NtWaitForSingleObject failed (Status 0x%08lx)\n", Status);
         return Status;
     }
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("NtWaitForSingleObject failed (Status 0x%08lx)\n", Status);
         return Status;
     }
-#endif
 
 
-    /* Now attempt the connection */
-    RtlInitUnicodeString(&PortName, L"\\LsaAuthenticationPort");
+    /* Establish the connection */
+    RtlInitUnicodeString(&PortName,
+                         L"\\LsaAuthenticationPort");
 
     SecurityQos.Length              = sizeof(SecurityQos);
     SecurityQos.ImpersonationLevel  = SecurityIdentification;
 
     SecurityQos.Length              = sizeof(SecurityQos);
     SecurityQos.ImpersonationLevel  = SecurityIdentification;
@@ -328,7 +335,7 @@ LsaDeregisterLogonProcess(IN HANDLE LsaHandle)
         return ApiMessage.Status;
     }
 
         return ApiMessage.Status;
     }
 
-    NtClose(LsaHandle);
+    ZwClose(LsaHandle);
 
     DPRINT("LsaDeregisterLogonProcess() done (Status 0x%08lx)\n", Status);
 
 
     DPRINT("LsaDeregisterLogonProcess() done (Status 0x%08lx)\n", Status);