[SMSS]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 23 May 2010 17:28:06 +0000 (17:28 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 23 May 2010 17:28:06 +0000 (17:28 +0000)
- Remove the system environment variable PROCESSOR_ARCHITECTURE from the hivesys*.inf files.
- Let SMSS add the system environment variables PROCESSOR_ARCHITECTURE and PROCESSOR_IDENTIFIER to the registry.

svn path=/trunk/; revision=47330

reactos/base/system/smss/initenv.c
reactos/boot/bootdata/hivesys_arm.inf
reactos/boot/bootdata/hivesys_i386.inf

index 66a0f49..e97cf28 100644 (file)
@@ -29,7 +29,7 @@ SmCreateEnvironment(VOID)
 static NTSTATUS
 SmpSetEnvironmentVariable(IN PVOID Context,
                           IN PWSTR ValueName,
-                          IN PVOID ValueData)
+                          IN PWSTR ValueData)
 {
     UNICODE_STRING EnvVariable;
     UNICODE_STRING EnvValue;
@@ -37,7 +37,7 @@ SmpSetEnvironmentVariable(IN PVOID Context,
     RtlInitUnicodeString(&EnvVariable,
                          ValueName);
     RtlInitUnicodeString(&EnvValue,
-                         (PWSTR)ValueData);
+                         ValueData);
     return RtlSetEnvironmentVariable(Context,
                               &EnvVariable,
                               &EnvValue);
@@ -58,12 +58,93 @@ SmpEnvironmentQueryRoutine(IN PWSTR ValueName,
         return STATUS_SUCCESS;
 
     DPRINT("ValueData '%S'\n", (PWSTR)ValueData);
-    return SmpSetEnvironmentVariable(Context,ValueName,ValueData);
+    return SmpSetEnvironmentVariable(Context,ValueName,(PWSTR)ValueData);
 }
 
 
 NTSTATUS
 SmSetEnvironmentVariables(VOID)
+{
+    PWSTR ProcessorArchitecture = L"";
+    RTL_QUERY_REGISTRY_TABLE QueryTable[3];
+    UNICODE_STRING Identifier;
+    UNICODE_STRING VendorIdentifier;
+    UNICODE_STRING ProcessorIdentifier;
+    WCHAR Buffer[256];
+    NTSTATUS Status;
+
+    /* Set the 'PROCESSOR_ARCHITECTURE' system environment variable */
+#ifdef _M_IX86
+    ProcessorArchitecture = L"x86";
+#elif _M_MD64
+    ProcessorArchitecture = L"AMD64";
+#elif _M_ARM
+    ProcessorArchitecture = L"ARM";
+#elif _M_PPC
+    ProcessorArchitecture = 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));
+
+
+    /* Set the 'PROCESSOR_IDENTIFIER' system environment variable */
+    RtlInitUnicodeString(&Identifier, NULL);
+    RtlInitUnicodeString(&VendorIdentifier, NULL);
+
+    RtlZeroMemory(&QueryTable,
+                  sizeof(QueryTable));
+
+    QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
+    QueryTable[0].Name = L"Identifier";
+    QueryTable[0].EntryContext = &Identifier;
+
+    QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
+    QueryTable[1].Name = L"VendorIdentifier";
+    QueryTable[1].EntryContext = &VendorIdentifier;
+
+    Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
+                                    L"\\Registry\\Machine\\Hardware\\Description\\System\\CentralProcessor\\0",
+                                    QueryTable,
+                                    NULL,
+                                    NULL);
+    if (NT_SUCCESS(Status))
+    {
+        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);
+
+        RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
+                              L"Session Manager\\Environment",
+                              L"PROCESSOR_IDENTIFIER",
+                              REG_SZ,
+                              ProcessorIdentifier.Buffer,
+                              (wcslen(ProcessorIdentifier.Buffer) + 1) * sizeof(WCHAR));
+    }
+
+    RtlFreeUnicodeString(&Identifier);
+    RtlFreeUnicodeString(&VendorIdentifier);
+
+    return STATUS_SUCCESS;
+}
+
+
+/**********************************************************************
+ *  Set environment variables from registry
+ */
+NTSTATUS
+SmUpdateEnvironment(VOID)
 {
     RTL_QUERY_REGISTRY_TABLE QueryTable[2];
     WCHAR ValueBuffer[MAX_PATH];
@@ -106,14 +187,4 @@ SmSetEnvironmentVariables(VOID)
     return Status;
 }
 
-/**********************************************************************
- *  Set environment variables from registry
- */
-NTSTATUS
-SmUpdateEnvironment(VOID)
-{
-    /* TODO */
-    return STATUS_SUCCESS;
-}
-
 /* EOF */
index 277600b..39e94e1 100644 (file)
@@ -760,7 +760,6 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","windir",0x0
 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","PROCESSOR_ARCHITECTURE",0x00020000,"x86"
 
 
 ; Known DLLs
index 05e0005..e46e6b3 100644 (file)
@@ -907,7 +907,6 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","windir",0x0
 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","PROCESSOR_ARCHITECTURE",0x00020000,"x86"
 
 
 ; Known DLLs