2004-01-30 23:57:21 +01:00
|
|
|
/*
|
|
|
|
* Activation contexts
|
|
|
|
*
|
|
|
|
* Copyright 2004 Jon Griffiths
|
2007-05-07 21:49:40 +02:00
|
|
|
* Copyright 2007 Eric Pouech
|
|
|
|
* Copyright 2007 Jacek Caban for CodeWeavers
|
2004-01-30 23:57:21 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-01-30 23:57:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
2007-05-07 21:49:40 +02:00
|
|
|
#include "winnls.h"
|
2007-07-19 17:01:04 +02:00
|
|
|
#include "winternl.h"
|
2004-01-30 23:57:21 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(actctx);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateActCtxA (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Create an activation context.
|
|
|
|
*/
|
2019-04-23 20:11:14 +02:00
|
|
|
HANDLE WINAPI DECLSPEC_HOTPATCH CreateActCtxA(PCACTCTXA pActCtx)
|
2004-01-30 23:57:21 +01:00
|
|
|
{
|
2007-05-07 21:49:40 +02:00
|
|
|
ACTCTXW actw;
|
|
|
|
SIZE_T len;
|
|
|
|
HANDLE ret = INVALID_HANDLE_VALUE;
|
|
|
|
LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
|
2006-03-07 10:24:24 +01:00
|
|
|
|
2007-05-07 21:49:40 +02:00
|
|
|
TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
|
|
|
|
|
2007-07-19 17:01:04 +02:00
|
|
|
if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
|
2007-05-07 21:49:40 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
actw.cbSize = sizeof(actw);
|
|
|
|
actw.dwFlags = pActCtx->dwFlags;
|
|
|
|
if (pActCtx->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);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2007-05-11 11:19:38 +02:00
|
|
|
if ((ULONG_PTR)pActCtx->lpResourceName >> 16)
|
2007-05-07 21:49:40 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2007-08-30 10:18:25 +02:00
|
|
|
else actw.lpResourceName = (LPCWSTR)pActCtx->lpResourceName;
|
2007-05-07 21:49:40 +02:00
|
|
|
}
|
|
|
|
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;
|
2004-01-30 23:57:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FindActCtxSectionStringA (KERNEL32.@)
|
|
|
|
*
|
2009-12-17 21:57:23 +01:00
|
|
|
* Find information about a string in an activation context.
|
2004-01-30 23:57:21 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID* lpExtGuid,
|
|
|
|
ULONG ulId, LPCSTR lpSearchStr,
|
2004-02-27 22:28:34 +01:00
|
|
|
PACTCTX_SECTION_KEYED_DATA pInfo)
|
2004-01-30 23:57:21 +01:00
|
|
|
{
|
2007-07-25 20:37:49 +02:00
|
|
|
LPWSTR search_str;
|
|
|
|
DWORD len;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
|
|
|
|
ulId, debugstr_a(lpSearchStr), pInfo);
|
|
|
|
|
2015-03-16 03:38:58 +01:00
|
|
|
if (!lpSearchStr || !pInfo)
|
2007-07-25 20:37:49 +02:00
|
|
|
{
|
|
|
|
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;
|
2004-01-30 23:57:21 +01:00
|
|
|
}
|