https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b076800dd8518cd5be25a…
commit b076800dd8518cd5be25a3b59fc63f2cd79d0bbf
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Oct 23 19:59:08 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 8 23:47:02 2022 +0100
[SMSS] Fix the displayed subsystem name in the failure path of SmpSbCreateSession().
The SubSystemNames array didn't correlate with the possible values of
SubSystemType (e.g. index 4 was "Posix" whereas Posix is type 7; Posix
and OS/2 entries were inverted; Windows CUI subsystem (type 3) was
mapped to "Posix"), and the array dereferencing was out of bounds if the
SubSystemType of the image happened to be larger than 8.
I know (strings extraction from debug build of Windows' SMSS.EXE) that
they use that same old'n'broken array. Perhaps a leftover from very old
times (NT 3.1 betas) where the PE format was under work and the
subsystem numbers didn't have their definitive values... (This has
already happened with the NT PDK v1.196 from September 1991.)
---
base/system/smss/smsbapi.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/base/system/smss/smsbapi.c b/base/system/smss/smsbapi.c
index 0cd49e1ed19..1eed513601c 100644
--- a/base/system/smss/smsbapi.c
+++ b/base/system/smss/smsbapi.c
@@ -15,14 +15,19 @@
/* GLOBALS ********************************************************************/
-PCHAR SmpSubSystemNames[] =
+#if DBG
+const PCSTR SmpSubSystemNames[] =
{
"Unknown",
"Native",
- "Windows",
- "Posix",
- "OS/2"
+ "Windows GUI",
+ "Windows CUI",
+ NULL,
+ "OS/2 CUI"
+ NULL,
+ "Posix CUI"
};
+#endif
/* FUNCTIONS ******************************************************************/
@@ -35,6 +40,7 @@ SmpSbCreateSession(IN PVOID Reserved,
IN PCLIENT_ID DbgClientId)
{
NTSTATUS Status;
+ ULONG SubSystemType = ProcessInformation->ImageInformation.SubSystemType;
PSMP_SUBSYSTEM KnownSubsys;
SB_API_MSG SbApiMsg;
ULONG SessionId;
@@ -65,9 +71,7 @@ SmpSbCreateSession(IN PVOID Reserved,
}
/* Find the subsystem we have for this initial process */
- KnownSubsys = SmpLocateKnownSubSysByType(MuSessionId,
- ProcessInformation->
- ImageInformation.SubSystemType);
+ KnownSubsys = SmpLocateKnownSubSysByType(MuSessionId, SubSystemType);
if (KnownSubsys)
{
/* Duplicate the process handle into the message */
@@ -142,11 +146,22 @@ SmpSbCreateSession(IN PVOID Reserved,
}
/* If we don't yet have a subsystem, only native images can be launched */
- if (ProcessInformation->ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_NATIVE)
+ if (SubSystemType != IMAGE_SUBSYSTEM_NATIVE)
{
/* Fail */
- DPRINT1("SMSS: %s SubSystem has not been started.\n",
-
SmpSubSystemNames[ProcessInformation->ImageInformation.SubSystemType]);
+#if DBG
+ PCSTR SubSysName = NULL;
+ CHAR SubSysTypeName[sizeof("Type 0x")+8];
+
+ if (SubSystemType < RTL_NUMBER_OF(SmpSubSystemNames))
+ SubSysName = SmpSubSystemNames[SubSystemType];
+ if (!SubSysName)
+ {
+ SubSysName = SubSysTypeName;
+ sprintf(SubSysTypeName, "Type 0x%08x", SubSystemType);
+ }
+ DPRINT1("SMSS: %s SubSystem not found (either not started or
destroyed).\n", SubSysName);
+#endif
Status = STATUS_UNSUCCESSFUL;
NtClose(ProcessInformation->ProcessHandle);
NtClose(ProcessInformation->ThreadHandle);