[MSV1_0] Create stubs for SECPKG_USER_FUNCTION_TABLE

This commit fixes a bug as well: old code of SpUserModeInitialze returns
a pointer to a local variable (SECPKG_USER_FUNCTION_TABLE).
This commit is contained in:
Andreas Maier 2021-12-25 00:10:33 +01:00 committed by GitHub
parent 1c82bf0324
commit 0901077f8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 377 additions and 34 deletions

View file

@ -4,7 +4,9 @@ spec2def(msv1_0.dll msv1_0.spec)
list(APPEND SOURCE
lsa.c
msv1_0.c
precomp.h
ntlm/global.c
user.c
usercontext.c
${CMAKE_CURRENT_BINARY_DIR}/msv1_0_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/msv1_0.def)

View file

@ -1,9 +1,7 @@
/*
* 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)
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: NTLM functions returned from SpLsaModeInitialize (PSECPKG_FUNCTION_TABLE)
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/

View file

@ -1,13 +1,11 @@
/*
* 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
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Header for lsa.c
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/
#ifndef _MSV1_0_LSA_H_
#define _MSV1_0_LSA_H_
#pragma once
// functions we provide to LSA in SpLsaModeInitialize
extern SECPKG_FUNCTION_TABLE NtlmLsaFn[1];
@ -138,5 +136,3 @@ NTAPI
LsaSpSetExtendedInformation(
_In_ SECPKG_EXTENDED_INFORMATION_CLASS Class,
_In_ PSECPKG_EXTENDED_INFORMATION Info);
#endif /* _MSV1_0_LSA_H_ */

View file

@ -1769,7 +1769,6 @@ SpLsaModeInitialize(
return STATUS_SUCCESS;
}
/*
* @unimplemented
*/
@ -1781,8 +1780,6 @@ SpUserModeInitialize(
_Out_ PSECPKG_USER_FUNCTION_TABLE *ppTables,
_Out_ PULONG pcTables)
{
SECPKG_USER_FUNCTION_TABLE Tables[1];
TRACE("SpUserModeInitialize(0x%lx %p %p %p)\n",
LsaVersion, PackageVersion, ppTables, pcTables);
@ -1791,24 +1788,7 @@ SpUserModeInitialize(
*PackageVersion = SECPKG_INTERFACE_VERSION;
RtlZeroMemory(&Tables, sizeof(Tables));
// Tables[0].InstanceInit = SpInstanceInit;
// Tables[0].InitUserModeContext = NULL;
// Tables[0].MakeSignature = NULL;
// Tables[0].VerifySignature = NULL;
// Tables[0].SealMessage = NULL;
// Tables[0].UnsealMessage = NULL;
// Tables[0].GetContextToken = NULL;
// Tables[0].SpQueryContextAttributes = NULL;
// Tables[0].CompleteAuthToken = NULL;
// Tables[0].DeleteUserModeContext = NULL;
// Tables[0].FormatCredentials = NULL;
// Tables[0].MarshallSupplementalCreds = NULL;
// Tables[0].ExportContext = NULL;
// Tables[0].ImportContext = NULL;
*ppTables = Tables;
*ppTables = NtlmUsrFn;
*pcTables = 1;
return STATUS_SUCCESS;

View file

@ -11,6 +11,6 @@
@ stub MsvSamValidate
@ stub MsvValidateTarget
@ stdcall SpInitialize(long ptr ptr)
@ stub SpInstanceInit
@ stdcall SpInstanceInit(long ptr ptr)
@ stdcall SpLsaModeInitialize(long ptr ptr ptr)
@ stdcall SpUserModeInitialize(long ptr ptr ptr)

View file

@ -0,0 +1,34 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: NTLM globals definitions (header)
* COPYRIGHT: Copyright 2011 Samuel Serapión
* Copyright 2020 Andreas Maier <staubim@quantentunnel.de>
*/
#include "../precomp.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ntlm);
/* globals */
PSECPKG_DLL_FUNCTIONS UsrFunctions = NULL;
SECPKG_USER_FUNCTION_TABLE NtlmUsrFn[1] =
{
{
.InstanceInit = SpInstanceInit,
.InitUserModeContext = UsrSpInitUserModeContext,
.MakeSignature = UsrSpMakeSignature,
.VerifySignature = UsrSpVerifySignature,
.SealMessage = UsrSpSealMessage,
.UnsealMessage = UsrSpUnsealMessage,
.GetContextToken = UsrSpGetContextToken,
.SpQueryContextAttributes = UsrSpQueryContextAttributes,
.CompleteAuthToken = UsrSpCompleteAuthToken,
.DeleteUserModeContext = UsrSpDeleteUserModeContext,
.FormatCredentials = UsrSpFormatCredentials,
.MarshallSupplementalCreds = UsrSpMarshallSupplementalCreds,
.ExportContext = UsrSpExportSecurityContext,
.ImportContext = UsrSpImportSecurityContext
}
};

View file

@ -0,0 +1,17 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: ntlm globals definitions (header)
* COPYRIGHT: Copyright 2011 Samuel Serapión
* Copyright 2020 Andreas Maier (staubim@quantentunnel.de)
*/
#ifndef _MSV1_0_NTLM_GLOBALS_H_
#define _MSV1_0_NTLM_GLOBALS_H_
/* functions provided by LSA in SpInstanceInit */
extern PSECPKG_DLL_FUNCTIONS UsrFunctions;
/* functions we provide to LSA in SpUserModeInitialize */
extern SECPKG_USER_FUNCTION_TABLE NtlmUsrFn[1];
#endif

View file

@ -30,8 +30,12 @@
#include <samsrv/samsrv.h>
//#include <lsass/lsasrv.h>
#include "ntlm/global.h"
#include "lsa.h"
#include "msv1_0.h"
#include "user.h"
#include "usercontext.h"
#include <wine/debug.h>

176
dll/win32/msv1_0/user.c Normal file
View file

@ -0,0 +1,176 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: NTLM Functions returned from SpUserModeInitialize (PSECPKG_USER_FUNCTION_TABLE)
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/
#include "precomp.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msv1_0);
NTSTATUS
NTAPI
SpInstanceInit(
_In_ ULONG Version,
_In_ PSECPKG_DLL_FUNCTIONS FunctionTable,
_Inout_ PVOID *UserFunctions)
{
TRACE("SpInstanceInit(Version 0x%lx, 0x%p, 0x%p)\n",
Version, FunctionTable, UserFunctions);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpMakeSignature(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ ULONG QualityOfProtection,
_Inout_ PSecBufferDesc MessageBuffers,
_In_ ULONG MessageSequenceNumber)
{
TRACE("UsrSpMakeSignature(0x%p 0x%x 0x%p 0x%x)\n",
ContextHandle, QualityOfProtection,
MessageBuffers, MessageSequenceNumber);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpVerifySignature(
_In_ LSA_SEC_HANDLE phContext,
_In_ PSecBufferDesc pMessage,
_In_ ULONG MessageSeqNo,
_In_ PULONG pfQOP)
{
TRACE("UsrSpVerifySignature(0x%p 0x%x 0x%x 0x%p)\n",
phContext, pMessage, MessageSeqNo, pfQOP);
return ERROR_NOT_SUPPORTED;
}
NTSTATUS
NTAPI
UsrSpSealMessage(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ ULONG QualityOfProtection,
_Inout_ PSecBufferDesc MessageBuffers,
_In_ ULONG MessageSequenceNumber)
{
TRACE("UsrSpSealMessage(0x%p 0x%x 0x%p 0x%x)\n",
ContextHandle, QualityOfProtection,
MessageBuffers, MessageSequenceNumber);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpUnsealMessage(
_In_ LSA_SEC_HANDLE ContextHandle,
_Inout_ PSecBufferDesc MessageBuffers,
_In_ ULONG MessageSequenceNumber,
_In_ PULONG QualityOfProtection)
{
TRACE("UsrSpUnsealMessage(0x%p 0x%x 0x%p 0x%x)\n",
ContextHandle, MessageBuffers,
MessageSequenceNumber, QualityOfProtection);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpGetContextToken(
_In_ LSA_SEC_HANDLE ContextHandle,
_Inout_ PHANDLE ImpersonationToken)
{
TRACE("UsrSpGetContextToken(0x%p 0x%p)\n",
ContextHandle, ImpersonationToken);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpQueryContextAttributes(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ ULONG ContextAttribute,
_Inout_ PVOID Buffer)
{
TRACE("UsrSpQueryContextAttributes(0x%p 0x%x 0x%p)\n",
ContextHandle, ContextAttribute, Buffer);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpCompleteAuthToken(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBufferDesc InputBuffer)
{
TRACE("UsrSpCompleteAuthToken(0x%p 0x%p)\n",
ContextHandle, InputBuffer);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpDeleteUserModeContext(
_In_ LSA_SEC_HANDLE ContextHandle)
{
TRACE("UsrSpDeleteUserModeContext(0x%p)\n",
ContextHandle);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
UsrSpFormatCredentials(
_In_ PSecBuffer Credentials,
_Inout_ PSecBuffer FormattedCredentials)
{
TRACE("UsrSpFormatCredentials(0x%p 0x%p)\n",
Credentials, FormattedCredentials);
return ERROR_NOT_SUPPORTED;
}
NTSTATUS
NTAPI
UsrSpMarshallSupplementalCreds(
_In_ ULONG CredentialSize,
_In_ PUCHAR Credentials,
_Inout_ PULONG MarshalledCredSize,
_Inout_ PVOID *MarshalledCreds)
{
TRACE("UsrSpMarshallSupplementalCreds(0x%x 0x%p 0x%p 0x%p)\n",
CredentialSize, Credentials, MarshalledCredSize, MarshalledCreds);
return ERROR_NOT_SUPPORTED;
}
NTSTATUS
NTAPI
UsrSpExportSecurityContext(
_In_ LSA_SEC_HANDLE phContext,
_In_ ULONG fFlags,
_Inout_ PSecBuffer pPackedContext,
_Inout_ PHANDLE pToken)
{
TRACE("UsrSpExportSecurityContext(0x%p 0x%x 0x%p 0x%p)\n",
phContext, fFlags, pPackedContext, pToken);
return ERROR_NOT_SUPPORTED;
}
NTSTATUS
NTAPI
UsrSpImportSecurityContext(
_In_ PSecBuffer pPackedContext,
_In_ HANDLE Token,
_Inout_ PLSA_SEC_HANDLE phContext)
{
TRACE("UsrSpImportSecurityContext(0x%p 0x%x 0x%p)\n",
pPackedContext, Token, phContext);
return ERROR_NOT_SUPPORTED;
}

100
dll/win32/msv1_0/user.h Normal file
View file

@ -0,0 +1,100 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Header for user.c
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/
#pragma once
NTSTATUS
NTAPI
SpInstanceInit(
_In_ ULONG Version,
_In_ PSECPKG_DLL_FUNCTIONS FunctionTable,
_Inout_ PVOID *UserFunctions);
NTSTATUS
NTAPI
UsrSpMakeSignature(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ ULONG QualityOfProtection,
_Inout_ PSecBufferDesc MessageBuffers,
_In_ ULONG MessageSequenceNumber);
NTSTATUS
NTAPI
UsrSpVerifySignature(
_In_ LSA_SEC_HANDLE phContext,
_In_ PSecBufferDesc pMessage,
_In_ ULONG MessageSeqNo,
_In_ PULONG pfQOP);
NTSTATUS
NTAPI
UsrSpSealMessage(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ ULONG QualityOfProtection,
_Inout_ PSecBufferDesc MessageBuffers,
_In_ ULONG MessageSequenceNumber);
NTSTATUS
NTAPI
UsrSpUnsealMessage(
_In_ LSA_SEC_HANDLE ContextHandle,
_Inout_ PSecBufferDesc MessageBuffers,
_In_ ULONG MessageSequenceNumber,
_In_ PULONG QualityOfProtection);
NTSTATUS
NTAPI
UsrSpGetContextToken(
_In_ LSA_SEC_HANDLE ContextHandle,
_Inout_ PHANDLE ImpersonationToken);
NTSTATUS
NTAPI
UsrSpQueryContextAttributes(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ ULONG ContextAttribute,
_Inout_ PVOID Buffer);
NTSTATUS
NTAPI
UsrSpCompleteAuthToken(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBufferDesc InputBuffer);
NTSTATUS
NTAPI
UsrSpDeleteUserModeContext(
_In_ LSA_SEC_HANDLE ContextHandle);
NTSTATUS
NTAPI
UsrSpFormatCredentials(
_In_ PSecBuffer Credentials,
_Inout_ PSecBuffer FormattedCredentials);
NTSTATUS
NTAPI
UsrSpMarshallSupplementalCreds(
_In_ ULONG CredentialSize,
_In_ PUCHAR Credentials,
_Inout_ PULONG MarshalledCredSize,
_Inout_ PVOID *MarshalledCreds);
NTSTATUS
NTAPI
UsrSpExportSecurityContext(
_In_ LSA_SEC_HANDLE phContext,
_In_ ULONG fFlags,
_Inout_ PSecBuffer pPackedContext,
_Inout_ PHANDLE pToken);
NTSTATUS
NTAPI
UsrSpImportSecurityContext(
_In_ PSecBuffer pPackedContext,
_In_ HANDLE Token,
_Inout_ PLSA_SEC_HANDLE phContext);

View file

@ -0,0 +1,22 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Manage user mode contexts (create, destroy, reference)
* COPYRIGHT: Copyright 2019-2020 Andreas Maier (staubim@quantentunnel.de)
*/
#include "precomp.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msv1_0);
NTSTATUS
NTAPI
UsrSpInitUserModeContext(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBuffer PackedContext)
{
TRACE("UsrSpInitUserModeContext(%p %p)\n",
ContextHandle, PackedContext);
return STATUS_NOT_IMPLEMENTED;
}

View file

@ -0,0 +1,14 @@
/*
* PROJECT: Authentication Package DLL
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Manage user mode contexts (create, destroy, reference)
* COPYRIGHT: Copyright 2019-2020 Andreas Maier <staubim@quantentunnel.de>
*/
#pragma once
NTSTATUS
NTAPI
UsrSpInitUserModeContext(
_In_ LSA_SEC_HANDLE ContextHandle,
_In_ PSecBuffer PackedContext);