[ADVAPI32]

Do not deregister the logon process after logon. Close the port when the DLL is unloaded.

svn path=/trunk/; revision=61285
This commit is contained in:
Eric Kohl 2013-12-17 21:01:18 +00:00
parent a740935f27
commit b1932aac4d
3 changed files with 90 additions and 40 deletions

View file

@ -56,6 +56,11 @@
#define FN_PROGRESSA FN_PROGRESS
#endif
/* logon.c */
NTSTATUS
CloseLogonLsaHandle(VOID);
/* rpc.c */
RPC_STATUS EvtBindRpc(LPCWSTR pszMachine,

View file

@ -15,8 +15,10 @@ extern BOOL RegInitialize(VOID);
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 @@ DllMain(HINSTANCE hinstDll,
DisableThreadLibraryCalls(hinstDll);
RegInitialize();
break;
case DLL_PROCESS_DETACH:
CloseLogonLsaHandle();
RegCleanup();
UnloadNtMarta();
break;

View file

@ -9,8 +9,83 @@
#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 @@ LogonUserW(LPWSTR lpszUsername,
{
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,33 +321,13 @@ LogonUserW(LPWSTR lpszUsername,
*phToken = NULL;
RtlInitAnsiString((PANSI_STRING)&LogonProcessName,
"User32LogonProcess");
Status = LsaRegisterLogonProcess(&LogonProcessName,
&LsaHandle,
&SecurityMode);
if (!NT_SUCCESS(Status))
if (LsaHandle == NULL)
{
TRACE("LsaRegisterLogonProcess failed (Status 0x%08lx)\n", Status);
goto done;
Status = OpenLogonLsaHandle();
if (!NT_SUCCESS(Status))
return Status;
}
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);
RtlInitAnsiString((PANSI_STRING)&OriginName,
"Testapp");
@ -454,15 +504,6 @@ done:
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));