blob: 729d9a8ba951f70720d81ddfed97ff2366c204ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
session.c
Abstract:
This module contains the worker routines called by the Sb API
Request routines in sbapi.c to create and delete sessions. Also
called whenever an application process creates a new child process
within the same session.
Author:
Steve Wood (stevewo) 08-Oct-1990
Revision History:
--*/
#include "csrsrv.h"
NTSTATUS
CsrInitializeNtSessionList( VOID )
{
NTSTATUS Status;
InitializeListHead( &CsrNtSessionList );
Status = RtlInitializeCriticalSection( &CsrNtSessionLock );
return( Status );
}
PCSR_NT_SESSION
CsrAllocateNtSession(
ULONG SessionId
)
{
PCSR_NT_SESSION Session;
Session = RtlAllocateHeap( CsrHeap, MAKE_TAG( PROCESS_TAG ), sizeof( CSR_NT_SESSION ) );
ASSERT( Session != NULL );
if (Session != NULL) {
Session->SessionId = SessionId;
Session->ReferenceCount = 1;
LockNtSessionList();
InsertHeadList( &CsrNtSessionList, &Session->SessionLink );
UnlockNtSessionList();
}
return( Session );
}
VOID
CsrReferenceNtSession(
PCSR_NT_SESSION Session
)
{
LockNtSessionList();
ASSERT( !IsListEmpty( &Session->SessionLink ) );
ASSERT( Session->SessionId != 0 );
ASSERT( Session->ReferenceCount != 0 );
Session->ReferenceCount++;
UnlockNtSessionList();
}
VOID
CsrDereferenceNtSession(
PCSR_NT_SESSION Session,
NTSTATUS ExitStatus
)
{
LockNtSessionList();
ASSERT( !IsListEmpty( &Session->SessionLink ) );
ASSERT( Session->SessionId != 0 );
ASSERT( Session->ReferenceCount != 0 );
if (--Session->ReferenceCount == 0) {
RemoveEntryList( &Session->SessionLink );
UnlockNtSessionList();
SmSessionComplete(CsrSmApiPort,Session->SessionId,ExitStatus);
RtlFreeHeap( CsrHeap, 0, Session );
}
else {
UnlockNtSessionList();
}
}
|