Author: ekohl
Date: Wed Sep 21 10:27:06 2016
New Revision: 72756

URL: http://svn.reactos.org/svn/reactos?rev=72756&view=rev
Log:
[LSALIB]
- LsaRegisterLogonProcess: Wait for the LSA_AUTHENTICATION_INITIALIZED event.
- LsaDeregisterLogonProcess: Use ZwClose to close the port handle.

Modified:
    trunk/reactos/sdk/lib/lsalib/lsa.c

Modified: trunk/reactos/sdk/lib/lsalib/lsa.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/lsalib/lsa.c?rev=72756&r1=72755&r2=72756&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/lsalib/lsa.c  [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/lsalib/lsa.c  [iso-8859-1] Wed Sep 21 10:27:06 2016
@@ -209,17 +209,14 @@
                         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);
+    UNICODE_STRING PortName;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    UNICODE_STRING EventName;
+    HANDLE EventHandle;
+    NTSTATUS Status;
 
     DPRINT("LsaRegisterLogonProcess()\n");
 
@@ -227,36 +224,46 @@
     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,
-                               &PortName,
-                               OBJ_CASE_INSENSITIVE,
+                               &EventName,
+                               OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
                                NULL,
                                NULL);
-    Status = NtOpenEvent(&EventHandle, SYNCHRONIZE, &ObjectAttributes);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT1("NtOpenEvent failed (Status 0x%08lx)\n", Status);
-        return Status;
-    }
-
-    Status = NtWaitForSingleObject(EventHandle, TRUE, NULL);
-    NtClose(EventHandle);
+    Status = ZwOpenEvent(&EventHandle,
+                         SYNCHRONIZE,
+                         &ObjectAttributes);
+    if (!NT_SUCCESS(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 = ZwWaitForSingleObject(EventHandle,
+                                   TRUE,
+                                   NULL);
+    ZwClose(EventHandle);
     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;
@@ -328,7 +335,7 @@
         return ApiMessage.Status;
     }
 
-    NtClose(LsaHandle);
+    ZwClose(LsaHandle);
 
     DPRINT("LsaDeregisterLogonProcess() done (Status 0x%08lx)\n", Status);
 


Reply via email to