|
|
Definition at line 45 of file ppb.c.
{
PRTL_USER_PROCESS_PARAMETERS Param = NULL;
ULONG Length = 0;
PWCHAR Dest;
UNICODE_STRING EmptyString;
HANDLE CurrentDirectoryHandle;
HANDLE ConsoleHandle;
ULONG ConsoleFlags;
DPRINT ("RtlCreateProcessParameters\n");
RtlAcquirePebLock();
EmptyString.Length = 0;
EmptyString.MaximumLength = sizeof(WCHAR);
EmptyString.Buffer = L"";
if (RtlpGetMode() == UserMode)
{
if (DllPath == NULL)
DllPath = &NtCurrentPeb()->ProcessParameters->DllPath;
if (Environment == NULL)
Environment = NtCurrentPeb()->ProcessParameters->Environment;
if (CurrentDirectory == NULL)
CurrentDirectory = &NtCurrentPeb()->ProcessParameters->CurrentDirectory.DosPath;
CurrentDirectoryHandle = NtCurrentPeb()->ProcessParameters->CurrentDirectory.Handle;
ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
ConsoleFlags = NtCurrentPeb()->ProcessParameters->ConsoleFlags;
}
else
{
if (DllPath == NULL)
DllPath = &EmptyString;
if (CurrentDirectory == NULL)
CurrentDirectory = &EmptyString;
CurrentDirectoryHandle = NULL;
ConsoleHandle = NULL;
ConsoleFlags = 0;
}
if (CommandLine == NULL)
CommandLine = &EmptyString;
if (WindowTitle == NULL)
WindowTitle = &EmptyString;
if (DesktopInfo == NULL)
DesktopInfo = &EmptyString;
if (ShellInfo == NULL)
ShellInfo = &EmptyString;
if (RuntimeData == NULL)
RuntimeData = &EmptyString;
Length = sizeof(RTL_USER_PROCESS_PARAMETERS);
Length += (MAX_PATH * sizeof(WCHAR));
Length += ALIGN(DllPath->MaximumLength, sizeof(ULONG));
Length += ALIGN(ImagePathName->Length + sizeof(WCHAR), sizeof(ULONG));
Length += ALIGN(CommandLine->Length + sizeof(WCHAR), sizeof(ULONG));
Length += ALIGN(WindowTitle->MaximumLength, sizeof(ULONG));
Length += ALIGN(DesktopInfo->MaximumLength, sizeof(ULONG));
Length += ALIGN(ShellInfo->MaximumLength, sizeof(ULONG));
Length += ALIGN(RuntimeData->MaximumLength, sizeof(ULONG));
Param = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Length);
if (!Param)
{
RtlReleasePebLock();
return STATUS_INSUFFICIENT_RESOURCES;
}
DPRINT ("Process parameters allocated\n");
Param->MaximumLength = Length;
Param->Length = Length;
Param->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED;
Param->Environment = Environment;
Param->CurrentDirectory.Handle = CurrentDirectoryHandle;
Param->ConsoleHandle = ConsoleHandle;
Param->ConsoleFlags = ConsoleFlags;
Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS));
RtlpCopyParameterString(&Dest,
&Param->CurrentDirectory.DosPath,
CurrentDirectory,
MAX_PATH * sizeof(WCHAR));
if (Param->CurrentDirectory.DosPath.Length > 0)
{
ULONG Length;
Length = Param->CurrentDirectory.DosPath.Length / sizeof(WCHAR);
if (Param->CurrentDirectory.DosPath.Buffer[Length-1] != L'\\')
{
Param->CurrentDirectory.DosPath.Buffer[Length] = L'\\';
Param->CurrentDirectory.DosPath.Buffer[Length + 1] = 0;
Param->CurrentDirectory.DosPath.Length += sizeof(WCHAR);
}
}
RtlpCopyParameterString(&Dest,
&Param->DllPath,
DllPath,
0);
RtlpCopyParameterString(&Dest,
&Param->ImagePathName,
ImagePathName,
ImagePathName->Length + sizeof(WCHAR));
RtlpCopyParameterString(&Dest,
&Param->CommandLine,
CommandLine,
CommandLine->Length + sizeof(WCHAR));
RtlpCopyParameterString(&Dest,
&Param->WindowTitle,
WindowTitle,
0);
RtlpCopyParameterString(&Dest,
&Param->DesktopInfo,
DesktopInfo,
0);
RtlpCopyParameterString(&Dest,
&Param->ShellInfo,
ShellInfo,
0);
RtlpCopyParameterString(&Dest,
&Param->RuntimeData,
RuntimeData,
0);
RtlDeNormalizeProcessParams(Param);
*ProcessParameters = Param;
RtlReleasePebLock();
return STATUS_SUCCESS;
}
|