[MSV1_0] Create stubs for SECPKG_FUNCTION_TABLE (SpLsaModeInitialize)

This commit fixes a bug too.
Old code of SpLsaModeInitialze returns a pointer to a local variable (SECPKG_FUNCTION_TABLE).
This commit is contained in:
Andreas Maier 2020-04-11 23:32:04 +02:00 committed by Mark Jansen
parent a16a37fd2d
commit f95c96e207
6 changed files with 405 additions and 32 deletions

View file

@ -2,6 +2,7 @@
spec2def(msv1_0.dll msv1_0.spec)
list(APPEND SOURCE
lsa.c
msv1_0.c
precomp.h
${CMAKE_CURRENT_BINARY_DIR}/msv1_0_stubs.c

228
dll/win32/msv1_0/lsa.c Normal file
View file

@ -0,0 +1,228 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL - See COPYING in the top level directory
* FILE: dll/win32/msv1_0/lsa.c
* PURPOSE: NTLM-functions returned from SpLsaModeInitialize
(PSECPKG_FUNCTION_TABLE)
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/
#include "precomp.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msv1_0);
SECPKG_FUNCTION_TABLE NtlmLsaFn[1];
NTSTATUS
NTAPI
SpInitialize(
_In_ ULONG_PTR PackageId,
_In_ PSECPKG_PARAMETERS Parameters,
_In_ PLSA_SECPKG_FUNCTION_TABLE FunctionTable)
{
TRACE("LsaSpInitialize (0x%p, 0x%p, 0x%p)\n",
PackageId, Parameters, FunctionTable);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpShutDown(VOID)
{
TRACE("LsaSpShutDown\n");
return STATUS_NOT_IMPLEMENTED;
}
/* MS doc says name must be SpAcceptCredentials! */
NTSTATUS
NTAPI
SpAcceptCredentials(
_In_ SECURITY_LOGON_TYPE LogonType,
_In_ PUNICODE_STRING AccountName,
_In_ PSECPKG_PRIMARY_CRED PrimaryCredentials,
_In_ PSECPKG_SUPPLEMENTAL_CRED SupplementalCredentials)
{
TRACE("LsaSpAcceptCredentials(%li %wZ 0x%p 0x%p)\n",
LogonType, AccountName, PrimaryCredentials, SupplementalCredentials);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpAcquireCredentialsHandle(
_In_ PUNICODE_STRING PrincipalName,
_In_ ULONG CredentialUseFlags,
_In_ PLUID LogonId,
_In_ PVOID AuthorizationData,
_In_ PVOID GetKeyFunciton,
_In_ PVOID GetKeyArgument,
_Out_ PLSA_SEC_HANDLE CredentialHandle,
_Out_ PTimeStamp ExpirationTime)
{
TRACE("LsaSpAcquireCredentialsHandle(%wZ 0x%lx 0x%p 0x%p 0x%p 0x%p 0x%p 0x%p)\n",
PrincipalName, CredentialUseFlags, LogonId,
AuthorizationData, GetKeyFunciton, GetKeyArgument,
CredentialHandle, ExpirationTime);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpQueryCredentialsAttributes(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ ULONG CredentialAttribute,
_Inout_ PVOID Buffer)
{
TRACE("LsaSpQueryCredentialsAttributes(0x%p 0x%lx 0x%p)\n",
CredentialHandle, CredentialAttribute, Buffer);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpFreeCredentialsHandle(
_In_ LSA_SEC_HANDLE CredentialHandle)
{
TRACE("LsaSpFreeCredentialsHandle(0x%p)", CredentialHandle);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpSaveCredentials(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ PSecBuffer Credentials)
{
TRACE("LsaSpSaveCredentials(0x%p 0x%p)\n", CredentialHandle, Credentials);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpGetCredentials(
_In_ LSA_SEC_HANDLE CredentialHandle,
_Inout_ PSecBuffer Credentials)
{
TRACE("LsaSpGetCredentials(0x%p 0x%p)\n", CredentialHandle, Credentials);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpDeleteCredentials(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ PSecBuffer Key)
{
TRACE("LsaSpDeleteCredentials(0x%p 0x%p)\n", CredentialHandle, Key);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpGetInfoW(
_Out_ PSecPkgInfoW PackageInfo)
{
TRACE("LsaGetInfo(0x%p)\n", PackageInfo);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpInitLsaModeContext(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PUNICODE_STRING TargetName,
_In_ ULONG ContextRequirements,
_In_ ULONG TargetDataRep,
_In_ PSecBufferDesc InputBuffers,
_Out_ PLSA_SEC_HANDLE NewContextHandle,
_Inout_ PSecBufferDesc OutputBuffers,
_Out_ PULONG ContextAttributes,
_Out_ PTimeStamp ExpirationTime,
_Out_ PBOOLEAN MappedContext,
_Out_ PSecBuffer ContextData)
{
TRACE("LsaSpInitLsaModeContext(0x%p 0x%p %wZ 0x%lx %i 0x%p 0x%p 0x%p "
"0x%p 0x%p 0x%p 0x%p 0x%p 0x%p 0x%p 0x%p)\n",
CredentialHandle, ContextHandle, TargetName,
ContextRequirements, TargetDataRep, InputBuffers,
NewContextHandle, OutputBuffers, ContextAttributes,
ExpirationTime, MappedContext, ContextData);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpAcceptLsaModeContext(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBufferDesc InputBuffer,
_In_ ULONG ContextRequirements,
_In_ ULONG TargetDataRep,
_Out_ PLSA_SEC_HANDLE NewContextHandle,
_Inout_ PSecBufferDesc OutputBuffer,
_Out_ PULONG ContextAttributes,
_Out_ PTimeStamp ExpirationTime,
_Out_ PBOOLEAN MappedContext,
_Out_ PSecBuffer ContextData)
{
TRACE("LsaSpAcceptLsaModeContext(0x%p 0x%p 0x%p %i %i 0x%p 0x%p 0x%p "
"0x%p 0x%p 0x%p)\n",
CredentialHandle, ContextHandle, InputBuffer, ContextRequirements,
TargetDataRep, NewContextHandle, OutputBuffer,
ContextAttributes, ExpirationTime, MappedContext, ContextData);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpDeleteContext(
_In_ LSA_SEC_HANDLE ContextHandle)
{
TRACE("LsaSpDeleteContext(0x%p)\n", ContextHandle);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpApplyControlToken(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBufferDesc ControlToken)
{
TRACE("LsaSpApplyControlToken(0x%p 0x%p)\n", ContextHandle, ControlToken);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpGetUserInfo(
_In_ PLUID LogonId,
_In_ ULONG Flags,
_Out_ PSecurityUserData *UserData)
{
TRACE("LsaSpGetUserInfo(0x%p 0x%lx 0x%p)\n", LogonId, Flags, UserData);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpGetExtendedInformation(
_In_ SECPKG_EXTENDED_INFORMATION_CLASS Class,
_Out_ PSECPKG_EXTENDED_INFORMATION *ppInfo)
{
TRACE("LsaSpGetExtendedInformation(0x%lx 0x%p)\n",
Class, ppInfo);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
LsaSpSetExtendedInformation(
_In_ SECPKG_EXTENDED_INFORMATION_CLASS Class,
_In_ PSECPKG_EXTENDED_INFORMATION Info)
{
TRACE("LsaSpSetExtendedInformation(0x%lx 0x%p)\n",
Class, Info);
return STATUS_NOT_IMPLEMENTED;
}

142
dll/win32/msv1_0/lsa.h Normal file
View file

@ -0,0 +1,142 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL - See COPYING in the top level directory
* FILE: dll/win32/msv1_0/lsa.h
* PURPOSE: header for lsa.c
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/
#ifndef _MSV1_0_LSA_H_
#define _MSV1_0_LSA_H_
// functions we provide to LSA in SpLsaModeInitialize
extern SECPKG_FUNCTION_TABLE NtlmLsaFn[1];
NTSTATUS
NTAPI
SpInitialize(
_In_ ULONG_PTR PackageId,
_In_ PSECPKG_PARAMETERS Parameters,
_In_ PLSA_SECPKG_FUNCTION_TABLE FunctionTable);
NTSTATUS
NTAPI
LsaSpShutDown(VOID);
NTSTATUS
NTAPI
SpAcceptCredentials(
_In_ SECURITY_LOGON_TYPE LogonType,
_In_ PUNICODE_STRING AccountName,
_In_ PSECPKG_PRIMARY_CRED PrimaryCredentials,
_In_ PSECPKG_SUPPLEMENTAL_CRED SupplementalCredentials);
NTSTATUS
NTAPI
LsaSpAcquireCredentialsHandle(
_In_ PUNICODE_STRING PrincipalName,
_In_ ULONG CredentialUseFlags,
_In_ PLUID LogonId,
_In_ PVOID AuthorizationData,
_In_ PVOID GetKeyFunciton,
_In_ PVOID GetKeyArgument,
_Out_ PLSA_SEC_HANDLE CredentialHandle,
_Out_ PTimeStamp ExpirationTime);
NTSTATUS
NTAPI
LsaSpQueryCredentialsAttributes(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ ULONG CredentialAttribute,
_Inout_ PVOID Buffer);
NTSTATUS
NTAPI
LsaSpFreeCredentialsHandle(
_In_ LSA_SEC_HANDLE CredentialHandle);
NTSTATUS
NTAPI
LsaSpSaveCredentials(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ PSecBuffer Credentials);
NTSTATUS
NTAPI
LsaSpGetCredentials(
_In_ LSA_SEC_HANDLE CredentialHandle,
_Inout_ PSecBuffer Credentials);
NTSTATUS
NTAPI
LsaSpDeleteCredentials(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ PSecBuffer Key);
NTSTATUS
NTAPI
LsaSpGetInfoW(
_Out_ PSecPkgInfoW PackageInfo);
NTSTATUS
NTAPI
LsaSpInitLsaModeContext(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PUNICODE_STRING TargetName,
_In_ ULONG ContextRequirements,
_In_ ULONG TargetDataRep,
_In_ PSecBufferDesc InputBuffers,
_Out_ PLSA_SEC_HANDLE NewContextHandle,
_Inout_ PSecBufferDesc OutputBuffers,
_Out_ PULONG ContextAttributes,
_Out_ PTimeStamp ExpirationTime,
_Out_ PBOOLEAN MappedContext,
_Out_ PSecBuffer ContextData);
NTSTATUS
NTAPI
LsaSpAcceptLsaModeContext(
_In_ LSA_SEC_HANDLE CredentialHandle,
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBufferDesc InputBuffer,
_In_ ULONG ContextRequirements,
_In_ ULONG TargetDataRep,
_Out_ PLSA_SEC_HANDLE NewContextHandle,
_Inout_ PSecBufferDesc OutputBuffer,
_Out_ PULONG ContextAttributes,
_Out_ PTimeStamp ExpirationTime,
_Out_ PBOOLEAN MappedContext,
_Out_ PSecBuffer ContextData);
NTSTATUS
NTAPI
LsaSpDeleteContext(
_In_ LSA_SEC_HANDLE ContextHandle);
NTSTATUS
NTAPI
LsaSpApplyControlToken(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBufferDesc ControlToken);
NTSTATUS
NTAPI
LsaSpGetUserInfo(
_In_ PLUID LogonId,
_In_ ULONG Flags,
_Out_ PSecurityUserData *UserData);
NTSTATUS
NTAPI
LsaSpGetExtendedInformation(
_In_ SECPKG_EXTENDED_INFORMATION_CLASS Class,
_Out_ PSECPKG_EXTENDED_INFORMATION *ppInfo);
NTSTATUS
NTAPI
LsaSpSetExtendedInformation(
_In_ SECPKG_EXTENDED_INFORMATION_CLASS Class,
_In_ PSECPKG_EXTENDED_INFORMATION Info);
#endif /* _MSV1_0_LSA_H_ */

View file

@ -1716,8 +1716,6 @@ SpLsaModeInitialize(
_Out_ PSECPKG_FUNCTION_TABLE *ppTables,
_Out_ PULONG pcTables)
{
SECPKG_FUNCTION_TABLE Tables[1];
TRACE("SpLsaModeInitialize(0x%lx %p %p %p)\n",
LsaVersion, PackageVersion, ppTables, pcTables);
@ -1726,37 +1724,40 @@ SpLsaModeInitialize(
*PackageVersion = SECPKG_INTERFACE_VERSION;
RtlZeroMemory(&Tables, sizeof(Tables));
RtlZeroMemory(NtlmLsaFn, sizeof(NtlmLsaFn));
Tables[0].InitializePackage = LsaApInitializePackage;
// Tables[0].LogonUser = NULL;
Tables[0].CallPackage = (PLSA_AP_CALL_PACKAGE)LsaApCallPackage;
Tables[0].LogonTerminated = LsaApLogonTerminated;
Tables[0].CallPackageUntrusted = LsaApCallPackageUntrusted;
Tables[0].CallPackagePassthrough = (PLSA_AP_CALL_PACKAGE_PASSTHROUGH)LsaApCallPackagePassthrough;
// Tables[0].LogonUserEx = NULL;
Tables[0].LogonUserEx2 = LsaApLogonUserEx2;
// Tables[0].Initialize = SpInitialize;
// Tables[0].Shutdown = NULL;
// Tables[0].GetInfo = NULL;
// Tables[0].AcceptCredentials = NULL;
// Tables[0].SpAcquireCredentialsHandle = NULL;
// Tables[0].SpQueryCredentialsAttributes = NULL;
// Tables[0].FreeCredentialsHandle = NULL;
// Tables[0].SaveCredentials = NULL;
// Tables[0].GetCredentials = NULL;
// Tables[0].DeleteCredentials = NULL;
// Tables[0].InitLsaModeContext = NULL;
// Tables[0].AcceptLsaModeContext = NULL;
// Tables[0].DeleteContext = NULL;
// Tables[0].ApplyControlToken = NULL;
// Tables[0].GetUserInfo = NULL;
// Tables[0].GetExtendedInformation = NULL;
// Tables[0].SpQueryContextAttributes = NULL;
// Tables[0].SpAddCredentials = NULL;
// Tables[0].SetExtendedInformation = NULL;
/* msv1_0 (XP, win2k) returns NULL for
* InitializePackage, LsaLogonUser,LsaLogonUserEx,
* SpQueryContextAttributes and SpAddCredentials */
NtlmLsaFn[0].InitializePackage = NULL;
NtlmLsaFn[0].LsaLogonUser = NULL;
NtlmLsaFn[0].CallPackage = LsaApCallPackage;
NtlmLsaFn[0].LogonTerminated = LsaApLogonTerminated;
NtlmLsaFn[0].CallPackageUntrusted = LsaApCallPackageUntrusted;
NtlmLsaFn[0].CallPackagePassthrough = LsaApCallPackagePassthrough;
NtlmLsaFn[0].LogonUserEx = NULL;
NtlmLsaFn[0].LogonUserEx2 = LsaApLogonUserEx2;
NtlmLsaFn[0].Initialize = SpInitialize;
NtlmLsaFn[0].Shutdown = LsaSpShutDown;
NtlmLsaFn[0].GetInfo = LsaSpGetInfoW;
NtlmLsaFn[0].AcceptCredentials = SpAcceptCredentials;
NtlmLsaFn[0].SpAcquireCredentialsHandle = LsaSpAcquireCredentialsHandle;
NtlmLsaFn[0].SpQueryCredentialsAttributes = LsaSpQueryCredentialsAttributes;
NtlmLsaFn[0].FreeCredentialsHandle = LsaSpFreeCredentialsHandle;
NtlmLsaFn[0].SaveCredentials = LsaSpSaveCredentials;
NtlmLsaFn[0].GetCredentials = LsaSpGetCredentials;
NtlmLsaFn[0].DeleteCredentials = LsaSpDeleteCredentials;
NtlmLsaFn[0].InitLsaModeContext = LsaSpInitLsaModeContext;
NtlmLsaFn[0].AcceptLsaModeContext = LsaSpAcceptLsaModeContext;
NtlmLsaFn[0].DeleteContext = LsaSpDeleteContext;
NtlmLsaFn[0].ApplyControlToken = LsaSpApplyControlToken;
NtlmLsaFn[0].GetUserInfo = LsaSpGetUserInfo;
NtlmLsaFn[0].GetExtendedInformation = LsaSpGetExtendedInformation;
NtlmLsaFn[0].SpQueryContextAttributes = NULL;
NtlmLsaFn[0].SpAddCredentials = NULL;
NtlmLsaFn[0].SetExtendedInformation = LsaSpSetExtendedInformation;
*ppTables = Tables;
*ppTables = NtlmLsaFn;
*pcTables = 1;
return STATUS_SUCCESS;

View file

@ -10,7 +10,7 @@
@ stub MsvSamLogoff
@ stub MsvSamValidate
@ stub MsvValidateTarget
@ stub SpInitialize
@ stdcall SpInitialize(long ptr ptr)
@ stub SpInstanceInit
@ stdcall SpLsaModeInitialize(long ptr ptr ptr)
@ stdcall SpUserModeInitialize(long ptr ptr ptr)

View file

@ -29,6 +29,7 @@
#include <samsrv/samsrv.h>
//#include <lsass/lsasrv.h>
#include "lsa.h"
#include "msv1_0.h"
#include <wine/debug.h>