2 * PROJECT: ReactOS Session Manager
3 * LICENSE: GPL v2 or later - See COPYING in the top level directory
4 * FILE: base/system/smss/initenv.c
5 * PURPOSE: Environment initialization.
6 * PROGRAMMERS: ReactOS Development Team
9 /* INCLUDES ******************************************************************/
17 PWSTR SmSystemEnvironment
= NULL
;
23 SmCreateEnvironment(VOID
)
25 return RtlCreateEnvironment(FALSE
, &SmSystemEnvironment
);
30 SmpSetEnvironmentVariable(IN PVOID Context
,
34 UNICODE_STRING EnvVariable
;
35 UNICODE_STRING EnvValue
;
37 RtlInitUnicodeString(&EnvVariable
,
39 RtlInitUnicodeString(&EnvValue
,
41 return RtlSetEnvironmentVariable(Context
,
48 SmpEnvironmentQueryRoutine(IN PWSTR ValueName
,
53 IN PVOID EntryContext
)
55 DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName
, ValueType
, ValueLength
);
57 if (ValueType
!= REG_SZ
&& ValueType
!= REG_EXPAND_SZ
)
58 return STATUS_SUCCESS
;
60 DPRINT("ValueData '%S'\n", (PWSTR
)ValueData
);
61 return SmpSetEnvironmentVariable(Context
,ValueName
,ValueData
);
66 SmSetEnvironmentVariables(VOID
)
68 RTL_QUERY_REGISTRY_TABLE QueryTable
[2];
69 WCHAR ValueBuffer
[MAX_PATH
];
73 * The following environment variables must be set prior to reading
74 * other variables from the registry.
76 * Variables (example):
77 * SystemRoot = "C:\reactos"
81 /* Copy system root into value buffer */
83 SharedUserData
->NtSystemRoot
);
85 /* Set SystemRoot = "C:\reactos" */
86 SmpSetEnvironmentVariable(&SmSystemEnvironment
, L
"SystemRoot", ValueBuffer
);
88 /* Cut off trailing path */
91 /* Set SystemDrive = "C:" */
92 SmpSetEnvironmentVariable(&SmSystemEnvironment
, L
"SystemDrive", ValueBuffer
);
94 /* Read system environment from the registry. */
95 RtlZeroMemory(&QueryTable
,
98 QueryTable
[0].QueryRoutine
= SmpEnvironmentQueryRoutine
;
100 Status
= RtlQueryRegistryValues(RTL_REGISTRY_CONTROL
,
101 L
"Session Manager\\Environment",
103 &SmSystemEnvironment
,
104 SmSystemEnvironment
);
109 /**********************************************************************
110 * Set environment variables from registry
113 SmUpdateEnvironment(VOID
)
116 return STATUS_SUCCESS
;