ReactOS 0.4.15-dev-7953-g1f49173
smsessn.c File Reference
#include "smss.h"
#include <debug.h>
Include dependency graph for smsessn.c:

Go to the source code of this file.

Classes

struct  _SMP_SESSION
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _SMP_SESSION SMP_SESSION
 
typedef struct _SMP_SESSIONPSMP_SESSION
 

Functions

BOOLEAN NTAPI SmpCheckDuplicateMuSessionId (IN ULONG MuSessionId)
 
PSMP_SESSION NTAPI SmpSessionIdToSession (IN ULONG SessionId)
 
VOID NTAPI SmpDeleteSession (IN ULONG SessionId)
 
ULONG NTAPI SmpAllocateSessionId (IN PSMP_SUBSYSTEM Subsystem, IN PSMP_SUBSYSTEM OtherSubsystem)
 
NTSTATUS NTAPI SmpGetProcessMuSessionId (IN HANDLE ProcessHandle, OUT PULONG SessionId)
 
NTSTATUS NTAPI SmpSetProcessMuSessionId (IN HANDLE ProcessHandle, IN ULONG SessionId)
 

Variables

RTL_CRITICAL_SECTION SmpSessionListLock
 
LIST_ENTRY SmpSessionListHead
 
ULONG SmpNextSessionId
 
BOOLEAN SmpNextSessionIdScanMode
 
BOOLEAN SmpDbgSsLoaded
 
HANDLE SmpSessionsObjectDirectory
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file smsessn.c.

Typedef Documentation

◆ PSMP_SESSION

◆ SMP_SESSION

Function Documentation

◆ SmpAllocateSessionId()

ULONG NTAPI SmpAllocateSessionId ( IN PSMP_SUBSYSTEM  Subsystem,
IN PSMP_SUBSYSTEM  OtherSubsystem 
)

Definition at line 123 of file smsessn.c.

125{
127 PSMP_SESSION Session;
128
129 /* Allocate a new ID while under the lock */
132
133 /* Check for overflow */
135 {
136 /* Break if it happened */
137 UNIMPLEMENTED_DBGBREAK("SMSS: SessionId's Wrapped\n");
138 }
139 else
140 {
141 /* Detect it for next time */
142 if (!SmpNextSessionId)
144 }
145
146 /* Allocate a session structure */
147 Session = RtlAllocateHeap(SmpHeap, 0, sizeof(SMP_SESSION));
148 if (Session)
149 {
150 /* Write the session data and insert it into the session list */
151 Session->Subsystem = Subsystem;
152 Session->SessionId = SessionId;
153 Session->OtherSubsystem = OtherSubsystem;
155 }
156 else
157 {
158 DPRINT1("SMSS: Unable to keep track of session ID -- no memory available\n");
159 }
160
161 /* Release the session lock */
163 return SessionId;
164}
#define DPRINT1
Definition: precomp.h:8
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
#define TRUE
Definition: types.h:120
ULONG SessionId
Definition: dllmain.c:28
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define InsertTailList(ListHead, Entry)
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
PVOID SmpHeap
Definition: sminit.c:25
LIST_ENTRY SmpSessionListHead
Definition: smsessn.c:27
RTL_CRITICAL_SECTION SmpSessionListLock
Definition: smsessn.c:26
BOOLEAN SmpNextSessionIdScanMode
Definition: smsessn.c:29
ULONG SmpNextSessionId
Definition: smsessn.c:28
PSMP_SUBSYSTEM Subsystem
Definition: smsessn.c:22
LIST_ENTRY Entry
Definition: smsessn.c:20
PSMP_SUBSYSTEM OtherSubsystem
Definition: smsessn.c:23
ULONG SessionId
Definition: smsessn.c:21
uint32_t ULONG
Definition: typedefs.h:59

Referenced by SmpLoadSubSystem(), and SmpSbCreateSession().

◆ SmpCheckDuplicateMuSessionId()

BOOLEAN NTAPI SmpCheckDuplicateMuSessionId ( IN ULONG  MuSessionId)

Definition at line 37 of file smsessn.c.

38{
39 PSMP_SUBSYSTEM Subsystem;
40 BOOLEAN FoundDuplicate = FALSE;
41 PLIST_ENTRY NextEntry;
42
43 /* Lock the subsystem database */
45
46 /* Scan each entry */
47 NextEntry = SmpKnownSubSysHead.Flink;
48 while (NextEntry != &SmpKnownSubSysHead)
49 {
50 /* Check if this entry has the same session ID */
51 Subsystem = CONTAINING_RECORD(NextEntry, SMP_SUBSYSTEM, Entry);
52 if (Subsystem->MuSessionId == MuSessionId)
53 {
54 /* Break out of here! */
55 FoundDuplicate = TRUE;
56 break;
57 }
58
59 /* Keep going */
60 NextEntry = NextEntry->Flink;
61 }
62
63 /* Release the database and return the result */
65 return FoundDuplicate;
66}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
RTL_CRITICAL_SECTION SmpKnownSubSysLock
Definition: smsubsys.c:18
LIST_ENTRY SmpKnownSubSysHead
Definition: smsubsys.c:19
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG MuSessionId
Definition: smss.h:72
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by SmpLoadDeferedSubsystem(), SmpLoadSubSystem(), and SmpSbCreateSession().

◆ SmpDeleteSession()

VOID NTAPI SmpDeleteSession ( IN ULONG  SessionId)

Definition at line 98 of file smsessn.c.

99{
100 PSMP_SESSION Session;
101
102 /* Enter the lock and get the session structure */
105 if (Session)
106 {
107 /* Remove it from the list */
108 RemoveEntryList(&Session->Entry);
110
111 /* Now free the structure outside of the lock */
112 RtlFreeHeap(SmpHeap, 0, Session);
113 }
114 else
115 {
116 /* ID doesn't map to one of our structures, nothing to do... */
118 }
119}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
PSMP_SESSION NTAPI SmpSessionIdToSession(IN ULONG SessionId)
Definition: smsessn.c:70

Referenced by SmpLoadSubSystem(), and SmpSbCreateSession().

◆ SmpGetProcessMuSessionId()

NTSTATUS NTAPI SmpGetProcessMuSessionId ( IN HANDLE  ProcessHandle,
OUT PULONG  SessionId 
)

Definition at line 168 of file smsessn.c.

170{
172 ULONG ProcessSession;
173
174 /* Query the kernel for the session ID */
177 &ProcessSession,
178 sizeof(ProcessSession),
179 NULL);
180 if (NT_SUCCESS(Status))
181 {
182 /* Copy it back into the buffer */
183 *SessionId = ProcessSession;
184 }
185 else
186 {
187 /* Failure -- assume session zero */
188 DPRINT1("SMSS: GetProcessMuSessionId, Process=%p, Status=%x\n",
190 *SessionId = 0;
191 }
192
193 /* Return result */
194 return Status;
195}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
@ ProcessSessionInformation
Definition: winternl.h:880
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59

Referenced by SmpHandleConnectionRequest(), SmpLoadDeferedSubsystem(), and SmpSbCreateSession().

◆ SmpSessionIdToSession()

PSMP_SESSION NTAPI SmpSessionIdToSession ( IN ULONG  SessionId)

Definition at line 70 of file smsessn.c.

71{
72 PSMP_SESSION Session, FoundSession = NULL;
73 PLIST_ENTRY NextEntry;
74
75 /* Loop the session list -- lock must already be held! */
76 NextEntry = SmpSessionListHead.Flink;
77 while (NextEntry != &SmpSessionListHead)
78 {
79 /* Check if this session's ID matches */
80 Session = CONTAINING_RECORD(NextEntry, SMP_SESSION, Entry);
81 if (Session->SessionId == SessionId)
82 {
83 /* Set this as the found session and break out */
84 FoundSession = Session;
85 break;
86 }
87
88 /* Keep going */
89 NextEntry = NextEntry->Flink;
90 }
91
92 /* Return the session that was found and exit */
93 return FoundSession;
94}

Referenced by SmpDeleteSession().

◆ SmpSetProcessMuSessionId()

NTSTATUS NTAPI SmpSetProcessMuSessionId ( IN HANDLE  ProcessHandle,
IN ULONG  SessionId 
)

Definition at line 199 of file smsessn.c.

201{
203
204 /* Tell the kernel about the session ID */
207 &SessionId,
208 sizeof(SessionId));
209 if (!NT_SUCCESS(Status))
210 {
211 DPRINT1("SMSS: SetProcessMuSessionId, Process=%p, Status=%x\n",
213 }
214
215 /* Return */
216 return Status;
217}
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1105

Referenced by SmpExecuteImage().

Variable Documentation

◆ SmpDbgSsLoaded

BOOLEAN SmpDbgSsLoaded

Definition at line 30 of file smsessn.c.

Referenced by SmpInit(), and SmpSbCreateSession().

◆ SmpNextSessionId

ULONG SmpNextSessionId

Definition at line 28 of file smsessn.c.

Referenced by SmpAllocateSessionId(), and SmpInit().

◆ SmpNextSessionIdScanMode

BOOLEAN SmpNextSessionIdScanMode

Definition at line 29 of file smsessn.c.

Referenced by SmpAllocateSessionId(), and SmpInit().

◆ SmpSessionListHead

LIST_ENTRY SmpSessionListHead

Definition at line 27 of file smsessn.c.

Referenced by SmpAllocateSessionId(), SmpInit(), and SmpSessionIdToSession().

◆ SmpSessionListLock

RTL_CRITICAL_SECTION SmpSessionListLock

Definition at line 26 of file smsessn.c.

Referenced by SmpAllocateSessionId(), SmpDeleteSession(), and SmpInit().

◆ SmpSessionsObjectDirectory

HANDLE SmpSessionsObjectDirectory

Definition at line 31 of file smsessn.c.

Referenced by SmpLoadDataFromRegistry().