From a4b0bea539bb216e517e0f6afa4b4b21bb18d623 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 30 Apr 2011 22:09:16 +0000 Subject: [PATCH] =?UTF-8?q?[SMSS]=20Fix=20for=20the=20loading=20of=20the?= =?UTF-8?q?=20"KnownDlls"=20in=20SMSS.=20Patch=20by=20Herm=C3=A8s=20B?= =?UTF-8?q?=C3=89LUSCA=20-=20MA=C3=8FTO.=20The=20patch=20was=20applied=20w?= =?UTF-8?q?ithout=20changes=20to=20comments,=20indentation=20and=20coding?= =?UTF-8?q?=20style.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See issue #6159 for more details. svn path=/trunk/; revision=51511 --- reactos/base/system/smss/init.c | 2 +- reactos/base/system/smss/initenv.c | 62 +++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/reactos/base/system/smss/init.c b/reactos/base/system/smss/init.c index 6d5bc643994..146a4418cf4 100644 --- a/reactos/base/system/smss/init.c +++ b/reactos/base/system/smss/init.c @@ -30,10 +30,10 @@ struct { {TRUE, SmInitDosDevices, "create dos device links"}, {TRUE, SmRunBootApplications, "run boot applications"}, {TRUE, SmProcessFileRenameList, "process the file rename list"}, + {FALSE, SmUpdateEnvironment, "update environment variables"}, {FALSE, SmLoadKnownDlls, "preload system DLLs"}, {TRUE, SmCreatePagingFiles, "create paging files"}, {TRUE, SmInitializeRegistry, "initialize the registry"}, - {FALSE, SmUpdateEnvironment, "update environment variables"}, {TRUE, SmInitializeClientManagement, "initialize client management"}, {TRUE, SmLoadSubsystems, "load subsystems"} }; diff --git a/reactos/base/system/smss/initenv.c b/reactos/base/system/smss/initenv.c index 24ccc3bb5c4..21874e366ff 100644 --- a/reactos/base/system/smss/initenv.c +++ b/reactos/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); - - swprintf(Buffer, L"%wZ, %wZ", &Identifier, &VendorIdentifier); - - RtlWriteRegistryValue(RTL_REGISTRY_CONTROL, - L"Session Manager\\Environment", - L"PROCESSOR_IDENTIFIER", - REG_SZ, - Buffer, - (wcslen(Buffer) + 1) * sizeof(WCHAR)); + DPRINT1("SM: Failed to retrieve processor Identifier and/or VendorIdentifier (Status %08lx)", Status); + goto done; } - RtlFreeUnicodeString(&Identifier); - RtlFreeUnicodeString(&VendorIdentifier); + DPRINT("SM: szIdentifier: %wZ\n" , &Identifier); + DPRINT("SM: szVendorIdentifier: %wZ\n", &VendorIdentifier); - return STATUS_SUCCESS; + 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; + } + +done: + /* Close the handle */ + NtClose(EnvironmentKey); + + 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; }