Author: fireball Date: Fri Apr 8 17:49:49 2011 New Revision: 51281
URL: http://svn.reactos.org/svn/reactos?rev=51281&view=rev Log: [NTDLL] - Fix incorrect prototypes and partially implement fast unsafe versions of activation context activation/deactivation, however disable them for now, until the new loader is in place. - Fix their usage in the new loader code, which by mistake (which got copypasted into three other places) was passing a totally empty activation context to the activate function.
Modified: trunk/reactos/dll/ntdll/def/ntdll.pspec trunk/reactos/dll/ntdll/ldr/ldrinit.c trunk/reactos/dll/ntdll/ldr/ldrpe.c trunk/reactos/include/ndk/rtlfuncs.h trunk/reactos/lib/rtl/actctx.c
Modified: trunk/reactos/dll/ntdll/def/ntdll.pspec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.pspec?r... ============================================================================== --- trunk/reactos/dll/ntdll/def/ntdll.pspec [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/def/ntdll.pspec [iso-8859-1] Fri Apr 8 17:49:49 2011 @@ -419,7 +419,7 @@ @ stdcall RtlAcquireSRWLockShared(ptr) @ stdcall RtlActivateActivationContext(long ptr ptr) //@ stdcall RtlActivateActivationContextEx -@ stdcall RtlActivateActivationContextUnsafeFast(ptr ptr) +@ fastcall RtlActivateActivationContextUnsafeFast(ptr ptr) @ stdcall RtlAddAccessAllowedAce(ptr long long ptr) @ stdcall RtlAddAccessAllowedAceEx(ptr long long long ptr) @ stdcall RtlAddAccessAllowedObjectAce(ptr long long long ptr ptr ptr) @@ -532,7 +532,7 @@ @ stdcall RtlCutoverTimeToSystemTime(ptr ptr ptr long) @ stdcall RtlDeNormalizeProcessParams(ptr) @ stdcall RtlDeactivateActivationContext(long long) -@ stdcall RtlDeactivateActivationContextUnsafeFast(ptr) +@ fastcall RtlDeactivateActivationContextUnsafeFast(ptr) //@ stdcall RtlDebugPrintTimes @ stdcall RtlDecodePointer(ptr) @ stdcall RtlDecodeSystemPointer(ptr) RtlEncodeSystemPointer
Modified: trunk/reactos/dll/ntdll/ldr/ldrinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrinit.c?rev... ============================================================================== --- trunk/reactos/dll/ntdll/ldr/ldrinit.c [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/ldr/ldrinit.c [iso-8859-1] Fri Apr 8 17:49:49 2011 @@ -616,8 +616,8 @@
/* Set up the Act Ctx */ ActCtx.Size = sizeof(ActCtx); - ActCtx.Frame.Flags = ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID; - RtlZeroMemory(&ActCtx, sizeof(ActCtx)); + ActCtx.Format = 1; + RtlZeroMemory(&ActCtx.Frame, sizeof(RTL_ACTIVATION_CONTEXT_STACK_FRAME));
/* Activate the ActCtx */ RtlActivateActivationContextUnsafeFast(&ActCtx, @@ -682,8 +682,8 @@ { /* Set up the Act Ctx */ ActCtx.Size = sizeof(ActCtx); - ActCtx.Frame.Flags = ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID; - RtlZeroMemory(&ActCtx, sizeof(ActCtx)); + ActCtx.Format = 1; + RtlZeroMemory(&ActCtx.Frame, sizeof(RTL_ACTIVATION_CONTEXT_STACK_FRAME));
/* Activate the ActCtx */ RtlActivateActivationContextUnsafeFast(&ActCtx,
Modified: trunk/reactos/dll/ntdll/ldr/ldrpe.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrpe.c?rev=5... ============================================================================== --- trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] Fri Apr 8 17:49:49 2011 @@ -660,8 +660,8 @@ DPRINT1("LdrpWalkImportDescriptor('%S' %x)\n", DllPath, LdrEntry); /* Set up the Act Ctx */ ActCtx.Size = sizeof(ActCtx); - ActCtx.Frame.Flags = ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID; - RtlZeroMemory(&ActCtx, sizeof(ActCtx)); + ActCtx.Frame.Flags = 1; + RtlZeroMemory(&ActCtx.Frame, sizeof(RTL_ACTIVATION_CONTEXT_STACK_FRAME));
/* Check if we have a manifest prober routine */ if (LdrpManifestProberRoutine)
Modified: trunk/reactos/include/ndk/rtlfuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev=... ============================================================================== --- trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] Fri Apr 8 17:49:49 2011 @@ -3071,8 +3071,8 @@
NTSYSAPI -NTSTATUS -NTAPI +PRTL_ACTIVATION_CONTEXT_STACK_FRAME +FASTCALL RtlActivateActivationContextUnsafeFast( IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context @@ -3121,8 +3121,8 @@ RtlFreeThreadActivationContextStack(void);
NTSYSAPI -NTSTATUS -NTAPI +PRTL_ACTIVATION_CONTEXT_STACK_FRAME +FASTCALL RtlDeactivateActivationContextUnsafeFast( IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame );
Modified: trunk/reactos/lib/rtl/actctx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/actctx.c?rev=51281&... ============================================================================== --- trunk/reactos/lib/rtl/actctx.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/actctx.c [iso-8859-1] Fri Apr 8 17:49:49 2011 @@ -21,6 +21,8 @@ #include <debug.h>
#include <wine/unicode.h> + +BOOLEAN RtlpNotAllowingMultipleActivation;
#define QUERY_ACTCTX_FLAG_ACTIVE (0x00000001)
@@ -2730,31 +2732,75 @@ return STATUS_SUCCESS; }
-NTSTATUS -NTAPI +PRTL_ACTIVATION_CONTEXT_STACK_FRAME +FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context) { - static int i; - - if (i == 0) - UNIMPLEMENTED; - i++; - - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -NTAPI +#if NEW_NTDLL_LOADER + RTL_ACTIVATION_CONTEXT_STACK_FRAME *ActiveFrame; + + /* Get the curren active frame */ + ActiveFrame = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame; + + DPRINT1("ActiveFrame %p, &Frame->Frame %p, Context %p\n", ActiveFrame, &Frame->Frame, Context); + + /* Actually activate it */ + Frame->Frame.Previous = ActiveFrame; + Frame->Frame.ActivationContext = Context; + Frame->Frame.Flags = 0; + + /* Check if we can activate this context */ + if ((ActiveFrame && (ActiveFrame->ActivationContext != Context)) || + Context) + { + /* Set new active frame */ + NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = &Frame->Frame; + return &Frame->Frame; + } + + /* We can get here only one way: it was already activated */ + DPRINT1("Trying to activate improper activation context\n"); + + /* Activate only if we are allowing multiple activation */ + if (!RtlpNotAllowingMultipleActivation) + { + NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = &Frame->Frame; + } + else + { + /* Set flag */ + Frame->Frame.Flags = 0x30; + } + + /* Return pointer to the activation frame */ + return &Frame->Frame; +#else + return NULL; +#endif +} + +PRTL_ACTIVATION_CONTEXT_STACK_FRAME +FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame) { - static int i; - - if (i == 0) - UNIMPLEMENTED; - i++; - - return STATUS_NOT_IMPLEMENTED; +#if NEW_NTDLL_LOADER + RTL_ACTIVATION_CONTEXT_STACK_FRAME *frame, *top; + + /* find the right frame */ + top = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame; + frame = &Frame->Frame; + + if (!frame) + RtlRaiseStatus( STATUS_SXS_INVALID_DEACTIVATION ); + + /* pop everything up to and including frame */ + NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = frame->Previous; + + return frame; +#else + return NULL; +#endif }