From 0b60acbc3c0a2a35f0ab16cf16211774e13eeacf Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Fri, 1 Apr 2005 00:39:52 +0000 Subject: [PATCH] -move ppb from ntdll to rtl smapiexec.c: free ppb on failure. resume thread (RtlCreateUserProcess is supposed to create the thread suspended) svn path=/trunk/; revision=14402 --- reactos/lib/ntdll/makefile | 1 - reactos/lib/ntdll/rtl/teb.c | 23 +++++++++++++++++++++++ reactos/lib/rtl/makefile | 1 + reactos/lib/{ntdll => }/rtl/ppb.c | 30 +++++++----------------------- reactos/ntoskrnl/rtl/libsupp.c | 10 +++++++++- reactos/subsys/smss/smapiexec.c | 6 +++++- 6 files changed, 45 insertions(+), 26 deletions(-) rename reactos/lib/{ntdll => }/rtl/ppb.c (94%) diff --git a/reactos/lib/ntdll/makefile b/reactos/lib/ntdll/makefile index 7b2a4932cd4..5286ac590e8 100644 --- a/reactos/lib/ntdll/makefile +++ b/reactos/lib/ntdll/makefile @@ -76,7 +76,6 @@ RTL_OBJECTS = \ rtl/message.o \ rtl/misc.o \ rtl/path.o \ - rtl/ppb.o \ rtl/process.o \ rtl/propvar.o \ rtl/rangelist.o \ diff --git a/reactos/lib/ntdll/rtl/teb.c b/reactos/lib/ntdll/rtl/teb.c index bb8e1ca1be1..dc0c67ab19b 100644 --- a/reactos/lib/ntdll/rtl/teb.c +++ b/reactos/lib/ntdll/rtl/teb.c @@ -9,7 +9,30 @@ #include #include + PTEB STDCALL _NtCurrentTeb() { return NtCurrentTeb(); } + +/* + * @implemented + */ +VOID STDCALL +RtlAcquirePebLock(VOID) +{ + PPEB Peb = NtCurrentPeb (); + Peb->FastPebLockRoutine (Peb->FastPebLock); +} + + +/* + * @implemented + */ +VOID STDCALL +RtlReleasePebLock(VOID) +{ + PPEB Peb = NtCurrentPeb (); + Peb->FastPebUnlockRoutine (Peb->FastPebLock); +} + /* EOF */ diff --git a/reactos/lib/rtl/makefile b/reactos/lib/rtl/makefile index 321875b2ee4..2a0f381d0c0 100644 --- a/reactos/lib/rtl/makefile +++ b/reactos/lib/rtl/makefile @@ -18,6 +18,7 @@ endif TARGET_OBJECTS = \ acl.o \ + ppb.o \ bit.o \ bitmap.o \ bootdata.o \ diff --git a/reactos/lib/ntdll/rtl/ppb.c b/reactos/lib/rtl/ppb.c similarity index 94% rename from reactos/lib/ntdll/rtl/ppb.c rename to reactos/lib/rtl/ppb.c index d05a9633840..2a06f1f2874 100644 --- a/reactos/lib/ntdll/rtl/ppb.c +++ b/reactos/lib/rtl/ppb.c @@ -28,28 +28,12 @@ #define ALIGN(x,align) (((ULONG)(x)+(align)-1UL)&(~((align)-1UL))) +KPROCESSOR_MODE +RtlpGetMode(); + + /* FUNCTIONS ****************************************************************/ -/* - * @implemented - */ -VOID STDCALL -RtlAcquirePebLock(VOID) -{ - PPEB Peb = NtCurrentPeb (); - Peb->FastPebLockRoutine (Peb->FastPebLock); -} - - -/* - * @implemented - */ -VOID STDCALL -RtlReleasePebLock(VOID) -{ - PPEB Peb = NtCurrentPeb (); - Peb->FastPebUnlockRoutine (Peb->FastPebLock); -} static inline VOID RtlpCopyParameterString(PWCHAR *Ptr, @@ -100,7 +84,7 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, EmptyString.MaximumLength = sizeof(WCHAR); EmptyString.Buffer = L""; - if (NtCurrentPeb()->ProcessParameters) + if (RtlpGetMode() == UserMode) { if (DllPath == NULL) DllPath = &NtCurrentPeb()->ProcessParameters->DllPath; @@ -152,7 +136,7 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, /* Calculate the required block size */ RegionSize = ROUNDUP(Length, PAGE_SIZE); - Status = NtAllocateVirtualMemory(NtCurrentProcess(), + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), (PVOID*)&Param, 0, &RegionSize, @@ -253,7 +237,7 @@ RtlDestroyProcessParameters(PRTL_USER_PROCESS_PARAMETERS ProcessParameters) { ULONG RegionSize = 0; - return NtFreeVirtualMemory (NtCurrentProcess (), + return ZwFreeVirtualMemory (NtCurrentProcess (), (PVOID)ProcessParameters, &RegionSize, MEM_RELEASE); diff --git a/reactos/ntoskrnl/rtl/libsupp.c b/reactos/ntoskrnl/rtl/libsupp.c index bfc592a491b..900ba741139 100644 --- a/reactos/ntoskrnl/rtl/libsupp.c +++ b/reactos/ntoskrnl/rtl/libsupp.c @@ -20,6 +20,13 @@ /* FUNCTIONS *****************************************************************/ + +KPROCESSOR_MODE +RtlpGetMode() +{ + return KernelMode; +} + /* * @implemented */ @@ -38,11 +45,12 @@ RtlReleasePebLock(VOID) } + PPEB STDCALL RtlpCurrentPeb(VOID) { - return ((PEPROCESS)(KeGetCurrentThread()->ApcState.Process))->Peb; + return ((PEPROCESS)(KeGetCurrentThread()->ApcState.Process))->Peb; } NTSTATUS diff --git a/reactos/subsys/smss/smapiexec.c b/reactos/subsys/smss/smapiexec.c index ad83e512667..f961c917c0e 100644 --- a/reactos/subsys/smss/smapiexec.c +++ b/reactos/subsys/smss/smapiexec.c @@ -81,6 +81,9 @@ SmCreateUserProcess (LPWSTR ImagePath, NULL, NULL, pProcessInfo); + + RtlDestroyProcessParameters (ProcessParameters); + if (!NT_SUCCESS(Status)) { DPRINT1("SM: %s: Running \"%S\" failed (Status=0x%08lx)\n", @@ -88,7 +91,8 @@ SmCreateUserProcess (LPWSTR ImagePath, return Status; } - RtlDestroyProcessParameters (ProcessParameters); + NtResumeThread(pProcessInfo->ThreadHandle, NULL); + /* Wait for process termination */ if(WaitForIt)