Author: cwittich Date: Tue Jan 20 01:40:15 2009 New Revision: 38969
URL: http://svn.reactos.org/svn/reactos?rev=38969&view=rev Log: stublement some more Activation Context stuff fix RTL_ACTIVATION_CONTEXT_STACK_FRAME in NDK
Modified: trunk/reactos/dll/win32/kernel32/misc/actctx.c trunk/reactos/include/ndk/rtltypes.h trunk/reactos/lib/rtl/actctx.c
Modified: trunk/reactos/dll/win32/kernel32/misc/actctx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/act... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/actctx.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/actctx.c [iso-8859-1] Tue Jan 20 01:40:15 2009 @@ -138,7 +138,8 @@
DPRINT("ActivateActCtx(%p %p)\n", hActCtx, ulCookie );
- if ((Status = RtlActivateActivationContext(0, hActCtx, ulCookie))) + Status = RtlActivateActivationContext(0, hActCtx, ulCookie); + if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; @@ -173,7 +174,8 @@
DPRINT("CreateActCtxW(%p %08lx)\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
- if ((Status = RtlCreateActivationContext(&hActCtx, &pActCtx))) + Status = RtlCreateActivationContext(&hActCtx, &pActCtx); + if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return INVALID_HANDLE_VALUE; @@ -235,7 +237,8 @@ NTSTATUS Status;
RtlInitUnicodeString(&us, lpStringToFind); - if ((Status = RtlFindActivationContextSectionString(dwFlags, lpExtensionGuid, ulSectionId, &us, ReturnedData))) + Status = RtlFindActivationContextSectionString(dwFlags, lpExtensionGuid, ulSectionId, &us, ReturnedData); + if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; @@ -254,7 +257,8 @@ NTSTATUS Status;
DPRINT("GetCurrentActCtx(%p)\n", phActCtx); - if ((Status = RtlGetActiveActivationContext(phActCtx))) + Status = RtlGetActiveActivationContext(phActCtx); + if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; @@ -305,8 +309,15 @@ HANDLE hActCtx ) { + NTSTATUS Status; DPRINT("ZombifyActCtx(%p)\n", hActCtx); - if (hActCtx != ACTCTX_FAKE_HANDLE) + + Status = RtlZombifyActivationContext(hActCtx); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); return FALSE; - return TRUE; -} + } + + return TRUE; +}
Modified: trunk/reactos/include/ndk/rtltypes.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtltypes.h?rev=... ============================================================================== --- trunk/reactos/include/ndk/rtltypes.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/rtltypes.h [iso-8859-1] Tue Jan 20 01:40:15 2009 @@ -742,7 +742,7 @@ // typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME { - struct __RTL_ACTIVATION_CONTEXT_STACK_FRAME *Previous; + struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME *Previous; PACTIVATION_CONTEXT ActivationContext; ULONG Flags; } RTL_ACTIVATION_CONTEXT_STACK_FRAME,
Modified: trunk/reactos/lib/rtl/actctx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/actctx.c?rev=38969&... ============================================================================== --- trunk/reactos/lib/rtl/actctx.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/actctx.c [iso-8859-1] Tue Jan 20 01:40:15 2009 @@ -28,6 +28,24 @@ #define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa) #define ACTCTX_FAKE_COOKIE ((ULONG_PTR) 0xf00bad)
+ +/* INTERNAL FUNCTIONS *******************************************************/ + +static NTSTATUS open_nt_file( HANDLE *handle, UNICODE_STRING *name ) +{ + OBJECT_ATTRIBUTES attr; + IO_STATUS_BLOCK io; + + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.Attributes = OBJ_CASE_INSENSITIVE; + attr.ObjectName = name; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + return NtOpenFile( handle, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); +} + + /* FUNCTIONS ***************************************************************/
VOID @@ -58,10 +76,16 @@ NTAPI RtlGetActiveActivationContext(IN PVOID *Context) { - UNIMPLEMENTED; - + /* + if (NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame) + { + *Context = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame->ActivationContext; + RtlAddRefActivationContext(*Context); + } + else + *Context = 0; + */ *Context = ACTCTX_FAKE_HANDLE; - return STATUS_SUCCESS; }
@@ -80,7 +104,16 @@ IN PUNICODE_STRING SectionName, IN OUT PVOID ReturnedData) { - UNIMPLEMENTED; + PACTCTX_SECTION_KEYED_DATA Data = ReturnedData; + + UNIMPLEMENTED; + + if (!Data || Data->cbSize < offsetof(ACTCTX_SECTION_KEYED_DATA, ulAssemblyRosterIndex) || + !SectionName || !SectionName->Buffer) + { + return STATUS_INVALID_PARAMETER; + } + return STATUS_NOT_IMPLEMENTED; }
@@ -119,6 +152,10 @@ RtlZombifyActivationContext(PVOID Context) { UNIMPLEMENTED; + + if (Context == ACTCTX_FAKE_HANDLE) + return STATUS_SUCCESS; + return STATUS_NOT_IMPLEMENTED; }
@@ -147,11 +184,27 @@ NTAPI RtlActivateActivationContext(IN ULONG Unknown, IN HANDLE Handle, OUT PULONG_PTR Cookie) { + /* + PRTL_ACTIVATION_CONTEXT_STACK_FRAME Frame; + + Frame = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*Frame) ); + if (!Frame) + return STATUS_NO_MEMORY; + + Frame->Previous = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame; + Frame->ActivationContext = Handle; + Frame->Flags = 0; + NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = Frame; + RtlAddRefActivationContext(Handle); + + *Cookie = (ULONG_PTR)Frame; + DPRINT( "%p Cookie=%lx\n", Handle, *Cookie ); + */ + UNIMPLEMENTED;
if (Cookie) *Cookie = ACTCTX_FAKE_COOKIE; - return STATUS_SUCCESS; }
@@ -160,16 +213,61 @@ RtlCreateActivationContext(OUT PHANDLE Handle, IN OUT PVOID ReturnedData) { PCACTCTXW pActCtx = (PCACTCTXW) ReturnedData; - - UNIMPLEMENTED; - - if (!pActCtx) - *Handle = INVALID_HANDLE_VALUE; - if (pActCtx->cbSize != sizeof *pActCtx) - *Handle = INVALID_HANDLE_VALUE; - if (pActCtx->dwFlags & ~ACTCTX_FLAGS_ALL) - *Handle = INVALID_HANDLE_VALUE; + UNICODE_STRING NameW; + NTSTATUS Status = STATUS_SUCCESS; + HANDLE hFile = INVALID_HANDLE_VALUE; + + UNIMPLEMENTED; + + if (!pActCtx || (pActCtx->cbSize < sizeof(*pActCtx)) || + (pActCtx->dwFlags & ~ACTCTX_FLAGS_ALL)) + return STATUS_INVALID_PARAMETER; + + NameW.Buffer = NULL; + if (pActCtx->lpSource) + { + if (!RtlDosPathNameToNtPathName_U(pActCtx->lpSource, &NameW, NULL, NULL)) + { + Status = STATUS_NO_SUCH_FILE; + goto Error; + } + Status = open_nt_file( &hFile, &NameW ); + if (!NT_SUCCESS(Status)) + { + RtlFreeUnicodeString( &NameW ); + goto Error; + } + } + + if (pActCtx->dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID) + { + /* if we have a resource it's a PE file */ + if (pActCtx->dwFlags & ACTCTX_FLAG_HMODULE_VALID) + { + } + else if (pActCtx->lpSource) + { + } + else + { + Status = STATUS_INVALID_PARAMETER; + } + } + else + { + /* manifest file */ + } + + if (hFile) + NtClose( hFile ); + if (NameW.Buffer) + RtlFreeUnicodeString( &NameW ); + *Handle = ACTCTX_FAKE_HANDLE; - - return STATUS_SUCCESS; -} + return Status; + +Error: + if (hFile) NtClose( hFile ); + return Status; + +}