ReactOS 0.4.15-dev-8093-g3285f69
lsa.c File Reference
#include <ndk/exfuncs.h>
#include <ndk/lpctypes.h>
#include <ndk/lpcfuncs.h>
#include <ndk/mmfuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/obfuncs.h>
#include <lsass/lsass.h>
#include <debug.h>
Include dependency graph for lsa.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI LsaCallAuthenticationPackage (IN HANDLE LsaHandle, IN ULONG AuthenticationPackage, IN PVOID ProtocolSubmitBuffer, IN ULONG SubmitBufferLength, OUT PVOID *ProtocolReturnBuffer, OUT PULONG ReturnBufferLength, OUT PNTSTATUS ProtocolStatus)
 
NTSTATUS NTAPI LsaDeregisterLogonProcess (IN HANDLE LsaHandle)
 
NTSTATUS NTAPI LsaFreeReturnBuffer (IN PVOID Buffer)
 
NTSTATUS NTAPI LsaLookupAuthenticationPackage (IN HANDLE LsaHandle, IN PLSA_STRING PackageName, OUT PULONG AuthenticationPackage)
 
NTSTATUS NTAPI LsaLogonUser (IN HANDLE LsaHandle, IN PLSA_STRING OriginName, IN SECURITY_LOGON_TYPE LogonType, IN ULONG AuthenticationPackage, IN PVOID AuthenticationInformation, IN ULONG AuthenticationInformationLength, IN PTOKEN_GROUPS LocalGroups OPTIONAL, IN PTOKEN_SOURCE SourceContext, OUT PVOID *ProfileBuffer, OUT PULONG ProfileBufferLength, OUT PLUID LogonId, OUT PHANDLE Token, OUT PQUOTA_LIMITS Quotas, OUT PNTSTATUS SubStatus)
 
NTSTATUS NTAPI LsaRegisterLogonProcess (IN PLSA_STRING LogonProcessName, OUT PHANDLE LsaHandle, OUT PLSA_OPERATIONAL_MODE OperationalMode)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 20 of file lsa.c.

Function Documentation

◆ LsaCallAuthenticationPackage()

NTSTATUS NTAPI LsaCallAuthenticationPackage ( IN HANDLE  LsaHandle,
IN ULONG  AuthenticationPackage,
IN PVOID  ProtocolSubmitBuffer,
IN ULONG  SubmitBufferLength,
OUT PVOID ProtocolReturnBuffer,
OUT PULONG  ReturnBufferLength,
OUT PNTSTATUS  ProtocolStatus 
)

Definition at line 30 of file lsa.c.

37{
38 LSA_API_MSG ApiMessage;
40
41 DPRINT1("LsaCallAuthenticationPackage()\n");
42
44 ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.CallAuthenticationPackage);
45 ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
46 ApiMessage.h.u2.ZeroInit = 0;
47
48 ApiMessage.CallAuthenticationPackage.Request.AuthenticationPackage = AuthenticationPackage;
49 ApiMessage.CallAuthenticationPackage.Request.ProtocolSubmitBuffer = ProtocolSubmitBuffer;
50 ApiMessage.CallAuthenticationPackage.Request.SubmitBufferLength = SubmitBufferLength;
51
53 (PPORT_MESSAGE)&ApiMessage,
54 (PPORT_MESSAGE)&ApiMessage);
55 if (!NT_SUCCESS(Status))
56 {
57 DPRINT1("ZwRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status);
58 return Status;
59 }
60
61 if (!NT_SUCCESS(ApiMessage.Status))
62 {
63 DPRINT1("ZwRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage.Status);
64 return ApiMessage.Status;
65 }
66
67 *ProtocolReturnBuffer = ApiMessage.CallAuthenticationPackage.Reply.ProtocolReturnBuffer;
68 *ReturnBufferLength = ApiMessage.CallAuthenticationPackage.Reply.ReturnBufferLength;
69 *ProtocolStatus = ApiMessage.CallAuthenticationPackage.Reply.ProtocolStatus;
70
71 return Status;
72}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
HANDLE LsaHandle
Definition: wkssvc.c:41
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG AuthenticationPackage
Definition: logon.c:18
Status
Definition: gdiplustypes.h:25
VOID NTAPI ProtocolStatus(NDIS_HANDLE BindingContext, NDIS_STATUS GenerelStatus, PVOID StatusBuffer, UINT StatusBufferSize)
Called by NDIS when the underlying driver has changed state.
Definition: lan.c:461
NTSYSAPI NTSTATUS NTAPI ZwRequestWaitReplyPort(_In_ HANDLE PortHandle, _Out_ PPORT_MESSAGE LpcReply, _In_ PPORT_MESSAGE LpcRequest)
#define LSA_PORT_MESSAGE_SIZE
Definition: lsass.h:200
#define LSA_PORT_DATA_SIZE(c)
Definition: lsass.h:199
@ LSASS_REQUEST_CALL_AUTHENTICATION_PACKAGE
Definition: lsass.h:20
PORT_MESSAGE h
Definition: lsass.h:177
LSA_API_NUMBER ApiNumber
Definition: lsass.h:183
LSA_CALL_AUTHENTICATION_PACKAGE_MSG CallAuthenticationPackage
Definition: lsass.h:188
struct _LSA_CALL_AUTHENTICATION_PACKAGE_MSG::@3499::@3501 Request

◆ LsaDeregisterLogonProcess()

NTSTATUS NTAPI LsaDeregisterLogonProcess ( IN HANDLE  LsaHandle)

Definition at line 80 of file lsa.c.

81{
82 LSA_API_MSG ApiMessage;
84
85 DPRINT("LsaDeregisterLogonProcess()\n");
86
88 ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.DeregisterLogonProcess);
89 ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
90 ApiMessage.h.u2.ZeroInit = 0;
91
93 (PPORT_MESSAGE)&ApiMessage,
94 (PPORT_MESSAGE)&ApiMessage);
95 if (!NT_SUCCESS(Status))
96 {
97 DPRINT1("ZwRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status);
98 return Status;
99 }
100
101 if (!NT_SUCCESS(ApiMessage.Status))
102 {
103 DPRINT1("ZwRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage.Status);
104 return ApiMessage.Status;
105 }
106
108
109 DPRINT("LsaDeregisterLogonProcess() done (Status 0x%08lx)\n", Status);
110
111 return Status;
112}
@ LSASS_REQUEST_DEREGISTER_LOGON_PROCESS
Definition: lsass.h:21
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define DPRINT
Definition: sndvol32.h:73
LSA_DEREGISTER_LOGON_PROCESS_MSG DeregisterLogonProcess
Definition: lsass.h:189

◆ LsaFreeReturnBuffer()

NTSTATUS NTAPI LsaFreeReturnBuffer ( IN PVOID  Buffer)

Definition at line 120 of file lsa.c.

121{
122 SIZE_T Size = 0;
123
124 return ZwFreeVirtualMemory(NtCurrentProcess(),
125 &Buffer,
126 &Size,
128}
Definition: bufpool.h:45
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define MEM_RELEASE
Definition: nt_native.h:1316
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ LsaLogonUser()

NTSTATUS NTAPI LsaLogonUser ( IN HANDLE  LsaHandle,
IN PLSA_STRING  OriginName,
IN SECURITY_LOGON_TYPE  LogonType,
IN ULONG  AuthenticationPackage,
IN PVOID  AuthenticationInformation,
IN ULONG  AuthenticationInformationLength,
IN PTOKEN_GROUPS LocalGroups  OPTIONAL,
IN PTOKEN_SOURCE  SourceContext,
OUT PVOID ProfileBuffer,
OUT PULONG  ProfileBufferLength,
OUT PLUID  LogonId,
OUT PHANDLE  Token,
OUT PQUOTA_LIMITS  Quotas,
OUT PNTSTATUS  SubStatus 
)

Definition at line 184 of file lsa.c.

198{
199 LSA_API_MSG ApiMessage;
201
203 ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.LogonUser);
204 ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
205 ApiMessage.h.u2.ZeroInit = 0;
206
207 ApiMessage.LogonUser.Request.OriginName = *OriginName;
208 ApiMessage.LogonUser.Request.LogonType = LogonType;
209 ApiMessage.LogonUser.Request.AuthenticationPackage = AuthenticationPackage;
210 ApiMessage.LogonUser.Request.AuthenticationInformation = AuthenticationInformation;
211 ApiMessage.LogonUser.Request.AuthenticationInformationLength = AuthenticationInformationLength;
212 ApiMessage.LogonUser.Request.LocalGroups = LocalGroups;
213 if (LocalGroups != NULL)
214 ApiMessage.LogonUser.Request.LocalGroupsCount = LocalGroups->GroupCount;
215 else
216 ApiMessage.LogonUser.Request.LocalGroupsCount = 0;
217 ApiMessage.LogonUser.Request.SourceContext = *SourceContext;
218
220 (PPORT_MESSAGE)&ApiMessage,
221 (PPORT_MESSAGE)&ApiMessage);
222 if (!NT_SUCCESS(Status))
223 {
224 return Status;
225 }
226
227 *SubStatus = ApiMessage.LogonUser.Reply.SubStatus;
228
229 if (!NT_SUCCESS(ApiMessage.Status))
230 {
231 return ApiMessage.Status;
232 }
233
234 *ProfileBuffer = ApiMessage.LogonUser.Reply.ProfileBuffer;
235 *ProfileBufferLength = ApiMessage.LogonUser.Reply.ProfileBufferLength;
236 *LogonId = ApiMessage.LogonUser.Reply.LogonId;
237 *Token = ApiMessage.LogonUser.Reply.Token;
238 *Quotas = ApiMessage.LogonUser.Reply.Quotas;
239
240 return Status;
241}
#define NULL
Definition: types.h:112
@ LSASS_REQUEST_LOGON_USER
Definition: lsass.h:22
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE LogonType
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS LocalGroups
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE _Out_ PQUOTA_LIMITS Quotas
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE SourceContext
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE _Out_ PQUOTA_LIMITS _Out_ PNTSTATUS SubStatus
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG AuthenticationInformationLength
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID * ProfileBuffer
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG ProfileBufferLength
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID LogonId
_IRQL_requires_same_ _In_ PLSA_STRING OriginName
LSA_LOGON_USER_MSG LogonUser
Definition: lsass.h:187
struct _LSA_LOGON_USER_MSG::@3495::@3497 Request

◆ LsaLookupAuthenticationPackage()

NTSTATUS NTAPI LsaLookupAuthenticationPackage ( IN HANDLE  LsaHandle,
IN PLSA_STRING  PackageName,
OUT PULONG  AuthenticationPackage 
)

Definition at line 136 of file lsa.c.

139{
140 LSA_API_MSG ApiMessage;
142
143 /* Check the package name length */
144 if (PackageName->Length > LSASS_MAX_PACKAGE_NAME_LENGTH)
145 {
147 }
148
150 ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.LookupAuthenticationPackage);
151 ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
152 ApiMessage.h.u2.ZeroInit = 0;
153
154 ApiMessage.LookupAuthenticationPackage.Request.PackageNameLength = PackageName->Length;
155 strncpy(ApiMessage.LookupAuthenticationPackage.Request.PackageName,
156 PackageName->Buffer,
157 ApiMessage.LookupAuthenticationPackage.Request.PackageNameLength);
158 ApiMessage.LookupAuthenticationPackage.Request.PackageName[ApiMessage.LookupAuthenticationPackage.Request.PackageNameLength] = ANSI_NULL;
159
161 (PPORT_MESSAGE)&ApiMessage,
162 (PPORT_MESSAGE)&ApiMessage);
163 if (!NT_SUCCESS(Status))
164 {
165 return Status;
166 }
167
168 if (!NT_SUCCESS(ApiMessage.Status))
169 {
170 return ApiMessage.Status;
171 }
172
173 *AuthenticationPackage = ApiMessage.LookupAuthenticationPackage.Reply.Package;
174
175 return Status;
176}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define LSASS_MAX_PACKAGE_NAME_LENGTH
Definition: lsass.h:16
@ LSASS_REQUEST_LOOKUP_AUTHENTICATION_PACKAGE
Definition: lsass.h:23
#define ANSI_NULL
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:498
LSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG LookupAuthenticationPackage
Definition: lsass.h:190
struct _LSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG::@3507::@3509 Request

◆ LsaRegisterLogonProcess()

NTSTATUS NTAPI LsaRegisterLogonProcess ( IN PLSA_STRING  LogonProcessName,
OUT PHANDLE  LsaHandle,
OUT PLSA_OPERATIONAL_MODE  OperationalMode 
)

Definition at line 249 of file lsa.c.

252{
253 SECURITY_QUALITY_OF_SERVICE SecurityQos;
254 LSA_CONNECTION_INFO ConnectInfo;
255 ULONG ConnectInfoLength = sizeof(ConnectInfo);
258 UNICODE_STRING EventName;
261
262 DPRINT("LsaRegisterLogonProcess()\n");
263
264 /* Check the logon process name length */
265 if (LogonProcessName->Length > LSASS_MAX_LOGON_PROCESS_NAME_LENGTH)
267
268 /* Wait for the LSA authentication thread */
269 RtlInitUnicodeString(&EventName,
270 L"\\SECURITY\\LSA_AUTHENTICATION_INITIALIZED");
272 &EventName,
274 NULL,
275 NULL);
279 if (!NT_SUCCESS(Status))
280 {
281 DPRINT("ZwOpenEvent failed (Status 0x%08lx)\n", Status);
282
283 Status = ZwCreateEvent(&EventHandle,
287 FALSE);
288 if (!NT_SUCCESS(Status))
289 {
290 DPRINT1("ZwCreateEvent failed (Status 0x%08lx)\n", Status);
291 return Status;
292 }
293 }
294
295 Status = ZwWaitForSingleObject(EventHandle,
296 TRUE,
297 NULL);
299 if (!NT_SUCCESS(Status))
300 {
301 DPRINT1("ZwWaitForSingleObject failed (Status 0x%08lx)\n", Status);
302 return Status;
303 }
304
305 /* Establish the connection */
307 L"\\LsaAuthenticationPort");
308
309 SecurityQos.Length = sizeof(SecurityQos);
312 SecurityQos.EffectiveOnly = TRUE;
313
315 LogonProcessName->Buffer,
316 LogonProcessName->Length);
317 ConnectInfo.Length = LogonProcessName->Length;
318 ConnectInfo.LogonProcessNameBuffer[ConnectInfo.Length] = ANSI_NULL;
319 ConnectInfo.CreateContext = TRUE;
320
322 &PortName,
323 &SecurityQos,
324 NULL,
325 NULL,
326 NULL,
327 &ConnectInfo,
328 &ConnectInfoLength);
329 if (!NT_SUCCESS(Status))
330 {
331 DPRINT1("ZwConnectPort failed (Status 0x%08lx)\n", Status);
332 return Status;
333 }
334
335 DPRINT("ConnectInfo.OperationalMode: 0x%08lx\n", ConnectInfo.OperationalMode);
336 *OperationalMode = ConnectInfo.OperationalMode;
337
338 if (!NT_SUCCESS(ConnectInfo.Status))
339 {
340 DPRINT1("ConnectInfo.Status: 0x%08lx\n", ConnectInfo.Status);
341 }
342
343 return ConnectInfo.Status;
344}
static UNICODE_STRING PortName
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define OBJ_PERMANENT
Definition: winternl.h:226
NTSYSAPI NTSTATUS NTAPI ZwConnectPort(_Out_ PHANDLE PortHandle, _In_ PUNICODE_STRING PortName, _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos, _In_opt_ PPORT_VIEW ClientView, _In_opt_ PREMOTE_PORT_VIEW ServerView, _In_opt_ PULONG MaxMessageLength, _In_opt_ PVOID ConnectionInformation, _In_opt_ PULONG ConnectionInformationLength)
@ SecurityIdentification
Definition: lsa.idl:56
#define LSASS_MAX_LOGON_PROCESS_NAME_LENGTH
Definition: lsass.h:15
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSCALLAPI NTSTATUS NTAPI ZwOpenEvent(_Out_ PHANDLE EventHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
@ NotificationEvent
#define L(x)
Definition: ntvdm.h:50
BOOL CreateContext
Definition: lsass.h:37
LSA_OPERATIONAL_MODE OperationalMode
Definition: lsass.h:34
NTSTATUS Status
Definition: lsass.h:33
CHAR LogonProcessNameBuffer[LSASS_MAX_LOGON_PROCESS_NAME_LENGTH+1]
Definition: lsass.h:36
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
uint32_t ULONG
Definition: typedefs.h:59
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103