mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 16:10:29 +00:00
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:
parent
dfa9eb6204
commit
7dc08676d7
5 changed files with 355 additions and 262 deletions
91
reactos/dll/ntdll/ldr/actctx.c
Normal file
91
reactos/dll/ntdll/ldr/actctx.c
Normal 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;
|
||||
}
|
|
@ -61,6 +61,9 @@ static NTSTATUS LdrpLoadModule(IN PWSTR SearchPath 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 *****************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
|
@ -699,13 +702,23 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL,
|
|||
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 @@ LdrpGetOrLoadModule(PWCHAR SearchPath,
|
|||
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 @@ LdrpGetOrLoadModule(PWCHAR SearchPath,
|
|||
ULONG_PTR ErrorParameter = (ULONG_PTR)&DllName;
|
||||
|
||||
DPRINT1("failed to load %wZ\n", &DllName);
|
||||
|
||||
NtRaiseHardError(STATUS_DLL_NOT_FOUND,
|
||||
1,
|
||||
1,
|
||||
|
@ -1761,6 +1775,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
|||
PCHAR ImportedName;
|
||||
PWSTR ModulePath;
|
||||
ULONG Size;
|
||||
ULONG_PTR cookie;
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -1977,6 +2002,8 @@ Success:
|
|||
LdrpAcquireTlsSlot(Module, TlsSize, FALSE);
|
||||
}
|
||||
|
||||
if (Module->EntryPointActivationContext) RtlDeactivateActivationContext( 0, cookie );
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2019,6 +2046,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
|
|||
PIMAGE_DOS_HEADER DosHeader;
|
||||
PIMAGE_NT_HEADERS NTHeaders;
|
||||
PLDR_DATA_TABLE_ENTRY tmpModule;
|
||||
PVOID ActivationContextStack;
|
||||
|
||||
DPRINT("LdrPEStartup(ImageBase %p SectionHandle %p)\n",
|
||||
ImageBase, SectionHandle);
|
||||
|
@ -2066,6 +2094,19 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
|
|||
(*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
|
||||
* modules, fixup the imported calls entry points.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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@reactos.org)
|
||||
* Samuel Serapión
|
||||
*/
|
||||
|
||||
/* synched with wine 1.1.26 */
|
||||
|
||||
#include <k32.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include "wine/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 )
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(actctx);
|
||||
|
||||
#define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa)
|
||||
#define ACTCTX_FAKE_COOKIE ((ULONG_PTR) 0xf00bad)
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
/***********************************************************************
|
||||
* CreateActCtxA (KERNEL32.@)
|
||||
*
|
||||
* Create an activation context.
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
FindActCtxSectionStringA(
|
||||
DWORD dwFlags,
|
||||
const GUID *lpExtensionGuid,
|
||||
ULONG ulSectionId,
|
||||
LPCSTR lpStringToFind,
|
||||
PACTCTX_SECTION_KEYED_DATA ReturnedData
|
||||
)
|
||||
HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
|
||||
{
|
||||
BOOL bRetVal;
|
||||
LPWSTR lpStringToFindW = NULL;
|
||||
ACTCTXW actw;
|
||||
SIZE_T len;
|
||||
HANDLE ret = INVALID_HANDLE_VALUE;
|
||||
LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
|
||||
|
||||
/* Convert lpStringToFind */
|
||||
if (lpStringToFind)
|
||||
TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
|
||||
|
||||
if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
|
||||
{
|
||||
BasepAnsiStringToHeapUnicodeString(lpStringToFind,
|
||||
(LPWSTR*) &lpStringToFindW);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
actw.cbSize = sizeof(actw);
|
||||
actw.dwFlags = pActCtx->dwFlags;
|
||||
if (pActCtx->lpSource)
|
||||
{
|
||||
BasepAnsiStringToHeapUnicodeString(pActCtx->lpSource,
|
||||
(LPWSTR*) &pActCtxW.lpSource);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
actw.lpSource = src;
|
||||
|
||||
/* 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);
|
||||
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;
|
||||
|
||||
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
|
||||
WINAPI
|
||||
ActivateActCtx(
|
||||
HANDLE hActCtx,
|
||||
ULONG_PTR *ulCookie
|
||||
)
|
||||
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
|
||||
{
|
||||
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;
|
||||
NTSTATUS status;
|
||||
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 (!NT_SUCCESS(Status))
|
||||
if ((status = RtlCreateActivationContext(&hActCtx, (PVOID*)pActCtx)))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
SetLastError(RtlNtStatusToDosError(status));
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
return hActCtx;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
/***********************************************************************
|
||||
* ActivateActCtx (KERNEL32.@)
|
||||
*
|
||||
* Activate an activation context.
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
DeactivateActCtx(
|
||||
DWORD dwFlags,
|
||||
ULONG_PTR ulCookie
|
||||
)
|
||||
BOOL WINAPI ActivateActCtx(HANDLE hActCtx, ULONG_PTR *ulCookie)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
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__);
|
||||
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))
|
||||
if ((status = RtlActivateActivationContext( 0, hActCtx, ulCookie )))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
SetLastError(RtlNtStatusToDosError(status));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
/***********************************************************************
|
||||
* DeactivateActCtx (KERNEL32.@)
|
||||
*
|
||||
* Deactivate an activation context.
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetCurrentActCtx(
|
||||
HANDLE *phActCtx)
|
||||
BOOL WINAPI DeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
RtlDeactivateActivationContext( dwFlags, ulCookie );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DPRINT("GetCurrentActCtx(%p)\n", phActCtx);
|
||||
Status = RtlGetActiveActivationContext(phActCtx);
|
||||
if (!NT_SUCCESS(Status))
|
||||
/***********************************************************************
|
||||
* GetCurrentActCtx (KERNEL32.@)
|
||||
*
|
||||
* 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 TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
/***********************************************************************
|
||||
* AddRefActCtx (KERNEL32.@)
|
||||
*
|
||||
* Add a reference to an activation context.
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
QueryActCtxW(
|
||||
DWORD dwFlags,
|
||||
HANDLE hActCtx,
|
||||
PVOID pvSubInstance,
|
||||
ULONG ulInfoClass,
|
||||
PVOID pvBuffer,
|
||||
SIZE_T cbBuffer OPTIONAL,
|
||||
SIZE_T *pcbWrittenOrRequired OPTIONAL
|
||||
)
|
||||
void WINAPI AddRefActCtx(HANDLE hActCtx)
|
||||
{
|
||||
DPRINT("%s() is UNIMPLEMENTED!\n", __FUNCTION__);
|
||||
/* this makes Adobe Photoshop 7.0 happy */
|
||||
SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
RtlAddRefActivationContext(hActCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
/***********************************************************************
|
||||
* ReleaseActCtx (KERNEL32.@)
|
||||
*
|
||||
* Release a reference to an activation context.
|
||||
*/
|
||||
VOID
|
||||
WINAPI
|
||||
ReleaseActCtx(
|
||||
HANDLE hActCtx
|
||||
)
|
||||
void WINAPI ReleaseActCtx(HANDLE hActCtx)
|
||||
{
|
||||
DPRINT("ReleaseActCtx(%p)\n", hActCtx);
|
||||
RtlReleaseActivationContext(hActCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
/***********************************************************************
|
||||
* ZombifyActCtx (KERNEL32.@)
|
||||
*
|
||||
* Release a reference to an activation context.
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
ZombifyActCtx(
|
||||
HANDLE hActCtx
|
||||
)
|
||||
BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
DPRINT("ZombifyActCtx(%p)\n", hActCtx);
|
||||
FIXME("%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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue