1 /* 2 * PROJECT: ReactOS Windows-Compatible Session Manager 3 * LICENSE: BSD 2-Clause License 4 * FILE: base/system/smss/smss.h 5 * PURPOSE: Main SMSS Header 6 * PROGRAMMERS: Alex Ionescu 7 */ 8 9 #ifndef _SM_ 10 #define _SM_ 11 12 #pragma once 13 14 /* DEPENDENCIES ***************************************************************/ 15 16 #include <stdio.h> 17 18 /* Native Headers */ 19 #define WIN32_NO_STATUS 20 #include <windef.h> 21 #include <winbase.h> 22 #include <winreg.h> 23 24 #define NTOS_MODE_USER 25 #include <ndk/cmfuncs.h> 26 #include <ndk/exfuncs.h> 27 #include <ndk/iofuncs.h> 28 #include <ndk/kefuncs.h> 29 #include <ndk/lpcfuncs.h> 30 #include <ndk/mmfuncs.h> 31 #include <ndk/obfuncs.h> 32 #include <ndk/psfuncs.h> 33 #include <ndk/rtlfuncs.h> 34 #include <ndk/setypes.h> 35 #include <ndk/umfuncs.h> 36 37 #include <ntstrsafe.h> 38 39 /* SM Protocol Header */ 40 #include <sm/smmsg.h> 41 42 /* DEFINES ********************************************************************/ 43 44 #define SMP_DEBUG_FLAG 0x01 45 #define SMP_ASYNC_FLAG 0x02 46 #define SMP_AUTOCHK_FLAG 0x04 47 #define SMP_SUBSYSTEM_FLAG 0x08 48 #define SMP_INVALID_PATH 0x10 49 #define SMP_DEFERRED_FLAG 0x20 50 #define SMP_POSIX_FLAG 0x100 51 #define SMP_OS2_FLAG 0x200 52 53 /* STRUCTURES *****************************************************************/ 54 55 typedef struct _SMP_REGISTRY_VALUE 56 { 57 LIST_ENTRY Entry; 58 UNICODE_STRING Name; 59 UNICODE_STRING Value; 60 PCHAR AnsiValue; 61 } SMP_REGISTRY_VALUE, *PSMP_REGISTRY_VALUE; 62 63 typedef struct _SMP_SUBSYSTEM 64 { 65 LIST_ENTRY Entry; 66 HANDLE Event; 67 HANDLE ProcessHandle; 68 ULONG ImageType; 69 HANDLE PortHandle; 70 HANDLE SbApiPort; 71 CLIENT_ID ClientId; 72 ULONG MuSessionId; 73 BOOLEAN Terminating; 74 ULONG ReferenceCount; 75 } SMP_SUBSYSTEM, *PSMP_SUBSYSTEM; 76 77 /* EXTERNALS ******************************************************************/ 78 79 extern RTL_CRITICAL_SECTION SmpKnownSubSysLock; 80 extern LIST_ENTRY SmpKnownSubSysHead; 81 extern RTL_CRITICAL_SECTION SmpSessionListLock; 82 extern LIST_ENTRY SmpSessionListHead; 83 extern ULONG SmpNextSessionId; 84 extern BOOLEAN SmpNextSessionIdScanMode; 85 extern BOOLEAN SmpDbgSsLoaded; 86 extern HANDLE SmpWindowsSubSysProcess; 87 extern HANDLE SmpSessionsObjectDirectory; 88 extern HANDLE SmpWindowsSubSysProcessId; 89 extern BOOLEAN RegPosixSingleInstance; 90 extern UNICODE_STRING SmpDebugKeyword, SmpASyncKeyword, SmpAutoChkKeyword; 91 extern PVOID SmpHeap; 92 extern ULONG SmBaseTag; 93 extern UNICODE_STRING SmpSystemRoot; 94 extern PWCHAR SmpDefaultEnvironment; 95 extern UNICODE_STRING SmpDefaultLibPath; 96 extern LIST_ENTRY SmpSetupExecuteList; 97 extern LIST_ENTRY SmpSubSystemList; 98 extern LIST_ENTRY SmpSubSystemsToLoad; 99 extern LIST_ENTRY SmpSubSystemsToDefer; 100 extern LIST_ENTRY SmpExecuteList; 101 extern ULONG AttachedSessionId; 102 extern BOOLEAN SmpDebug; 103 104 /* FUNCTIONS ******************************************************************/ 105 106 /* crashdmp.c */ 107 108 BOOLEAN 109 NTAPI 110 SmpCheckForCrashDump( 111 IN PUNICODE_STRING FileName 112 ); 113 114 /* pagefile.c */ 115 116 VOID 117 NTAPI 118 SmpPagingFileInitialize( 119 VOID 120 ); 121 122 NTSTATUS 123 NTAPI 124 SmpCreatePagingFileDescriptor( 125 IN PUNICODE_STRING PageFileToken 126 ); 127 128 NTSTATUS 129 NTAPI 130 SmpCreatePagingFiles( 131 VOID 132 ); 133 134 /* sminit.c */ 135 136 VOID 137 NTAPI 138 SmpTranslateSystemPartitionInformation( 139 VOID 140 ); 141 142 NTSTATUS 143 NTAPI 144 SmpCreateSecurityDescriptors( 145 IN BOOLEAN InitialCall 146 ); 147 148 NTSTATUS 149 NTAPI 150 SmpInit( 151 IN PUNICODE_STRING InitialCommand, 152 OUT PHANDLE ProcessHandle 153 ); 154 155 /* smloop.c */ 156 157 ULONG 158 NTAPI 159 SmpApiLoop( 160 IN PVOID Parameter 161 ); 162 163 /* smsbapi.c */ 164 165 NTSTATUS 166 NTAPI 167 SmpSbCreateSession( 168 IN PVOID Reserved, 169 IN PSMP_SUBSYSTEM OtherSubsystem, 170 IN PRTL_USER_PROCESS_INFORMATION ProcessInformation, 171 IN ULONG DbgSessionId, 172 IN PCLIENT_ID DbgUiClientId 173 ); 174 175 /* smsessn.c */ 176 177 BOOLEAN 178 NTAPI 179 SmpCheckDuplicateMuSessionId( 180 IN ULONG MuSessionId 181 ); 182 183 VOID 184 NTAPI 185 SmpDeleteSession( 186 IN ULONG SessionId 187 ); 188 189 ULONG 190 NTAPI 191 SmpAllocateSessionId( 192 IN PSMP_SUBSYSTEM Subsystem, 193 IN PSMP_SUBSYSTEM OtherSubsystem 194 ); 195 196 NTSTATUS 197 NTAPI 198 SmpGetProcessMuSessionId( 199 IN HANDLE ProcessHandle, 200 OUT PULONG SessionId 201 ); 202 203 NTSTATUS 204 NTAPI 205 SmpSetProcessMuSessionId( 206 IN HANDLE ProcessHandle, 207 IN ULONG SessionId 208 ); 209 210 /* smss.c */ 211 212 NTSTATUS 213 NTAPI 214 SmpExecuteImage( 215 IN PUNICODE_STRING FileName, 216 IN PUNICODE_STRING Directory, 217 IN PUNICODE_STRING CommandLine, 218 IN ULONG MuSessionId, 219 IN ULONG Flags, 220 IN PRTL_USER_PROCESS_INFORMATION ProcessInformation 221 ); 222 223 NTSTATUS 224 NTAPI 225 SmpExecuteCommand( 226 IN PUNICODE_STRING CommandLine, 227 IN ULONG MuSessionId, 228 OUT PHANDLE ProcessId, 229 IN ULONG Flags 230 ); 231 232 NTSTATUS 233 NTAPI 234 SmpExecuteInitialCommand(IN ULONG MuSessionId, 235 IN PUNICODE_STRING InitialCommand, 236 IN HANDLE InitialCommandProcess, 237 OUT PHANDLE ReturnPid); 238 239 NTSTATUS 240 NTAPI 241 SmpTerminate( 242 IN PULONG_PTR Parameters, 243 IN ULONG ParameterMask, 244 IN ULONG ParameterCount 245 ); 246 247 /* smsubsys.c */ 248 249 VOID 250 NTAPI 251 SmpDereferenceSubsystem( 252 IN PSMP_SUBSYSTEM SubSystem 253 ); 254 255 PSMP_SUBSYSTEM 256 NTAPI 257 SmpLocateKnownSubSysByCid( 258 IN PCLIENT_ID ClientId 259 ); 260 261 PSMP_SUBSYSTEM 262 NTAPI 263 SmpLocateKnownSubSysByType( 264 IN ULONG MuSessionId, 265 IN ULONG ImageType 266 ); 267 268 NTSTATUS 269 NTAPI 270 SmpLoadSubSystem( 271 IN PUNICODE_STRING FileName, 272 IN PUNICODE_STRING Directory, 273 IN PUNICODE_STRING CommandLine, 274 IN ULONG MuSessionId, 275 OUT PHANDLE ProcessId, 276 IN ULONG Flags 277 ); 278 279 NTSTATUS 280 NTAPI 281 SmpLoadSubSystemsForMuSession( 282 IN PULONG MuSessionId, 283 OUT PHANDLE ProcessId, 284 IN PUNICODE_STRING InitialCommand 285 ); 286 287 /* smutil.c */ 288 289 NTSTATUS 290 NTAPI 291 SmpAcquirePrivilege( 292 IN ULONG Privilege, 293 OUT PVOID *PrivilegeStat 294 ); 295 296 VOID 297 NTAPI 298 SmpReleasePrivilege( 299 IN PVOID State 300 ); 301 302 NTSTATUS 303 NTAPI 304 SmpParseCommandLine( 305 IN PUNICODE_STRING CommandLine, 306 OUT PULONG Flags, 307 OUT PUNICODE_STRING FileName, 308 OUT PUNICODE_STRING Directory, 309 OUT PUNICODE_STRING Arguments 310 ); 311 312 BOOLEAN 313 NTAPI 314 SmpQueryRegistrySosOption( 315 VOID 316 ); 317 318 BOOLEAN 319 NTAPI 320 SmpSaveAndClearBootStatusData( 321 OUT PBOOLEAN BootOkay, 322 OUT PBOOLEAN ShutdownOkay 323 ); 324 325 VOID 326 NTAPI 327 SmpRestoreBootStatusData( 328 IN BOOLEAN BootOkay, 329 IN BOOLEAN ShutdownOkay 330 ); 331 332 #endif /* _SM_ */ 333