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