diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/csr/server/session.c | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/csr/server/session.c')
-rw-r--r-- | private/csr/server/session.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/private/csr/server/session.c b/private/csr/server/session.c new file mode 100644 index 000000000..729d9a8ba --- /dev/null +++ b/private/csr/server/session.c @@ -0,0 +1,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(); + } +} |