Author: mjmartin
Date: Thu Dec 3 06:42:58 2009
New Revision: 44371
URL:
http://svn.reactos.org/svn/reactos?rev=44371&view=rev
Log:
SXS Support Part 2 of 2.
[dll/ntdll]
- Import find_actctx_dll from WINE. Add create_module_activation_context based on WINE.
- Search for an active context dlls during mapping dll's in LdrpMapDllImageFile.
- Allocate memory for the ActivationContextStackPointer when loading the executable image
in LdrPEStartup.
[dll/kernel32]
- Import kernel32 ActCtx related apis from WINE.
Now active.
Added:
trunk/reactos/dll/ntdll/ldr/actctx.c (with props)
Modified:
trunk/reactos/dll/ntdll/ldr/utils.c
trunk/reactos/dll/ntdll/ntdll.rbuild
trunk/reactos/dll/win32/kernel32/kernel32.pspec
trunk/reactos/dll/win32/kernel32/misc/actctx.c
Added: trunk/reactos/dll/ntdll/ldr/actctx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/actctx.c?rev…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/actctx.c (added)
+++ trunk/reactos/dll/ntdll/ldr/actctx.c [iso-8859-1] Thu Dec 3 06:42:58 2009
@@ -1,0 +1,91 @@
+
+#include <ntdll.h>
+#define NDEBUG
+#include <debug.h>
+
+#include "wine/unicode.h"
+
+
+/***********************************************************************
+ * create_module_activation_context
+ */
+NTSTATUS create_module_activation_context( LDR_DATA_TABLE_ENTRY *module )
+{
+ NTSTATUS status;
+ LDR_RESOURCE_INFO info;
+ IMAGE_RESOURCE_DATA_ENTRY *entry;
+
+ info.Type = (ULONG)RT_MANIFEST;
+ info.Name = (ULONG)ISOLATIONAWARE_MANIFEST_RESOURCE_ID;
+ info.Language = 0;
+ if (!(status = LdrFindResource_U( module->DllBase, &info, 3, &entry )))
+ {
+ ACTCTXW ctx;
+ ctx.cbSize = sizeof(ctx);
+ ctx.lpSource = NULL;
+ ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
+ ctx.hModule = module->DllBase;
+ ctx.lpResourceName = (LPCWSTR)ISOLATIONAWARE_MANIFEST_RESOURCE_ID;
+ status = RtlCreateActivationContext( &module->EntryPointActivationContext,
&ctx );
+ }
+ return status;
+}
+
+NTSTATUS find_actctx_dll( LPCWSTR libname, WCHAR *fullname )
+{
+ static const WCHAR winsxsW[] =
{'\\','w','i','n','s','x','s','\\',0};
+ /* FIXME: Handle modules that have a private manifest file
+ static const WCHAR dotManifestW[] =
{'.','m','a','n','i','f','e','s','t',0};
*/
+
+ ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info;
+ ACTCTX_SECTION_KEYED_DATA data;
+ UNICODE_STRING nameW;
+ NTSTATUS status;
+ SIZE_T needed, size = 1024;
+
+ RtlInitUnicodeString( &nameW, libname );
+ data.cbSize = sizeof(data);
+ status = RtlFindActivationContextSectionString(
FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
+
ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
+ &nameW, &data );
+ if (status != STATUS_SUCCESS) return status;
+
+ for (;;)
+ {
+ if (!(info = RtlAllocateHeap( RtlGetProcessHeap(), 0, size )))
+ {
+ status = STATUS_NO_MEMORY;
+ goto done;
+ }
+ status = RtlQueryInformationActivationContext( 0, data.hActCtx,
&data.ulAssemblyRosterIndex,
+
AssemblyDetailedInformationInActivationContext,
+ info, size, &needed );
+ if (status == STATUS_SUCCESS) break;
+ if (status != STATUS_BUFFER_TOO_SMALL) goto done;
+ RtlFreeHeap( RtlGetProcessHeap(), 0, info );
+ size = needed;
+ }
+
+ DPRINT1("manafestpath === %S\n", info->lpAssemblyManifestPath);
+ DPRINT1("DirectoryName === %S\n", info->lpAssemblyDirectoryName);
+ if (!info->lpAssemblyManifestPath || !info->lpAssemblyDirectoryName)
+ {
+ status = STATUS_SXS_KEY_NOT_FOUND;
+ goto done;
+ }
+
+ DPRINT("%S. %S\n", info->lpAssemblyManifestPath,
info->lpAssemblyDirectoryName);
+ wcscpy(fullname , SharedUserData->NtSystemRoot);
+ wcscat(fullname, winsxsW);
+ wcscat(fullname, info->lpAssemblyDirectoryName);
+ wcscat(fullname, L"\\");
+ wcscat(fullname, libname);
+ DPRINT("Successfully found a side by side %S\n", fullname);
+ status = STATUS_SUCCESS;
+
+done:
+ RtlFreeHeap( RtlGetProcessHeap(), 0, info );
+ RtlReleaseActivationContext( data.hActCtx );
+ DPRINT("%S\n", fullname);
+ return status;
+}
Propchange: trunk/reactos/dll/ntdll/ldr/actctx.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/ntdll/ldr/actctx.c
------------------------------------------------------------------------------
svn:keywords = author date id revision
Modified: trunk/reactos/dll/ntdll/ldr/utils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/utils.c?rev=…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] Thu Dec 3 06:42:58 2009
@@ -60,6 +60,9 @@
OUT PVOID *BaseAddress OPTIONAL);
static NTSTATUS LdrpAttachProcess(VOID);
static VOID LdrpDetachProcess(BOOLEAN UnloadAll);
+
+NTSTATUS find_actctx_dll( LPCWSTR libname, WCHAR *fulldosname );
+NTSTATUS create_module_activation_context( LDR_DATA_TABLE_ENTRY *module );
/* FUNCTIONS *****************************************************************/
@@ -699,13 +702,23 @@
MAX_PATH,
DosName,
NULL) == 0)
- return STATUS_DLL_NOT_FOUND;
+ {
+ /* try to find active context dll */
+ Status = find_actctx_dll(DllName->Buffer, DosName);
+ if(Status == STATUS_SUCCESS)
+ DPRINT("found %S for %S\n", DosName,DllName->Buffer);
+ else
+ return STATUS_DLL_NOT_FOUND;
+ }
if (!RtlDosPathNameToNtPathName_U (DosName,
&FullNtFileName,
NULL,
NULL))
+ {
+ DPRINT("Dll %wZ not found!\n", DllName);
return STATUS_DLL_NOT_FOUND;
+ }
DPRINT("FullNtFileName %wZ\n", &FullNtFileName);
@@ -1426,10 +1439,10 @@
if (Load && !NT_SUCCESS(Status))
{
Status = LdrpLoadModule(SearchPath,
- 0,
+ 0,
&DllName,
Module,
- NULL);
+ NULL);
if (NT_SUCCESS(Status))
{
Status = LdrFindEntryForName (&DllName, Module, FALSE);
@@ -1440,6 +1453,7 @@
ULONG_PTR ErrorParameter = (ULONG_PTR)&DllName;
DPRINT1("failed to load %wZ\n", &DllName);
+
NtRaiseHardError(STATUS_DLL_NOT_FOUND,
1,
1,
@@ -1761,6 +1775,7 @@
PCHAR ImportedName;
PWSTR ModulePath;
ULONG Size;
+ ULONG_PTR cookie;
DPRINT("LdrFixupImports(SearchPath %S, Module %p)\n", SearchPath, Module);
@@ -1783,6 +1798,16 @@
TlsDirectory = NULL;
}
}
+
+ if (!create_module_activation_context( Module ))
+ {
+ if (Module->EntryPointActivationContext == NULL)
+ {
+ DPRINT("EntryPointActivationContext has not be allocated\n");
+ DPRINT("Module->DllBaseName %wZ\n", Module->BaseDllName);
+ }
+ RtlActivateActivationContext( 0, Module->EntryPointActivationContext,
&cookie );
+ }
/*
* Process each import module.
@@ -1977,6 +2002,8 @@
LdrpAcquireTlsSlot(Module, TlsSize, FALSE);
}
+ if (Module->EntryPointActivationContext) RtlDeactivateActivationContext( 0, cookie
);
+
return STATUS_SUCCESS;
}
@@ -2019,6 +2046,7 @@
PIMAGE_DOS_HEADER DosHeader;
PIMAGE_NT_HEADERS NTHeaders;
PLDR_DATA_TABLE_ENTRY tmpModule;
+ PVOID ActivationContextStack;
DPRINT("LdrPEStartup(ImageBase %p SectionHandle %p)\n",
ImageBase, SectionHandle);
@@ -2065,6 +2093,19 @@
{
(*Module)->Flags |= LDRP_IMAGE_NOT_AT_BASE;
}
+
+ /* Allocate memory for the ActivationContextStack */
+ /* FIXME: Verify RtlAllocateActivationContextStack behavior */
+ Status = RtlAllocateActivationContextStack(&ActivationContextStack);
+ if (NT_SUCCESS(Status))
+ {
+ DPRINT("ActivationContextStack %x\n",ActivationContextStack);
+ DPRINT("ActiveFrame %x\n",
((PACTIVATION_CONTEXT_STACK)ActivationContextStack)->ActiveFrame);
+ NtCurrentTeb()->ActivationContextStackPointer = ActivationContextStack;
+ NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = NULL;
+ }
+ else
+ DPRINT1("Warning: Unable to allocate ActivationContextStack\n");
/*
* If the DLL's imports symbols from other
Modified: trunk/reactos/dll/ntdll/ntdll.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ntdll.rbuild?rev…
==============================================================================
--- trunk/reactos/dll/ntdll/ntdll.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ntdll.rbuild [iso-8859-1] Thu Dec 3 06:42:58 2009
@@ -46,6 +46,7 @@
<directory name="ldr">
<file>startup.c</file>
<file>utils.c</file>
+ <file>actctx.c</file>
</directory>
<directory name="rtl">
<file>libsupp.c</file>
Modified: trunk/reactos/dll/win32/kernel32/kernel32.pspec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel3…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] Thu Dec 3 06:42:58 2009
@@ -1,13 +1,13 @@
@ stdcall AcquireSRWLockExclusive(ptr) ntdll.RtlAcquireSRWLockExclusive
@ stdcall AcquireSRWLockShare(ptr) ntdll.RtlAcquireSRWLockShared
-;@ stdcall ActivateActCtx(ptr ptr)
+@ stdcall ActivateActCtx(ptr ptr)
@ stdcall AddAtomA(str)
@ stdcall AddAtomW(wstr)
@ stdcall AddConsoleAliasA(str str str) ;check
@ stdcall AddConsoleAliasW(wstr wstr wstr) ;check
@ stdcall AddLocalAlternateComputerNameA(str ptr)
@ stdcall AddLocalAlternateComputerNameW(wstr ptr)
-;@ stdcall AddRefActCtx(ptr)
+@ stdcall AddRefActCtx(ptr)
@ stdcall AddVectoredContinueHandler(long ptr) ntdll.RtlAddVectoredContinueHandler
@ stdcall AddVectoredExceptionHandler(long ptr) ntdll.RtlAddVectoredExceptionHandler
@ stdcall AllocConsole()
@@ -77,8 +77,8 @@
@ stdcall CopyFileExW (wstr wstr ptr ptr ptr long)
@ stdcall CopyFileW(wstr wstr long)
@ stdcall CopyLZFile(long long) LZCopy
-;@ stdcall CreateActCtxA(ptr)
-;@ stdcall CreateActCtxW(ptr)
+@ stdcall CreateActCtxA(ptr)
+@ stdcall CreateActCtxW(ptr)
@ stdcall CreateConsoleScreenBuffer(long long ptr long ptr)
@ stdcall CreateDirectoryA(str ptr)
@ stdcall CreateDirectoryExA(str str ptr)
@@ -131,7 +131,7 @@
@ stdcall CreateWaitableTimerW(ptr long wstr)
@ stdcall CreateWaitableTimerExA (ptr str long long)
@ stdcall CreateWaitableTimerExW (ptr wstr long long)
-;@ stdcall DeactivateActCtx(long ptr)
+@ stdcall DeactivateActCtx(long ptr)
@ stdcall DebugActiveProcess(long)
@ stdcall DebugActiveProcessStop(long)
@ stdcall DebugBreak() ntdll.DbgBreakPoint
@@ -215,9 +215,9 @@
@ stdcall FillConsoleOutputAttribute(long long long long ptr)
@ stdcall FillConsoleOutputCharacterA(long long long long ptr)
@ stdcall FillConsoleOutputCharacterW(long long long long ptr)
-;@ stdcall FindActCtxSectionGuid(long ptr long ptr ptr)
-;@ stdcall FindActCtxSectionStringA(long ptr long str ptr)
-;@ stdcall FindActCtxSectionStringW(long ptr long wstr ptr)
+@ stdcall FindActCtxSectionGuid(long ptr long ptr ptr)
+@ stdcall FindActCtxSectionStringA(long ptr long str ptr)
+@ stdcall FindActCtxSectionStringW(long ptr long wstr ptr)
@ stdcall FindAtomA(str)
@ stdcall FindAtomW(wstr)
@ stdcall FindClose(long)
@@ -332,7 +332,7 @@
@ stdcall GetConsoleWindow()
@ stdcall GetCurrencyFormatA(long long str ptr str long)
@ stdcall GetCurrencyFormatW(long long str ptr str long)
-;@ stdcall GetCurrentActCtx(ptr)
+@ stdcall GetCurrentActCtx(ptr)
@ stdcall GetCurrentConsoleFont(long long ptr)
@ stdcall GetCurrentDirectoryA(long ptr)
@ stdcall GetCurrentDirectoryW(long ptr)
@@ -697,7 +697,7 @@
@ stdcall ProcessIdToSessionId(long ptr)
@ stdcall PulseEvent(long)
@ stdcall PurgeComm(long long)
-;@ stdcall QueryActCtxW(long ptr ptr long ptr long ptr)
+@ stdcall QueryActCtxW(long ptr ptr long ptr long ptr)
@ stdcall QueryDepthSList(ptr) ntdll.RtlQueryDepthSList
@ stdcall QueryDosDeviceA(str ptr long)
@ stdcall QueryDosDeviceW(wstr ptr long)
@@ -739,7 +739,7 @@
@ stdcall RegisterWaitForSingleObjectEx(long ptr ptr long long)
@ stdcall RegisterWowBaseHandlers(long)
@ stdcall RegisterWowExec(long)
-;@ stdcall ReleaseActCtx(ptr)
+@ stdcall ReleaseActCtx(ptr)
@ stdcall ReleaseMutex(long)
@ stdcall ReleaseSemaphore(long long ptr)
@ stdcall ReleaseSRWLockExclusive(ptr) ntdll.RtlReleaseSRWLockExclusive
@@ -989,7 +989,7 @@
@ stdcall WriteProfileStringW(wstr wstr wstr)
@ stdcall WriteTapemark(ptr long long long)
@ stdcall WTSGetActiveConsoleSessionId()
-;@ stdcall ZombifyActCtx(ptr)
+@ stdcall ZombifyActCtx(ptr)
@ stub _DebugOut ; missing in XP SP3
@ stub _DebugPrintf ; missing in XP SP3
@ stdcall _hread(long ptr long)
Modified: trunk/reactos/dll/win32/kernel32/misc/actctx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ac…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/actctx.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/actctx.c [iso-8859-1] Thu Dec 3 06:42:58 2009
@@ -2,322 +2,282 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: dll/win32/kernel32/misc/actctx.c
- * PURPOSE: Comm functions
+ * PURPOSE: Activation contexts
* PROGRAMMERS: Jacek Caban for CodeWeavers
* Eric Pouech
* Jon Griffiths
* Dmitry Chapyshev (dmitry(a)reactos.org)
- */
+ * Samuel Serapión
+ */
+
+/* synched with wine 1.1.26 */
#include <k32.h>
-#define NDEBUG
-#include <debug.h>
-
-#define ACTCTX_FLAGS_ALL (\
- ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID |\
- ACTCTX_FLAG_LANGID_VALID |\
- ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID |\
- ACTCTX_FLAG_RESOURCE_NAME_VALID |\
- ACTCTX_FLAG_SET_PROCESS_DEFAULT |\
- ACTCTX_FLAG_APPLICATION_NAME_VALID |\
- ACTCTX_FLAG_SOURCE_IS_ASSEMBLYREF |\
- ACTCTX_FLAG_HMODULE_VALID )
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(actctx);
#define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa)
-#define ACTCTX_FAKE_COOKIE ((ULONG_PTR) 0xf00bad)
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-FindActCtxSectionStringA(
- DWORD dwFlags,
- const GUID *lpExtensionGuid,
- ULONG ulSectionId,
- LPCSTR lpStringToFind,
- PACTCTX_SECTION_KEYED_DATA ReturnedData
- )
-{
- BOOL bRetVal;
- LPWSTR lpStringToFindW = NULL;
-
- /* Convert lpStringToFind */
- if (lpStringToFind)
- {
- BasepAnsiStringToHeapUnicodeString(lpStringToFind,
- (LPWSTR*) &lpStringToFindW);
- }
-
- /* Call the Unicode function */
- bRetVal = FindActCtxSectionStringW(dwFlags,
- lpExtensionGuid,
- ulSectionId,
- lpStringToFindW,
- ReturnedData);
-
- /* Clean up */
- if (lpStringToFindW)
- RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpStringToFindW);
-
- return bRetVal;
-}
-
-
-/*
- * @implemented
- */
-HANDLE
-WINAPI
-CreateActCtxA(
- PCACTCTXA pActCtx
- )
-{
- ACTCTXW pActCtxW;
- HANDLE hRetVal;
-
- ZeroMemory(&pActCtxW, sizeof(ACTCTXW));
- pActCtxW.cbSize = sizeof(ACTCTXW);
- pActCtxW.dwFlags = pActCtx->dwFlags;
- pActCtxW.wLangId = pActCtx->wLangId;
- pActCtxW.hModule = pActCtx->hModule;
- pActCtxW.wProcessorArchitecture = pActCtx->wProcessorArchitecture;
-
- pActCtxW.hModule = pActCtx->hModule;
-
- /* Convert ActCtx Strings */
+
+/***********************************************************************
+ * CreateActCtxA (KERNEL32.@)
+ *
+ * Create an activation context.
+ */
+HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
+{
+ ACTCTXW actw;
+ SIZE_T len;
+ HANDLE ret = INVALID_HANDLE_VALUE;
+ LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
+
+ TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
+
+ if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return INVALID_HANDLE_VALUE;
+ }
+
+ actw.cbSize = sizeof(actw);
+ actw.dwFlags = pActCtx->dwFlags;
if (pActCtx->lpSource)
{
- BasepAnsiStringToHeapUnicodeString(pActCtx->lpSource,
- (LPWSTR*) &pActCtxW.lpSource);
- }
- if (pActCtx->lpAssemblyDirectory)
- {
- BasepAnsiStringToHeapUnicodeString(pActCtx->lpAssemblyDirectory,
- (LPWSTR*) &pActCtxW.lpAssemblyDirectory);
- }
- if (HIWORD(pActCtx->lpResourceName))
- {
- BasepAnsiStringToHeapUnicodeString(pActCtx->lpResourceName,
- (LPWSTR*) &pActCtxW.lpResourceName);
- }
- else
- {
- pActCtxW.lpResourceName = (LPWSTR) pActCtx->lpResourceName;
- }
- if (pActCtx->lpApplicationName)
- {
- BasepAnsiStringToHeapUnicodeString(pActCtx->lpApplicationName,
- (LPWSTR*) &pActCtxW.lpApplicationName);
- }
- /* Call the Unicode function */
- hRetVal = CreateActCtxW(&pActCtxW);
-
- /* Clean up */
- RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpSource);
- RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpAssemblyDirectory);
- if (HIWORD(pActCtx->lpResourceName))
- RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpResourceName);
- RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpApplicationName);
-
- return hRetVal;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-ActivateActCtx(
- HANDLE hActCtx,
- ULONG_PTR *ulCookie
- )
-{
- NTSTATUS Status;
-
- DPRINT("ActivateActCtx(%p %p)\n", hActCtx, ulCookie );
-
- Status = RtlActivateActivationContext(0, hActCtx, ulCookie);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-VOID
-WINAPI
-AddRefActCtx(
- HANDLE hActCtx
- )
-{
- DPRINT("AddRefActCtx(%p)\n", hActCtx);
+ len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, NULL, 0);
+ src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!src) return INVALID_HANDLE_VALUE;
+ MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, src, len);
+ }
+ actw.lpSource = src;
+
+ if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
+ actw.wProcessorArchitecture = pActCtx->wProcessorArchitecture;
+ if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
+ actw.wLangId = pActCtx->wLangId;
+ if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, NULL,
0);
+ assdir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!assdir) goto done;
+ MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, assdir,
len);
+ actw.lpAssemblyDirectory = assdir;
+ }
+ if (actw.dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID)
+ {
+ if ((ULONG_PTR)pActCtx->lpResourceName >> 16)
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, NULL,
0);
+ resname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!resname) goto done;
+ MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, resname,
len);
+ actw.lpResourceName = resname;
+ }
+ else actw.lpResourceName = (LPCWSTR)pActCtx->lpResourceName;
+ }
+ if (actw.dwFlags & ACTCTX_FLAG_APPLICATION_NAME_VALID)
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, NULL,
0);
+ appname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!appname) goto done;
+ MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, appname, len);
+ actw.lpApplicationName = appname;
+ }
+ if (actw.dwFlags & ACTCTX_FLAG_HMODULE_VALID)
+ actw.hModule = pActCtx->hModule;
+
+ ret = CreateActCtxW(&actw);
+
+done:
+ HeapFree(GetProcessHeap(), 0, src);
+ HeapFree(GetProcessHeap(), 0, assdir);
+ HeapFree(GetProcessHeap(), 0, resname);
+ HeapFree(GetProcessHeap(), 0, appname);
+ return ret;
+}
+
+/***********************************************************************
+ * CreateActCtxW (KERNEL32.@)
+ *
+ * Create an activation context.
+ */
+HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
+{
+ NTSTATUS status;
+ HANDLE hActCtx;
+
+ TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
+
+ if ((status = RtlCreateActivationContext(&hActCtx, (PVOID*)pActCtx)))
+ {
+ SetLastError(RtlNtStatusToDosError(status));
+ return INVALID_HANDLE_VALUE;
+ }
+ 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);
}
-/*
- * @unimplemented
- */
-HANDLE
-WINAPI
-CreateActCtxW(
- PCACTCTXW pActCtx
- )
-{
- NTSTATUS Status;
- HANDLE hActCtx;
-
- DPRINT("CreateActCtxW(%p %08lx)\n", pActCtx, pActCtx ? pActCtx->dwFlags
: 0);
-
- Status = RtlCreateActivationContext(&hActCtx, (PVOID*)&pActCtx);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return INVALID_HANDLE_VALUE;
- }
- return hActCtx;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-DeactivateActCtx(
- DWORD dwFlags,
- ULONG_PTR ulCookie
- )
-{
- NTSTATUS Status;
-
- DPRINT("DeactivateActCtx(%08lx %08lx)\n", dwFlags, ulCookie);
- Status = RtlDeactivateActivationContext(dwFlags, ulCookie);
-
- if (!NT_SUCCESS(Status)) return FALSE;
-
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-FindActCtxSectionGuid(
- DWORD dwFlags,
- const GUID *lpExtensionGuid,
- ULONG ulSectionId,
- const GUID *lpGuidToFind,
- PACTCTX_SECTION_KEYED_DATA ReturnedData
- )
-{
- DPRINT("%s() is UNIMPLEMENTED!\n", __FUNCTION__);
+/***********************************************************************
+ * 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;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-FindActCtxSectionStringW(
- DWORD dwFlags,
- const GUID *lpExtensionGuid,
- ULONG ulSectionId,
- LPCWSTR lpStringToFind,
- PACTCTX_SECTION_KEYED_DATA ReturnedData
- )
+ return TRUE;
+}
+
+/***********************************************************************
+ * FindActCtxSectionStringA (KERNEL32.@)
+ *
+ * Find information about a GUID in an activation context.
+ */
+BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID* lpExtGuid,
+ ULONG ulId, LPCSTR lpSearchStr,
+ PACTCTX_SECTION_KEYED_DATA pInfo)
+{
+ LPWSTR search_str;
+ DWORD len;
+ BOOL ret;
+
+ TRACE("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
+ ulId, debugstr_a(lpSearchStr), pInfo);
+
+ if (!lpSearchStr)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ len = MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, NULL, 0);
+ search_str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, search_str, len);
+
+ ret = FindActCtxSectionStringW(dwFlags, lpExtGuid, ulId, search_str, pInfo);
+
+ HeapFree(GetProcessHeap(), 0, search_str);
+ return ret;
+}
+
+/***********************************************************************
+ * FindActCtxSectionStringW (KERNEL32.@)
+ *
+ * Find information about a GUID in an activation context.
+ */
+BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID* lpExtGuid,
+ ULONG ulId, LPCWSTR lpSearchStr,
+ PACTCTX_SECTION_KEYED_DATA pInfo)
{
UNICODE_STRING us;
- NTSTATUS Status;
-
- RtlInitUnicodeString(&us, lpStringToFind);
- Status = RtlFindActivationContextSectionString(dwFlags, lpExtensionGuid, ulSectionId,
&us, ReturnedData);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-GetCurrentActCtx(
- HANDLE *phActCtx)
-{
- NTSTATUS Status;
-
- DPRINT("GetCurrentActCtx(%p)\n", phActCtx);
- Status = RtlGetActiveActivationContext(phActCtx);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-QueryActCtxW(
- DWORD dwFlags,
- HANDLE hActCtx,
- PVOID pvSubInstance,
- ULONG ulInfoClass,
- PVOID pvBuffer,
- SIZE_T cbBuffer OPTIONAL,
- SIZE_T *pcbWrittenOrRequired OPTIONAL
- )
-{
- DPRINT("%s() is UNIMPLEMENTED!\n", __FUNCTION__);
- /* this makes Adobe Photoshop 7.0 happy */
- SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
-
-/*
- * @unimplemented
- */
-VOID
-WINAPI
-ReleaseActCtx(
- HANDLE hActCtx
- )
-{
- DPRINT("ReleaseActCtx(%p)\n", hActCtx);
- RtlReleaseActivationContext(hActCtx);
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-ZombifyActCtx(
- HANDLE hActCtx
- )
-{
- NTSTATUS Status;
- DPRINT("ZombifyActCtx(%p)\n", hActCtx);
-
- Status = RtlZombifyActivationContext(hActCtx);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
-}
+ NTSTATUS status;
+
+ RtlInitUnicodeString(&us, lpSearchStr);
+ if ((status = RtlFindActivationContextSectionString(dwFlags, lpExtGuid, ulId,
&us, pInfo)))
+ {
+ SetLastError(RtlNtStatusToDosError(status));
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/***********************************************************************
+ * FindActCtxSectionGuid (KERNEL32.@)
+ *
+ * Find information about a GUID in an activation context.
+ */
+BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID* lpExtGuid,
+ ULONG ulId, const GUID* lpSearchGuid,
+ PACTCTX_SECTION_KEYED_DATA pInfo)
+{
+ FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
+ ulId, debugstr_guid(lpSearchGuid), pInfo);
+ SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
+ 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;
+}