mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
[SMSS]
- Add the system environment variables PROCESSOR_LEVEL and PROCESSOR_REVISION. svn path=/trunk/; revision=47336
This commit is contained in:
parent
7fa77031b0
commit
4841dde246
1 changed files with 68 additions and 14 deletions
|
@ -66,20 +66,27 @@ NTSTATUS
|
||||||
SmSetEnvironmentVariables(VOID)
|
SmSetEnvironmentVariables(VOID)
|
||||||
{
|
{
|
||||||
SYSTEM_BASIC_INFORMATION BasicInformation;
|
SYSTEM_BASIC_INFORMATION BasicInformation;
|
||||||
|
SYSTEM_PROCESSOR_INFORMATION ProcessorInformation;
|
||||||
RTL_QUERY_REGISTRY_TABLE QueryTable[3];
|
RTL_QUERY_REGISTRY_TABLE QueryTable[3];
|
||||||
UNICODE_STRING Identifier;
|
UNICODE_STRING Identifier;
|
||||||
UNICODE_STRING VendorIdentifier;
|
UNICODE_STRING VendorIdentifier;
|
||||||
WCHAR Buffer[256];
|
WCHAR Buffer[256];
|
||||||
|
|
||||||
UNICODE_STRING EnvironmentKeyName;
|
UNICODE_STRING EnvironmentKeyName;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
HANDLE EnvironmentKey;
|
HANDLE EnvironmentKey;
|
||||||
UNICODE_STRING VariableName;
|
UNICODE_STRING VariableName;
|
||||||
PWSTR VariableData;
|
PWSTR VariableData;
|
||||||
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtQuerySystemInformation(SystemProcessorInformation,
|
||||||
|
&ProcessorInformation,
|
||||||
|
sizeof(SYSTEM_PROCESSOR_INFORMATION),
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SM: Failed to retrieve system processor information (Status %08lx)", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Status = NtQuerySystemInformation(SystemBasicInformation,
|
Status = NtQuerySystemInformation(SystemBasicInformation,
|
||||||
&BasicInformation,
|
&BasicInformation,
|
||||||
|
@ -149,17 +156,28 @@ SmSetEnvironmentVariables(VOID)
|
||||||
RtlInitUnicodeString(&VariableName,
|
RtlInitUnicodeString(&VariableName,
|
||||||
L"PROCESSOR_ARCHITECTURE");
|
L"PROCESSOR_ARCHITECTURE");
|
||||||
|
|
||||||
#ifdef _M_IX86
|
switch (ProcessorInformation.ProcessorArchitecture)
|
||||||
VariableData = L"x86";
|
{
|
||||||
#elif _M_MD64
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||||
VariableData = L"AMD64";
|
VariableData = L"x86";
|
||||||
#elif _M_ARM
|
break;
|
||||||
VariableData = L"ARM";
|
|
||||||
#elif _M_PPC
|
case PROCESSOR_ARCHITECTURE_PPC:
|
||||||
VariableData = L"PPC";
|
VariableData = L"PPC";
|
||||||
#else
|
break;
|
||||||
#error "Unsupported Architecture!\n"
|
|
||||||
#endif
|
case PROCESSOR_ARCHITECTURE_ARM:
|
||||||
|
VariableData = L"ARM";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||||
|
VariableData = L"AMD64";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
VariableData = L"Unknown";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Status = NtSetValueKey(EnvironmentKey,
|
Status = NtSetValueKey(EnvironmentKey,
|
||||||
&VariableName,
|
&VariableName,
|
||||||
|
@ -173,6 +191,42 @@ SmSetEnvironmentVariables(VOID)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the 'PROCESSOR_LEVEL' system environment variable */
|
||||||
|
RtlInitUnicodeString(&VariableName,
|
||||||
|
L"PROCESSOR_LEVEL");
|
||||||
|
|
||||||
|
swprintf(Buffer, L"%lu", ProcessorInformation.ProcessorLevel);
|
||||||
|
|
||||||
|
Status = NtSetValueKey(EnvironmentKey,
|
||||||
|
&VariableName,
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
Buffer,
|
||||||
|
(wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SM: Failed to set the PROCESSOR_LEVEL environment variable (Status %08lx)", Status);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the 'PROCESSOR_REVISION' system environment variable */
|
||||||
|
RtlInitUnicodeString(&VariableName,
|
||||||
|
L"PROCESSOR_REVISION");
|
||||||
|
|
||||||
|
swprintf(Buffer, L"%04x", ProcessorInformation.ProcessorRevision);
|
||||||
|
|
||||||
|
Status = NtSetValueKey(EnvironmentKey,
|
||||||
|
&VariableName,
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
Buffer,
|
||||||
|
(wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SM: Failed to set the PROCESSOR_REVISION environment variable (Status %08lx)", Status);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
NtClose(EnvironmentKey);
|
NtClose(EnvironmentKey);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue