Author: hbelusca
Date: Thu Jan 7 16:57:05 2016
New Revision: 70529
URL:
http://svn.reactos.org/svn/reactos?rev=70529&view=rev
Log:
[SMSS]
- Use CRT string functions to loop through multi-strings.
- Do not fail the full KnownDll setup if one dll fails to load. Instead, just properly
skip the file (and related to that, fix a bug when skipping excluded known dll files).
- Page files should be created only when we are not in WinPE mode (aka. MiniNTBoot =
FALSE).
- Formatting fix in smloop.c, no code change.
Modified:
trunk/reactos/base/system/smss/sminit.c
trunk/reactos/base/system/smss/smloop.c
Modified: trunk/reactos/base/system/smss/sminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss/sminit.c?…
==============================================================================
--- trunk/reactos/base/system/smss/sminit.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss/sminit.c [iso-8859-1] Thu Jan 7 16:57:05 2016
@@ -38,7 +38,7 @@
PISECURITY_DESCRIPTOR SmpKnownDllsSecurityDescriptor, SmpApiPortSecurityDescriptor;
ULONG SmpAllowProtectedRenames, SmpProtectionMode = 1;
-BOOLEAN MiniNTBoot;
+BOOLEAN MiniNTBoot = FALSE;
#define SMSS_CHECKPOINT(x, y) \
{ \
@@ -325,7 +325,7 @@
}
/* Move to the next requested object */
- while (*SourceString++);
+ SourceString += wcslen(SourceString) + 1;
}
/* All done */
@@ -403,7 +403,7 @@
if (!(NT_SUCCESS(Status)) || (ValueType == REG_SZ)) return Status;
/* Otherwise, move to the next DLL name */
- while (*DllName++);
+ DllName += wcslen(DllName) + 1;
}
}
@@ -585,7 +585,7 @@
}
/* Move to the next name */
- while (*SubsystemName++);
+ SubsystemName += wcslen(SubsystemName) + 1;
}
}
@@ -1495,9 +1495,13 @@
NextEntry = SmpKnownDllsList.Flink;
while (NextEntry != &SmpKnownDllsList)
{
- /* Get the entry and skip it if it's in the exluded list */
+ /* Get the entry and move on */
RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+ NextEntry = NextEntry->Flink;
+
DPRINT("Processing known DLL: %wZ-%wZ\n", &RegEntry->Name,
&RegEntry->Value);
+
+ /* Skip the entry if it's in the exluded list */
if ((SmpFindRegistryValue(&SmpExcludeKnownDllsList,
RegEntry->Name.Buffer)) ||
(SmpFindRegistryValue(&SmpExcludeKnownDllsList,
@@ -1512,14 +1516,15 @@
OBJ_CASE_INSENSITIVE,
DirFileHandle,
NULL);
- Status = NtOpenFile(&FileHandle,
- SYNCHRONIZE | FILE_EXECUTE,
- &ObjectAttributes,
- &IoStatusBlock,
- FILE_SHARE_READ | FILE_SHARE_DELETE,
- FILE_NON_DIRECTORY_FILE |
- FILE_SYNCHRONOUS_IO_NONALERT);
- if (!NT_SUCCESS(Status)) break;
+ Status1 = NtOpenFile(&FileHandle,
+ SYNCHRONIZE | FILE_EXECUTE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ FILE_SHARE_READ | FILE_SHARE_DELETE,
+ FILE_NON_DIRECTORY_FILE |
+ FILE_SYNCHRONOUS_IO_NONALERT);
+ /* If we failed, skip it */
+ if (!NT_SUCCESS(Status1)) continue;
/* Checksum it */
Status = LdrVerifyImageMatchesChecksum((HANDLE)((ULONG_PTR)FileHandle | 1),
@@ -1536,8 +1541,7 @@
ErrorParameters[2] = (ULONG)&RegEntry->Value;
SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
}
- else
- if (!(ImageCharacteristics & IMAGE_FILE_DLL))
+ else if (!(ImageCharacteristics & IMAGE_FILE_DLL))
{
/* An invalid known DLL entry will also kill SMSS */
RtlInitUnicodeString(&ErrorResponse,
@@ -1589,9 +1593,6 @@
/* Close the file since we can move on to the next one */
Status1 = NtClose(FileHandle);
ASSERT(NT_SUCCESS(Status1));
-
- /* Go to the next entry */
- NextEntry = NextEntry->Flink;
}
Quickie:
@@ -1652,7 +1653,7 @@
UNICODE_STRING ValueName, DestinationString;
HANDLE KeyHandle, KeyHandle2;
ULONG ResultLength;
- PWCHAR ArchName;
+ PWCHAR ValueData;
WCHAR ValueBuffer[512], ValueBuffer2[512];
PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)ValueBuffer;
PKEY_VALUE_PARTIAL_INFORMATION PartialInfo2 = (PVOID)ValueBuffer2;
@@ -1700,13 +1701,14 @@
/* First let's write the OS variable */
RtlInitUnicodeString(&ValueName, L"OS");
- DPRINT("Setting %wZ to %S\n", &ValueName, L"Windows_NT");
+ ValueData = L"Windows_NT";
+ DPRINT("Setting %wZ to %S\n", &ValueName, ValueData);
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
- L"Windows_NT",
- wcslen(L"Windows_NT") * sizeof(WCHAR) +
sizeof(UNICODE_NULL));
+ ValueData,
+ (wcslen(ValueData) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
@@ -1721,30 +1723,30 @@
{
/* Pick the correct string that matches the architecture */
case PROCESSOR_ARCHITECTURE_INTEL:
- ArchName = L"x86";
+ ValueData = L"x86";
break;
case PROCESSOR_ARCHITECTURE_AMD64:
- ArchName = L"AMD64";
+ ValueData = L"AMD64";
break;
case PROCESSOR_ARCHITECTURE_IA64:
- ArchName = L"IA64";
+ ValueData = L"IA64";
break;
default:
- ArchName = L"Unknown";
+ ValueData = L"Unknown";
break;
}
/* Set it */
- DPRINT("Setting %wZ to %S\n", &ValueName, ArchName);
+ DPRINT("Setting %wZ to %S\n", &ValueName, ValueData);
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
- ArchName,
- wcslen(ArchName) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
+ ValueData,
+ (wcslen(ValueData) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
@@ -1762,7 +1764,7 @@
0,
REG_SZ,
ValueBuffer,
- wcslen(ValueBuffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
+ (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
@@ -1830,7 +1832,7 @@
0,
REG_SZ,
PartialInfo->Data,
- wcslen((PWCHAR)PartialInfo->Data) * sizeof(WCHAR) +
sizeof(UNICODE_NULL));
+ (wcslen((PWCHAR)PartialInfo->Data) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
@@ -1872,7 +1874,7 @@
0,
REG_SZ,
ValueBuffer,
- wcslen(ValueBuffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
+ (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
@@ -1890,7 +1892,7 @@
0,
REG_SZ,
ValueBuffer,
- wcslen(ValueBuffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
+ (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
@@ -1944,7 +1946,7 @@
0,
REG_SZ,
ValueBuffer,
- wcslen(ValueBuffer) * sizeof(WCHAR) +
sizeof(UNICODE_NULL));
+ (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SMSS: Failed writing %wZ environment variable -
%x\n",
@@ -2335,25 +2337,29 @@
return Status;
}
- /* Loop every page file */
- Head = &SmpPagingFileList;
- while (!IsListEmpty(Head))
- {
- /* Remove each one from the list */
- NextEntry = RemoveHeadList(Head);
-
- /* Create the descriptor for it */
- RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
- SmpCreatePagingFileDescriptor(&RegEntry->Name);
-
- /* And free it */
- if (RegEntry->AnsiValue) RtlFreeHeap(RtlGetProcessHeap(), 0,
RegEntry->AnsiValue);
- if (RegEntry->Value.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0,
RegEntry->Value.Buffer);
- RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
- }
-
- /* Now create all the paging files for the descriptors that we have */
- SmpCreatePagingFiles();
+ /* Create the needed page files */
+ if (!MiniNTBoot)
+ {
+ /* Loop every page file */
+ Head = &SmpPagingFileList;
+ while (!IsListEmpty(Head))
+ {
+ /* Remove each one from the list */
+ NextEntry = RemoveHeadList(Head);
+
+ /* Create the descriptor for it */
+ RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+ SmpCreatePagingFileDescriptor(&RegEntry->Name);
+
+ /* And free it */
+ if (RegEntry->AnsiValue) RtlFreeHeap(RtlGetProcessHeap(), 0,
RegEntry->AnsiValue);
+ if (RegEntry->Value.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0,
RegEntry->Value.Buffer);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
+ }
+
+ /* Now create all the paging files for the descriptors that we have */
+ SmpCreatePagingFiles();
+ }
/* Tell Cm it's now safe to fully enable write access to the registry */
NtInitializeRegistry(CM_BOOT_FLAG_SMSS);
Modified: trunk/reactos/base/system/smss/smloop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss/smloop.c?…
==============================================================================
--- trunk/reactos/base/system/smss/smloop.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss/smloop.c [iso-8859-1] Thu Jan 7 16:57:05 2016
@@ -380,7 +380,7 @@
case LPC_CONNECTION_REQUEST:
/* Create the right structures for it */
SmpHandleConnectionRequest(SmApiPort, (PSB_API_MSG)&RequestMsg);
- ReplyMsg = NULL;
+ ReplyMsg = NULL;
break;
/* A closed connection */