Author: ekohl
Date: Sun May 23 21:27:04 2010
New Revision: 47333
URL: 
http://svn.reactos.org/svn/reactos?rev=47333&view=rev
Log:
[SMSS]
- Remove the system environment variable OS from the hivesys*.inf files.
- Change the type of the system environment variable PATHEXT in the hivesys*.inf files
from REG_EXPAND_SZ to REG_SZ.
- Let SMSS add the system environment variables OS and NUMBER_OF_PROCESSORS to the
registry.
Modified:
    trunk/reactos/base/system/smss/initenv.c
    trunk/reactos/boot/bootdata/hivesys_arm.inf
    trunk/reactos/boot/bootdata/hivesys_i386.inf
Modified: trunk/reactos/base/system/smss/initenv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss/initenv.c…
==============================================================================
--- trunk/reactos/base/system/smss/initenv.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss/initenv.c [iso-8859-1] Sun May 23 21:27:04 2010
@@ -65,33 +65,116 @@
 NTSTATUS
 SmSetEnvironmentVariables(VOID)
 {
-    PWSTR ProcessorArchitecture = L"";
+    SYSTEM_BASIC_INFORMATION BasicInformation;
+
     RTL_QUERY_REGISTRY_TABLE QueryTable[3];
     UNICODE_STRING Identifier;
     UNICODE_STRING VendorIdentifier;
-    UNICODE_STRING ProcessorIdentifier;
     WCHAR Buffer[256];
+
+    UNICODE_STRING EnvironmentKeyName;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    HANDLE EnvironmentKey;
+    UNICODE_STRING VariableName;
+    PWSTR VariableData;
+
     NTSTATUS Status;
+
+    Status = NtQuerySystemInformation(SystemBasicInformation,
+                                      &BasicInformation,
+                                      sizeof(SYSTEM_BASIC_INFORMATION),
+                                      NULL);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SM: Failed to retrieve system basic information (Status
%08lx)", Status);
+        return Status;
+    }
+
+    RtlInitUnicodeString(&EnvironmentKeyName,
+
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session
Manager\\Environment");
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &EnvironmentKeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+
+    /* Open the system environment key */
+    Status = NtOpenKey(&EnvironmentKey,
+                       GENERIC_WRITE,
+                       &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SM: Failed to open the environment key (Status %08lx)",
Status);
+        return Status;
+    }
+
+    /* Set the 'NUMBER_OF_PROCESSORS' system environment variable */
+    RtlInitUnicodeString(&VariableName,
+                         L"NUMBER_OF_PROCESSORS");
+
+    swprintf(Buffer, L"%lu", BasicInformation.NumberOfProcessors);
+
+    Status = NtSetValueKey(EnvironmentKey,
+                           &VariableName,
+                           0,
+                           REG_SZ,
+                           Buffer,
+                           (wcslen(Buffer) + 1) * sizeof(WCHAR));
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SM: Failed to set the NUMBER_OF_PROCESSORS environment variable
(Status %08lx)", Status);
+        goto done;
+    }
+
+    /* Set the 'OS' system environment variable */
+    RtlInitUnicodeString(&VariableName,
+                         L"OS");
+
+    VariableData = L"ReactOS";
+
+    Status = NtSetValueKey(EnvironmentKey,
+                           &VariableName,
+                           0,
+                           REG_SZ,
+                           VariableData,
+                           (wcslen(VariableData) + 1) * sizeof(WCHAR));
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SM: Failed to set the OS environment variable (Status %08lx)",
Status);
+        goto done;
+    }
+
     /* Set the 'PROCESSOR_ARCHITECTURE' system environment variable */
+    RtlInitUnicodeString(&VariableName,
+                         L"PROCESSOR_ARCHITECTURE");
+
 #ifdef _M_IX86
-    ProcessorArchitecture = L"x86";
+    VariableData = L"x86";
 #elif _M_MD64
-    ProcessorArchitecture = L"AMD64";
+    VariableData = L"AMD64";
 #elif _M_ARM
-    ProcessorArchitecture = L"ARM";
+    VariableData = L"ARM";
 #elif _M_PPC
-    ProcessorArchitecture = L"PPC";
+    VariableData = L"PPC";
 #else
     #error "Unsupported Architecture!\n"
 #endif
-    RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
-                          L"Session Manager\\Environment",
-                          L"PROCESSOR_ARCHITECTURE",
-                          REG_SZ,
-                          ProcessorArchitecture,
-                          (wcslen(ProcessorArchitecture) + 1) * sizeof(WCHAR));
+    Status = NtSetValueKey(EnvironmentKey,
+                           &VariableName,
+                           0,
+                           REG_SZ,
+                           VariableData,
+                           (wcslen(VariableData) + 1) * sizeof(WCHAR));
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SM: Failed to set the PROCESSOR_ARCHITECTURE environment variable
(Status %08lx)", Status);
+        goto done;
+    }
+
+done:
+    NtClose(EnvironmentKey);
     /* Set the 'PROCESSOR_IDENTIFIER' system environment variable */
@@ -119,18 +202,14 @@
         DPRINT("SM: szIdentifier: %wZ\n", &Identifier);
         DPRINT("SM: szVendorIdentifier: %wZ\n", &VendorIdentifier);
-        RtlInitEmptyUnicodeString(&ProcessorIdentifier, Buffer, 256 * sizeof(WCHAR));
-
-        RtlAppendUnicodeStringToString(&ProcessorIdentifier, &Identifier);
-        RtlAppendUnicodeToString(&ProcessorIdentifier, L", ");
-        RtlAppendUnicodeStringToString(&ProcessorIdentifier, &VendorIdentifier);
+        swprintf(Buffer, L"%wZ, %wZ", &Identifier, &VendorIdentifier);
         RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
                               L"Session Manager\\Environment",
                               L"PROCESSOR_IDENTIFIER",
                               REG_SZ,
-                              ProcessorIdentifier.Buffer,
-                              (wcslen(ProcessorIdentifier.Buffer) + 1) * sizeof(WCHAR));
+                              Buffer,
+                              (wcslen(Buffer) + 1) * sizeof(WCHAR));
     }
     RtlFreeUnicodeString(&Identifier);
Modified: trunk/reactos/boot/bootdata/hivesys_arm.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys_arm.…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesys_arm.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesys_arm.inf [iso-8859-1] Sun May 23 21:27:04 2010
@@ -754,12 +754,11 @@
 ; System environment settings
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","ComSpec",0x00020000,"%SystemRoot%\system32\cmd.exe"
-HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","OS",0x00020000,"ReactOS"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","Path",0x00020000,"%SystemRoot%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","windir",0x00020000,"%SystemRoot%"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","TEMP",0x00020000,"%SystemDrive%\TEMP"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","TMP",0x00020000,"%SystemDrive%\TEMP"
-HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","PATHEXT",0x00020000,".COM;.EXE;.BAT;.CMD"
+HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","PATHEXT",0x00000000,".COM;.EXE;.BAT;.CMD"
 ; Known DLLs
Modified: trunk/reactos/boot/bootdata/hivesys_i386.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys_i386…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesys_i386.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesys_i386.inf [iso-8859-1] Sun May 23 21:27:04 2010
@@ -901,12 +901,11 @@
 ; System environment settings
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","ComSpec",0x00020000,"%SystemRoot%\system32\cmd.exe"
-HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","OS",0x00020000,"ReactOS"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","Path",0x00020000,"%SystemRoot%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","windir",0x00020000,"%SystemRoot%"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","TEMP",0x00020000,"%SystemDrive%\TEMP"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","TMP",0x00020000,"%SystemDrive%\TEMP"
-HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","PATHEXT",0x00020000,".COM;.EXE;.BAT;.CMD"
+HKLM,"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment","PATHEXT",0x00000000,".COM;.EXE;.BAT;.CMD"
 ; Known DLLs