/* NT Boot Path */
UNICODE_STRING NtSystemRoot;
-/* NT Initial User Application */
-WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss.exe";
-ULONG NtInitialUserProcessBufferLength = sizeof(NtInitialUserProcessBuffer) -
- sizeof(WCHAR);
-ULONG NtInitialUserProcessBufferType = REG_SZ;
-
/* Boot NLS information */
PVOID ExpNlsTableBase;
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
&LinkName,
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
NULL,
- SePublicDefaultUnrestrictedSd);
+ SePublicDefaultSd);
/* Create it */
Status = NtCreateDirectoryObject(&LinkHandle,
&LinkName,
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
NULL,
- SePublicDefaultUnrestrictedSd);
+ SePublicDefaultSd);
/* Create it */
Status = NtCreateDirectoryObject(&LinkHandle,
&LinkName,
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
NULL,
- SePublicDefaultUnrestrictedSd);
+ SePublicDefaultSd);
/* Build the ARC name */
sprintf(Buffer,
PWSTR p;
UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
UNICODE_STRING SmssName, Environment, SystemDriveString;
- PVOID EnvironmentPtr = NULL;
/* Allocate memory for the process parameters */
Size = sizeof(RTL_USER_PROCESS_PARAMETERS) +
- ((MAX_PATH * 6) * sizeof(WCHAR));
+ ((MAX_PATH * 4) * sizeof(WCHAR));
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
(PVOID)&ProcessParameters,
0,
/* Allocate a page for the environment */
Size = PAGE_SIZE;
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
- &EnvironmentPtr,
+ (PVOID)&ProcessParameters->Environment,
0,
&Size,
MEM_COMMIT,
KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
- /* Write the pointer */
- ProcessParameters->Environment = EnvironmentPtr;
-
/* Make a buffer for the DOS path */
p = (PWSTR)(ProcessParameters + 1);
ProcessParameters->CurrentDirectory.DosPath.Buffer = p;
ProcessParameters->ImagePathName.Buffer = p;
ProcessParameters->ImagePathName.MaximumLength = MAX_PATH * sizeof(WCHAR);
- /* Make sure the buffer is a valid string which within the given length */
- if ((NtInitialUserProcessBufferType != REG_SZ) ||
- ((NtInitialUserProcessBufferLength != -1) &&
- ((NtInitialUserProcessBufferLength < sizeof(WCHAR)) ||
- (NtInitialUserProcessBufferLength >
- sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
- {
- /* Invalid initial process string, bugcheck */
- KeBugCheckEx(SESSION2_INITIALIZATION_FAILED,
- (ULONG_PTR)STATUS_INVALID_PARAMETER,
- NtInitialUserProcessBufferType,
- NtInitialUserProcessBufferLength,
- sizeof(NtInitialUserProcessBuffer));
- }
-
- /* Cut out anything after a space */
- p = NtInitialUserProcessBuffer;
- while (*p && *p != L' ') p++;
-
- /* Set the image path length */
- ProcessParameters->ImagePathName.Length =
- (USHORT)((PCHAR)p - (PCHAR)NtInitialUserProcessBuffer);
-
- /* Copy the actual buffer */
- RtlCopyMemory(ProcessParameters->ImagePathName.Buffer,
- NtInitialUserProcessBuffer,
- ProcessParameters->ImagePathName.Length);
-
- /* Null-terminate it */
- ProcessParameters->
- ImagePathName.Buffer[ProcessParameters->ImagePathName.Length /
- sizeof(WCHAR)] = UNICODE_NULL;
-
- /* Make a buffer for the command line */
- p = (PWSTR)((PCHAR)ProcessParameters->ImagePathName.Buffer +
- ProcessParameters->ImagePathName.MaximumLength);
- ProcessParameters->CommandLine.Buffer = p;
- ProcessParameters->CommandLine.MaximumLength = MAX_PATH * sizeof(WCHAR);
-
- /* Add the image name to the command line */
- RtlAppendUnicodeToString(&ProcessParameters->CommandLine,
- NtInitialUserProcessBuffer);
+ /* Append the system path and session manager name */
+ RtlAppendUnicodeToString(&ProcessParameters->ImagePathName,
+ L"\\SystemRoot\\System32");
+ RtlAppendUnicodeToString(&ProcessParameters->ImagePathName,
+ L"\\smss.exe");
/* Create the environment string */
RtlInitEmptyUnicodeString(&Environment,
RtlAppendUnicodeStringToString(&Environment, &NtSystemRoot);
RtlAppendUnicodeStringToString(&Environment, &NullString);
- /* Create SMSS process */
+ /* Get and set the command line equal to the image path */
+ ProcessParameters->CommandLine = ProcessParameters->ImagePathName;
SmssName = ProcessParameters->ImagePathName;
+
+ /* Create SMSS process */
Status = RtlCreateUserProcess(&SmssName,
OBJ_CASE_INSENSITIVE,
RtlDeNormalizeProcessParams(
Buffer[--AnsiPath.Length] = ANSI_NULL;
/* Get the string from KUSER_SHARED_DATA's buffer */
- RtlInitEmptyUnicodeString(&NtSystemRoot,
- SharedUserData->NtSystemRoot,
- sizeof(SharedUserData->NtSystemRoot));
+ NtSystemRoot.Buffer = SharedUserData->NtSystemRoot;
+ NtSystemRoot.MaximumLength = sizeof(SharedUserData->NtSystemRoot) / sizeof(WCHAR);
+ NtSystemRoot.Length = 0;
/* Now fill it in */
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
/* Bugcheck the system if SMSS couldn't initialize */
KeBugCheck(SESSION5_INITIALIZATION_FAILED);
}
+ else
+ {
+ /* Close process handles */
+ ZwClose(ThreadHandle);
+ ZwClose(ProcessHandle);
- /* Close process handles */
- ZwClose(ThreadHandle);
- ZwClose(ProcessHandle);
-
- /* FIXME: We should free the initial process' memory!*/
+ /* FIXME: We should free the initial process' memory!*/
- /* Increase init phase */
- ExpInitializationPhase += 1;
+ /* Increase init phase */
+ ExpInitializationPhase += 1;
- /* Jump into zero page thread */
- MmZeroPageThreadMain(NULL);
+ /* Jump into zero page thread */
+ MmZeroPageThreadMain(NULL);
+ }
}
/* EOF */