mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:16:07 +00:00
[NDK]: Add some RTL_ACTIVATION_CONTEXT flags from the ASSERTs in the checked ntdll.dll. Guess some other ones based on what seems to be the naming pattern (can't find them on Google, so who knows).
[RTL]: Make the Wine RtlActivationContext* APIs use the native RTL flags, not the Win32 flags. [KERNEL32]: Separate Wine-specific ActCtx code from NT-compatible ActCtx code, and reimplement the latter. Now all ActCtx APIs except CreateActCtx (which is a mess on Windows) are compatible with the real NT RtlActivationContext APIs in terms of flags. [KERNEL32]: Fix the hacks which were sending Win32 flags to the NT Native Rtl* functions. svn path=/trunk/; revision=59866
This commit is contained in:
parent
34287c50dc
commit
098160c171
6 changed files with 454 additions and 225 deletions
|
@ -4,6 +4,7 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/subsys)
|
||||||
spec2def(kernel32.dll kernel32.spec ADD_IMPORTLIB)
|
spec2def(kernel32.dll kernel32.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
|
client/actctx.c
|
||||||
client/appcache.c
|
client/appcache.c
|
||||||
client/atom.c
|
client/atom.c
|
||||||
client/compname.c
|
client/compname.c
|
||||||
|
|
418
reactos/dll/win32/kernel32/client/actctx.c
Normal file
418
reactos/dll/win32/kernel32/client/actctx.c
Normal file
|
@ -0,0 +1,418 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/thread/thread.c
|
||||||
|
* PURPOSE: Thread functions
|
||||||
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||||
|
* Ariadne ( ariadne@xs4all.nl)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <k32.h>
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#define QUERY_ACTCTX_FLAG_VALID (QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX | \
|
||||||
|
QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE | \
|
||||||
|
QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS | \
|
||||||
|
QUERY_ACTCTX_FLAG_NO_ADDREF)
|
||||||
|
|
||||||
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
BasepFreeActivationContextActivationBlock(IN PBASEP_ACTCTX_BLOCK ActivationBlock)
|
||||||
|
{
|
||||||
|
/* Exit if there was nothing passed in */
|
||||||
|
if (!ActivationBlock) return;
|
||||||
|
|
||||||
|
/* Do we have a context? */
|
||||||
|
if (ActivationBlock->ActivationContext)
|
||||||
|
{
|
||||||
|
/* Release and clear it */
|
||||||
|
RtlReleaseActivationContext(ActivationBlock->ActivationContext);
|
||||||
|
ActivationBlock->ActivationContext = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the block */
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, ActivationBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
BasepAllocateActivationContextActivationBlock(IN DWORD Flags,
|
||||||
|
IN PVOID CompletionRoutine,
|
||||||
|
IN PVOID CompletionContext,
|
||||||
|
OUT PBASEP_ACTCTX_BLOCK *ActivationBlock)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
ACTIVATION_CONTEXT_BASIC_INFORMATION ContextInfo;
|
||||||
|
|
||||||
|
/* Clear the info structure */
|
||||||
|
ContextInfo.dwFlags = 0;
|
||||||
|
ContextInfo.hActCtx = NULL;
|
||||||
|
|
||||||
|
/* Assume failure */
|
||||||
|
if (ActivationBlock) *ActivationBlock = NULL;
|
||||||
|
|
||||||
|
/* Only support valid flags */
|
||||||
|
if (Flags & ~(1 | 2)) // FIXME: What are they? 2 looks like BASEP_ACTCTX_FORCE_BLOCK
|
||||||
|
{
|
||||||
|
/* Fail if unknown flags are passed in */
|
||||||
|
Status = STATUS_INVALID_PARAMETER_1;
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Caller should have passed in an activation block */
|
||||||
|
if (!ActivationBlock)
|
||||||
|
{
|
||||||
|
/* Fail otherwise */
|
||||||
|
Status = STATUS_INVALID_PARAMETER_4;
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Query RTL for information on the current activation context */
|
||||||
|
Status = RtlQueryInformationActivationContext(RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
ActivationContextBasicInformation,
|
||||||
|
&ContextInfo,
|
||||||
|
sizeof(ContextInfo),
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Failed -- bail out */
|
||||||
|
DPRINT1("SXS: %s - Failure getting active activation context; ntstatus %08lx\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the current one should be freed */
|
||||||
|
if (ContextInfo.dwFlags & 1)
|
||||||
|
{
|
||||||
|
/* Release and clear it */
|
||||||
|
RtlReleaseActivationContext(ContextInfo.hActCtx);
|
||||||
|
ContextInfo.hActCtx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if there's an active context, or if the caller is forcing one */
|
||||||
|
if (!(Flags & 2) || (ContextInfo.hActCtx))
|
||||||
|
{
|
||||||
|
/* Allocate the block */
|
||||||
|
*ActivationBlock = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
|
0,
|
||||||
|
sizeof(BASEP_ACTCTX_BLOCK));
|
||||||
|
if (!(*ActivationBlock))
|
||||||
|
{
|
||||||
|
/* Ran out of memory, fail */
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill it out */
|
||||||
|
(*ActivationBlock)->ActivationContext = ContextInfo.hActCtx;
|
||||||
|
(*ActivationBlock)->Flags = 0;
|
||||||
|
if (Flags & 1) (*ActivationBlock)->Flags |= 1; // Not sure about this flag
|
||||||
|
(*ActivationBlock)->CompletionRoutine = CompletionRoutine;
|
||||||
|
(*ActivationBlock)->CompletionContext = CompletionContext;
|
||||||
|
|
||||||
|
/* Tell Quickie below not to free anything, since this is success */
|
||||||
|
ContextInfo.hActCtx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set success status */
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
Quickie:
|
||||||
|
/* Failure or success path, return to caller and free on failure */
|
||||||
|
if (ContextInfo.hActCtx) RtlReleaseActivationContext(ContextInfo.hActCtx);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PUBLIC FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
VOID
|
||||||
|
WINAPI
|
||||||
|
AddRefActCtx(IN HANDLE hActCtx)
|
||||||
|
{
|
||||||
|
/* Call the native API */
|
||||||
|
RtlAddRefActivationContext(hActCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
VOID
|
||||||
|
WINAPI
|
||||||
|
ReleaseActCtx(IN HANDLE hActCtx)
|
||||||
|
{
|
||||||
|
/* Call the native API */
|
||||||
|
RtlReleaseActivationContext(hActCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
ZombifyActCtx(HANDLE hActCtx)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Call the native API */
|
||||||
|
Status = RtlZombifyActivationContext(hActCtx);
|
||||||
|
if (NT_SUCCESS(Status)) return TRUE;
|
||||||
|
|
||||||
|
/* Set last error if we failed */
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
ActivateActCtx(IN HANDLE hActCtx,
|
||||||
|
OUT PULONG_PTR ulCookie)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Check if the handle was invalid */
|
||||||
|
if (hActCtx == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
/* Set error and bail out */
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the native API */
|
||||||
|
Status = RtlActivateActivationContext(0, hActCtx, ulCookie);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Set error and bail out */
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* It worked */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
DeactivateActCtx(IN DWORD dwFlags,
|
||||||
|
IN ULONG_PTR ulCookie)
|
||||||
|
{
|
||||||
|
ULONG NativeFlags;
|
||||||
|
|
||||||
|
/* Check if the flags are invalid */
|
||||||
|
if ((dwFlags & ~DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION) != 0)
|
||||||
|
{
|
||||||
|
/* Set error and bail out */
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert flags */
|
||||||
|
NativeFlags = 0;
|
||||||
|
if (dwFlags & DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION)
|
||||||
|
{
|
||||||
|
NativeFlags = RTL_DEACTIVATE_ACTIVATION_CONTEXT_FLAG_FORCE_EARLY_DEACTIVATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the native API -- it can never fail */
|
||||||
|
RtlDeactivateActivationContext(NativeFlags, ulCookie);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
GetCurrentActCtx(OUT PHANDLE phActCtx)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Check if the output handle pointer was invalid */
|
||||||
|
if (phActCtx == NULL)
|
||||||
|
{
|
||||||
|
/* Set error and bail out */
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the native API */
|
||||||
|
Status = RtlGetActiveActivationContext(phActCtx);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Set error and bail out */
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* It worked */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
QueryActCtxW(IN DWORD dwFlags,
|
||||||
|
IN HANDLE hActCtx,
|
||||||
|
IN PVOID pvSubInstance,
|
||||||
|
IN ULONG ulInfoClass,
|
||||||
|
IN PVOID pvBuffer,
|
||||||
|
IN SIZE_T cbBuffer,
|
||||||
|
IN OUT SIZE_T *pcbWrittenOrRequired OPTIONAL)
|
||||||
|
{
|
||||||
|
ULONG NativeFlags = 0;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Assume failure */
|
||||||
|
if (pcbWrittenOrRequired) *pcbWrittenOrRequired = 0;
|
||||||
|
|
||||||
|
/* Check if native flags were passed in to the Win32 function */
|
||||||
|
switch (dwFlags & 3)
|
||||||
|
{
|
||||||
|
case RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT:
|
||||||
|
dwFlags |= QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX;
|
||||||
|
break;
|
||||||
|
case RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_HMODULE:
|
||||||
|
dwFlags |= QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE;
|
||||||
|
break;
|
||||||
|
case (RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_ADDRESS - 1): // Yep, not sure why
|
||||||
|
dwFlags |= QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now mask out the native flags */
|
||||||
|
dwFlags &= ~3;
|
||||||
|
|
||||||
|
/* Check if any invalid flags are left */
|
||||||
|
if (dwFlags & ~QUERY_ACTCTX_FLAG_VALID)
|
||||||
|
{
|
||||||
|
/* Yep, bail out */
|
||||||
|
DPRINT1("SXS: %s() bad flags(passed: 0x%lx, allowed: 0x%lx, bad: 0x%lx)\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
dwFlags,
|
||||||
|
QUERY_ACTCTX_FLAG_VALID,
|
||||||
|
dwFlags & ~QUERY_ACTCTX_FLAG_VALID);
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER_1);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See if additional parameters are required */
|
||||||
|
switch (ulInfoClass)
|
||||||
|
{
|
||||||
|
case ActivationContextBasicInformation:
|
||||||
|
case ActivationContextDetailedInformation:
|
||||||
|
|
||||||
|
/* Nothing to check */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssemblyDetailedInformationInActivationContext:
|
||||||
|
case FileInformationInAssemblyOfAssemblyInActivationContext:
|
||||||
|
|
||||||
|
/* We need a subinstance for these queries*/
|
||||||
|
if (!pvSubInstance)
|
||||||
|
{
|
||||||
|
/* None present, bail out */
|
||||||
|
DPRINT1("SXS: %s() InfoClass 0x%lx requires SubInstance != NULL\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ulInfoClass);
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER_3);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
/* Invalid class, bail out */
|
||||||
|
DPRINT1("SXS: %s() bad InfoClass(0x%lx)\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ulInfoClass);
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER_2);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if no buffer was passed in*/
|
||||||
|
if (!pvBuffer)
|
||||||
|
{
|
||||||
|
/* But a non-zero length was? */
|
||||||
|
if (cbBuffer)
|
||||||
|
{
|
||||||
|
/* This is bogus... */
|
||||||
|
DPRINT1("SXS: %s() (pvBuffer == NULL) && ((cbBuffer=0x%lu) != 0)\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
cbBuffer);
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER_4);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* But the caller doesn't want to know how big to make it? */
|
||||||
|
if (!pcbWrittenOrRequired)
|
||||||
|
{
|
||||||
|
/* That's bogus */
|
||||||
|
DPRINT1("SXS: %s() (pvBuffer == NULL) && (pcbWrittenOrRequired == NULL)\n",
|
||||||
|
__FUNCTION__);
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER_5);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* These 3 flags are mutually exclusive -- only one should be present */
|
||||||
|
switch (dwFlags & (QUERY_ACTCTX_FLAG_VALID & ~ QUERY_ACTCTX_FLAG_NO_ADDREF))
|
||||||
|
{
|
||||||
|
/* Convert into native format */
|
||||||
|
case QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX:
|
||||||
|
NativeFlags = RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT;
|
||||||
|
break;
|
||||||
|
case QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE:
|
||||||
|
NativeFlags = RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_HMODULE;
|
||||||
|
break;
|
||||||
|
case QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS:
|
||||||
|
NativeFlags = RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_ADDRESS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* More than one flag is set... */
|
||||||
|
default:
|
||||||
|
/* Bail out */
|
||||||
|
DPRINT1("SXS: %s(dwFlags=0x%lx) more than one flag in 0x%lx was passed\n", 0x1C);
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER_1);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert this last flag */
|
||||||
|
if (dwFlags & QUERY_ACTCTX_FLAG_NO_ADDREF)
|
||||||
|
{
|
||||||
|
NativeFlags |= RTL_QUERY_ACTIVATION_CONTEXT_FLAG_NO_ADDREF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now call the native API */
|
||||||
|
Status = RtlQueryInformationActivationContext(NativeFlags,
|
||||||
|
hActCtx,
|
||||||
|
pvSubInstance,
|
||||||
|
ulInfoClass,
|
||||||
|
pvBuffer,
|
||||||
|
cbBuffer,
|
||||||
|
pcbWrittenOrRequired);
|
||||||
|
if (NT_SUCCESS(Status)) return TRUE;
|
||||||
|
|
||||||
|
/* Failed, set error and return */
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -260,8 +260,7 @@ CreateRemoteThread(IN HANDLE hProcess,
|
||||||
Teb->ActivationContextStackPointer = ActivationContextStack;
|
Teb->ActivationContextStackPointer = ActivationContextStack;
|
||||||
|
|
||||||
/* Query the Context */
|
/* Query the Context */
|
||||||
// WARNING!!! THIS IS USING THE WIN32 FLAG BECAUSE REACTOS CONTINUES TO BE A POS!!! ///
|
Status = RtlQueryInformationActivationContext(RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT,
|
||||||
Status = RtlQueryInformationActivationContext(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
|
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
ActivationContextBasicInformation,
|
ActivationContextBasicInformation,
|
||||||
|
@ -934,8 +933,7 @@ QueueUserAPC(IN PAPCFUNC pfnAPC,
|
||||||
|
|
||||||
/* Zero the activation context and query information on it */
|
/* Zero the activation context and query information on it */
|
||||||
RtlZeroMemory(&ActCtxInfo, sizeof(ActCtxInfo));
|
RtlZeroMemory(&ActCtxInfo, sizeof(ActCtxInfo));
|
||||||
// WARNING!!! THIS IS USING THE WIN32 FLAG BECAUSE REACTOS CONTINUES TO BE A POS!!! ///
|
Status = RtlQueryInformationActivationContext(RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT,
|
||||||
Status = RtlQueryInformationActivationContext(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
|
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
ActivationContextBasicInformation,
|
ActivationContextBasicInformation,
|
||||||
|
|
|
@ -115,84 +115,6 @@ HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
|
||||||
return hActCtx;
|
return hActCtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ActivateActCtx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Activate an activation context.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI ActivateActCtx(HANDLE hActCtx, ULONG_PTR *ulCookie)
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if ((status = RtlActivateActivationContext( 0, hActCtx, ulCookie )))
|
|
||||||
{
|
|
||||||
SetLastError(RtlNtStatusToDosError(status));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* DeactivateActCtx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Deactivate an activation context.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI DeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
|
|
||||||
{
|
|
||||||
RtlDeactivateActivationContext( dwFlags, ulCookie );
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* GetCurrentActCtx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Get the current activation context.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI GetCurrentActCtx(HANDLE* phActCtx)
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if ((status = RtlGetActiveActivationContext(phActCtx)))
|
|
||||||
{
|
|
||||||
SetLastError(RtlNtStatusToDosError(status));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* AddRefActCtx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Add a reference to an activation context.
|
|
||||||
*/
|
|
||||||
void WINAPI AddRefActCtx(HANDLE hActCtx)
|
|
||||||
{
|
|
||||||
RtlAddRefActivationContext(hActCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ReleaseActCtx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Release a reference to an activation context.
|
|
||||||
*/
|
|
||||||
void WINAPI ReleaseActCtx(HANDLE hActCtx)
|
|
||||||
{
|
|
||||||
RtlReleaseActivationContext(hActCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ZombifyActCtx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Release a reference to an activation context.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
|
|
||||||
{
|
|
||||||
FIXME("%p\n", hActCtx);
|
|
||||||
if (hActCtx != ACTCTX_FAKE_HANDLE)
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* FindActCtxSectionStringA (KERNEL32.@)
|
* FindActCtxSectionStringA (KERNEL32.@)
|
||||||
*
|
*
|
||||||
|
@ -261,136 +183,5 @@ BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID* lpExtGuid,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* QueryActCtxW (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Get information about an activation context.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI QueryActCtxW(DWORD dwFlags, HANDLE hActCtx, PVOID pvSubInst,
|
|
||||||
ULONG ulClass, PVOID pvBuff, SIZE_T cbBuff,
|
|
||||||
SIZE_T *pcbLen)
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if ((status = RtlQueryInformationActivationContext( dwFlags, hActCtx, pvSubInst, ulClass,
|
|
||||||
pvBuff, cbBuff, pcbLen )))
|
|
||||||
{
|
|
||||||
SetLastError(RtlNtStatusToDosError(status));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* REACTOS PRIVATE ************************************************************/
|
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
BasepFreeActivationContextActivationBlock(IN PBASEP_ACTCTX_BLOCK ActivationBlock)
|
|
||||||
{
|
|
||||||
/* Exit if there was nothing passed in */
|
|
||||||
if (!ActivationBlock) return;
|
|
||||||
|
|
||||||
/* Do we have a context? */
|
|
||||||
if (ActivationBlock->ActivationContext)
|
|
||||||
{
|
|
||||||
/* Release and clear it */
|
|
||||||
RtlReleaseActivationContext(ActivationBlock->ActivationContext);
|
|
||||||
ActivationBlock->ActivationContext = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the block */
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ActivationBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
BasepAllocateActivationContextActivationBlock(IN DWORD Flags,
|
|
||||||
IN PVOID CompletionRoutine,
|
|
||||||
IN PVOID CompletionContext,
|
|
||||||
OUT PBASEP_ACTCTX_BLOCK *ActivationBlock)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
ACTIVATION_CONTEXT_BASIC_INFORMATION ContextInfo;
|
|
||||||
|
|
||||||
/* Clear the info structure */
|
|
||||||
ContextInfo.dwFlags = 0;
|
|
||||||
ContextInfo.hActCtx = NULL;
|
|
||||||
|
|
||||||
/* Assume failure */
|
|
||||||
if (ActivationBlock) *ActivationBlock = NULL;
|
|
||||||
|
|
||||||
/* Only support valid flags */
|
|
||||||
if (Flags & ~(1 | 2)) // FIXME: What are they? 2 looks like BASEP_ACTCTX_FORCE_BLOCK
|
|
||||||
{
|
|
||||||
/* Fail if unknown flags are passed in */
|
|
||||||
Status = STATUS_INVALID_PARAMETER_1;
|
|
||||||
goto Quickie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Caller should have passed in an activation block */
|
|
||||||
if (!ActivationBlock)
|
|
||||||
{
|
|
||||||
/* Fail otherwise */
|
|
||||||
Status = STATUS_INVALID_PARAMETER_4;
|
|
||||||
goto Quickie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Query RTL for information on the current activation context */
|
|
||||||
Status = RtlQueryInformationActivationContext(1,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
ActivationContextBasicInformation,
|
|
||||||
&ContextInfo,
|
|
||||||
sizeof(ContextInfo),
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Failed -- bail out */
|
|
||||||
DPRINT1("SXS: %s - Failure getting active activation context; ntstatus %08lx\n",
|
|
||||||
__FUNCTION__, Status);
|
|
||||||
goto Quickie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the current one should be freed */
|
|
||||||
if (ContextInfo.dwFlags & 1)
|
|
||||||
{
|
|
||||||
/* Release and clear it */
|
|
||||||
RtlReleaseActivationContext(ContextInfo.hActCtx);
|
|
||||||
ContextInfo.hActCtx = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if there's an active context, or if the caller is forcing one */
|
|
||||||
if (!(Flags & 2) || (ContextInfo.hActCtx))
|
|
||||||
{
|
|
||||||
/* Allocate the block */
|
|
||||||
*ActivationBlock = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
sizeof(BASEP_ACTCTX_BLOCK));
|
|
||||||
if (!(*ActivationBlock))
|
|
||||||
{
|
|
||||||
/* Ran out of memory, fail */
|
|
||||||
Status = STATUS_NO_MEMORY;
|
|
||||||
goto Quickie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill it out */
|
|
||||||
(*ActivationBlock)->ActivationContext = ContextInfo.hActCtx;
|
|
||||||
(*ActivationBlock)->Flags = 0;
|
|
||||||
if (Flags & 1) (*ActivationBlock)->Flags |= 1; // Not sure about this flag
|
|
||||||
(*ActivationBlock)->CompletionRoutine = CompletionRoutine;
|
|
||||||
(*ActivationBlock)->CompletionContext = CompletionContext;
|
|
||||||
|
|
||||||
/* Tell Quickie below not to free anything, since this is success */
|
|
||||||
ContextInfo.hActCtx = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set success status */
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
Quickie:
|
|
||||||
/* Failure or success path, return to caller and free on failure */
|
|
||||||
if (ContextInfo.hActCtx) RtlReleaseActivationContext(ContextInfo.hActCtx);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -72,16 +72,37 @@ extern "C" {
|
||||||
#define RTL_RANGE_CONFLICT 0x02
|
#define RTL_RANGE_CONFLICT 0x02
|
||||||
|
|
||||||
//
|
//
|
||||||
// Activation Context Frame Flags
|
// Flags in RTL_ACTIVATION_CONTEXT_STACK_FRAME (from Checked NTDLL)
|
||||||
//
|
//
|
||||||
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER \
|
#define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_NO_DEACTIVATE 0x02
|
||||||
0x1
|
#define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_ON_FREE_LIST 0x04
|
||||||
|
#define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_HEAP_ALLOCATED 0x08
|
||||||
|
#define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_NOT_REALLY_ACTIVATED 0x10
|
||||||
|
#define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_ACTIVATED 0x20
|
||||||
|
#define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_DEACTIVATED 0x40
|
||||||
|
|
||||||
//
|
//
|
||||||
// RtlActivateActivationContextEx Flags
|
// Activation Context Frame Flags (from Checked NTDLL)
|
||||||
//
|
//
|
||||||
#define RTL_ACTIVATE_ACTIVATION_CONTEXT_EX_FLAG_RELEASE_ON_STACK_DEALLOCATION \
|
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER 0x01
|
||||||
0x1
|
|
||||||
|
//
|
||||||
|
// RtlActivateActivationContextEx Flags (from Checked NTDLL)
|
||||||
|
//
|
||||||
|
#define RTL_ACTIVATE_ACTIVATION_CONTEXT_EX_FLAG_RELEASE_ON_STACK_DEALLOCATION 0x01
|
||||||
|
|
||||||
|
//
|
||||||
|
// RtlDeactivateActivationContext Flags (based on Win32 flag and name of above)
|
||||||
|
//
|
||||||
|
#define RTL_DEACTIVATE_ACTIVATION_CONTEXT_FLAG_FORCE_EARLY_DEACTIVATION 0x01
|
||||||
|
|
||||||
|
//
|
||||||
|
// RtlQueryActivationContext Flags (based on Win32 flag and name of above)
|
||||||
|
//
|
||||||
|
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT 0x01
|
||||||
|
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_HMODULE 0x02
|
||||||
|
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_ADDRESS 0x04
|
||||||
|
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_NO_ADDREF 0x80000000
|
||||||
|
|
||||||
//
|
//
|
||||||
// Public Heap Flags
|
// Public Heap Flags
|
||||||
|
|
|
@ -2099,14 +2099,14 @@ static NTSTATUS find_query_actctx( HANDLE *handle, DWORD flags, ULONG class )
|
||||||
{
|
{
|
||||||
NTSTATUS status = STATUS_SUCCESS;
|
NTSTATUS status = STATUS_SUCCESS;
|
||||||
|
|
||||||
if (flags & QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX)
|
if (flags & RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT)
|
||||||
{
|
{
|
||||||
if (*handle) return STATUS_INVALID_PARAMETER;
|
if (*handle) return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame)
|
if (NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame)
|
||||||
*handle = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame->ActivationContext;
|
*handle = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame->ActivationContext;
|
||||||
}
|
}
|
||||||
else if (flags & (QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS|QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE))
|
else if (flags & (RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_ADDRESS | RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_HMODULE))
|
||||||
{
|
{
|
||||||
ULONG magic;
|
ULONG magic;
|
||||||
LDR_DATA_TABLE_ENTRY *pldr;
|
LDR_DATA_TABLE_ENTRY *pldr;
|
||||||
|
@ -2116,7 +2116,7 @@ static NTSTATUS find_query_actctx( HANDLE *handle, DWORD flags, ULONG class )
|
||||||
LdrLockLoaderLock( 0, NULL, &magic );
|
LdrLockLoaderLock( 0, NULL, &magic );
|
||||||
if (!LdrFindEntryForAddress( *handle, &pldr ))
|
if (!LdrFindEntryForAddress( *handle, &pldr ))
|
||||||
{
|
{
|
||||||
if ((flags & QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE) && *handle != pldr->DllBase)
|
if ((flags & RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_HMODULE) && *handle != pldr->DllBase)
|
||||||
status = STATUS_DLL_NOT_FOUND;
|
status = STATUS_DLL_NOT_FOUND;
|
||||||
else
|
else
|
||||||
*handle = pldr->EntryPointActivationContext;
|
*handle = pldr->EntryPointActivationContext;
|
||||||
|
@ -2417,7 +2417,7 @@ RtlDeactivateActivationContext( ULONG flags, ULONG_PTR cookie )
|
||||||
if (!frame)
|
if (!frame)
|
||||||
RtlRaiseStatus( STATUS_SXS_INVALID_DEACTIVATION );
|
RtlRaiseStatus( STATUS_SXS_INVALID_DEACTIVATION );
|
||||||
|
|
||||||
if (frame != top && !(flags & DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION))
|
if (frame != top && !(flags & RTL_DEACTIVATE_ACTIVATION_CONTEXT_FLAG_FORCE_EARLY_DEACTIVATION))
|
||||||
RtlRaiseStatus( STATUS_SXS_EARLY_DEACTIVATION );
|
RtlRaiseStatus( STATUS_SXS_EARLY_DEACTIVATION );
|
||||||
|
|
||||||
/* pop everything up to and including frame */
|
/* pop everything up to and including frame */
|
||||||
|
@ -2524,7 +2524,7 @@ RtlQueryInformationActivationContext( ULONG flags, HANDLE handle, PVOID subinst,
|
||||||
|
|
||||||
info->hActCtx = handle;
|
info->hActCtx = handle;
|
||||||
info->dwFlags = 0; /* FIXME */
|
info->dwFlags = 0; /* FIXME */
|
||||||
if (!(flags & QUERY_ACTCTX_FLAG_NO_ADDREF)) RtlAddRefActivationContext( handle );
|
if (!(flags & RTL_QUERY_ACTIVATION_CONTEXT_FLAG_NO_ADDREF)) RtlAddRefActivationContext(handle);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2707,7 +2707,7 @@ RtlQueryInformationActiveActivationContext(ULONG ulInfoClass,
|
||||||
SIZE_T cbBuffer OPTIONAL,
|
SIZE_T cbBuffer OPTIONAL,
|
||||||
SIZE_T *pcbWrittenOrRequired OPTIONAL)
|
SIZE_T *pcbWrittenOrRequired OPTIONAL)
|
||||||
{
|
{
|
||||||
return RtlQueryInformationActivationContext(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
|
return RtlQueryInformationActivationContext(RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
ulInfoClass,
|
ulInfoClass,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue