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.

svn path=/trunk/; revision=44371
This commit is contained in:
Michael Martin 2009-12-03 05:42:58 +00:00
parent dfa9eb6204
commit 7dc08676d7
5 changed files with 355 additions and 262 deletions

View file

@ -0,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;
}

View file

@ -61,6 +61,9 @@ static NTSTATUS LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
static NTSTATUS LdrpAttachProcess(VOID); static NTSTATUS LdrpAttachProcess(VOID);
static VOID LdrpDetachProcess(BOOLEAN UnloadAll); static VOID LdrpDetachProcess(BOOLEAN UnloadAll);
NTSTATUS find_actctx_dll( LPCWSTR libname, WCHAR *fulldosname );
NTSTATUS create_module_activation_context( LDR_DATA_TABLE_ENTRY *module );
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
BOOLEAN BOOLEAN
@ -699,13 +702,23 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL,
MAX_PATH, MAX_PATH,
DosName, DosName,
NULL) == 0) 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, if (!RtlDosPathNameToNtPathName_U (DosName,
&FullNtFileName, &FullNtFileName,
NULL, NULL,
NULL)) NULL))
{
DPRINT("Dll %wZ not found!\n", DllName);
return STATUS_DLL_NOT_FOUND; return STATUS_DLL_NOT_FOUND;
}
DPRINT("FullNtFileName %wZ\n", &FullNtFileName); DPRINT("FullNtFileName %wZ\n", &FullNtFileName);
@ -1426,10 +1439,10 @@ LdrpGetOrLoadModule(PWCHAR SearchPath,
if (Load && !NT_SUCCESS(Status)) if (Load && !NT_SUCCESS(Status))
{ {
Status = LdrpLoadModule(SearchPath, Status = LdrpLoadModule(SearchPath,
0, 0,
&DllName, &DllName,
Module, Module,
NULL); NULL);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
Status = LdrFindEntryForName (&DllName, Module, FALSE); Status = LdrFindEntryForName (&DllName, Module, FALSE);
@ -1440,6 +1453,7 @@ LdrpGetOrLoadModule(PWCHAR SearchPath,
ULONG_PTR ErrorParameter = (ULONG_PTR)&DllName; ULONG_PTR ErrorParameter = (ULONG_PTR)&DllName;
DPRINT1("failed to load %wZ\n", &DllName); DPRINT1("failed to load %wZ\n", &DllName);
NtRaiseHardError(STATUS_DLL_NOT_FOUND, NtRaiseHardError(STATUS_DLL_NOT_FOUND,
1, 1,
1, 1,
@ -1761,6 +1775,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
PCHAR ImportedName; PCHAR ImportedName;
PWSTR ModulePath; PWSTR ModulePath;
ULONG Size; ULONG Size;
ULONG_PTR cookie;
DPRINT("LdrFixupImports(SearchPath %S, Module %p)\n", SearchPath, Module); DPRINT("LdrFixupImports(SearchPath %S, Module %p)\n", SearchPath, Module);
@ -1784,6 +1799,16 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
} }
} }
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. * Process each import module.
*/ */
@ -1977,6 +2002,8 @@ Success:
LdrpAcquireTlsSlot(Module, TlsSize, FALSE); LdrpAcquireTlsSlot(Module, TlsSize, FALSE);
} }
if (Module->EntryPointActivationContext) RtlDeactivateActivationContext( 0, cookie );
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -2019,6 +2046,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
PIMAGE_DOS_HEADER DosHeader; PIMAGE_DOS_HEADER DosHeader;
PIMAGE_NT_HEADERS NTHeaders; PIMAGE_NT_HEADERS NTHeaders;
PLDR_DATA_TABLE_ENTRY tmpModule; PLDR_DATA_TABLE_ENTRY tmpModule;
PVOID ActivationContextStack;
DPRINT("LdrPEStartup(ImageBase %p SectionHandle %p)\n", DPRINT("LdrPEStartup(ImageBase %p SectionHandle %p)\n",
ImageBase, SectionHandle); ImageBase, SectionHandle);
@ -2066,6 +2094,19 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
(*Module)->Flags |= LDRP_IMAGE_NOT_AT_BASE; (*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 * If the DLL's imports symbols from other
* modules, fixup the imported calls entry points. * modules, fixup the imported calls entry points.

View file

@ -46,6 +46,7 @@
<directory name="ldr"> <directory name="ldr">
<file>startup.c</file> <file>startup.c</file>
<file>utils.c</file> <file>utils.c</file>
<file>actctx.c</file>
</directory> </directory>
<directory name="rtl"> <directory name="rtl">
<file>libsupp.c</file> <file>libsupp.c</file>

View file

@ -1,13 +1,13 @@
@ stdcall AcquireSRWLockExclusive(ptr) ntdll.RtlAcquireSRWLockExclusive @ stdcall AcquireSRWLockExclusive(ptr) ntdll.RtlAcquireSRWLockExclusive
@ stdcall AcquireSRWLockShare(ptr) ntdll.RtlAcquireSRWLockShared @ stdcall AcquireSRWLockShare(ptr) ntdll.RtlAcquireSRWLockShared
;@ stdcall ActivateActCtx(ptr ptr) @ stdcall ActivateActCtx(ptr ptr)
@ stdcall AddAtomA(str) @ stdcall AddAtomA(str)
@ stdcall AddAtomW(wstr) @ stdcall AddAtomW(wstr)
@ stdcall AddConsoleAliasA(str str str) ;check @ stdcall AddConsoleAliasA(str str str) ;check
@ stdcall AddConsoleAliasW(wstr wstr wstr) ;check @ stdcall AddConsoleAliasW(wstr wstr wstr) ;check
@ stdcall AddLocalAlternateComputerNameA(str ptr) @ stdcall AddLocalAlternateComputerNameA(str ptr)
@ stdcall AddLocalAlternateComputerNameW(wstr ptr) @ stdcall AddLocalAlternateComputerNameW(wstr ptr)
;@ stdcall AddRefActCtx(ptr) @ stdcall AddRefActCtx(ptr)
@ stdcall AddVectoredContinueHandler(long ptr) ntdll.RtlAddVectoredContinueHandler @ stdcall AddVectoredContinueHandler(long ptr) ntdll.RtlAddVectoredContinueHandler
@ stdcall AddVectoredExceptionHandler(long ptr) ntdll.RtlAddVectoredExceptionHandler @ stdcall AddVectoredExceptionHandler(long ptr) ntdll.RtlAddVectoredExceptionHandler
@ stdcall AllocConsole() @ stdcall AllocConsole()
@ -77,8 +77,8 @@
@ stdcall CopyFileExW (wstr wstr ptr ptr ptr long) @ stdcall CopyFileExW (wstr wstr ptr ptr ptr long)
@ stdcall CopyFileW(wstr wstr long) @ stdcall CopyFileW(wstr wstr long)
@ stdcall CopyLZFile(long long) LZCopy @ stdcall CopyLZFile(long long) LZCopy
;@ stdcall CreateActCtxA(ptr) @ stdcall CreateActCtxA(ptr)
;@ stdcall CreateActCtxW(ptr) @ stdcall CreateActCtxW(ptr)
@ stdcall CreateConsoleScreenBuffer(long long ptr long ptr) @ stdcall CreateConsoleScreenBuffer(long long ptr long ptr)
@ stdcall CreateDirectoryA(str ptr) @ stdcall CreateDirectoryA(str ptr)
@ stdcall CreateDirectoryExA(str str ptr) @ stdcall CreateDirectoryExA(str str ptr)
@ -131,7 +131,7 @@
@ stdcall CreateWaitableTimerW(ptr long wstr) @ stdcall CreateWaitableTimerW(ptr long wstr)
@ stdcall CreateWaitableTimerExA (ptr str long long) @ stdcall CreateWaitableTimerExA (ptr str long long)
@ stdcall CreateWaitableTimerExW (ptr wstr long long) @ stdcall CreateWaitableTimerExW (ptr wstr long long)
;@ stdcall DeactivateActCtx(long ptr) @ stdcall DeactivateActCtx(long ptr)
@ stdcall DebugActiveProcess(long) @ stdcall DebugActiveProcess(long)
@ stdcall DebugActiveProcessStop(long) @ stdcall DebugActiveProcessStop(long)
@ stdcall DebugBreak() ntdll.DbgBreakPoint @ stdcall DebugBreak() ntdll.DbgBreakPoint
@ -215,9 +215,9 @@
@ stdcall FillConsoleOutputAttribute(long long long long ptr) @ stdcall FillConsoleOutputAttribute(long long long long ptr)
@ stdcall FillConsoleOutputCharacterA(long long long long ptr) @ stdcall FillConsoleOutputCharacterA(long long long long ptr)
@ stdcall FillConsoleOutputCharacterW(long long long long ptr) @ stdcall FillConsoleOutputCharacterW(long long long long ptr)
;@ stdcall FindActCtxSectionGuid(long ptr long ptr ptr) @ stdcall FindActCtxSectionGuid(long ptr long ptr ptr)
;@ stdcall FindActCtxSectionStringA(long ptr long str ptr) @ stdcall FindActCtxSectionStringA(long ptr long str ptr)
;@ stdcall FindActCtxSectionStringW(long ptr long wstr ptr) @ stdcall FindActCtxSectionStringW(long ptr long wstr ptr)
@ stdcall FindAtomA(str) @ stdcall FindAtomA(str)
@ stdcall FindAtomW(wstr) @ stdcall FindAtomW(wstr)
@ stdcall FindClose(long) @ stdcall FindClose(long)
@ -332,7 +332,7 @@
@ stdcall GetConsoleWindow() @ stdcall GetConsoleWindow()
@ stdcall GetCurrencyFormatA(long long str ptr str long) @ stdcall GetCurrencyFormatA(long long str ptr str long)
@ stdcall GetCurrencyFormatW(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 GetCurrentConsoleFont(long long ptr)
@ stdcall GetCurrentDirectoryA(long ptr) @ stdcall GetCurrentDirectoryA(long ptr)
@ stdcall GetCurrentDirectoryW(long ptr) @ stdcall GetCurrentDirectoryW(long ptr)
@ -697,7 +697,7 @@
@ stdcall ProcessIdToSessionId(long ptr) @ stdcall ProcessIdToSessionId(long ptr)
@ stdcall PulseEvent(long) @ stdcall PulseEvent(long)
@ stdcall PurgeComm(long 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 QueryDepthSList(ptr) ntdll.RtlQueryDepthSList
@ stdcall QueryDosDeviceA(str ptr long) @ stdcall QueryDosDeviceA(str ptr long)
@ stdcall QueryDosDeviceW(wstr ptr long) @ stdcall QueryDosDeviceW(wstr ptr long)
@ -739,7 +739,7 @@
@ stdcall RegisterWaitForSingleObjectEx(long ptr ptr long long) @ stdcall RegisterWaitForSingleObjectEx(long ptr ptr long long)
@ stdcall RegisterWowBaseHandlers(long) @ stdcall RegisterWowBaseHandlers(long)
@ stdcall RegisterWowExec(long) @ stdcall RegisterWowExec(long)
;@ stdcall ReleaseActCtx(ptr) @ stdcall ReleaseActCtx(ptr)
@ stdcall ReleaseMutex(long) @ stdcall ReleaseMutex(long)
@ stdcall ReleaseSemaphore(long long ptr) @ stdcall ReleaseSemaphore(long long ptr)
@ stdcall ReleaseSRWLockExclusive(ptr) ntdll.RtlReleaseSRWLockExclusive @ stdcall ReleaseSRWLockExclusive(ptr) ntdll.RtlReleaseSRWLockExclusive
@ -989,7 +989,7 @@
@ stdcall WriteProfileStringW(wstr wstr wstr) @ stdcall WriteProfileStringW(wstr wstr wstr)
@ stdcall WriteTapemark(ptr long long long) @ stdcall WriteTapemark(ptr long long long)
@ stdcall WTSGetActiveConsoleSessionId() @ stdcall WTSGetActiveConsoleSessionId()
;@ stdcall ZombifyActCtx(ptr) @ stdcall ZombifyActCtx(ptr)
@ stub _DebugOut ; missing in XP SP3 @ stub _DebugOut ; missing in XP SP3
@ stub _DebugPrintf ; missing in XP SP3 @ stub _DebugPrintf ; missing in XP SP3
@ stdcall _hread(long ptr long) @ stdcall _hread(long ptr long)

View file

@ -2,322 +2,282 @@
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: dll/win32/kernel32/misc/actctx.c * FILE: dll/win32/kernel32/misc/actctx.c
* PURPOSE: Comm functions * PURPOSE: Activation contexts
* PROGRAMMERS: Jacek Caban for CodeWeavers * PROGRAMMERS: Jacek Caban for CodeWeavers
* Eric Pouech * Eric Pouech
* Jon Griffiths * Jon Griffiths
* Dmitry Chapyshev (dmitry@reactos.org) * Dmitry Chapyshev (dmitry@reactos.org)
* Samuel Serapión
*/ */
/* synched with wine 1.1.26 */
#include <k32.h> #include <k32.h>
#define NDEBUG #include "wine/debug.h"
#include <debug.h>
#define ACTCTX_FLAGS_ALL (\ WINE_DEFAULT_DEBUG_CHANNEL(actctx);
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 )
#define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa) #define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa)
#define ACTCTX_FAKE_COOKIE ((ULONG_PTR) 0xf00bad)
/* /***********************************************************************
* @implemented * CreateActCtxA (KERNEL32.@)
*
* Create an activation context.
*/ */
BOOL HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
WINAPI
FindActCtxSectionStringA(
DWORD dwFlags,
const GUID *lpExtensionGuid,
ULONG ulSectionId,
LPCSTR lpStringToFind,
PACTCTX_SECTION_KEYED_DATA ReturnedData
)
{ {
BOOL bRetVal; ACTCTXW actw;
LPWSTR lpStringToFindW = NULL; SIZE_T len;
HANDLE ret = INVALID_HANDLE_VALUE;
LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
/* Convert lpStringToFind */ TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
if (lpStringToFind)
if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
{ {
BasepAnsiStringToHeapUnicodeString(lpStringToFind, SetLastError(ERROR_INVALID_PARAMETER);
(LPWSTR*) &lpStringToFindW); return INVALID_HANDLE_VALUE;
} }
/* Call the Unicode function */ actw.cbSize = sizeof(actw);
bRetVal = FindActCtxSectionStringW(dwFlags, actw.dwFlags = pActCtx->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 */
if (pActCtx->lpSource) if (pActCtx->lpSource)
{ {
BasepAnsiStringToHeapUnicodeString(pActCtx->lpSource, len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, NULL, 0);
(LPWSTR*) &pActCtxW.lpSource); src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!src) return INVALID_HANDLE_VALUE;
MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, src, len);
} }
if (pActCtx->lpAssemblyDirectory) actw.lpSource = src;
{
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 */ if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpSource); actw.wProcessorArchitecture = pActCtx->wProcessorArchitecture;
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpAssemblyDirectory); if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
if (HIWORD(pActCtx->lpResourceName)) actw.wLangId = pActCtx->wLangId;
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpResourceName); if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) pActCtxW.lpApplicationName); {
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;
return hRetVal; ret = CreateActCtxW(&actw);
done:
HeapFree(GetProcessHeap(), 0, src);
HeapFree(GetProcessHeap(), 0, assdir);
HeapFree(GetProcessHeap(), 0, resname);
HeapFree(GetProcessHeap(), 0, appname);
return ret;
} }
/* /***********************************************************************
* @unimplemented * CreateActCtxW (KERNEL32.@)
*
* Create an activation context.
*/ */
BOOL HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
WINAPI
ActivateActCtx(
HANDLE hActCtx,
ULONG_PTR *ulCookie
)
{ {
NTSTATUS Status; 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);
RtlAddRefActivationContext(hActCtx);
}
/*
* @unimplemented
*/
HANDLE
WINAPI
CreateActCtxW(
PCACTCTXW pActCtx
)
{
NTSTATUS Status;
HANDLE hActCtx; HANDLE hActCtx;
DPRINT("CreateActCtxW(%p %08lx)\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0); TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
Status = RtlCreateActivationContext(&hActCtx, (PVOID*)&pActCtx); if ((status = RtlCreateActivationContext(&hActCtx, (PVOID*)pActCtx)))
if (!NT_SUCCESS(Status))
{ {
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(status));
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
return hActCtx; return hActCtx;
} }
/* /***********************************************************************
* @unimplemented * ActivateActCtx (KERNEL32.@)
*
* Activate an activation context.
*/ */
BOOL BOOL WINAPI ActivateActCtx(HANDLE hActCtx, ULONG_PTR *ulCookie)
WINAPI
DeactivateActCtx(
DWORD dwFlags,
ULONG_PTR ulCookie
)
{ {
NTSTATUS Status; NTSTATUS status;
DPRINT("DeactivateActCtx(%08lx %08lx)\n", dwFlags, ulCookie); if ((status = RtlActivateActivationContext( 0, hActCtx, 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__);
return FALSE;
}
/*
* @unimplemented
*/
BOOL
WINAPI
FindActCtxSectionStringW(
DWORD dwFlags,
const GUID *lpExtensionGuid,
ULONG ulSectionId,
LPCWSTR lpStringToFind,
PACTCTX_SECTION_KEYED_DATA ReturnedData
)
{
UNICODE_STRING us;
NTSTATUS Status;
RtlInitUnicodeString(&us, lpStringToFind);
Status = RtlFindActivationContextSectionString(dwFlags, lpExtensionGuid, ulSectionId, &us, ReturnedData);
if (!NT_SUCCESS(Status))
{ {
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(status));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
/* /***********************************************************************
* @unimplemented * DeactivateActCtx (KERNEL32.@)
*
* Deactivate an activation context.
*/ */
BOOL BOOL WINAPI DeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
WINAPI
GetCurrentActCtx(
HANDLE *phActCtx)
{ {
NTSTATUS Status; RtlDeactivateActivationContext( dwFlags, ulCookie );
return TRUE;
}
DPRINT("GetCurrentActCtx(%p)\n", phActCtx); /***********************************************************************
Status = RtlGetActiveActivationContext(phActCtx); * GetCurrentActCtx (KERNEL32.@)
if (!NT_SUCCESS(Status)) *
* Get the current activation context.
*/
BOOL WINAPI GetCurrentActCtx(HANDLE* phActCtx)
{
NTSTATUS status;
if ((status = RtlGetActiveActivationContext(phActCtx)))
{ {
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(status));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
/* /***********************************************************************
* @unimplemented * AddRefActCtx (KERNEL32.@)
*
* Add a reference to an activation context.
*/ */
BOOL void WINAPI AddRefActCtx(HANDLE hActCtx)
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__); RtlAddRefActivationContext(hActCtx);
/* this makes Adobe Photoshop 7.0 happy */
SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
} }
/* /***********************************************************************
* @unimplemented * ReleaseActCtx (KERNEL32.@)
*
* Release a reference to an activation context.
*/ */
VOID void WINAPI ReleaseActCtx(HANDLE hActCtx)
WINAPI
ReleaseActCtx(
HANDLE hActCtx
)
{ {
DPRINT("ReleaseActCtx(%p)\n", hActCtx);
RtlReleaseActivationContext(hActCtx); RtlReleaseActivationContext(hActCtx);
} }
/* /***********************************************************************
* @unimplemented * ZombifyActCtx (KERNEL32.@)
*
* Release a reference to an activation context.
*/ */
BOOL BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
WINAPI
ZombifyActCtx(
HANDLE hActCtx
)
{ {
NTSTATUS Status; FIXME("%p\n", hActCtx);
DPRINT("ZombifyActCtx(%p)\n", hActCtx); if (hActCtx != ACTCTX_FAKE_HANDLE)
return FALSE;
return TRUE;
}
Status = RtlZombifyActivationContext(hActCtx); /***********************************************************************
if (!NT_SUCCESS(Status)) * 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(RtlNtStatusToDosError(Status)); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; 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, 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; return TRUE;
} }