https://git.reactos.org/?p=reactos.git;a=commitdiff;h=258caa85d1745796c7d19…
commit 258caa85d1745796c7d192d8d0b6baa70fa0b9ac
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Nov 2 15:46:08 2022 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Nov 3 02:55:51 2022 +0100
[SMSS] Call SmpConfigureEnvironment() twice in order to resolve forward environment
variables references.
Example: environment variable EnvVar1 that refers to a later-defined
variable EnvVar2.
---
base/system/smss/sminit.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/base/system/smss/sminit.c b/base/system/smss/sminit.c
index 8960010fcc8..da11f72e000 100644
--- a/base/system/smss/sminit.c
+++ b/base/system/smss/sminit.c
@@ -477,6 +477,12 @@ SmpConfigureKnownDlls(IN PWSTR ValueName,
}
}
+/**
+ * @remark
+ * SmpConfigureEnvironment() should be called twice in order to resolve
+ * forward references to environment variables.
+ * See the two L"Environment" entries in SmpRegistryConfigurationTable[].
+ **/
NTSTATUS
NTAPI
SmpConfigureEnvironment(IN PWSTR ValueName,
@@ -493,7 +499,7 @@ SmpConfigureEnvironment(IN PWSTR ValueName,
RtlInitUnicodeString(&ValueString, ValueName);
RtlInitUnicodeString(&DataString, ValueData);
DPRINT("Setting %wZ = %wZ\n", &ValueString, &DataString);
- Status = RtlSetEnvironmentVariable(0, &ValueString, &DataString);
+ Status = RtlSetEnvironmentVariable(NULL, &ValueString, &DataString);
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: 'SET %wZ = %wZ' failed - Status == %lx\n",
@@ -716,6 +722,13 @@ SmpRegistryConfigurationTable[] =
0
},
+ /**
+ * @remark
+ * SmpConfigureEnvironment() is expected to be called twice
+ * (see SmpCalledConfigEnv) in order to resolve forward references
+ * to environment variables (e.g. EnvVar1 referring to EnvVar2,
+ * before EnvVar2 is defined).
+ **/
{
SmpConfigureEnvironment,
RTL_QUERY_REGISTRY_SUBKEY,
@@ -726,6 +739,17 @@ SmpRegistryConfigurationTable[] =
0
},
+ {
+ SmpConfigureEnvironment,
+ RTL_QUERY_REGISTRY_SUBKEY,
+ L"Environment",
+ NULL,
+ REG_NONE,
+ NULL,
+ 0
+ },
+ /****/
+
{
SmpConfigureSubSystems,
RTL_QUERY_REGISTRY_SUBKEY,