[ros-diffs] [ion] 55467: [SMSS2]: Implement SmpTranslateSystemPartitionInformation which sets a few last registry keys as part of the initialization process. [SMSS2]: Implement SmpLoadSubsystemsForMuSession wh...

ion at svn.reactos.org ion at svn.reactos.org
Mon Feb 6 18:57:18 UTC 2012


Author: ion
Date: Mon Feb  6 18:57:18 2012
New Revision: 55467

URL: http://svn.reactos.org/svn/reactos?rev=55467&view=rev
Log:
[SMSS2]: Implement SmpTranslateSystemPartitionInformation which sets a few last registry keys as part of the initialization process.
[SMSS2]: Implement SmpLoadSubsystemsForMuSession which correctly creates a session, loads win32k.sys inside of it, and then detaches from the session. Winlogon.exe is set as the initial command (but not launched), and CSRSS is fake-started.
[CSRSRV]: No longer start win32k.sys, that's not your job.
[SMSS2]: Kill most debug prints that aren't errors.

Modified:
    trunk/reactos/base/system/smss2/sminit.c
    trunk/reactos/base/system/smss2/smss.c
    trunk/reactos/base/system/smss2/smss.h
    trunk/reactos/base/system/smss2/smsubsys.c
    trunk/reactos/subsystems/win32/csrss/csrsrv/init.c

Modified: trunk/reactos/base/system/smss2/sminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss2/sminit.c?rev=55467&r1=55466&r2=55467&view=diff
==============================================================================
--- trunk/reactos/base/system/smss2/sminit.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss2/sminit.c [iso-8859-1] Mon Feb  6 18:57:18 2012
@@ -13,14 +13,6 @@
 #include "debug.h"
 
 /* GLOBALS ********************************************************************/
-
-typedef struct _SMP_REGISTRY_VALUE
-{
-    LIST_ENTRY Entry;
-    UNICODE_STRING Name;
-    UNICODE_STRING Value;
-    PCHAR AnsiValue;
-} SMP_REGISTRY_VALUE, *PSMP_REGISTRY_VALUE;
 
 UNICODE_STRING SmpSubsystemName, PosixName, Os2Name;
 LIST_ENTRY SmpBootExecuteList, SmpSetupExecuteList, SmpPagingFileList;
@@ -244,7 +236,7 @@
 
     /* Recreate the security descriptors to take into account security mode */
     SmpCreateSecurityDescriptors(FALSE);
-    DPRINT1("SmpProtectionMode: %d\n", SmpProtectionMode);
+    DPRINT("SmpProtectionMode: %d\n", SmpProtectionMode);
     return STATUS_SUCCESS;
 }
 
@@ -269,7 +261,7 @@
         SmpAllowProtectedRenames = 0;
     }
 
-    DPRINT1("SmpAllowProtectedRenames: %d\n", SmpAllowProtectedRenames);
+    DPRINT("SmpAllowProtectedRenames: %d\n", SmpAllowProtectedRenames);
     return STATUS_SUCCESS;
 }
 
@@ -315,7 +307,7 @@
                                    OBJ_PERMANENT,
                                    NULL,
                                    SecDescriptor);
-        DPRINT1("Creating: %wZ directory\n", &SearchString);
+        DPRINT("Creating: %wZ directory\n", &SearchString);
         Status = NtCreateDirectoryObject(&DirHandle,
                                          DIRECTORY_ALL_ACCESS,
                                          &ObjectAttributes);
@@ -403,7 +395,7 @@
         while (*DllName)
         {
             /* Add this to the linked list */
-            DPRINT1("Excluded DLL: %S\n", DllName);
+            DPRINT("Excluded DLL: %S\n", DllName);
             Status = SmpSaveRegistryValue(EntryContext, DllName, NULL, TRUE);
 
             /* Bail out on failure or if only one DLL name was present */
@@ -478,7 +470,7 @@
     }
 
     /* This is the directory, initialize it */
-    DPRINT1("KnownDll Path: %S\n", ValueData);
+    DPRINT("KnownDll Path: %S\n", ValueData);
     return SmpInitializeKnownDllPath(&SmpKnownDllPath, ValueData, ValueLength);
 }
 
@@ -497,7 +489,7 @@
     /* Convert the strings into UNICODE_STRING and set the variable defined */
     RtlInitUnicodeString(&ValueString, ValueName);
     RtlInitUnicodeString(&DataString, ValueData);
-    DPRINT1("Setting %wZ = %wZ\n", &ValueString, &DataString);
+    DPRINT("Setting %wZ = %wZ\n", &ValueString, &DataString);
     Status = RtlSetEnvironmentVariable(0, &ValueString, &DataString);
     if (!NT_SUCCESS(Status))
     {
@@ -545,7 +537,7 @@
             (ValueType != REG_DWORD))
         {
             /* It isn't, must be a subsystem entry, add it to the list */
-            DPRINT1("Subsystem entry: %S-%S\n", ValueName, ValueData);
+            DPRINT("Subsystem entry: %S-%S\n", ValueName, ValueData);
             return SmpSaveRegistryValue(EntryContext, ValueName, ValueData, TRUE);
         }
 
@@ -562,7 +554,7 @@
         while (*SubsystemName)
         {
             /* We should have already put it into the list when we found it */
-            DPRINT1("Found subsystem: %S\n", SubsystemName);
+            DPRINT("Found subsystem: %S\n", SubsystemName);
             RegEntry = SmpFindRegistryValue(EntryContext, SubsystemName);
             if (!RegEntry)
             {
@@ -578,13 +570,13 @@
                 if (_wcsicmp(ValueName, L"Required"))
                 {
                     /* Put it into the optional list */
-                    DPRINT1("Optional\n");
+                    DPRINT("Optional\n");
                     InsertTailList(&SmpSubSystemsToDefer, &RegEntry->Entry);
                 }
                 else
                 {
                     /* Put it into the required list */
-                    DPRINT1("Required\n");
+                    DPRINT("Required\n");
                     InsertTailList(&SmpSubSystemsToLoad, &RegEntry->Entry);
                 }
             }
@@ -795,6 +787,161 @@
 };
 
 /* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+SmpTranslateSystemPartitionInformation(VOID)
+{
+    NTSTATUS Status;
+    UNICODE_STRING UnicodeString, LinkTarget, SearchString, SystemPartition;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    HANDLE KeyHandle, LinkHandle;
+    CHAR ValueBuffer[512 + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
+    PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)ValueBuffer;
+    ULONG Length, Context;
+    CHAR DirInfoBuffer[512 + sizeof(OBJECT_DIRECTORY_INFORMATION)];
+    POBJECT_DIRECTORY_INFORMATION DirInfo = (PVOID)DirInfoBuffer;
+    WCHAR LinkBuffer[MAX_PATH];
+
+    /* Open the setup key */
+    RtlInitUnicodeString(&UnicodeString, L"\\Registry\\Machine\\System\\Setup");
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &UnicodeString,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+    Status = NtOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SMSS: can't open system setup key for reading: 0x%x\n", Status);
+        return;
+    }
+
+    /* Query the system partition */
+    RtlInitUnicodeString(&UnicodeString, L"SystemPartition");
+    Status = NtQueryValueKey(KeyHandle,
+                             &UnicodeString,
+                             KeyValuePartialInformation,
+                             PartialInfo,
+                             sizeof(ValueBuffer),
+                             &Length);
+    NtClose(KeyHandle);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SMSS: can't query SystemPartition value: 0x%x\n", Status);
+        return;
+    }
+
+    /* Initialize the system partition string string */
+    RtlInitUnicodeString(&SystemPartition, (PWCHAR)PartialInfo->Data);
+
+    /* Enumerate the directory looking for the symbolic link string */
+    RtlInitUnicodeString(&SearchString, L"SymbolicLink");
+    RtlInitEmptyUnicodeString(&LinkTarget, LinkBuffer, sizeof(LinkBuffer));
+    Status = NtQueryDirectoryObject(SmpDosDevicesObjectDirectory,
+                                    DirInfo,
+                                    sizeof(DirInfoBuffer),
+                                    TRUE,
+                                    TRUE,
+                                    &Context,
+                                    NULL);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SMSS: can't find drive letter for system partition\n");
+        return;
+    }
+
+    /* Keep searching until we find it */
+    do
+    {
+        /* Is this it? */
+        if ((RtlEqualUnicodeString(&DirInfo->TypeName, &SearchString, TRUE)) &&
+            (DirInfo->Name.Length == 2 * sizeof(WCHAR)) &&
+            (DirInfo->Name.Buffer[1] == L':'))
+        {
+            /* Looks like we found it, open the link to get its target */
+            InitializeObjectAttributes(&ObjectAttributes,
+                                       &DirInfo->Name,
+                                       OBJ_CASE_INSENSITIVE,
+                                       SmpDosDevicesObjectDirectory,
+                                       NULL);
+            Status = NtOpenSymbolicLinkObject(&LinkHandle,
+                                              SYMBOLIC_LINK_ALL_ACCESS,
+                                              &ObjectAttributes);
+            if (NT_SUCCESS(Status))
+            {
+                /* Open worked, query the target now */
+                Status = NtQuerySymbolicLinkObject(LinkHandle,
+                                                   &LinkTarget,
+                                                   NULL);
+                NtClose(LinkHandle);
+
+                /* Check if it matches the string we had found earlier */
+                if ((NT_SUCCESS(Status)) &&
+                    ((RtlEqualUnicodeString(&SystemPartition,
+                                           &LinkTarget,
+                                           TRUE)) ||
+                    ((RtlPrefixUnicodeString(&SystemPartition,
+                                             &LinkTarget,
+                                             TRUE)) &&
+                     (LinkTarget.Buffer[SystemPartition.Length / sizeof(WCHAR)] == L'\\'))))
+                {
+                    /* All done */
+                    break;
+                }
+            }
+        }
+
+        /* Couldn't find it, try again */
+        Status = NtQueryDirectoryObject(SmpDosDevicesObjectDirectory,
+                                        DirInfo,
+                                        sizeof(DirInfoBuffer),
+                                        TRUE,
+                                        FALSE,
+                                        &Context,
+                                        NULL);
+    } while (NT_SUCCESS(Status));
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SMSS: can't find drive letter for system partition\n");
+        return;
+    }
+
+    /* Open the setup key again, for full access this time */
+    RtlInitUnicodeString(&UnicodeString,
+                         L"\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup");
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &UnicodeString,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+    Status = NtOpenKey(&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SMSS: can't open software setup key for writing: 0x%x\n",
+                Status);
+        return;
+    }
+
+    /* Wrap up the end of the link buffer */
+    wcsncpy(LinkBuffer, DirInfo->Name.Buffer, 2);
+    LinkBuffer[2] = L'\\';
+    LinkBuffer[3] = L'\0';
+
+    /* Now set this as the "BootDir" */
+    RtlInitUnicodeString(&UnicodeString, L"BootDir");
+    Status = NtSetValueKey(KeyHandle,
+                           &UnicodeString,
+                           0,
+                           REG_SZ,
+                           LinkBuffer,
+                           4 * sizeof(WCHAR));
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("SMSS: couldn't write BootDir value: 0x%x\n", Status);
+    }
+    NtClose(KeyHandle);
+}
 
 NTSTATUS
 NTAPI
@@ -1151,7 +1298,7 @@
         }
 
         /* Create the symbolic link */
-        DPRINT1("Creating symlink for %wZ to %wZ\n", &RegEntry->Name, &RegEntry->Value);
+        DPRINT("Creating symlink for %wZ to %wZ\n", &RegEntry->Name, &RegEntry->Value);
         Status = NtCreateSymbolicLinkObject(&DirHandle,
                                             SYMBOLIC_LINK_ALL_ACCESS,
                                             &ObjectAttributes,
@@ -1357,7 +1504,7 @@
     {
         /* Get the entry and skip it if it's in the exluded list */
         RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
-        DPRINT1("Processing known DLL: %wZ-%wZ\n", &RegEntry->Name, &RegEntry->Value);
+        DPRINT("Processing known DLL: %wZ-%wZ\n", &RegEntry->Name, &RegEntry->Value);
         if ((SmpFindRegistryValue(&SmpExcludeKnownDllsList,
                                   RegEntry->Name.Buffer)) ||
             (SmpFindRegistryValue(&SmpExcludeKnownDllsList,
@@ -1388,6 +1535,8 @@
                                                &ImageCharacteristics);
         if (!NT_SUCCESS(Status))
         {
+            DPRINT1("Hey ReactOS -- you suck! Please fix the checksum (or the API) behind: %wZ\n", &RegEntry->Value);
+            #if 0
             /* Checksum failed, so don't even try going further -- kill SMSS */
             RtlInitUnicodeString(&ErrorResponse,
                                  L"Verification of a KnownDLL failed.");
@@ -1395,6 +1544,7 @@
             ErrorParameters[1] = Status;
             ErrorParameters[2] = (ULONG)&RegEntry->Value;
             SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
+            #endif
         }
         else if (!(ImageCharacteristics & IMAGE_FILE_DLL))
         {
@@ -1559,7 +1709,7 @@
 
     /* First let's write the OS variable */
     RtlInitUnicodeString(&ValueName, L"OS");
-    DPRINT1("Setting %wZ to %S\n", &ValueName, L"Windows_NT");
+    DPRINT("Setting %wZ to %S\n", &ValueName, L"Windows_NT");
     Status = NtSetValueKey(KeyHandle,
                            &ValueName,
                            0,
@@ -1597,7 +1747,7 @@
     }
 
     /* Set it */
-    DPRINT1("Setting %wZ to %S\n", &ValueName, ArchName);
+    DPRINT("Setting %wZ to %S\n", &ValueName, ArchName);
     Status = NtSetValueKey(KeyHandle,
                            &ValueName,
                            0,
@@ -1615,7 +1765,7 @@
     /* And now let's write the processor level */
     RtlInitUnicodeString(&ValueName, L"PROCESSOR_LEVEL");
     swprintf(ValueBuffer, L"%u", ProcessorInfo.ProcessorLevel);
-    DPRINT1("Setting %wZ to %S\n", &ValueName, ValueBuffer);
+    DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
     Status = NtSetValueKey(KeyHandle,
                            &ValueName,
                            0,
@@ -1683,7 +1833,7 @@
 
     /* So that we can set this as the PROCESSOR_IDENTIFIER variable */
     RtlInitUnicodeString(&ValueName, L"PROCESSOR_IDENTIFIER");
-    DPRINT1("Setting %wZ to %S\n", &ValueName, PartialInfo->Data);
+    DPRINT("Setting %wZ to %S\n", &ValueName, PartialInfo->Data);
     Status = NtSetValueKey(KeyHandle,
                            &ValueName,
                            0,
@@ -1725,7 +1875,7 @@
     }
 
     /* Write the revision to the registry */
-    DPRINT1("Setting %wZ to %S\n", &ValueName, ValueBuffer);
+    DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
     Status = NtSetValueKey(KeyHandle,
                            &ValueName,
                            0,
@@ -1743,7 +1893,7 @@
     /* And finally, write the number of CPUs */
     RtlInitUnicodeString(&ValueName, L"NUMBER_OF_PROCESSORS");
     swprintf(ValueBuffer, L"%u", BasicInfo.NumberOfProcessors);
-    DPRINT1("Setting %wZ to %S\n", &ValueName, ValueBuffer);
+    DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
     Status = NtSetValueKey(KeyHandle,
                            &ValueName,
                            0,
@@ -1797,7 +1947,7 @@
             }
 
             /* And write it in the environment! */
-            DPRINT1("Setting %wZ to %S\n", &ValueName, ValueBuffer);
+            DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
             Status = NtSetValueKey(KeyHandle,
                                    &ValueName,
                                    0,

Modified: trunk/reactos/base/system/smss2/smss.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss2/smss.c?rev=55467&r1=55466&r2=55467&view=diff
==============================================================================
--- trunk/reactos/base/system/smss2/smss.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss2/smss.c [iso-8859-1] Mon Feb  6 18:57:18 2012
@@ -627,7 +627,7 @@
         Status = SmpInit(&InitialCommand, Handles);
         if (!NT_SUCCESS(Status))
         {
-            DPRINT1("SMSS: SmpInit return failure - Status == %x\n");
+            DPRINT1("SMSS: SmpInit return failure - Status == %x\n", Status);
             RtlInitUnicodeString(&DbgString, L"Session Manager Initialization");
             Parameters[1] = Status;
             //_SEH2_LEAVE; Hack so that setup can work. will go away later

Modified: trunk/reactos/base/system/smss2/smss.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss2/smss.h?rev=55467&r1=55466&r2=55467&view=diff
==============================================================================
--- trunk/reactos/base/system/smss2/smss.h [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss2/smss.h [iso-8859-1] Mon Feb  6 18:57:18 2012
@@ -36,6 +36,16 @@
 #define SMP_SUBSYSTEM_FLAG  0x08
 #define SMP_INVALID_PATH    0x10
 #define SMP_DEFERRED_FLAG   0x20
+
+/* STRUCTURES *****************************************************************/
+
+typedef struct _SMP_REGISTRY_VALUE
+{
+    LIST_ENTRY Entry;
+    UNICODE_STRING Name;
+    UNICODE_STRING Value;
+    PCHAR AnsiValue;
+} SMP_REGISTRY_VALUE, *PSMP_REGISTRY_VALUE;
 
 /* EXTERNALS ******************************************************************/
 
@@ -56,6 +66,11 @@
 extern UNICODE_STRING SmpSystemRoot;
 extern PWCHAR SmpDefaultEnvironment;
 extern UNICODE_STRING SmpDefaultLibPath;
+extern LIST_ENTRY SmpSetupExecuteList;
+extern LIST_ENTRY SmpSubSystemsToLoad;
+extern LIST_ENTRY SmpExecuteList;
+extern LIST_ENTRY SmpSubSystemList;
+extern ULONG AttachedSessionId;
 
 /* FUNCTIONS ******************************************************************/
 
@@ -187,4 +202,8 @@
     IN PUNICODE_STRING FileName
 );
 
-
+VOID
+NTAPI
+SmpTranslateSystemPartitionInformation(
+    VOID
+    );

Modified: trunk/reactos/base/system/smss2/smsubsys.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss2/smsubsys.c?rev=55467&r1=55466&r2=55467&view=diff
==============================================================================
--- trunk/reactos/base/system/smss2/smsubsys.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss2/smsubsys.c [iso-8859-1] Mon Feb  6 18:57:18 2012
@@ -19,6 +19,7 @@
 HANDLE SmpWindowsSubSysProcess;
 HANDLE SmpWindowsSubSysProcessId;
 BOOLEAN RegPosixSingleInstance;
+WCHAR InitialCommandBuffer[256];
 
 /* FUNCTIONS ******************************************************************/
 
@@ -31,7 +32,7 @@
                  OUT PHANDLE ProcessId)
 {
     DPRINT1("Should start subsystem %wZ for Session: %lx\n", FileName, MuSessionId);
-    return STATUS_SUCCESS; 
+    return STATUS_SUCCESS;
 }
 
 NTSTATUS
@@ -40,7 +41,169 @@
                               OUT PHANDLE ProcessId,
                               IN PUNICODE_STRING InitialCommand)
 {
-    DPRINT1("Should start subsystems for Session: %lx\n", *MuSessionId);
-    return STATUS_SUCCESS;
+    NTSTATUS Status = STATUS_SUCCESS, Status2;
+    PSMP_REGISTRY_VALUE RegEntry;
+    UNICODE_STRING DestinationString, NtPath;
+    PLIST_ENTRY NextEntry;
+    LARGE_INTEGER Timeout;
+    PVOID State;
+
+    /* Write a few last registry keys with the boot partition information */
+    SmpTranslateSystemPartitionInformation();
+
+    /* Process "SetupExecute" values */
+    NextEntry = SmpSetupExecuteList.Flink;
+    while (NextEntry != &SmpSetupExecuteList)
+    {
+        /* Execute each one and move on */
+        RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+        DPRINT1("SetupExecute entry: %wZ\n", &RegEntry->Name);
+        SmpExecuteCommand(&RegEntry->Name, 0, NULL, 0);
+        NextEntry = NextEntry->Flink;
+    }
+
+    /* Now process the subsystems */
+    NextEntry = SmpSubSystemList.Flink;
+    while (NextEntry != &SmpSubSystemList)
+    {
+        /* Get the entry and check if this is the special Win32k entry */
+        RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+        DPRINT1("Subsystem: %wZ\n", &RegEntry->Name);
+        if (!_wcsicmp(RegEntry->Name.Buffer, L"Kmode"))
+        {
+            /* Translate it */
+            if (!RtlDosPathNameToNtPathName_U(RegEntry->Value.Buffer,
+                                              &NtPath,
+                                              NULL,
+                                              NULL))
+            {
+                Status = STATUS_OBJECT_PATH_SYNTAX_BAD;
+                DPRINT1("Failed: %lx\n", Status);
+            }
+            else
+            {
+                /* Get the driver privilege */
+                Status = SmpAcquirePrivilege(SE_LOAD_DRIVER_PRIVILEGE, &State);
+                if (NT_SUCCESS(Status))
+                {
+                    /* Create the new session */
+                    ASSERT(AttachedSessionId == -1);
+                    Status = NtSetSystemInformation(SystemSessionCreate,
+                                                    MuSessionId,
+                                                    sizeof(*MuSessionId));
+                    if (!NT_SUCCESS(Status))
+                    {
+                        DPRINT1("SMSS: Session space creation failed\n");
+                        SmpReleasePrivilege(State);
+                        RtlFreeHeap(RtlGetProcessHeap(), 0, NtPath.Buffer);
+                        return Status;
+                    }
+                    AttachedSessionId = *MuSessionId;
+
+                    /* Start Win32k.sys on this session */
+                    DPRINT1("Starting win32k.sys...\n");
+                    RtlInitUnicodeString(&DestinationString,
+                                         L"\\SystemRoot\\System32\\win32k.sys");
+                    Status = NtSetSystemInformation(SystemExtendServiceTableInformation,
+                                                    &DestinationString,
+                                                    sizeof(DestinationString));
+                    RtlFreeHeap(RtlGetProcessHeap(), 0, NtPath.Buffer);
+                    SmpReleasePrivilege(State);
+                    if (!NT_SUCCESS(Status))
+                    {
+                        DPRINT1("SMSS: Load of WIN32K failed.\n");
+                        return Status;
+                    }
+                }
+            }
+        }
+
+        /* Next entry */
+        NextEntry = NextEntry->Flink;
+    }
+
+    /* Now parse the required subsystem list */
+    NextEntry = SmpSubSystemsToLoad.Flink;
+    while (NextEntry != &SmpSubSystemsToLoad)
+    {
+        /* Get each entry and check if it's the internal debug or not */
+        RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+        DPRINT1("Subsystem (required): %wZ\n", &RegEntry->Name);
+        if (_wcsicmp(RegEntry->Name.Buffer, L"debug"))
+        {
+            /* Load the required subsystem */
+            Status = SmpExecuteCommand(&RegEntry->Value,
+                                       *MuSessionId,
+                                       ProcessId,
+                                       SMP_SUBSYSTEM_FLAG);
+        }
+        else
+        {
+            /* Load the internal debug system */
+            Status = SmpExecuteCommand(&RegEntry->Value,
+                                       *MuSessionId,
+                                       ProcessId,
+                                       SMP_DEBUG_FLAG | SMP_SUBSYSTEM_FLAG);
+        }
+        if (!NT_SUCCESS(Status))
+        {
+            DbgPrint("SMSS: Subsystem execute failed (%WZ)\n", &RegEntry->Value);
+            return Status;
+        }
+
+        /* Move to the next entry */
+        NextEntry = NextEntry->Flink;
+    }
+
+    /* Process the "Execute" list now */
+    NextEntry = SmpExecuteList.Blink;
+    if (NextEntry != &SmpExecuteList)
+    {
+        /* Get the custom initial command */
+        RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+        DPRINT1("Initial command found: %wZ\n", &RegEntry->Name);
+
+        /* Write the initial command and wait for 5 seconds (why??!) */
+        *InitialCommand = RegEntry->Name;
+        Timeout.QuadPart = -50000000;
+        NtDelayExecution(FALSE, &Timeout);
+    }
+    else
+    {
+        /* Use the default Winlogon initial command */
+        RtlInitUnicodeString(InitialCommand, L"winlogon.exe");
+        InitialCommandBuffer[0] = UNICODE_NULL;
+        DPRINT1("Initial command found: %wZ\n", InitialCommand);
+
+        /* Check if there's a debugger for Winlogon */
+        Status2 = LdrQueryImageFileExecutionOptions(InitialCommand,
+                                                    L"Debugger",
+                                                    REG_SZ,
+                                                    InitialCommandBuffer,
+                                                    sizeof(InitialCommandBuffer) -
+                                                    InitialCommand->Length,
+                                                    NULL);
+        if ((NT_SUCCESS(Status2)) && (InitialCommandBuffer[0]))
+        {
+            /* Put the debugger string with the Winlogon string */
+            wcscat(InitialCommandBuffer, L" ");
+            wcscat(InitialCommandBuffer, InitialCommand->Buffer);
+            RtlInitUnicodeString(InitialCommand, InitialCommandBuffer);
+        }
+    }
+
+    /* Finally check if there was a custom initial command */
+    NextEntry = SmpExecuteList.Flink;
+    while (NextEntry != &SmpExecuteList)
+    {
+        /* Execute each one */
+        RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
+        DPRINT1("Initial command (custom): %wZ\n", &RegEntry->Name);
+        SmpExecuteCommand(&RegEntry->Name, *MuSessionId, NULL, 0);
+        NextEntry = NextEntry->Flink;
+    }
+
+    /* Return status */
+    return Status;
 }
 

Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csrsrv/init.c?rev=55467&r1=55466&r2=55467&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Mon Feb  6 18:57:18 2012
@@ -598,6 +598,7 @@
 	return Status;
 }
 
+#if 0
 /**********************************************************************
  * 	CsrpLoadKernelModeDriver/3
  */
@@ -641,6 +642,7 @@
 	}
 	return Status;
 }
+#endif
 
 /**********************************************************************
  * CsrpCreateApiPort/2
@@ -753,7 +755,7 @@
 	{TRUE, CsrpCreateApiPort,        "create the api port \\Windows\\ApiPort"},
     {TRUE, CsrpCreateHardErrorPort,  "create the hard error port"},
 	{TRUE, CsrpCreateObjectDirectory,"create the object directory \\Windows"},
-	{TRUE, CsrpLoadKernelModeDriver, "load Kmode driver"},
+//	{TRUE, CsrpLoadKernelModeDriver, "load Kmode driver"},
 	{TRUE, CsrpInitVideo,            "initialize video"},
 	{TRUE, CsrpApiRegisterDef,       "initialize api definitions"},
 	{TRUE, CsrpCCTS,                 "connect client to server"},




More information about the Ros-diffs mailing list