ReactOS 0.4.15-dev-8058-ga7cbb60
actctx.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/kernel32/wine/actctx.c
5 * PURPOSE: Activation contexts
6 * PROGRAMMERS: Jacek Caban for CodeWeavers
7 * Eric Pouech
8 * Jon Griffiths
9 * Dmitry Chapyshev (dmitry@reactos.org)
10 * Samuel Serapión
11 */
12
13/* Synched with Wine 1.7.55 */
14
15#include <k32.h>
16
17#define NDEBUG
18#include <debug.h>
20
21/***********************************************************************
22 * CreateActCtxA (KERNEL32.@)
23 *
24 * Create an activation context.
25 */
26HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
27{
28 ACTCTXW actw;
29 SIZE_T len;
31 LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
32
33 TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
34
35 if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
36 {
39 }
40
41 actw.cbSize = sizeof(actw);
42 actw.dwFlags = pActCtx->dwFlags;
43 if (pActCtx->lpSource)
44 {
45 len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, NULL, 0);
46 src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
47 if (!src) return INVALID_HANDLE_VALUE;
48 MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, src, len);
49 }
50 actw.lpSource = src;
51
52 if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
53 actw.wProcessorArchitecture = pActCtx->wProcessorArchitecture;
54 if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
55 actw.wLangId = pActCtx->wLangId;
56 if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
57 {
58 len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, NULL, 0);
59 assdir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
60 if (!assdir) goto done;
61 MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, assdir, len);
62 actw.lpAssemblyDirectory = assdir;
63 }
64 if (actw.dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID)
65 {
66 if ((ULONG_PTR)pActCtx->lpResourceName >> 16)
67 {
68 len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, NULL, 0);
69 resname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
70 if (!resname) goto done;
71 MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, resname, len);
72 actw.lpResourceName = resname;
73 }
74 else actw.lpResourceName = (LPCWSTR)pActCtx->lpResourceName;
75 }
76 if (actw.dwFlags & ACTCTX_FLAG_APPLICATION_NAME_VALID)
77 {
78 len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, NULL, 0);
79 appname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
80 if (!appname) goto done;
81 MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, appname, len);
82 actw.lpApplicationName = appname;
83 }
84 if (actw.dwFlags & ACTCTX_FLAG_HMODULE_VALID)
85 actw.hModule = pActCtx->hModule;
86
87 ret = CreateActCtxW(&actw);
88
89done:
91 HeapFree(GetProcessHeap(), 0, assdir);
92 HeapFree(GetProcessHeap(), 0, resname);
93 HeapFree(GetProcessHeap(), 0, appname);
94 return ret;
95}
96
97/***********************************************************************
98 * CreateActCtxW (KERNEL32.@)
99 *
100 * Create an activation context.
101 */
102HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
103{
105 HANDLE hActCtx;
106
107 TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
108
109 if ((status = RtlCreateActivationContext(0, (PVOID)pActCtx, 0, NULL, NULL, &hActCtx)))
110 {
113 }
114 return hActCtx;
115}
116
117#ifndef __REACTOS__
118/***********************************************************************
119 * ActivateActCtx (KERNEL32.@)
120 *
121 * Activate an activation context.
122 */
124{
126
127 if ((status = RtlActivateActivationContext( 0, hActCtx, ulCookie )))
128 {
130 return FALSE;
131 }
132 return TRUE;
133}
134
135/***********************************************************************
136 * DeactivateActCtx (KERNEL32.@)
137 *
138 * Deactivate an activation context.
139 */
141{
143 return TRUE;
144}
145
146/***********************************************************************
147 * GetCurrentActCtx (KERNEL32.@)
148 *
149 * Get the current activation context.
150 */
152{
154
155 if ((status = RtlGetActiveActivationContext(phActCtx)))
156 {
158 return FALSE;
159 }
160 return TRUE;
161}
162
163/***********************************************************************
164 * AddRefActCtx (KERNEL32.@)
165 *
166 * Add a reference to an activation context.
167 */
169{
171}
172
173/***********************************************************************
174 * ReleaseActCtx (KERNEL32.@)
175 *
176 * Release a reference to an activation context.
177 */
179{
181}
182
183/***********************************************************************
184 * ZombifyActCtx (KERNEL32.@)
185 *
186 * Deactivate context without releasing it.
187 */
189{
191
192 if ((status = RtlZombifyActivationContext(hActCtx)))
193 {
195 return FALSE;
196 }
197 return TRUE;
198}
199#endif // !__REACTOS__
200
201/***********************************************************************
202 * FindActCtxSectionStringA (KERNEL32.@)
203 *
204 * Find information about a string in an activation context.
205 */
207 ULONG ulId, LPCSTR lpSearchStr,
209{
210 LPWSTR search_str;
211 DWORD len;
212 BOOL ret;
213
214 TRACE("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
215 ulId, debugstr_a(lpSearchStr), pInfo);
216
217 if (!lpSearchStr || !pInfo)
218 {
220 return FALSE;
221 }
222
223 len = MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, NULL, 0);
224 search_str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
225 MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, search_str, len);
226
227 ret = FindActCtxSectionStringW(dwFlags, lpExtGuid, ulId, search_str, pInfo);
228
229 HeapFree(GetProcessHeap(), 0, search_str);
230 return ret;
231}
232
233/***********************************************************************
234 * FindActCtxSectionStringW (KERNEL32.@)
235 *
236 * Find information about a string in an activation context.
237 */
239 ULONG ulId, LPCWSTR lpSearchStr,
241{
244
245 if (!pInfo)
246 {
248 return FALSE;
249 }
250
251 RtlInitUnicodeString(&us, lpSearchStr);
252 if ((status = RtlFindActivationContextSectionString(dwFlags, lpExtGuid, ulId, &us, pInfo)))
253 {
255 return FALSE;
256 }
257 return TRUE;
258}
259
260/***********************************************************************
261 * FindActCtxSectionGuid (KERNEL32.@)
262 *
263 * Find information about a GUID in an activation context.
264 */
266 ULONG ulId, const GUID* lpSearchGuid,
268{
270
271 if ((status = RtlFindActivationContextSectionGuid(dwFlags, lpExtGuid, ulId, lpSearchGuid, pInfo)))
272 {
274 return FALSE;
275 }
276
277 return TRUE;
278}
279
280#ifndef __REACTOS__
281/***********************************************************************
282 * QueryActCtxW (KERNEL32.@)
283 *
284 * Get information about an activation context.
285 */
287 ULONG ulClass, PVOID pvBuff, SIZE_T cbBuff,
288 SIZE_T *pcbLen)
289{
291
292 if ((status = RtlQueryInformationActivationContext( dwFlags, hActCtx, pvSubInst, ulClass,
293 pvBuff, cbBuff, pcbLen )))
294 {
296 return FALSE;
297 }
298 return TRUE;
299}
300#endif // !__REACTOS__
LONG NTSTATUS
Definition: precomp.h:26
#define DEBUG_CHANNEL(args)
Definition: rdesktop.h:159
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
Definition: actctx.c:219
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
VOID WINAPI AddRefActCtx(IN HANDLE hActCtx)
Definition: actctx.c:197
BOOL WINAPI QueryActCtxW(IN DWORD dwFlags, IN HANDLE hActCtx, IN PVOID pvSubInstance, IN ULONG ulInfoClass, IN PVOID pvBuffer, IN SIZE_T cbBuffer, IN OUT SIZE_T *pcbWrittenOrRequired OPTIONAL)
Definition: actctx.c:328
BOOL WINAPI GetCurrentActCtx(OUT PHANDLE phActCtx)
Definition: actctx.c:298
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCWSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:238
HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
Definition: actctx.c:26
BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:206
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:102
BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:265
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
NTSYSAPI NTSTATUS WINAPI RtlActivateActivationContext(DWORD, HANDLE, ULONG_PTR *)
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG, const GUID *, ULONG, const UNICODE_STRING *, PVOID)
Definition: actctx.c:5863
NTSYSAPI NTSTATUS WINAPI RtlZombifyActivationContext(HANDLE)
Definition: actctx.c:5387
NTSYSAPI void WINAPI RtlAddRefActivationContext(HANDLE)
Definition: actctx.c:5362
NTSYSAPI void WINAPI RtlDeactivateActivationContext(DWORD, ULONG_PTR)
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5373
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSYSAPI NTSTATUS WINAPI RtlCreateActivationContext(HANDLE *, const void *)
NTSYSAPI NTSTATUS WINAPI RtlGetActiveActivationContext(HANDLE *)
Definition: actctx.c:5528
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5561
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define actctx
Definition: kernel32.h:8
static const BYTE us[]
Definition: encode.c:689
static const GUID PACTCTX_SECTION_KEYED_DATA
Definition: actctx.c:36
NTSYSAPI NTSTATUS NTAPI RtlFindActivationContextSectionGuid(ULONG flags, const GUID *extguid, ULONG section_kind, const GUID *guid, void *ptr)
Definition: actctx.c:5914
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define TRACE(s)
Definition: solgame.cpp:4
Definition: ps.c:97
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define WINAPI
Definition: msvc.h:6
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185