From 66f91ccbf96f6aad99c5fd1a7730393e6a0e5127 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 28 Dec 2000 20:38:28 +0000 Subject: [PATCH] Fixed some undocumented functions and types svn path=/trunk/; revision=1483 --- reactos/Makefile | 2 +- reactos/include/ddk/rtl.h | 6 +- reactos/include/napi/teb.h | 7 +- reactos/include/ntdll/rtl.h | 113 ++++----- reactos/lib/kernel32/process/proc.c | 24 +- reactos/lib/ntdll/rtl/env.c | 96 +++----- reactos/lib/ntdll/rtl/ppb.c | 356 ++++++++++++++-------------- reactos/lib/ntdll/rtl/process.c | 91 ++++--- reactos/lib/ntdll/rtl/thread.c | 33 ++- reactos/ntoskrnl/ps/create.c | 4 +- reactos/subsys/smss/init.c | 24 +- 11 files changed, 357 insertions(+), 399 deletions(-) diff --git a/reactos/Makefile b/reactos/Makefile index 3a272168057..e841585dfc7 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -54,7 +54,7 @@ NET_DEVICE_DRIVERS = ne2000 SYS_APPS = shell winlogon services APPS = args hello test cat bench apc shm lpc thread event file gditest \ - pteb consume dump_shared_data vmtest regtest ptest + pteb consume dump_shared_data vmtest regtest # objdir diff --git a/reactos/include/ddk/rtl.h b/reactos/include/ddk/rtl.h index 80bce68e503..ed555bac972 100644 --- a/reactos/include/ddk/rtl.h +++ b/reactos/include/ddk/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.44 2000/11/20 19:59:07 ekohl Exp $ +/* $Id: rtl.h,v 1.45 2000/12/28 20:38:26 ekohl Exp $ * */ @@ -16,13 +16,13 @@ typedef struct _INITIAL_TEB PVOID StackLimit; PVOID StackCommit; PVOID StackCommitMax; - PVOID StackReserved; + PVOID StackReserve; } INITIAL_TEB, *PINITIAL_TEB; typedef struct _CONTROLLER_OBJECT { CSHORT Type; - CSHORT Size; + CSHORT Size; PVOID ControllerExtension; KDEVICE_QUEUE DeviceWaitQueue; ULONG Spare1; diff --git a/reactos/include/napi/teb.h b/reactos/include/napi/teb.h index 677b4658336..0d2b65044d3 100644 --- a/reactos/include/napi/teb.h +++ b/reactos/include/napi/teb.h @@ -48,7 +48,7 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS UNICODE_STRING DllPath; // 30h UNICODE_STRING ImagePathName; // 38h UNICODE_STRING CommandLine; // 40h - PVOID Environment; // 48h + PWSTR Environment; // 48h ULONG StartingX; // 4Ch ULONG StartingY; // 50h ULONG CountX; // 54h @@ -61,7 +61,7 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS UNICODE_STRING WindowTitle; // 70h UNICODE_STRING DesktopInfo; // 78h UNICODE_STRING ShellInfo; // 80h - UNICODE_STRING RuntimeData; // 88h + UNICODE_STRING RuntimeInfo; // 88h RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20]; // 90h } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; @@ -214,12 +214,11 @@ typedef struct _NT_TEB PVOID StackCommit; // F88h PVOID StackCommitMax; // F8Ch - PVOID StackReserved; // F90h + PVOID StackReserve; // F90h } NT_TEB, *PNT_TEB; #define PEB_STARTUPINFO (0xb0003000) -//#define NtCurrentPeb() ((PPEB)PEB_BASE) #define NtCurrentPeb() (NtCurrentTeb()->Peb) static inline PNT_TEB NtCurrentTeb(VOID) diff --git a/reactos/include/ntdll/rtl.h b/reactos/include/ntdll/rtl.h index 035b23b4c1a..7177a3fc192 100644 --- a/reactos/include/ntdll/rtl.h +++ b/reactos/include/ntdll/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.19 2000/08/15 12:37:46 ekohl Exp $ +/* $Id: rtl.h,v 1.20 2000/12/28 20:38:27 ekohl Exp $ * */ @@ -28,24 +28,34 @@ typedef struct _CRITICAL_SECTION { } CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION; -/* - * Preliminary data type!! - * - * This definition is not finished yet. It will change in the future. - */ -typedef struct _RTL_USER_PROCESS_INFO +typedef struct _SECTION_IMAGE_INFORMATION { - ULONG Unknown1; // 0x00 - HANDLE ProcessHandle; // 0x04 - HANDLE ThreadHandle; // 0x08 - CLIENT_ID ClientId; // 0x0C - ULONG Unknown5; // 0x14 - LONG StackZeroBits; // 0x18 - LONG StackReserved; // 0x1C - LONG StackCommit; // 0x20 - ULONG Unknown9; // 0x24 -// more data ... ??? -} RTL_USER_PROCESS_INFO, *PRTL_USER_PROCESS_INFO; + PVOID ProcessEntryPoint; + ULONG StackZero; + ULONG StackReserve; + ULONG StackCommit; + ULONG SubsystemType; + USHORT MinorImageVersion; + USHORT MajorImageVersion; + ULONG u4; + ULONG Characteristics; + USHORT Machine; + BOOLEAN Executable; + USHORT u6; + ULONG u7; + ULONG u8; + ULONG u9; +}SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION; + + +typedef struct _RTL_PROCESS_INFO +{ + ULONG Size; + HANDLE ProcessHandle; + HANDLE ThreadHandle; + CLIENT_ID ClientId; + SECTION_IMAGE_INFORMATION ImageInfo; +} RTL_PROCESS_INFO, *PRTL_PROCESS_INFO; @@ -207,19 +217,19 @@ NTSTATUS STDCALL RtlCreateEnvironment ( BOOLEAN Inherit, - PVOID *Environment + PWSTR *Environment ); VOID STDCALL RtlDestroyEnvironment ( - PVOID Environment + PWSTR Environment ); NTSTATUS STDCALL RtlExpandEnvironmentStrings_U ( - PVOID Environment, + PWSTR Environment, PUNICODE_STRING Source, PUNICODE_STRING Destination, PULONG Length @@ -228,7 +238,7 @@ RtlExpandEnvironmentStrings_U ( NTSTATUS STDCALL RtlQueryEnvironmentVariable_U ( - PVOID Environment, + PWSTR Environment, PUNICODE_STRING Name, PUNICODE_STRING Value ); @@ -236,14 +246,14 @@ RtlQueryEnvironmentVariable_U ( VOID STDCALL RtlSetCurrentEnvironment ( - PVOID NewEnvironment, - PVOID *OldEnvironment + PWSTR NewEnvironment, + PWSTR *OldEnvironment ); NTSTATUS STDCALL RtlSetEnvironmentVariable ( - PVOID *Environment, + PWSTR *Environment, PUNICODE_STRING Name, PUNICODE_STRING Value ); @@ -255,7 +265,7 @@ RtlCreateUserThread ( IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN BOOLEAN CreateSuspended, IN LONG StackZeroBits, - IN OUT PULONG StackReserved, + IN OUT PULONG StackReserve, IN OUT PULONG StackCommit, IN PTHREAD_START_ROUTINE StartAddress, IN PVOID Parameter, @@ -270,57 +280,52 @@ RtlFreeUserThreadStack ( IN HANDLE ThreadHandle ); -/* - * Preliminary prototype!! - * - * This prototype is not finished yet. It will change in the future. - */ NTSTATUS STDCALL RtlCreateUserProcess ( - PUNICODE_STRING CommandLine, - ULONG Unknown2, - PRTL_USER_PROCESS_PARAMETERS ProcessParameters, // verified - PSECURITY_DESCRIPTOR ProcessSd, - PSECURITY_DESCRIPTOR ThreadSd, - BOOL bInheritHandles, - DWORD dwCreationFlags, - ULONG Unknown8, - ULONG Unknown9, - PRTL_USER_PROCESS_INFO ProcessInfo // verified + IN PUNICODE_STRING ImageFileName, + IN ULONG Attributes, + IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters, + IN PSECURITY_DESCRIPTOR ProcessSecutityDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor OPTIONAL, + IN HANDLE ParentProcess OPTIONAL, + IN BOOLEAN CurrentDirectory, + IN HANDLE DebugPort OPTIONAL, + IN HANDLE ExceptionPort OPTIONAL, + OUT PRTL_PROCESS_INFO ProcessInfo ); NTSTATUS STDCALL RtlCreateProcessParameters ( - IN OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, - IN PUNICODE_STRING CommandLine, - IN PUNICODE_STRING DllPath, - IN PUNICODE_STRING CurrentDirectory, - IN PUNICODE_STRING ImagePathName, - IN PVOID Environment, - IN PUNICODE_STRING WindowTitle, - IN PUNICODE_STRING DesktopInfo, - IN PUNICODE_STRING ShellInfo, - IN PUNICODE_STRING RuntimeData + OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, + IN PUNICODE_STRING ImagePathName OPTIONAL, + IN PUNICODE_STRING DllPath OPTIONAL, + IN PUNICODE_STRING CurrentDirectory OPTIONAL, + IN PUNICODE_STRING CommandLine OPTIONAL, + IN PWSTR Environment OPTIONAL, + IN PUNICODE_STRING WindowTitle OPTIONAL, + IN PUNICODE_STRING DesktopInfo OPTIONAL, + IN PUNICODE_STRING ShellInfo OPTIONAL, + IN PUNICODE_STRING RuntimeInfo OPTIONAL ); PRTL_USER_PROCESS_PARAMETERS STDCALL RtlDeNormalizeProcessParams ( - IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters + IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); VOID STDCALL RtlDestroyProcessParameters ( - IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters + IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); PRTL_USER_PROCESS_PARAMETERS STDCALL RtlNormalizeProcessParams ( - IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters + IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); NTSTATUS diff --git a/reactos/lib/kernel32/process/proc.c b/reactos/lib/kernel32/process/proc.c index a68307f8ffb..b770d65af5c 100644 --- a/reactos/lib/kernel32/process/proc.c +++ b/reactos/lib/kernel32/process/proc.c @@ -1,4 +1,4 @@ -/* $Id: proc.c,v 1.35 2000/09/05 13:52:30 ekohl Exp $ +/* $Id: proc.c,v 1.36 2000/12/28 20:38:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -306,11 +306,8 @@ SleepEx ( } -VOID -STDCALL -GetStartupInfoW ( - LPSTARTUPINFOW lpStartupInfo - ) +VOID STDCALL +GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo) { PRTL_USER_PROCESS_PARAMETERS Params; @@ -335,8 +332,8 @@ GetStartupInfoW ( lpStartupInfo->dwFlags = Params->Flags; lpStartupInfo->wShowWindow = Params->ShowWindowFlags; lpStartupInfo->lpReserved = Params->ShellInfo.Buffer; - lpStartupInfo->cbReserved2 = Params->RuntimeData.Length; - lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer; + lpStartupInfo->cbReserved2 = Params->RuntimeInfo.Length; + lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeInfo.Buffer; lpStartupInfo->hStdInput = Params->InputHandle; lpStartupInfo->hStdOutput = Params->OutputHandle; @@ -344,11 +341,8 @@ GetStartupInfoW ( } -VOID -STDCALL -GetStartupInfoA ( - LPSTARTUPINFOA lpStartupInfo - ) +VOID STDCALL +GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo) { PRTL_USER_PROCESS_PARAMETERS Params; ANSI_STRING AnsiString; @@ -399,8 +393,8 @@ GetStartupInfoA ( lpLocalStartupInfo->dwFillAttribute = Params->FillAttribute; lpLocalStartupInfo->dwFlags = Params->Flags; lpLocalStartupInfo->wShowWindow = Params->ShowWindowFlags; - lpLocalStartupInfo->cbReserved2 = Params->RuntimeData.Length; - lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer; + lpLocalStartupInfo->cbReserved2 = Params->RuntimeInfo.Length; + lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeInfo.Buffer; lpLocalStartupInfo->hStdInput = Params->InputHandle; lpLocalStartupInfo->hStdOutput = Params->OutputHandle; diff --git a/reactos/lib/ntdll/rtl/env.c b/reactos/lib/ntdll/rtl/env.c index 919ce37c544..664e1a3ee6d 100644 --- a/reactos/lib/ntdll/rtl/env.c +++ b/reactos/lib/ntdll/rtl/env.c @@ -1,4 +1,4 @@ -/* $Id: env.c,v 1.11 2000/08/05 18:01:52 dwelch Exp $ +/* $Id: env.c,v 1.12 2000/12/28 20:38:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -22,19 +22,16 @@ /* FUNCTIONS *****************************************************************/ -NTSTATUS -STDCALL -RtlCreateEnvironment ( - BOOLEAN Initialize, - PVOID *Environment - ) +NTSTATUS STDCALL +RtlCreateEnvironment(BOOLEAN Inherit, + PWSTR *Environment) { MEMORY_BASIC_INFORMATION MemInfo; PVOID EnvPtr = NULL; NTSTATUS Status = STATUS_SUCCESS; ULONG RegionSize = PAGESIZE; - if (Initialize == FALSE) + if (Inherit == TRUE) { RtlAcquirePebLock (); #if 0 @@ -95,30 +92,23 @@ RtlCreateEnvironment ( } -VOID -STDCALL -RtlDestroyEnvironment ( - PVOID Environment - ) +VOID STDCALL +RtlDestroyEnvironment(PWSTR Environment) { - ULONG Size = 0; + ULONG Size = 0; - NtFreeVirtualMemory (NtCurrentProcess (), - &Environment, - &Size, - MEM_RELEASE); + NtFreeVirtualMemory(NtCurrentProcess(), + (PVOID*)&Environment, + &Size, + MEM_RELEASE); } - -NTSTATUS -STDCALL -RtlExpandEnvironmentStrings_U ( - PVOID Environment, - PUNICODE_STRING Source, - PUNICODE_STRING Destination, - PULONG Length - ) +NTSTATUS STDCALL +RtlExpandEnvironmentStrings_U(PWSTR Environment, + PUNICODE_STRING Source, + PUNICODE_STRING Destination, + PULONG Length) { UNICODE_STRING var; UNICODE_STRING val; @@ -199,36 +189,31 @@ copy: } -VOID -STDCALL -RtlSetCurrentEnvironment ( - PVOID NewEnvironment, - PVOID *OldEnvironment - ) +VOID STDCALL +RtlSetCurrentEnvironment(PWSTR NewEnvironment, + PWSTR *OldEnvironment) { - PVOID EnvPtr; + PVOID EnvPtr; - DPRINT ("NewEnvironment %x OldEnvironment %x\n", - NewEnvironment, OldEnvironment); + DPRINT ("NewEnvironment %x OldEnvironment %x\n", + NewEnvironment, OldEnvironment); - RtlAcquirePebLock (); + RtlAcquirePebLock(); - EnvPtr = NtCurrentPeb()->ProcessParameters->Environment; - NtCurrentPeb()->ProcessParameters->Environment = NewEnvironment; + EnvPtr = NtCurrentPeb()->ProcessParameters->Environment; + NtCurrentPeb()->ProcessParameters->Environment = NewEnvironment; - if (OldEnvironment != NULL) - *OldEnvironment = EnvPtr; + if (OldEnvironment != NULL) + *OldEnvironment = EnvPtr; - RtlReleasePebLock (); + RtlReleasePebLock(); } -NTSTATUS -STDCALL -RtlSetEnvironmentVariable ( - PVOID *Environment, - PUNICODE_STRING Name, - PUNICODE_STRING Value) +NTSTATUS STDCALL +RtlSetEnvironmentVariable(PWSTR *Environment, + PUNICODE_STRING Name, + PUNICODE_STRING Value) { MEMORY_BASIC_INFORMATION mbi; UNICODE_STRING var; @@ -380,7 +365,7 @@ found: { size = 0; NtFreeVirtualMemory (NtCurrentProcess (), - (VOID**)&env, + (PVOID*)&env, &size, MEM_RELEASE); } @@ -412,19 +397,16 @@ found: } if (Environment == NULL) { - RtlReleasePebLock (); + RtlReleasePebLock(); } return Status; } -NTSTATUS -STDCALL -RtlQueryEnvironmentVariable_U ( - PVOID Environment, - PUNICODE_STRING Name, - PUNICODE_STRING Value - ) +NTSTATUS STDCALL +RtlQueryEnvironmentVariable_U(PWSTR Environment, + PUNICODE_STRING Name, + PUNICODE_STRING Value) { NTSTATUS Status; PWSTR wcs; diff --git a/reactos/lib/ntdll/rtl/ppb.c b/reactos/lib/ntdll/rtl/ppb.c index 5b9a5119f82..84429d95430 100644 --- a/reactos/lib/ntdll/rtl/ppb.c +++ b/reactos/lib/ntdll/rtl/ppb.c @@ -1,4 +1,4 @@ -/* $Id: ppb.c,v 1.8 2000/08/05 18:01:52 dwelch Exp $ +/* $Id: ppb.c,v 1.9 2000/12/28 20:38:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -29,53 +29,48 @@ /* FUNCTIONS ****************************************************************/ -VOID STDCALL RtlAcquirePebLock(VOID) +VOID STDCALL +RtlAcquirePebLock(VOID) { - PPEB Peb = NtCurrentPeb (); - Peb->FastPebLockRoutine (Peb->FastPebLock); + PPEB Peb = NtCurrentPeb (); + Peb->FastPebLockRoutine (Peb->FastPebLock); } -VOID STDCALL RtlReleasePebLock(VOID) +VOID STDCALL +RtlReleasePebLock(VOID) { - PPEB Peb = NtCurrentPeb (); - Peb->FastPebUnlockRoutine (Peb->FastPebLock); + PPEB Peb = NtCurrentPeb (); + Peb->FastPebUnlockRoutine (Peb->FastPebLock); } -static -inline -VOID -RtlpCopyParameterString ( - PWCHAR *Ptr, - PUNICODE_STRING Destination, - PUNICODE_STRING Source, - ULONG Size - ) +static inline VOID +RtlpCopyParameterString(PWCHAR *Ptr, + PUNICODE_STRING Destination, + PUNICODE_STRING Source, + ULONG Size) { - Destination->Length = Source->Length; - Destination->MaximumLength = Size ? Size : Source->MaximumLength; - Destination->Buffer = (PWCHAR)(*Ptr); - if (Source->Length) - memmove (Destination->Buffer, Source->Buffer, Source->Length); - Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0; - *Ptr += Destination->MaximumLength; + Destination->Length = Source->Length; + Destination->MaximumLength = Size ? Size : Source->MaximumLength; + Destination->Buffer = (PWCHAR)(*Ptr); + if (Source->Length) + memmove (Destination->Buffer, Source->Buffer, Source->Length); + Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0; + *Ptr += Destination->MaximumLength; } -NTSTATUS -STDCALL -RtlCreateProcessParameters ( - PRTL_USER_PROCESS_PARAMETERS *Ppb, - PUNICODE_STRING CommandLine, - PUNICODE_STRING DllPath, - PUNICODE_STRING CurrentDirectory, - PUNICODE_STRING ImagePathName, - PVOID Environment, - PUNICODE_STRING WindowTitle, - PUNICODE_STRING DesktopInfo, - PUNICODE_STRING ShellInfo, - PUNICODE_STRING RuntimeData - ) +NTSTATUS STDCALL +RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, + PUNICODE_STRING ImagePathName, + PUNICODE_STRING DllPath, + PUNICODE_STRING CurrentDirectory, + PUNICODE_STRING CommandLine, + PWSTR Environment, + PUNICODE_STRING WindowTitle, + PUNICODE_STRING DesktopInfo, + PUNICODE_STRING ShellInfo, + PUNICODE_STRING RuntimeInfo) { NTSTATUS Status = STATUS_SUCCESS; PRTL_USER_PROCESS_PARAMETERS Param = NULL; @@ -88,8 +83,8 @@ RtlCreateProcessParameters ( ULONG ConsoleFlags; DPRINT ("RtlCreateProcessParameters\n"); - - RtlAcquirePebLock (); + + RtlAcquirePebLock(); EmptyString.Length = 0; EmptyString.MaximumLength = sizeof(WCHAR); @@ -117,191 +112,184 @@ RtlCreateProcessParameters ( ConsoleHandle = NULL; ConsoleFlags = 0; } - - if (ImagePathName == NULL) - ImagePathName = CommandLine; - if (WindowTitle == NULL) - WindowTitle = &EmptyString; - if (DesktopInfo == NULL) - DesktopInfo = &EmptyString; - if (ShellInfo == NULL) - ShellInfo = &EmptyString; - if (RuntimeData == NULL) - RuntimeData = &EmptyString; - /* size of process parameter block */ - Length = sizeof (RTL_USER_PROCESS_PARAMETERS); + if (CommandLine == NULL) + CommandLine = &EmptyString; + if (WindowTitle == NULL) + WindowTitle = &EmptyString; + if (DesktopInfo == NULL) + DesktopInfo = &EmptyString; + if (ShellInfo == NULL) + ShellInfo = &EmptyString; + if (RuntimeInfo == NULL) + RuntimeInfo = &EmptyString; - /* size of current directory buffer */ - Length += (MAX_PATH * sizeof(WCHAR)); + /* size of process parameter block */ + Length = sizeof(RTL_USER_PROCESS_PARAMETERS); - /* add string lengths */ - Length += ALIGN(DllPath->MaximumLength, sizeof(ULONG)); - Length += ALIGN(CommandLine->Length, sizeof(ULONG)); - Length += ALIGN(ImagePathName->Length, 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)); + /* size of current directory buffer */ + Length += (MAX_PATH * sizeof(WCHAR)); - /* Calculate the required block size */ - RegionSize = ROUNDUP(Length, PAGESIZE); + /* add string lengths */ + Length += ALIGN(DllPath->MaximumLength, sizeof(ULONG)); + Length += ALIGN(ImagePathName->Length, sizeof(ULONG)); + Length += ALIGN(CommandLine->Length, sizeof(ULONG)); + Length += ALIGN(WindowTitle->MaximumLength, sizeof(ULONG)); + Length += ALIGN(DesktopInfo->MaximumLength, sizeof(ULONG)); + Length += ALIGN(ShellInfo->MaximumLength, sizeof(ULONG)); + Length += ALIGN(RuntimeInfo->MaximumLength, sizeof(ULONG)); - Status = NtAllocateVirtualMemory ( - NtCurrentProcess (), - (PVOID*)&Param, - 0, - &RegionSize, - MEM_COMMIT, - PAGE_READWRITE); - if (!NT_SUCCESS(Status)) - { - RtlReleasePebLock (); - return Status; - } + /* Calculate the required block size */ + RegionSize = ROUNDUP(Length, PAGESIZE); - DPRINT ("Ppb allocated\n"); + Status = NtAllocateVirtualMemory(NtCurrentProcess(), + (PVOID*)&Param, + 0, + &RegionSize, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + RtlReleasePebLock(); + return Status; + } - Param->MaximumLength = RegionSize; - Param->Length = Length; - Param->Flags = PPF_NORMALIZED; - Param->Environment = Environment; - Param->CurrentDirectory.Handle = CurrentDirectoryHandle; - Param->ConsoleHandle = ConsoleHandle; - Param->ConsoleFlags = ConsoleFlags; + DPRINT ("Process parameters allocated\n"); - Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS)); + Param->MaximumLength = RegionSize; + Param->Length = Length; + Param->Flags = PPF_NORMALIZED; + Param->Environment = Environment; + Param->CurrentDirectory.Handle = CurrentDirectoryHandle; + Param->ConsoleHandle = ConsoleHandle; + Param->ConsoleFlags = ConsoleFlags; - /* copy current directory */ - RtlpCopyParameterString (&Dest, - &Param->CurrentDirectory.DosPath, - CurrentDirectory, - MAX_PATH * sizeof(WCHAR)); + Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS)); - /* make sure the current directory has a trailing backslash */ - if (Param->CurrentDirectory.DosPath.Length > 0) - { - ULONG Length; + /* copy current directory */ + RtlpCopyParameterString(&Dest, + &Param->CurrentDirectory.DosPath, + CurrentDirectory, + MAX_PATH * sizeof(WCHAR)); - 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); - } - } + /* make sure the current directory has a trailing backslash */ + if (Param->CurrentDirectory.DosPath.Length > 0) + { + ULONG Length; - /* copy library path */ - RtlpCopyParameterString (&Dest, - &Param->DllPath, - DllPath, - 0); + 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); + } + } - /* copy command line */ - RtlpCopyParameterString (&Dest, - &Param->CommandLine, - CommandLine, - CommandLine->Length + sizeof(WCHAR)); + /* copy dll path */ + RtlpCopyParameterString(&Dest, + &Param->DllPath, + DllPath, + 0); - /* copy image name */ - RtlpCopyParameterString (&Dest, - &Param->ImagePathName, - ImagePathName, - ImagePathName->Length + sizeof(WCHAR)); + /* copy image path name */ + RtlpCopyParameterString(&Dest, + &Param->ImagePathName, + ImagePathName, + ImagePathName->Length + sizeof(WCHAR)); - /* copy title */ - RtlpCopyParameterString (&Dest, - &Param->WindowTitle, - WindowTitle, - 0); + /* copy command line */ + RtlpCopyParameterString(&Dest, + &Param->CommandLine, + CommandLine, + CommandLine->Length + sizeof(WCHAR)); - /* copy desktop */ - RtlpCopyParameterString (&Dest, - &Param->DesktopInfo, - DesktopInfo, - 0); + /* copy title */ + RtlpCopyParameterString(&Dest, + &Param->WindowTitle, + WindowTitle, + 0); - RtlpCopyParameterString (&Dest, - &Param->ShellInfo, - ShellInfo, - 0); + /* copy desktop */ + RtlpCopyParameterString(&Dest, + &Param->DesktopInfo, + DesktopInfo, + 0); - RtlpCopyParameterString (&Dest, - &Param->RuntimeData, - RuntimeData, - 0); + /* copy shell info */ + RtlpCopyParameterString(&Dest, + &Param->ShellInfo, + ShellInfo, + 0); - RtlDeNormalizeProcessParams (Param); - *Ppb = Param; - RtlReleasePebLock (); + /* copy runtime info */ + RtlpCopyParameterString(&Dest, + &Param->RuntimeInfo, + RuntimeInfo, + 0); - return STATUS_SUCCESS; + RtlDeNormalizeProcessParams(Param); + *ProcessParameters = Param; + RtlReleasePebLock(); + + return STATUS_SUCCESS; } -VOID -STDCALL -RtlDestroyProcessParameters ( - PRTL_USER_PROCESS_PARAMETERS Ppb - ) +VOID STDCALL +RtlDestroyProcessParameters(PRTL_USER_PROCESS_PARAMETERS ProcessParameters) { - ULONG RegionSize = 0; + ULONG RegionSize = 0; - NtFreeVirtualMemory (NtCurrentProcess (), - (PVOID)Ppb, - &RegionSize, - MEM_RELEASE); + NtFreeVirtualMemory (NtCurrentProcess (), + (PVOID)ProcessParameters, + &RegionSize, + MEM_RELEASE); } /* * denormalize process parameters (Pointer-->Offset) */ -PRTL_USER_PROCESS_PARAMETERS -STDCALL -RtlDeNormalizeProcessParams ( - PRTL_USER_PROCESS_PARAMETERS Params - ) +PRTL_USER_PROCESS_PARAMETERS STDCALL +RtlDeNormalizeProcessParams(PRTL_USER_PROCESS_PARAMETERS Params) { - if (Params && (Params->Flags & PPF_NORMALIZED)) - { - DENORMALIZE (Params->CurrentDirectory.DosPath.Buffer, Params); - DENORMALIZE (Params->DllPath.Buffer, Params); - DENORMALIZE (Params->CommandLine.Buffer, Params); - DENORMALIZE (Params->ImagePathName.Buffer, Params); - DENORMALIZE (Params->WindowTitle.Buffer, Params); - DENORMALIZE (Params->DesktopInfo.Buffer, Params); - DENORMALIZE (Params->ShellInfo.Buffer, Params); - DENORMALIZE (Params->RuntimeData.Buffer, Params); + if (Params && (Params->Flags & PPF_NORMALIZED)) + { + DENORMALIZE(Params->CurrentDirectory.DosPath.Buffer, Params); + DENORMALIZE(Params->DllPath.Buffer, Params); + DENORMALIZE(Params->ImagePathName.Buffer, Params); + DENORMALIZE(Params->CommandLine.Buffer, Params); + DENORMALIZE(Params->WindowTitle.Buffer, Params); + DENORMALIZE(Params->DesktopInfo.Buffer, Params); + DENORMALIZE(Params->ShellInfo.Buffer, Params); + DENORMALIZE(Params->RuntimeInfo.Buffer, Params); - Params->Flags &= ~PPF_NORMALIZED; - } + Params->Flags &= ~PPF_NORMALIZED; + } - return Params; + return Params; } /* * normalize process parameters (Offset-->Pointer) */ -PRTL_USER_PROCESS_PARAMETERS -STDCALL -RtlNormalizeProcessParams ( - PRTL_USER_PROCESS_PARAMETERS Params) +PRTL_USER_PROCESS_PARAMETERS STDCALL +RtlNormalizeProcessParams(PRTL_USER_PROCESS_PARAMETERS Params) { - if (Params && !(Params->Flags & PPF_NORMALIZED)) - { - NORMALIZE (Params->CurrentDirectory.DosPath.Buffer, Params); - NORMALIZE (Params->DllPath.Buffer, Params); - NORMALIZE (Params->CommandLine.Buffer, Params); - NORMALIZE (Params->ImagePathName.Buffer, Params); - NORMALIZE (Params->WindowTitle.Buffer, Params); - NORMALIZE (Params->DesktopInfo.Buffer, Params); - NORMALIZE (Params->ShellInfo.Buffer, Params); - NORMALIZE (Params->RuntimeData.Buffer, Params); + if (Params && !(Params->Flags & PPF_NORMALIZED)) + { + NORMALIZE(Params->CurrentDirectory.DosPath.Buffer, Params); + NORMALIZE(Params->DllPath.Buffer, Params); + NORMALIZE(Params->ImagePathName.Buffer, Params); + NORMALIZE(Params->CommandLine.Buffer, Params); + NORMALIZE(Params->WindowTitle.Buffer, Params); + NORMALIZE(Params->DesktopInfo.Buffer, Params); + NORMALIZE(Params->ShellInfo.Buffer, Params); + NORMALIZE(Params->RuntimeInfo.Buffer, Params); - Params->Flags |= PPF_NORMALIZED; - } + Params->Flags |= PPF_NORMALIZED; + } - return Params; + return Params; } /* EOF */ diff --git a/reactos/lib/ntdll/rtl/process.c b/reactos/lib/ntdll/rtl/process.c index 2ca64cd1bad..64bf1c2e452 100644 --- a/reactos/lib/ntdll/rtl/process.c +++ b/reactos/lib/ntdll/rtl/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.22 2000/12/09 04:34:52 phreak Exp $ +/* $Id: process.c,v 1.23 2000/12/28 20:38:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -26,9 +26,8 @@ #define STACK_TOP (0xb0000000) HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, - DWORD dwStackSize, + ULONG StackSize, LPTHREAD_START_ROUTINE lpStartAddress, - DWORD dwCreationFlags, PCLIENT_ID ClientId) { NTSTATUS Status; @@ -36,7 +35,6 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, OBJECT_ATTRIBUTES ObjectAttributes; CONTEXT ThreadContext; INITIAL_TEB InitialTeb; - BOOLEAN CreateSuspended = FALSE; PVOID BaseAddress; CLIENT_ID Cid; @@ -46,17 +44,11 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, ObjectAttributes.Attributes = 0; ObjectAttributes.SecurityQualityOfService = NULL; - if (dwCreationFlags & CREATE_SUSPENDED) - CreateSuspended = TRUE; - else - CreateSuspended = FALSE; - - - BaseAddress = (PVOID)(STACK_TOP - dwStackSize); + BaseAddress = (PVOID)(STACK_TOP - StackSize); Status = NtAllocateVirtualMemory(ProcessHandle, &BaseAddress, 0, - (PULONG)&dwStackSize, + (PULONG)&StackSize, MEM_COMMIT, PAGE_READWRITE); if (!NT_SUCCESS(Status)) @@ -85,7 +77,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, &Cid, &ThreadContext, &InitialTeb, - CreateSuspended); + FALSE); if (ClientId != NULL) { memcpy(&ClientId->UniqueThread, &Cid.UniqueThread, sizeof(ULONG)); @@ -94,11 +86,11 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, return(ThreadHandle); } -static NTSTATUS RtlpMapFile( -PRTL_USER_PROCESS_PARAMETERS Ppb, -//PUNICODE_STRING ApplicationName, - PHANDLE Section, - PCHAR ImageFileName) +static NTSTATUS +RtlpMapFile(PRTL_USER_PROCESS_PARAMETERS Ppb, + ULONG Attributes, + PHANDLE Section, + PCHAR ImageFileName) { HANDLE hFile; IO_STATUS_BLOCK IoStatusBlock; @@ -116,9 +108,8 @@ PRTL_USER_PROCESS_PARAMETERS Ppb, // DbgPrint("ImagePathName %x\n", Ppb->ImagePathName.Buffer); InitializeObjectAttributes(&ObjectAttributes, -// ApplicationName, &(Ppb->ImagePathName), - OBJ_CASE_INSENSITIVE, + Attributes & (OBJ_CASE_INSENSITIVE | OBJ_INHERIT), NULL, SecurityDescriptor); @@ -145,7 +136,7 @@ PRTL_USER_PROCESS_PARAMETERS Ppb, } for (i = 0; i < 8; i++) { - ImageFileName[i] = (CHAR)(s[i]); + ImageFileName[i] = (CHAR)(s[i]); } if (e != NULL) { @@ -282,50 +273,51 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle, return(STATUS_SUCCESS); } -NTSTATUS -STDCALL -RtlCreateUserProcess ( - PUNICODE_STRING CommandLine, // verified - ULONG Unknown2, - PRTL_USER_PROCESS_PARAMETERS Ppb, // verified - PSECURITY_DESCRIPTOR ProcessSd, - PSECURITY_DESCRIPTOR ThreadSd, - BOOL bInheritHandles, - DWORD dwCreationFlags, - ULONG Unknown8, - ULONG Unknown9, - PRTL_USER_PROCESS_INFO ProcessInfo // verified - ) + +NTSTATUS STDCALL +RtlCreateUserProcess(PUNICODE_STRING ImageFileName, + ULONG Attributes, + PRTL_USER_PROCESS_PARAMETERS ProcessParameters, + PSECURITY_DESCRIPTOR ProcessSecurityDescriptor, + PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, + HANDLE ParentProcess, + BOOLEAN CurrentDirectory, + HANDLE DebugPort, + HANDLE ExceptionPort, + PRTL_PROCESS_INFO ProcessInfo) { HANDLE hSection; HANDLE hThread; NTSTATUS Status; - LPTHREAD_START_ROUTINE lpStartAddress = NULL; + LPTHREAD_START_ROUTINE lpStartAddress = NULL; PROCESS_BASIC_INFORMATION ProcessBasicInfo; ULONG retlen; - CHAR ImageFileName[8]; + CHAR FileName[8]; ANSI_STRING ProcedureName; DPRINT("RtlCreateUserProcess\n"); -// Status = RtlpMapFile(CommandLine, - Status = RtlpMapFile(Ppb, + Status = RtlpMapFile(ProcessParameters, + Attributes, &hSection, - ImageFileName); + FileName); if( !NT_SUCCESS( Status ) ) return Status; + /* * Create a new process */ - + if (ParentProcess == NULL) + ParentProcess = NtCurrentProcess(); + Status = NtCreateProcess(&(ProcessInfo->ProcessHandle), PROCESS_ALL_ACCESS, NULL, - NtCurrentProcess(), - bInheritHandles, + ParentProcess, + CurrentDirectory, hSection, - NULL, - NULL); + DebugPort, + ExceptionPort); if (!NT_SUCCESS(Status)) { return(Status); @@ -334,7 +326,6 @@ RtlCreateUserProcess ( /* * Get some information about the process */ - NtQueryInformationProcess(ProcessInfo->ProcessHandle, ProcessBasicInformation, &ProcessBasicInfo, @@ -346,14 +337,15 @@ RtlCreateUserProcess ( Status = NtSetInformationProcess(ProcessInfo->ProcessHandle, ProcessImageFileName, - ImageFileName, + FileName, 8); - + /* * Create Process Environment Block */ DPRINT("Creating peb\n"); - KlInitPeb(ProcessInfo->ProcessHandle, Ppb); + KlInitPeb(ProcessInfo->ProcessHandle, + ProcessParameters); DPRINT("Retrieving entry point address\n"); RtlInitAnsiString (&ProcedureName, "LdrInitializeThunk"); @@ -373,7 +365,6 @@ RtlCreateUserProcess ( // Headers.OptionalHeader.SizeOfStackReserve, 0x200000, lpStartAddress, - dwCreationFlags, &(ProcessInfo->ClientId)); if (hThread == NULL) { diff --git a/reactos/lib/ntdll/rtl/thread.c b/reactos/lib/ntdll/rtl/thread.c index 125de0443b5..e535a4c93e1 100644 --- a/reactos/lib/ntdll/rtl/thread.c +++ b/reactos/lib/ntdll/rtl/thread.c @@ -14,7 +14,6 @@ #include #include #include -//#include #include #define NDEBUG @@ -29,7 +28,7 @@ RtlCreateUserThread(HANDLE ProcessHandle, PSECURITY_DESCRIPTOR SecurityDescriptor, BOOLEAN CreateSuspended, LONG StackZeroBits, - PULONG StackReserved, + PULONG StackReserve, PULONG StackCommit, PTHREAD_START_ROUTINE StartAddress, PVOID Parameter, @@ -41,7 +40,7 @@ RtlCreateUserThread(HANDLE ProcessHandle, OBJECT_ATTRIBUTES ObjectAttributes; INITIAL_TEB InitialTeb; CONTEXT ThreadContext; - ULONG ReservedSize; + ULONG ReserveSize; ULONG CommitSize; ULONG GuardSize; ULONG RegionSize; @@ -53,21 +52,21 @@ RtlCreateUserThread(HANDLE ProcessHandle, else CommitSize = PAGESIZE; - if ((StackReserved != NULL) && (*StackReserved > 0x100000)) - ReservedSize = *StackReserved; + if ((StackReserve != NULL) && (*StackReserve > 0x100000)) + ReserveSize = *StackReserve; else - ReservedSize = 0x100000; /* 1MByte */ + ReserveSize = 0x100000; /* 1MByte */ GuardSize = PAGESIZE; RegionSize = 0; /* Reserve stack */ - InitialTeb.StackReserved = NULL; + InitialTeb.StackReserve = NULL; Status = NtAllocateVirtualMemory(ProcessHandle, - &InitialTeb.StackReserved, + &InitialTeb.StackReserve, 0, - &ReservedSize, + &ReserveSize, MEM_RESERVE, PAGE_READWRITE); @@ -78,12 +77,12 @@ RtlCreateUserThread(HANDLE ProcessHandle, } DPRINT("StackReserved: %p ReservedSize: 0x%lx\n", - InitialTeb.StackReserved, ReservedSize); + InitialTeb.StackReserve, ReserveSize); - InitialTeb.StackBase = (PVOID)(InitialTeb.StackReserved + ReservedSize); + InitialTeb.StackBase = (PVOID)(InitialTeb.StackReserve + ReserveSize); InitialTeb.StackCommit = (PVOID)(InitialTeb.StackBase - CommitSize); InitialTeb.StackLimit = (PVOID)(InitialTeb.StackCommit - PAGESIZE); - InitialTeb.StackCommitMax = (PVOID)(InitialTeb.StackReserved + PAGESIZE); + InitialTeb.StackCommitMax = (PVOID)(InitialTeb.StackReserve + PAGESIZE); DPRINT("StackBase: %p\n", InitialTeb.StackBase); @@ -100,7 +99,7 @@ RtlCreateUserThread(HANDLE ProcessHandle, { /* release the stack space */ NtFreeVirtualMemory(ProcessHandle, - InitialTeb.StackReserved, + InitialTeb.StackReserve, &RegionSize, MEM_RELEASE); @@ -123,7 +122,7 @@ RtlCreateUserThread(HANDLE ProcessHandle, { /* release the stack space */ NtFreeVirtualMemory(ProcessHandle, - InitialTeb.StackReserved, + InitialTeb.StackReserve, &RegionSize, MEM_RELEASE); @@ -163,7 +162,7 @@ RtlCreateUserThread(HANDLE ProcessHandle, { /* release the stack space */ NtFreeVirtualMemory(ProcessHandle, - InitialTeb.StackReserved, + InitialTeb.StackReserve, &RegionSize, MEM_RELEASE); @@ -176,8 +175,8 @@ RtlCreateUserThread(HANDLE ProcessHandle, *StackCommit = CommitSize; /* return reserved stack size */ - if (StackReserved) - *StackReserved = ReservedSize; + if (StackReserve) + *StackReserve = ReserveSize; /* return thread handle */ if (ThreadHandle) diff --git a/reactos/ntoskrnl/ps/create.c b/reactos/ntoskrnl/ps/create.c index 2d4987441e8..fa1b738d506 100644 --- a/reactos/ntoskrnl/ps/create.c +++ b/reactos/ntoskrnl/ps/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.26 2000/12/23 02:37:40 dwelch Exp $ +/* $Id: create.c,v 1.27 2000/12/28 20:38:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -470,7 +470,7 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle, */ Teb.StackCommit = InitialTeb->StackCommit; Teb.StackCommitMax = InitialTeb->StackCommitMax; - Teb.StackReserved = InitialTeb->StackReserved; + Teb.StackReserve = InitialTeb->StackReserve; } diff --git a/reactos/subsys/smss/init.c b/reactos/subsys/smss/init.c index 64e2d5f0bc8..09ce79b3179 100644 --- a/reactos/subsys/smss/init.c +++ b/reactos/subsys/smss/init.c @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.20 2000/12/05 18:14:07 ekohl Exp $ +/* $Id: init.c,v 1.21 2000/12/28 20:38:28 ekohl Exp $ * * init.c - Session Manager initialization * @@ -41,7 +41,7 @@ HANDLE SmApiPort = INVALID_HANDLE_VALUE; HANDLE DbgSsApiPort = INVALID_HANDLE_VALUE; HANDLE DbgUiApiPort = INVALID_HANDLE_VALUE; -PVOID SmSystemEnvironment = NULL; +PWSTR SmSystemEnvironment = NULL; /* FUNCTIONS ****************************************************************/ @@ -168,7 +168,7 @@ BOOL InitSessionManager (HANDLE Children[]) OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING CmdLineW; PRTL_USER_PROCESS_PARAMETERS ProcessParameters; - RTL_USER_PROCESS_INFO ProcessInfo; + RTL_PROCESS_INFO ProcessInfo; HANDLE CsrssInitEvent; WCHAR UnicodeBuffer[MAX_PATH]; @@ -223,7 +223,7 @@ BOOL InitSessionManager (HANDLE Children[]) NULL); /* Create the system environment */ - Status = RtlCreateEnvironment (TRUE, + Status = RtlCreateEnvironment (FALSE, &SmSystemEnvironment); if (!NT_SUCCESS(Status)) return FALSE; @@ -302,14 +302,14 @@ BOOL InitSessionManager (HANDLE Children[]) NULL); Status = RtlCreateUserProcess (&UnicodeString, - 0, + OBJ_CASE_INSENSITIVE, ProcessParameters, NULL, NULL, + NULL, FALSE, - 0, - 0, - 0, + NULL, + NULL, &ProcessInfo); RtlDestroyProcessParameters (ProcessParameters); @@ -352,14 +352,14 @@ BOOL InitSessionManager (HANDLE Children[]) NULL); Status = RtlCreateUserProcess(&UnicodeString, - 0, + OBJ_CASE_INSENSITIVE, ProcessParameters, NULL, NULL, + NULL, FALSE, - 0, - 0, - 0, + NULL, + NULL, &ProcessInfo); RtlDestroyProcessParameters(ProcessParameters);