From 524f08e959c8123cee0a5c8d990e365fb3bb7d27 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 6 Feb 2012 18:57:18 +0000 Subject: [PATCH] [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. svn path=/trunk/; revision=55467 --- reactos/base/system/smss2/sminit.c | 204 ++++++++++++++++--- reactos/base/system/smss2/smss.c | 2 +- reactos/base/system/smss2/smss.h | 21 +- reactos/base/system/smss2/smsubsys.c | 169 ++++++++++++++- reactos/subsystems/win32/csrss/csrsrv/init.c | 4 +- 5 files changed, 367 insertions(+), 33 deletions(-) diff --git a/reactos/base/system/smss2/sminit.c b/reactos/base/system/smss2/sminit.c index c07bfc936a2..d05a84ce3de 100644 --- a/reactos/base/system/smss2/sminit.c +++ b/reactos/base/system/smss2/sminit.c @@ -14,14 +14,6 @@ /* 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; LIST_ENTRY SmpDosDevicesList, SmpFileRenameList, SmpKnownDllsList; @@ -244,7 +236,7 @@ SmpConfigureProtectionMode(IN PWSTR ValueName, /* 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 @@ SmpConfigureAllowProtectedRenames(IN PWSTR ValueName, SmpAllowProtectedRenames = 0; } - DPRINT1("SmpAllowProtectedRenames: %d\n", SmpAllowProtectedRenames); + DPRINT("SmpAllowProtectedRenames: %d\n", SmpAllowProtectedRenames); return STATUS_SUCCESS; } @@ -315,7 +307,7 @@ SmpConfigureObjectDirectories(IN PWSTR ValueName, 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 @@ SmpConfigureExcludeKnownDlls(IN PWSTR ValueName, 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 @@ SmpConfigureKnownDlls(IN PWSTR ValueName, } /* 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 @@ SmpConfigureEnvironment(IN PWSTR ValueName, /* 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 @@ SmpConfigureSubSystems(IN PWSTR ValueName, (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 @@ SmpConfigureSubSystems(IN PWSTR ValueName, 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 @@ SmpConfigureSubSystems(IN PWSTR ValueName, 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); } } @@ -796,6 +788,161 @@ SmpRegistryConfigurationTable[] = /* 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 SmpCreateSecurityDescriptors(IN BOOLEAN InitialCall) @@ -1151,7 +1298,7 @@ SmpInitializeDosDevices(VOID) } /* 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 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory, { /* 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 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory, &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 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory, 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) /* 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) } /* 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) /* 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) /* 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) } /* 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) /* 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 @@ SmpCreateDynamicEnvironmentVariables(VOID) } /* 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, diff --git a/reactos/base/system/smss2/smss.c b/reactos/base/system/smss2/smss.c index 5bc5b91a8a1..bfcd52f9418 100644 --- a/reactos/base/system/smss2/smss.c +++ b/reactos/base/system/smss2/smss.c @@ -627,7 +627,7 @@ _main(IN INT argc, 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 diff --git a/reactos/base/system/smss2/smss.h b/reactos/base/system/smss2/smss.h index d2e9604a841..b5117356b5f 100644 --- a/reactos/base/system/smss2/smss.h +++ b/reactos/base/system/smss2/smss.h @@ -37,6 +37,16 @@ #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 ******************************************************************/ extern RTL_CRITICAL_SECTION SmpKnownSubSysLock; @@ -56,6 +66,11 @@ extern ULONG SmBaseTag; 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 @@ SmpCheckForCrashDump( IN PUNICODE_STRING FileName ); - +VOID +NTAPI +SmpTranslateSystemPartitionInformation( + VOID + ); diff --git a/reactos/base/system/smss2/smsubsys.c b/reactos/base/system/smss2/smsubsys.c index 01c637434c5..16c407a5f6d 100644 --- a/reactos/base/system/smss2/smsubsys.c +++ b/reactos/base/system/smss2/smsubsys.c @@ -19,6 +19,7 @@ LIST_ENTRY SmpKnownSubSysHead; HANDLE SmpWindowsSubSysProcess; HANDLE SmpWindowsSubSysProcessId; BOOLEAN RegPosixSingleInstance; +WCHAR InitialCommandBuffer[256]; /* FUNCTIONS ******************************************************************/ @@ -31,7 +32,7 @@ SmpLoadSubSystem(IN PUNICODE_STRING FileName, 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 @@ SmpLoadSubSystemsForMuSession(IN PULONG MuSessionId, 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; } diff --git a/reactos/subsystems/win32/csrss/csrsrv/init.c b/reactos/subsystems/win32/csrss/csrsrv/init.c index e0b1a99c094..fde310f4f25 100644 --- a/reactos/subsystems/win32/csrss/csrsrv/init.c +++ b/reactos/subsystems/win32/csrss/csrsrv/init.c @@ -598,6 +598,7 @@ CsrpRegisterSubsystem (int argc, char ** argv, char ** envp) return Status; } +#if 0 /********************************************************************** * CsrpLoadKernelModeDriver/3 */ @@ -641,6 +642,7 @@ CsrpLoadKernelModeDriver (int argc, char ** argv, char ** envp) } return Status; } +#endif /********************************************************************** * CsrpCreateApiPort/2 @@ -753,7 +755,7 @@ struct { {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"},