X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=base%2Fsystem%2Fsmss%2Finitenv.c;h=21874e366ffa6283325efdf4afc9f1a45edc17ec;hp=24ccc3bb5c40d9c8f23af5bfe3e313c73523569f;hb=9fa710c8135d9c18cd6e828bc696b4a3a8b95f9d;hpb=6c8e7899a94651ed4d25ef2f83d9c5ce1df23b4d diff --git a/base/system/smss/initenv.c b/base/system/smss/initenv.c index 24ccc3bb5c4..21874e366ff 100644 --- a/base/system/smss/initenv.c +++ b/base/system/smss/initenv.c @@ -227,10 +227,6 @@ SmSetEnvironmentVariables(VOID) goto done; } -done: - NtClose(EnvironmentKey); - - /* Set the 'PROCESSOR_IDENTIFIER' system environment variable */ RtlInitUnicodeString(&Identifier, NULL); RtlInitUnicodeString(&VendorIdentifier, NULL); @@ -251,25 +247,37 @@ done: QueryTable, NULL, NULL); - if (NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - DPRINT("SM: szIdentifier: %wZ\n", &Identifier); - DPRINT("SM: szVendorIdentifier: %wZ\n", &VendorIdentifier); + DPRINT1("SM: Failed to retrieve processor Identifier and/or VendorIdentifier (Status %08lx)", Status); + goto done; + } - swprintf(Buffer, L"%wZ, %wZ", &Identifier, &VendorIdentifier); + DPRINT("SM: szIdentifier: %wZ\n" , &Identifier); + DPRINT("SM: szVendorIdentifier: %wZ\n", &VendorIdentifier); - RtlWriteRegistryValue(RTL_REGISTRY_CONTROL, - L"Session Manager\\Environment", - L"PROCESSOR_IDENTIFIER", - REG_SZ, - Buffer, - (wcslen(Buffer) + 1) * sizeof(WCHAR)); + RtlInitUnicodeString(&VariableName, L"PROCESSOR_IDENTIFIER"); + swprintf(Buffer, L"%wZ, %wZ", &Identifier, &VendorIdentifier); + RtlFreeUnicodeString(&VendorIdentifier); + RtlFreeUnicodeString(&Identifier); + + Status = NtSetValueKey(EnvironmentKey, + &VariableName, + 0, + REG_SZ, + Buffer, + (wcslen(Buffer) + 1) * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: Failed to set the PROCESSOR_IDENTIFIER environment variable (Status %08lx)", Status); + goto done; } - RtlFreeUnicodeString(&Identifier); - RtlFreeUnicodeString(&VendorIdentifier); +done: + /* Close the handle */ + NtClose(EnvironmentKey); - return STATUS_SUCCESS; + return Status; } @@ -282,6 +290,10 @@ SmUpdateEnvironment(VOID) RTL_QUERY_REGISTRY_TABLE QueryTable[2]; WCHAR ValueBuffer[MAX_PATH]; NTSTATUS Status; +#ifndef NDEBUG + ULONG ii; + PWSTR envp; +#endif /* * The following environment variables must be set prior to reading @@ -317,6 +329,18 @@ SmUpdateEnvironment(VOID) &SmSystemEnvironment, SmSystemEnvironment); +#ifndef NDEBUG + /* Print all environment varaibles */ + ii = 0; + envp = SmSystemEnvironment; + DbgPrint("SmUpdateEnvironment:\n"); + while (*envp) + { + DbgPrint(" %u: %S\n", ii++, envp); + envp += wcslen(envp) + 1; + } +#endif + return Status; }