Author: ekohl
Date: Tue Dec 17 21:01:18 2013
New Revision: 61285
URL:
http://svn.reactos.org/svn/reactos?rev=61285&view=rev
Log:
[ADVAPI32]
Do not deregister the logon process after logon. Close the port when the DLL is unloaded.
Modified:
trunk/reactos/dll/win32/advapi32/advapi32.h
trunk/reactos/dll/win32/advapi32/misc/dllmain.c
trunk/reactos/dll/win32/advapi32/misc/logon.c
Modified: trunk/reactos/dll/win32/advapi32/advapi32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/advapi3…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/advapi32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/advapi32.h [iso-8859-1] Tue Dec 17 21:01:18 2013
@@ -55,6 +55,11 @@
#ifndef HAS_FN_PROGRESSA
#define FN_PROGRESSA FN_PROGRESS
#endif
+
+/* logon.c */
+
+NTSTATUS
+CloseLogonLsaHandle(VOID);
/* rpc.c */
Modified: trunk/reactos/dll/win32/advapi32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/misc/dl…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/misc/dllmain.c [iso-8859-1] Tue Dec 17 21:01:18 2013
@@ -15,8 +15,10 @@
extern BOOL RegCleanup(VOID);
extern VOID UnloadNtMarta(VOID);
-BOOL WINAPI
-DllMain(HINSTANCE hinstDll,
+BOOL
+WINAPI
+DllMain(
+ HINSTANCE hinstDll,
DWORD dwReason,
LPVOID reserved)
{
@@ -26,7 +28,9 @@
DisableThreadLibraryCalls(hinstDll);
RegInitialize();
break;
+
case DLL_PROCESS_DETACH:
+ CloseLogonLsaHandle();
RegCleanup();
UnloadNtMarta();
break;
Modified: trunk/reactos/dll/win32/advapi32/misc/logon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/misc/lo…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/misc/logon.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/misc/logon.c [iso-8859-1] Tue Dec 17 21:01:18 2013
@@ -9,7 +9,82 @@
#include <advapi32.h>
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
+/* GLOBALS *****************************************************************/
+
+HANDLE LsaHandle = NULL;
+ULONG AuthenticationPackage = 0;
+
/* FUNCTIONS ***************************************************************/
+
+static
+NTSTATUS
+OpenLogonLsaHandle(VOID)
+{
+ LSA_STRING LogonProcessName;
+ LSA_STRING PackageName;
+ LSA_OPERATIONAL_MODE SecurityMode = 0;
+ NTSTATUS Status;
+
+ RtlInitAnsiString((PANSI_STRING)&LogonProcessName,
+ "User32LogonProcess");
+
+ Status = LsaRegisterLogonProcess(&LogonProcessName,
+ &LsaHandle,
+ &SecurityMode);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaRegisterLogonProcess failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ RtlInitAnsiString((PANSI_STRING)&PackageName,
+ MSV1_0_PACKAGE_NAME);
+
+ Status = LsaLookupAuthenticationPackage(LsaHandle,
+ &PackageName,
+ &AuthenticationPackage);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaLookupAuthenticationPackage failed (Status 0x%08lx)\n",
Status);
+ goto done;
+ }
+
+ TRACE("AuthenticationPackage: 0x%08lx\n", AuthenticationPackage);
+
+done:
+ if (!NT_SUCCESS(Status))
+ {
+ if (LsaHandle != NULL)
+ {
+ Status = LsaDeregisterLogonProcess(LsaHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n",
Status);
+ }
+ }
+ }
+
+ return Status;
+}
+
+
+NTSTATUS
+CloseLogonLsaHandle(VOID)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ if (LsaHandle != NULL)
+ {
+ Status = LsaDeregisterLogonProcess(LsaHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n",
Status);
+ }
+ }
+
+ return Status;
+}
+
/*
* @implemented
@@ -224,11 +299,6 @@
{
SID_IDENTIFIER_AUTHORITY LocalAuthority = {SECURITY_LOCAL_SID_AUTHORITY};
SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY};
- LSA_STRING LogonProcessName;
- LSA_STRING PackageName;
- HANDLE LsaHandle = NULL;
- LSA_OPERATIONAL_MODE SecurityMode = 0;
- ULONG AuthenticationPackage = 0;
PSID LogonSid = NULL;
PSID LocalSid = NULL;
LSA_STRING OriginName;
@@ -251,32 +321,12 @@
*phToken = NULL;
- RtlInitAnsiString((PANSI_STRING)&LogonProcessName,
- "User32LogonProcess");
-
- Status = LsaRegisterLogonProcess(&LogonProcessName,
- &LsaHandle,
- &SecurityMode);
- if (!NT_SUCCESS(Status))
- {
- TRACE("LsaRegisterLogonProcess failed (Status 0x%08lx)\n", Status);
- goto done;
- }
-
- RtlInitAnsiString((PANSI_STRING)&PackageName,
- MSV1_0_PACKAGE_NAME);
-
- Status = LsaLookupAuthenticationPackage(LsaHandle,
- &PackageName,
- &AuthenticationPackage);
- if (!NT_SUCCESS(Status))
- {
- TRACE("LsaLookupAuthenticationPackage failed (Status 0x%08lx)\n",
Status);
- goto done;
- }
-
- TRACE("AuthenticationPackage: 0x%08lx\n", AuthenticationPackage);
-
+ if (LsaHandle == NULL)
+ {
+ Status = OpenLogonLsaHandle();
+ if (!NT_SUCCESS(Status))
+ return Status;
+ }
RtlInitAnsiString((PANSI_STRING)&OriginName,
"Testapp");
@@ -454,15 +504,6 @@
if (AuthInfo != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, AuthInfo);
- if (LsaHandle != NULL)
- {
- Status = LsaDeregisterLogonProcess(LsaHandle);
- if (!NT_SUCCESS(Status))
- {
- TRACE("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n",
Status);
- }
- }
-
if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));