https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bcbfcd22788e5321ef09e…
commit bcbfcd22788e5321ef09e7b00079fa8a453b2fa0
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Oct 23 23:54:06 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 8 23:46:32 2022 +0100
[CSRSRV] Minimally-adapt CSRSRV to make it able to host other subsystems than Win32.
This is really ReactOS-specific, so I surround them with __REACTOS__
(even if this is our code) to differentiate these from Win2k3 behaviour,
even though they were strongly inspired by what was possible in the beta
versions of NT 3.1 (pre-3.10.404).
Interestingly, Windows 7+ partially re-introduced that functionality
(just in differencing "Windows=On" from "Off").
See
https://reactos.org/wiki/User:Hbelusca/CSRSS for more information.
---
subsystems/csr/csrsrv/init.c | 57 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 54 insertions(+), 3 deletions(-)
diff --git a/subsystems/csr/csrsrv/init.c b/subsystems/csr/csrsrv/init.c
index 69e9cfdea00..491a15d896a 100644
--- a/subsystems/csr/csrsrv/init.c
+++ b/subsystems/csr/csrsrv/init.c
@@ -31,6 +31,10 @@ PCSR_THREAD CsrSbApiRequestThreadPtr;
HANDLE CsrSmApiPort = NULL;
HANDLE hSbApiPort = NULL;
HANDLE CsrApiPort = NULL;
+#ifdef __REACTOS__
+BOOLEAN CsrWindowsControl;
+ULONG CsrSubSystemType; // Known as SessionFirstProcessImageType in Windows 7+
+#endif
ULONG CsrMaxApiRequestThreads;
ULONG CsrTotalPerProcessDataLength;
ULONG SessionId;
@@ -559,6 +563,10 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
/* Set the Defaults */
CsrTotalPerProcessDataLength = 0;
CsrObjectDirectory = NULL;
+#ifdef __REACTOS__
+ CsrWindowsControl = FALSE;
+ CsrSubSystemType = IMAGE_SUBSYSTEM_UNKNOWN;
+#endif
CsrMaxApiRequestThreads = 16;
/* Save our Session ID, and create a Directory for it */
@@ -619,7 +627,36 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
}
else if (_stricmp(ParameterName, "SubSystemType") == 0)
{
+#ifdef __REACTOS__
+ /* Well-known subsystems, specified by names */
+ if (_stricmp(ParameterValue, "windows") == 0)
+ {
+ /* Behaviour compatible with Windows 7+ */
+ if (CsrWindowsControl)
+ CsrSubSystemType = IMAGE_SUBSYSTEM_WINDOWS_GUI;
+ else
+ CsrSubSystemType = IMAGE_SUBSYSTEM_WINDOWS_CUI;
+ }
+ else if (_stricmp(ParameterValue, "posix") == 0)
+ {
+ CsrSubSystemType = IMAGE_SUBSYSTEM_POSIX_CUI;
+ }
+ else if (_stricmp(ParameterValue, "os2") == 0)
+ {
+ CsrSubSystemType = IMAGE_SUBSYSTEM_OS2_CUI;
+ }
+ else if (_stricmp(ParameterValue, "native") == 0)
+ {
+ CsrSubSystemType = IMAGE_SUBSYSTEM_NATIVE;
+ }
+ else
+ {
+ /* Another subsystem type, specified by a numerical value */
+ Status = RtlCharToInteger(ParameterValue, 0, &CsrSubSystemType);
+ }
+#else
/* Ignored */
+#endif
}
else if (_stricmp(ParameterName, "MaxRequestThreads") == 0)
{
@@ -634,7 +671,7 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
}
else if (_stricmp(ParameterName, "ProfileControl") == 0)
{
- /* Ignored */
+ /* Related functionality ignored since NT 3.5 */
}
else if (_stricmp(ParameterName, "SharedSection") == 0)
{
@@ -661,7 +698,7 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
/* Check for the Entry Point */
if ((*ServerString == ':') && (!EntryPoint))
{
- /* Found it. Add a nullchar and save it */
+ /* Found it. NULL-terminate and save it. */
*ServerString++ = ANSI_NULL;
EntryPoint = ServerString;
}
@@ -696,8 +733,11 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
}
else if (_stricmp(ParameterName, "Windows") == 0)
{
+#ifdef __REACTOS__
+ CsrWindowsControl = (_stricmp(ParameterValue, "On") == 0);
+#else
/* Ignored */
- // Check whether we want to start in pure GUI or pure CLI.
+#endif
}
else
{
@@ -1042,6 +1082,10 @@ CsrServerInitialization(IN ULONG ArgumentCount,
return Status;
}
+#ifdef __REACTOS__
+ if (CsrSubSystemType != IMAGE_SUBSYSTEM_UNKNOWN)
+ {
+#endif
/* Initialize the API Port for SM communication */
Status = CsrSbApiPortInitialize();
if (!NT_SUCCESS(Status))
@@ -1054,7 +1098,11 @@ CsrServerInitialization(IN ULONG ArgumentCount,
/* We're all set! Connect to SM! */
Status = SmConnectToSm(&CsrSbApiPortName,
CsrSbApiPort,
+#ifdef __REACTOS__
+ CsrSubSystemType,
+#else
IMAGE_SUBSYSTEM_WINDOWS_GUI,
+#endif
&CsrSmApiPort);
if (!NT_SUCCESS(Status))
{
@@ -1062,6 +1110,9 @@ CsrServerInitialization(IN ULONG ArgumentCount,
__FUNCTION__, Status);
return Status;
}
+#ifdef __REACTOS__
+ }
+#endif
/* Have us handle Hard Errors */
Status = NtSetDefaultHardErrorPort(CsrApiPort);