ReactOS 0.4.15-dev-7693-gd0e2924
actctx.c
Go to the documentation of this file.
1/*
2 * Copyright 2007 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "ntstatus.h"
20#define WIN32_NO_STATUS
21#include "wine/test.h"
22#include <winbase.h>
23#include <windef.h>
24#include <winnt.h>
25#include <winternl.h>
26#include <winnls.h>
27#include <stdio.h>
28
29#include "oaidl.h"
30#include "initguid.h"
31
32static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
33static HANDLE (WINAPI *pCreateActCtxA)(PCACTCTXA);
34static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
35static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
36static BOOL (WINAPI *pFindActCtxSectionStringA)(DWORD,const GUID *,ULONG,LPCSTR,PACTCTX_SECTION_KEYED_DATA);
37static BOOL (WINAPI *pFindActCtxSectionStringW)(DWORD,const GUID *,ULONG,LPCWSTR,PACTCTX_SECTION_KEYED_DATA);
38static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *);
39static BOOL (WINAPI *pIsDebuggerPresent)(void);
40static BOOL (WINAPI *pQueryActCtxW)(DWORD,HANDLE,PVOID,ULONG,PVOID,SIZE_T,SIZE_T*);
41static VOID (WINAPI *pReleaseActCtx)(HANDLE);
42static BOOL (WINAPI *pFindActCtxSectionGuid)(DWORD,const GUID*,ULONG,const GUID*,PACTCTX_SECTION_KEYED_DATA);
43static BOOL (WINAPI *pZombifyActCtx)(HANDLE);
44
45static NTSTATUS(NTAPI *pRtlFindActivationContextSectionString)(DWORD,const GUID *,ULONG,PUNICODE_STRING,PACTCTX_SECTION_KEYED_DATA);
46static BOOLEAN (NTAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, PCSZ);
47static VOID (NTAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
48
49static const char* strw(LPCWSTR x)
50{
51 static char buffer[1024];
52 char* p = buffer;
53
54 if (!x) return "(nil)";
55 else while ((*p++ = *x++));
56 return buffer;
57}
58
59#ifdef __i386__
60#define ARCH "x86"
61#elif defined __x86_64__
62#define ARCH "amd64"
63#elif defined __arm__
64#define ARCH "arm"
65#elif defined __aarch64__
66#define ARCH "arm64"
67#else
68#define ARCH "none"
69#endif
70
71static const char manifest1[] =
72"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
73"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
74"</assembly>";
75
76static const char manifest1_1[] =
77"<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
78"<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
79"</assembly>";
80
81static const char manifest2[] =
82"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
83"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
84"</assemblyIdentity>"
85"<dependency>"
86"<dependentAssembly>"
87"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\">"
88"</assemblyIdentity>"
89"</dependentAssembly>"
90"</dependency>"
91"</assembly>";
92
93DEFINE_GUID(IID_CoTest, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
94DEFINE_GUID(IID_CoTest2, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
95DEFINE_GUID(CLSID_clrclass,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
96DEFINE_GUID(IID_TlibTest, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
97DEFINE_GUID(IID_TlibTest2, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
98DEFINE_GUID(IID_TlibTest3, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
99DEFINE_GUID(IID_TlibTest4, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
100DEFINE_GUID(IID_Iifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
101DEFINE_GUID(IID_Ibifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
102DEFINE_GUID(IID_Iifaceps2, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
103DEFINE_GUID(IID_Iifaceps3, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
104DEFINE_GUID(IID_Iiface, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
105DEFINE_GUID(IID_PS32, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
106
107static const char manifest3[] =
108"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
109"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
110" publicKeyToken=\"6595b6414666f1df\" />"
111"<description />"
112"<file name=\"testlib.dll\">"
113"<windowClass>wndClass</windowClass>"
114" <comClass description=\"Test com class\""
115" clsid=\"{12345678-1234-5678-1234-111122223333}\""
116" tlbid=\"{99999999-8888-7777-6666-555555555555}\""
117" threadingModel=\"Neutral\""
118" progid=\"ProgId.ProgId\""
119" miscStatus=\"cantlinkinside\""
120" miscStatusIcon=\"recomposeonresize\""
121" miscStatusContent=\"insideout\""
122" miscStatusThumbnail=\"alignable\""
123" miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
124" >"
125" <progid>ProgId.ProgId.1</progid>"
126" <progid>ProgId.ProgId.2</progid>"
127" <progid>ProgId.ProgId.3</progid>"
128" <progid>ProgId.ProgId.4</progid>"
129" <progid>ProgId.ProgId.5</progid>"
130" <progid>ProgId.ProgId.6</progid>"
131" </comClass>"
132" <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
133" <progid>ProgId.ProgId.7</progid>"
134" </comClass>"
135" <comInterfaceProxyStub "
136" name=\"Iifaceps\""
137" tlbid=\"{99999999-8888-7777-6666-555555555558}\""
138" iid=\"{66666666-8888-7777-6666-555555555555}\""
139" proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
140" threadingModel=\"Free\""
141" numMethods=\"10\""
142" baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
143" />"
144"</file>"
145" <comInterfaceExternalProxyStub "
146" name=\"Iifaceps2\""
147" tlbid=\"{99999999-8888-7777-6666-555555555558}\""
148" iid=\"{76666666-8888-7777-6666-555555555555}\""
149" proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
150" numMethods=\"10\""
151" baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
152" />"
153" <comInterfaceExternalProxyStub "
154" name=\"Iifaceps3\""
155" tlbid=\"{99999999-8888-7777-6666-555555555558}\""
156" iid=\"{86666666-8888-7777-6666-555555555555}\""
157" numMethods=\"10\""
158" baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
159" />"
160" <clrSurrogate "
161" clsid=\"{96666666-8888-7777-6666-555555555555}\""
162" name=\"testsurrogate\""
163" runtimeVersion=\"v2.0.50727\""
164" />"
165" <clrClass "
166" clsid=\"{22345678-1234-5678-1234-111122223333}\""
167" name=\"clrclass\""
168" progid=\"clrprogid\""
169" description=\"test description\""
170" tlbid=\"{99999999-8888-7777-6666-555555555555}\""
171" runtimeVersion=\"1.2.3.4\""
172" threadingModel=\"Neutral\""
173" >"
174" <progid>clrprogid.1</progid>"
175" <progid>clrprogid.2</progid>"
176" <progid>clrprogid.3</progid>"
177" <progid>clrprogid.4</progid>"
178" <progid>clrprogid.5</progid>"
179" <progid>clrprogid.6</progid>"
180" </clrClass>"
181"</assembly>";
182
183static const char manifest_wndcls1[] =
184"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
185"<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
186"<file name=\"testlib1.dll\">"
187"<windowClass versioned=\"yes\">wndClass1</windowClass>"
188"<windowClass>wndClass2</windowClass>"
189" <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
190"</file>"
191"<file name=\"testlib1_2.dll\" />"
192"</assembly>";
193
194static const char manifest_wndcls2[] =
195"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
196"<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH "\" />"
197"<file name=\"testlib2.dll\">"
198" <windowClass versioned=\"no\">wndClass3</windowClass>"
199" <windowClass>wndClass4</windowClass>"
200" <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
201" flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
202" <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
203" <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
204"</file>"
205"<file name=\"testlib2_2.dll\" />"
206"</assembly>";
207
208static const char manifest_wndcls_main[] =
209"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
210"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
211"<dependency>"
212" <dependentAssembly>"
213" <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
214" </dependentAssembly>"
215"</dependency>"
216"<dependency>"
217" <dependentAssembly>"
218" <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH "\" />"
219" </dependentAssembly>"
220"</dependency>"
221"</assembly>";
222
223static const char manifest4[] =
224"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
225"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
226"</assemblyIdentity>"
227"<dependency>"
228"<dependentAssembly>"
229"<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
230 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH "\" publicKeyToken=\"6595b64144ccf1df\">"
231"</assemblyIdentity>"
232"</dependentAssembly>"
233"</dependency>"
234"</assembly>";
235
236static const char manifest5[] =
237"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
238"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
239"</assemblyIdentity>"
240"<dependency>"
241" <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
242" <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
243" </dependentAssembly>"
244"</dependency>"
245"</assembly>";
246
247static const char manifest6[] =
248"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
249"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
250"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
251" <security>"
252" <requestedPrivileges>"
253" <requestedExecutionLevel level=\"ASINVOKER\" uiAccess=\"false\"/>"
254" </requestedPrivileges>"
255" </security>"
256"</trustInfo>"
257"</assembly>";
258
259static const char manifest7[] =
260"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
261"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
262"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
263" <security>"
264" <requestedPrivileges>"
265" <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"TRUE\"/>"
266" </requestedPrivileges>"
267" </security>"
268"</trustInfo>"
269"</assembly>";
270
271static const char manifest8[] =
272"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
273"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
274"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
275" <security>"
276" <requestedPrivileges>"
277" <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\">"
278" </requestedExecutionLevel>"
279" </requestedPrivileges>"
280" </security>"
281"</trustInfo>"
282"</assembly>";
283
284static const char manifest9[] =
285"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
286"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
287"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
288" <security>"
289" <requestedPrivileges>"
290" <requestedExecutionLevel level=\"requireAdministrator\"/>"
291" </requestedPrivileges>"
292" </security>"
293"</trustInfo>"
294"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
295" <security>"
296" <requestedPrivileges>"
297" </requestedPrivileges>"
298" </security>"
299"</trustInfo>"
300"</assembly>";
301
302static const char testdep_manifest1[] =
303"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
304"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>"
305"</assembly>";
306
307static const char testdep_manifest2[] =
308"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
309"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />"
310"<file name=\"testlib.dll\"></file>"
311"<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
312"</assembly>";
313
314static const char testdep_manifest3[] =
315"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
316"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>"
317"<file name=\"testlib.dll\"/>"
318"<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
319"<windowClass>wndClass</windowClass>"
320"<windowClass>wndClass2</windowClass>"
321"</file>"
322"</assembly>";
323
324static const char wrong_manifest1[] =
325"<assembly manifestVersion=\"1.0\">"
326"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
327"</assembly>";
328
329static const char wrong_manifest2[] =
330"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
331"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
332"</assembly>";
333
334static const char wrong_manifest3[] =
335"<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
336"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
337"</assembly>";
338
339static const char wrong_manifest4[] =
340"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
341"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
342"<test></test>"
343"</assembly>";
344
345static const char wrong_manifest5[] =
346"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
347"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
348"</assembly>"
349"<test></test>";
350
351static const char wrong_manifest6[] =
352"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
353"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
354"</assembly>";
355
356static const char wrong_manifest7[] =
357"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
358"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />"
359"<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
360"</assembly>";
361
362static const char wrong_manifest8[] =
363"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
364"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
365"<file></file>"
366"</assembly>";
367
368static const char wrong_manifest9[] =
369"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
370"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
371"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
372" <security>"
373" <requestedPrivileges>"
374" <requestedExecutionLevel level=\"requireAdministrator\"/>"
375" <requestedExecutionLevel uiAccess=\"true\"/>"
376" </requestedPrivileges>"
377" </security>"
378"</trustInfo>"
379"</assembly>";
380
381static const char wrong_manifest10[] =
382"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
383"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
384"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
385" <security>"
386" <requestedPrivileges>"
387" <requestedExecutionLevel level=\"requireAdministrator\"/>"
388" </requestedPrivileges>"
389" </security>"
390"</trustInfo>"
391"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
392" <security>"
393" <requestedPrivileges>"
394" <requestedExecutionLevel uiAccess=\"true\"/>"
395" </requestedPrivileges>"
396" </security>"
397"</trustInfo>"
398"</assembly>";
399
400static const char wrong_depmanifest1[] =
401"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
402"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH "\" />"
403"</assembly>";
404
406"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
407" <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
408" <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
409" <application>"
410" </application>"
411" </compatibility>"
412"</assembly>";
413
414static const char compat_manifest_vista[] =
415"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
416" <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
417" <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
418" <application>"
419" <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */
420" </application>"
421" </compatibility>"
422"</assembly>";
423
425"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
426" <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
427" <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
428" <application>"
429" <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" ></supportedOS>" /* Windows Vista */
430" <supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" />" /* Windows 7 */
431" <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" ></supportedOS>" /* Windows 8 */
432" <supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" />" /* Windows 10 */
433" <supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" />" /* Windows 8.1 */
434" </application>"
435" </compatibility>"
436"</assembly>";
437
438static const char compat_manifest_other_guid[] =
439"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
440" <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
441" <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
442" <application>"
443" <supportedOS Id=\"{12345566-1111-2222-3333-444444444444}\" />"
444" </application>"
445" </compatibility>"
446"</assembly>";
447
448DEFINE_GUID(VISTA_COMPAT_GUID, 0xe2011457, 0x1546, 0x43c5, 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0);
449DEFINE_GUID(WIN7_COMPAT_GUID, 0x35138b9a, 0x5d96, 0x4fbd, 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a);
450DEFINE_GUID(WIN8_COMPAT_GUID, 0x4a2f28e3, 0x53b9, 0x4441, 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38);
451DEFINE_GUID(WIN81_COMPAT_GUID, 0x1f676c76, 0x80e1, 0x4239, 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78);
452DEFINE_GUID(WIN10_COMPAT_GUID, 0x8e0f7a12, 0xbfb3, 0x4fe8, 0xb9, 0xa5, 0x48, 0xfd, 0x50, 0xa1, 0x5a, 0x9a);
453DEFINE_GUID(OTHER_COMPAT_GUID, 0x12345566, 0x1111, 0x2222, 0x33, 0x33, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44);
454
455
456static const WCHAR testlib_dll[] =
457 {'t','e','s','t','l','i','b','.','d','l','l',0};
458static const WCHAR testlib2_dll[] =
459 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
460static const WCHAR wndClassW[] =
461 {'w','n','d','C','l','a','s','s',0};
462static const WCHAR wndClass1W[] =
463 {'w','n','d','C','l','a','s','s','1',0};
464static const WCHAR wndClass2W[] =
465 {'w','n','d','C','l','a','s','s','2',0};
466static const WCHAR wndClass3W[] =
467 {'w','n','d','C','l','a','s','s','3',0};
468
471
472static int strcmp_aw(LPCWSTR strw, const char *stra)
473{
474 WCHAR buf[1024];
475
476 if (!stra) return 1;
477 MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
478 return lstrcmpW(strw, buf);
479}
480
481static DWORD strlen_aw(const char *str)
482{
483 return MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0) - 1;
484}
485
486static BOOL create_manifest_file(const char *filename, const char *manifest, int manifest_len,
487 const char *depfile, const char *depmanifest)
488{
489 DWORD size;
490 HANDLE file;
492
495
496 if (manifest_len == -1)
497 manifest_len = strlen(manifest);
498
501 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
503 return FALSE;
504 WriteFile(file, manifest, manifest_len, &size, NULL);
506
507 if (depmanifest)
508 {
509 MultiByteToWideChar( CP_ACP, 0, depfile, -1, path, MAX_PATH );
513 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
515 return FALSE;
516 WriteFile(file, depmanifest, strlen(depmanifest), &size, NULL);
518 }
519 return TRUE;
520}
521
522static BOOL create_wide_manifest(const char *filename, const char *manifest, BOOL fBOM, BOOL fReverse)
523{
524 WCHAR *wmanifest = HeapAlloc(GetProcessHeap(), 0, (strlen(manifest)+2) * sizeof(WCHAR));
525 BOOL ret;
526 int offset = (fBOM ? 0 : 1);
527
528 MultiByteToWideChar(CP_ACP, 0, manifest, -1, &wmanifest[1], (strlen(manifest)+1));
529 wmanifest[0] = 0xfeff;
530 if (fReverse)
531 {
532 size_t i;
533 for (i = 0; i < strlen(manifest)+1; i++)
534 wmanifest[i] = (wmanifest[i] << 8) | ((wmanifest[i] >> 8) & 0xff);
535 }
536 ret = create_manifest_file(filename, (char *)&wmanifest[offset], (strlen(manifest)+1-offset) * sizeof(WCHAR), NULL, NULL);
537 HeapFree(GetProcessHeap(), 0, wmanifest);
538 return ret;
539}
540
541typedef struct {
551
553 0, 0, 0, 0, NULL, 0, 0, NULL
554};
555
557 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
558 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
559 work_dir,
560};
561
563 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, app_manifest_path,
564 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
565 app_dir,
566};
567
568/* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
570 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
571 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
572 work_dir,
573};
574
575static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int line)
576{
577 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp, *detailed_info;
578 SIZE_T size, exsize, retsize;
579 BOOL b;
580
581 exsize = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)
582 + (exinfo->root_manifest_path ? (lstrlenW(exinfo->root_manifest_path)+1)*sizeof(WCHAR):0)
583 + (exinfo->app_dir ? (lstrlenW(exinfo->app_dir)+1)*sizeof(WCHAR) : 0);
584
585 if(exsize != sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)) {
586 size = 0xdeadbeef;
587 b = pQueryActCtxW(0, handle, NULL,
588 ActivationContextDetailedInformation, &detailed_info_tmp,
589 sizeof(detailed_info_tmp), &size);
590 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
591 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
592 ok_(__FILE__, line)(size == exsize, "size=%ld, expected %ld\n", size, exsize);
593 }else {
594 size = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION);
595 }
596
597 detailed_info = HeapAlloc(GetProcessHeap(), 0, size);
598 memset(detailed_info, 0xfe, size);
599 b = pQueryActCtxW(0, handle, NULL,
600 ActivationContextDetailedInformation, detailed_info,
601 size, &retsize);
602 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
603 ok_(__FILE__, line)(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize);
604
605 ok_(__FILE__, line)(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags);
606 ok_(__FILE__, line)(detailed_info->ulFormatVersion == exinfo->format_version,
607 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info->ulFormatVersion,
608 exinfo->format_version);
609 ok_(__FILE__, line)(exinfo->assembly_cnt_min <= detailed_info->ulAssemblyCount &&
610 detailed_info->ulAssemblyCount <= exinfo->assembly_cnt_max,
611 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info->ulAssemblyCount,
612 exinfo->assembly_cnt_min, exinfo->assembly_cnt_max);
613 ok_(__FILE__, line)(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type,
614 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
615 detailed_info->ulRootManifestPathType, exinfo->root_manifest_type);
616 ok_(__FILE__, line)(detailed_info->ulRootManifestPathChars ==
617 (exinfo->root_manifest_path ? lstrlenW(exinfo->root_manifest_path) : 0),
618 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
619 detailed_info->ulRootManifestPathChars,
620 exinfo->root_manifest_path ?lstrlenW(exinfo->root_manifest_path) : 0);
621 ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type,
622 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
623 detailed_info->ulRootConfigurationPathType, exinfo->root_config_type);
624 ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathChars == 0,
625 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info->ulRootConfigurationPathChars);
626 ok_(__FILE__, line)(detailed_info->ulAppDirPathType == exinfo->app_dir_type,
627 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info->ulAppDirPathType,
628 exinfo->app_dir_type);
629 ok_(__FILE__, line)(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0),
630 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
631 detailed_info->ulAppDirPathChars, exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0);
632 if(exinfo->root_manifest_path) {
633 ok_(__FILE__, line)(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n");
634 if(detailed_info->lpRootManifestPath)
635 ok_(__FILE__, line)(!lstrcmpiW(detailed_info->lpRootManifestPath, exinfo->root_manifest_path),
636 "unexpected detailed_info->lpRootManifestPath\n");
637 }else {
638 ok_(__FILE__, line)(detailed_info->lpRootManifestPath == NULL, "detailed_info->lpRootManifestPath != NULL\n");
639 }
640 ok_(__FILE__, line)(detailed_info->lpRootConfigurationPath == NULL,
641 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info->lpRootConfigurationPath);
642 if(exinfo->app_dir) {
643 ok_(__FILE__, line)(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n");
644 if(detailed_info->lpAppDirPath)
645 ok_(__FILE__, line)(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath),
646 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info->lpAppDirPath));
647 }else {
648 ok_(__FILE__, line)(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n");
649 }
650
651 HeapFree(GetProcessHeap(), 0, detailed_info);
652}
653
654typedef struct {
656/* ULONG manifest_path_type; FIXME */
661
663 1, manifest_path,
664 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
665 FALSE
666};
667
670 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
671 FALSE
672};
673
675 1, manifest_path,
676 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
677 FALSE
678};
679
681 1, manifest_path,
682 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
683 FALSE
684};
685
687 1, manifest_path,
688 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
689 FALSE
690};
691
693 0x10, depmanifest_path,
694 "testdep,processorArchitecture=\"" ARCH "\","
695 "type=\"win32\",version=\"6.5.4.3\"",
696 TRUE
697};
698
700 0x10, depmanifest_path,
701 "testdep,processorArchitecture=\"" ARCH "\","
702 "type=\"win32\",version=\"6.5.4.3\"",
703 TRUE
704};
705
707 0x10, depmanifest_path,
708 "testdep,processorArchitecture=\"" ARCH "\",type=\"win32\",version=\"6.5.4.3\"",
709 TRUE
710};
711
713 0, NULL, NULL, TRUE /* These values may differ between Windows installations */
714};
715
716static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembly *exinfo, int line)
717{
718 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info, info_tmp;
719 SIZE_T size, exsize;
720 ULONG len;
721 BOOL b;
722
723 exsize = sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION);
724 if (exinfo->manifest_path) exsize += (lstrlenW(exinfo->manifest_path)+1) * sizeof(WCHAR);
725 if (exinfo->encoded_assembly_id) exsize += (strlen_aw(exinfo->encoded_assembly_id) + 1) * sizeof(WCHAR);
726
727 size = 0xdeadbeef;
728 b = pQueryActCtxW(0, handle, &id,
729 AssemblyDetailedInformationInActivationContext, &info_tmp,
730 sizeof(info_tmp), &size);
731 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
732 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
733
734 ok_(__FILE__, line)(size >= exsize, "size=%lu, expected %lu\n", size, exsize);
735
736 if (size == 0xdeadbeef)
737 {
738 skip("bad size\n");
739 return;
740 }
741
743 memset(info, 0xfe, size);
744
745 size = 0xdeadbeef;
746 b = pQueryActCtxW(0, handle, &id,
747 AssemblyDetailedInformationInActivationContext, info, size, &size);
748 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
749 if (!exinfo->manifest_path)
750 exsize += info->ulManifestPathLength + sizeof(WCHAR);
751 if (!exinfo->encoded_assembly_id)
752 exsize += info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
753 if (exinfo->has_assembly_dir)
754 exsize += info->ulAssemblyDirectoryNameLength + sizeof(WCHAR);
755 ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize);
756
757 if (0) /* FIXME: flags meaning unknown */
758 {
759 ok_(__FILE__, line)((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n",
760 info->ulFlags, exinfo->flags);
761 }
762 if(exinfo->encoded_assembly_id) {
763 len = strlen_aw(exinfo->encoded_assembly_id)*sizeof(WCHAR);
764 ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength == len,
765 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
766 info->ulEncodedAssemblyIdentityLength, len);
767 } else {
768 ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength != 0,
769 "info->ulEncodedAssemblyIdentityLength == 0\n");
770 }
771 ok_(__FILE__, line)(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
772 "info->ulManifestPathType = %x\n", info->ulManifestPathType);
773 if(exinfo->manifest_path) {
774 len = lstrlenW(exinfo->manifest_path)*sizeof(WCHAR);
775 ok_(__FILE__, line)(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n",
776 info->ulManifestPathLength, len);
777 } else {
778 ok_(__FILE__, line)(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n");
779 }
780
781 ok_(__FILE__, line)(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE,
782 "info->ulPolicyPathType = %x\n", info->ulPolicyPathType);
783 ok_(__FILE__, line)(info->ulPolicyPathLength == 0,
784 "info->ulPolicyPathLength = %u, expected 0\n", info->ulPolicyPathLength);
785 ok_(__FILE__, line)(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
786 info->ulMetadataSatelliteRosterIndex);
787 ok_(__FILE__, line)(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n",
788 info->ulManifestVersionMajor);
789 ok_(__FILE__, line)(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n",
790 info->ulManifestVersionMinor);
791 ok_(__FILE__, line)(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n",
792 info->ulPolicyVersionMajor);
793 ok_(__FILE__, line)(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n",
794 info->ulPolicyVersionMinor);
795 if(exinfo->has_assembly_dir)
796 ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength != 0,
797 "info->ulAssemblyDirectoryNameLength == 0\n");
798 else
799 ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength == 0,
800 "info->ulAssemblyDirectoryNameLength != 0\n");
801
802 ok_(__FILE__, line)(info->lpAssemblyEncodedAssemblyIdentity != NULL,
803 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
804 if(info->lpAssemblyEncodedAssemblyIdentity && exinfo->encoded_assembly_id) {
805 ok_(__FILE__, line)(!strcmp_aw(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id),
806 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
807 strw(info->lpAssemblyEncodedAssemblyIdentity), exinfo->encoded_assembly_id);
808 }
809 if(exinfo->manifest_path) {
810 ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
811 if(info->lpAssemblyManifestPath)
812 ok_(__FILE__, line)(!lstrcmpiW(info->lpAssemblyManifestPath, exinfo->manifest_path),
813 "unexpected info->lpAssemblyManifestPath\n");
814 }else {
815 ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
816 }
817
818 ok_(__FILE__, line)(info->lpAssemblyPolicyPath == NULL, "info->lpAssemblyPolicyPath != NULL\n");
819 if(info->lpAssemblyPolicyPath)
820 ok_(__FILE__, line)(*(WORD*)info->lpAssemblyPolicyPath == 0, "info->lpAssemblyPolicyPath is not empty\n");
821 if(exinfo->has_assembly_dir)
822 ok_(__FILE__, line)(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n");
823 else
824 ok_(__FILE__, line)(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n",
825 strw(info->lpAssemblyDirectoryName));
827}
828
829static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR filename, int line)
830{
831 ASSEMBLY_FILE_DETAILED_INFORMATION *info, info_tmp;
832 ACTIVATION_CONTEXT_QUERY_INDEX index = {assid, fileid};
833 SIZE_T size, exsize;
834 BOOL b;
835
836 exsize = sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION)
837 +(lstrlenW(filename)+1)*sizeof(WCHAR);
838
839 size = 0xdeadbeef;
840 b = pQueryActCtxW(0, handle, &index,
841 FileInformationInAssemblyOfAssemblyInActivationContext, &info_tmp,
842 sizeof(info_tmp), &size);
843 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
844 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
845 ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize);
846
847 if(size == 0xdeadbeef)
848 {
849 skip("bad size\n");
850 return;
851 }
852
854 memset(info, 0xfe, size);
855
856 b = pQueryActCtxW(0, handle, &index,
857 FileInformationInAssemblyOfAssemblyInActivationContext, info, size, &size);
858 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
859 ok_(__FILE__, line)(!size, "size=%lu, expected 0\n", size);
860
861 ok_(__FILE__, line)(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags);
862 ok_(__FILE__, line)(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR),
863 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
864 info->ulFilenameLength, lstrlenW(filename));
865 ok_(__FILE__, line)(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength);
866 ok_(__FILE__, line)(info->lpFileName != NULL, "info->lpFileName == NULL\n");
867 if(info->lpFileName)
868 ok_(__FILE__, line)(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n");
869 ok_(__FILE__, line)(info->lpFilePath == NULL, "info->lpFilePath != NULL\n");
871}
872
873typedef struct {
874 ACTCTX_REQUESTED_RUN_LEVEL run_level;
877
879 ACTCTX_RUN_LEVEL_UNSPECIFIED, FALSE,
880};
881
883 ACTCTX_RUN_LEVEL_AS_INVOKER, FALSE,
884};
885
887 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, TRUE,
888};
889
891 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, TRUE,
892};
893
895 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, FALSE,
896};
897
898static void test_runlevel_info(HANDLE handle, const runlevel_info_t *exinfo, int line)
899{
900 ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel_info;
901 SIZE_T size, retsize;
902 BOOL b;
903
904 size = sizeof(runlevel_info);
905 b = pQueryActCtxW(0, handle, NULL,
906 RunlevelInformationInActivationContext, &runlevel_info,
907 sizeof(runlevel_info), &retsize);
909 {
910 win_skip("RunlevelInformationInActivationContext not supported.\n");
911 return;
912 }
913
914 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
915 ok_(__FILE__, line)(retsize == size, "size=%ld, expected %ld\n", retsize, size);
916
917 ok_(__FILE__, line)(runlevel_info.ulFlags == 0, "runlevel_info.ulFlags=%x\n", runlevel_info.ulFlags);
918 ok_(__FILE__, line)(runlevel_info.RunLevel == exinfo->run_level,
919 "runlevel_info.RunLevel=%u, expected %u\n", runlevel_info.RunLevel, exinfo->run_level);
920 ok_(__FILE__, line)(runlevel_info.UiAccess == exinfo->ui_access,
921 "runlevel_info.UiAccess=%u, expected %u\n", runlevel_info.UiAccess, exinfo->ui_access);
922}
923
924static HANDLE test_create(const char *file)
925{
926 ACTCTXW actctx;
929
931 memset(&actctx, 0, sizeof(ACTCTXW));
932 actctx.cbSize = sizeof(ACTCTXW);
933 actctx.lpSource = path;
934
935 handle = pCreateActCtxW(&actctx);
936 /* to be tested outside of this helper, including last error */
937 if (handle == INVALID_HANDLE_VALUE) return handle;
938
939 ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
940 ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
941 ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
942 ok(actctx.wProcessorArchitecture == 0,
943 "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
944 ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId);
945 ok(actctx.lpAssemblyDirectory == NULL,
946 "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
947 ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName);
948 ok(actctx.lpApplicationName == NULL, "actctx.lpApplicationName=%p\n",
949 actctx.lpApplicationName);
950 ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule);
951
952 return handle;
953}
954
955static void test_create_and_fail(const char *manifest, const char *depmanifest, int todo, BOOL is_broken)
956{
957 ACTCTXW actctx;
960
961 MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH );
962 memset(&actctx, 0, sizeof(ACTCTXW));
963 actctx.cbSize = sizeof(ACTCTXW);
964 actctx.lpSource = path;
965
966 create_manifest_file("bad.manifest", manifest, -1, "testdep.manifest", depmanifest);
967 handle = pCreateActCtxW(&actctx);
969 {
970 if (is_broken)
972 "Unexpected context handle %p.\n", handle);
973 else
974 ok(handle == INVALID_HANDLE_VALUE, "Unexpected context handle %p.\n", handle);
975
977 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "Unexpected error %d.\n", GetLastError());
978 }
979 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle );
980 DeleteFileA("bad.manifest");
981 DeleteFileA("testdep.manifest");
982}
983
984static void test_create_wide_and_fail(const char *manifest, BOOL fBOM)
985{
986 ACTCTXW actctx;
989
990 MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH );
991 memset(&actctx, 0, sizeof(ACTCTXW));
992 actctx.cbSize = sizeof(ACTCTXW);
993 actctx.lpSource = path;
994
995 create_wide_manifest("bad.manifest", manifest, fBOM, FALSE);
996 handle = pCreateActCtxW(&actctx);
997 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
998 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
999
1000 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle );
1001 DeleteFileA("bad.manifest");
1002}
1003
1004static void test_create_fail(void)
1005{
1006 ACTCTXW actctx;
1007 HANDLE handle;
1009
1010 MultiByteToWideChar( CP_ACP, 0, "nonexistent.manifest", -1, path, MAX_PATH );
1011 memset(&actctx, 0, sizeof(ACTCTXW));
1012 actctx.cbSize = sizeof(ACTCTXW);
1013 actctx.lpSource = path;
1014
1015 handle = pCreateActCtxW(&actctx);
1016 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
1017 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError == %u\n", GetLastError());
1018
1019 trace("wrong_manifest1\n");
1021 trace("wrong_manifest2\n");
1023 trace("wrong_manifest3\n");
1025 trace("wrong_manifest4\n");
1027 trace("wrong_manifest5\n");
1029 trace("wrong_manifest6\n");
1031 trace("wrong_manifest7\n");
1033 trace("wrong_manifest8\n");
1035 trace("wrong_manifest9\n");
1037 trace("wrong_manifest10\n");
1039 trace("UTF-16 manifest1 without BOM\n");
1041 trace("manifest2\n");
1043 trace("manifest2+depmanifest1\n");
1045}
1046
1047struct strsection_header
1048{
1049 DWORD magic;
1050 ULONG size;
1051 DWORD unk1[3];
1052 ULONG count;
1054 DWORD unk2[2];
1057};
1058
1060{
1067};
1068
1070{
1079};
1080
1082{
1087};
1088
1090{
1091 ULONG size;
1092 DWORD res;
1094 ULONG name_offset; /* versioned name offset */
1096 ULONG module_offset;/* container name offset */
1097};
1098
1099struct dllredirect_data
1100{
1101 ULONG size;
1102 ULONG unk;
1103 DWORD res[3];
1104};
1105
1106struct tlibredirect_data
1107{
1108 ULONG size;
1109 DWORD res;
1112 LANGID langid;
1113 WORD flags;
1118};
1119
1121{
1122 ULONG size;
1125};
1126
1128{
1129 ACTCTX_SECTION_KEYED_DATA data;
1130 BOOL ret;
1131
1132 memset(&data, 0xfe, sizeof(data));
1133 data.cbSize = sizeof(data);
1134
1135 ret = pFindActCtxSectionStringW(0, NULL,
1136 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1137 libname, &data);
1138 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
1139 if (!ret) return;
1140
1141 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1142 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1143 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1144 ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
1145
1146 if (data.lpData)
1147 {
1148 struct dllredirect_data *dlldata = (struct dllredirect_data*)data.lpData;
1149 ok_(__FILE__, line)(dlldata->size == data.ulLength, "got wrong size %d\n", dlldata->size);
1150 ok_(__FILE__, line)(dlldata->unk == 2, "got wrong field value %d\n", dlldata->unk);
1151 ok_(__FILE__, line)(dlldata->res[0] == 0, "got wrong res[0] value %d\n", dlldata->res[0]);
1152 ok_(__FILE__, line)(dlldata->res[1] == 0, "got wrong res[1] value %d\n", dlldata->res[1]);
1153 ok_(__FILE__, line)(dlldata->res[2] == 0, "got wrong res[2] value %d\n", dlldata->res[2]);
1154 }
1155
1156 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1157 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1158 data.ulSectionGlobalDataLength);
1159 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1160 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1161 data.ulSectionTotalLength);
1162 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1163 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1164 data.ulAssemblyRosterIndex, exid);
1165
1166 memset(&data, 0xfe, sizeof(data));
1167 data.cbSize = sizeof(data);
1168
1169 ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
1170 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1171 libname, &data);
1172 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
1173 if (!ret) return;
1174
1175 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1176 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1177 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1178 ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
1179 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1180 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1181 data.ulSectionGlobalDataLength);
1182 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1183 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1184 data.ulSectionTotalLength);
1185 ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
1186 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1187 data.ulAssemblyRosterIndex, exid);
1188
1189 pReleaseActCtx(handle);
1190}
1191
1192static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, int line)
1193{
1194 struct wndclass_redirect_data *wnddata;
1195 struct strsection_header *header;
1196 ACTCTX_SECTION_KEYED_DATA data;
1197 BOOL ret;
1198
1199 memset(&data, 0xfe, sizeof(data));
1200 data.cbSize = sizeof(data);
1201
1202 ret = pFindActCtxSectionStringW(0, NULL,
1203 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1204 clsname, &data);
1205 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1206 wine_dbgstr_w(clsname));
1207 if (!ret) return;
1208
1209 header = (struct strsection_header*)data.lpSectionBase;
1210 wnddata = (struct wndclass_redirect_data*)data.lpData;
1211
1212 ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08x\n", header->magic);
1213 ok_(__FILE__, line)(header->count > 0, "got count %d\n", header->count);
1214 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1215 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1216 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1217 ok_(__FILE__, line)(wnddata->size == sizeof(*wnddata), "got %d for header size\n", wnddata->size);
1218 if (data.lpData && wnddata->size == sizeof(*wnddata))
1219 {
1220 static const WCHAR verW[] = {'6','.','5','.','4','.','3','!',0};
1221 WCHAR buff[50];
1222 WCHAR *ptr;
1223 ULONG len;
1224
1225 ok_(__FILE__, line)(wnddata->res == 0, "got reserved as %d\n", wnddata->res);
1226 /* redirect class name (versioned or not) is stored just after header data */
1227 ok_(__FILE__, line)(wnddata->name_offset == wnddata->size, "got name offset as %d\n", wnddata->name_offset);
1228 ok_(__FILE__, line)(wnddata->module_len > 0, "got module name length as %d\n", wnddata->module_len);
1229
1230 /* expected versioned name */
1231 lstrcpyW(buff, verW);
1232 lstrcatW(buff, clsname);
1233 ptr = (WCHAR*)((BYTE*)wnddata + wnddata->name_offset);
1234 ok_(__FILE__, line)(!lstrcmpW(ptr, buff), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(buff));
1235 ok_(__FILE__, line)(lstrlenW(ptr)*sizeof(WCHAR) == wnddata->name_len,
1236 "got wrong class name length %d, expected %d\n", wnddata->name_len, lstrlenW(ptr));
1237
1238 /* data length is simply header length + string data length including nulls */
1239 len = wnddata->size + wnddata->name_len + wnddata->module_len + 2*sizeof(WCHAR);
1240 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1241
1242 if (data.ulSectionTotalLength > wnddata->module_offset)
1243 {
1244 WCHAR *modulename, *sectionptr;
1245
1246 /* just compare pointers */
1247 modulename = (WCHAR*)((BYTE*)wnddata + wnddata->size + wnddata->name_len + sizeof(WCHAR));
1248 sectionptr = (WCHAR*)((BYTE*)data.lpSectionBase + wnddata->module_offset);
1249 ok_(__FILE__, line)(modulename == sectionptr, "got wrong name offset %p, expected %p\n", sectionptr, modulename);
1250 }
1251 }
1252
1253 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1254 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1255 data.ulSectionGlobalDataLength);
1256 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1257 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1258 data.ulSectionTotalLength);
1259 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1260 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1261 data.ulAssemblyRosterIndex, exid);
1262
1263 memset(&data, 0xfe, sizeof(data));
1264 data.cbSize = sizeof(data);
1265
1266 ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
1267 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1268 clsname, &data);
1269 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1270 wine_dbgstr_w(clsname));
1271 if (!ret) return;
1272
1273 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1274 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1275 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1276 ok_(__FILE__, line)(data.ulLength > 0, "data.ulLength=%u\n", data.ulLength);
1277 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1278 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1279 data.ulSectionGlobalDataLength);
1280 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1281 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
1282 ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
1283 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1284 data.ulAssemblyRosterIndex, exid);
1285
1286 pReleaseActCtx(handle);
1287}
1288
1289static void test_find_string_fail(void)
1290{
1291 ACTCTX_SECTION_KEYED_DATA data = {sizeof(data)};
1292 BOOL ret;
1293
1294 ret = pFindActCtxSectionStringW(0, NULL, 100, testlib_dll, &data);
1295 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1296 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1297
1298 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1299 testlib2_dll, &data);
1300 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1301 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1302
1303 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1304 testlib_dll, NULL);
1305 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1306 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1307
1308 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1309 NULL, &data);
1310 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1311 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1312
1313 data.cbSize = 0;
1314 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1315 testlib_dll, &data);
1316 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1317 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1318
1319 data.cbSize = 35;
1320 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1321 testlib_dll, &data);
1322 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1323 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1324}
1325
1326
1328{
1329 ACTIVATION_CONTEXT_BASIC_INFORMATION basic;
1330 SIZE_T size;
1331 BOOL b;
1332
1333 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
1334 ActivationContextBasicInformation, &basic,
1335 sizeof(basic), &size);
1336
1337 ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n");
1338 ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n");
1339 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
1340 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
1341
1342 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX |
1343 QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
1344 ActivationContextBasicInformation, &basic,
1345 sizeof(basic), &size);
1346 if (handle)
1347 {
1348 ok_(__FILE__, line) (!b,"ActivationContextBasicInformation succeeded\n");
1349 ok_(__FILE__, line) (size == 0,"size mismatch\n");
1350 ok_(__FILE__, line) (GetLastError() == ERROR_INVALID_PARAMETER, "Wrong last error\n");
1351 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
1352 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
1353 }
1354 else
1355 {
1356 ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n");
1357 ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n");
1358 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
1359 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
1360 }
1361}
1362
1370
1378
1379struct comclassredirect_data {
1380 ULONG size;
1381 BYTE res;
1382 BYTE miscmask;
1383 BYTE res1[2];
1384 DWORD model;
1385 GUID clsid;
1386 GUID alias;
1387 GUID clsid2;
1400};
1401
1402struct clrclass_data {
1403 ULONG size;
1404 DWORD res[2];
1411 DWORD res2[2];
1412};
1413
1414static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GUID *tlid, const WCHAR *progid, ULONG exid, int line)
1415{
1416 struct comclassredirect_data *comclass, *comclass2;
1417 ACTCTX_SECTION_KEYED_DATA data, data2;
1418 struct guidsection_header *header;
1419 BOOL ret;
1420
1421 memset(&data, 0xfe, sizeof(data));
1422 data.cbSize = sizeof(data);
1423
1424 ret = pFindActCtxSectionGuid(0, NULL,
1425 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1426 clsid, &data);
1427 if (!ret)
1428 {
1429 skip("failed for guid %s\n", wine_dbgstr_guid(clsid));
1430 return;
1431 }
1432 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1433
1434 comclass = (struct comclassredirect_data*)data.lpData;
1435
1436 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1437 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1438 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1439 ok_(__FILE__, line)(comclass->size == sizeof(*comclass), "got %d for header size\n", comclass->size);
1440 if (data.lpData && comclass->size == sizeof(*comclass))
1441 {
1442 WCHAR *ptr;
1443 ULONG len;
1444
1445 ok_(__FILE__, line)(comclass->res == 0, "got res as %d\n", comclass->res);
1446 ok_(__FILE__, line)(comclass->res1[0] == 0, "got res1[0] as %02x\n", comclass->res1[0]);
1447 ok_(__FILE__, line)(comclass->res1[1] == 0, "got res1[1] as %02x\n", comclass->res1[1]);
1448 ok_(__FILE__, line)(comclass->model == ThreadingModel_Neutral, "got model %d\n", comclass->model);
1449 ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass->clsid));
1450 ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid2, clsid), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass->clsid2));
1451 if (tlid)
1452 ok_(__FILE__, line)(IsEqualGUID(&comclass->tlid, tlid), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass->tlid));
1453 ok_(__FILE__, line)(comclass->name_len > 0, "got modulename len %d\n", comclass->name_len);
1454
1455 if (progid)
1456 {
1457 len = comclass->size + comclass->clrdata_len;
1458 ok_(__FILE__, line)(comclass->progid_offset == len, "got progid offset %d, expected %d\n", comclass->progid_offset, len);
1459 }
1460 else
1461 ok_(__FILE__, line)(comclass->progid_offset == 0, "got progid offset %d, expected 0\n", comclass->progid_offset);
1462
1463 if (comclass->progid_offset)
1464 {
1465 ptr = (WCHAR*)((BYTE*)comclass + comclass->progid_offset);
1466 ok_(__FILE__, line)(!lstrcmpW(ptr, progid), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(progid));
1467 ok_(__FILE__, line)(lstrlenW(progid)*sizeof(WCHAR) == comclass->progid_len,
1468 "got progid name length %d\n", comclass->progid_len);
1469 }
1470
1471 /* data length is simply header length + string data length including nulls */
1472 len = comclass->size + comclass->clrdata_len;
1473 if (comclass->progid_len) len += comclass->progid_len + sizeof(WCHAR);
1474 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1475
1476 /* keyed data structure doesn't include module name, it's available from section data */
1477 ok_(__FILE__, line)(data.ulSectionTotalLength > comclass->name_offset, "got wrong offset %d\n", comclass->name_offset);
1478
1479 /* check misc fields are set */
1480 if (comclass->miscmask)
1481 {
1482 if (comclass->miscmask & MiscStatus)
1483 ok_(__FILE__, line)(comclass->miscstatus != 0, "got miscstatus 0x%08x\n", comclass->miscstatus);
1484 if (comclass->miscmask & MiscStatusIcon)
1485 ok_(__FILE__, line)(comclass->miscstatusicon != 0, "got miscstatusicon 0x%08x\n", comclass->miscstatusicon);
1486 if (comclass->miscmask & MiscStatusContent)
1487 ok_(__FILE__, line)(comclass->miscstatuscontent != 0, "got miscstatuscontent 0x%08x\n", comclass->miscstatuscontent);
1488 if (comclass->miscmask & MiscStatusThumbnail)
1489 ok_(__FILE__, line)(comclass->miscstatusthumbnail != 0, "got miscstatusthumbnail 0x%08x\n", comclass->miscstatusthumbnail);
1490 if (comclass->miscmask & MiscStatusDocPrint)
1491 ok_(__FILE__, line)(comclass->miscstatusdocprint != 0, "got miscstatusdocprint 0x%08x\n", comclass->miscstatusdocprint);
1492 }
1493
1494 /* part used for clrClass only */
1495 if (comclass->clrdata_len)
1496 {
1497 static const WCHAR mscoreeW[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1498 static const WCHAR mscoree2W[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1499 struct clrclass_data *clrclass;
1500 WCHAR *ptrW;
1501
1502 clrclass = (struct clrclass_data*)((BYTE*)data.lpData + comclass->clrdata_offset);
1503 ok_(__FILE__, line)(clrclass->size == sizeof(*clrclass), "clrclass: got size %d\n", clrclass->size);
1504 ok_(__FILE__, line)(clrclass->res[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass->res[0]);
1505 ok_(__FILE__, line)(clrclass->res[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass->res[1]);
1506 ok_(__FILE__, line)(clrclass->module_len == lstrlenW(mscoreeW)*sizeof(WCHAR), "clrclass: got module len %d\n", clrclass->module_len);
1507 ok_(__FILE__, line)(clrclass->module_offset > 0, "clrclass: got module offset %d\n", clrclass->module_offset);
1508
1509 ok_(__FILE__, line)(clrclass->name_len > 0, "clrclass: got name len %d\n", clrclass->name_len);
1510 ok_(__FILE__, line)(clrclass->name_offset == clrclass->size, "clrclass: got name offset %d\n", clrclass->name_offset);
1511 ok_(__FILE__, line)(clrclass->version_len > 0, "clrclass: got version len %d\n", clrclass->version_len);
1512 ok_(__FILE__, line)(clrclass->version_offset > 0, "clrclass: got version offset %d\n", clrclass->version_offset);
1513
1514 ok_(__FILE__, line)(clrclass->res2[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass->res2[0]);
1515 ok_(__FILE__, line)(clrclass->res2[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass->res2[1]);
1516
1517 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1518 in lower case, clsclass subsection - in upper case */
1519 ok_(__FILE__, line)(comclass->name_len == lstrlenW(mscoree2W)*sizeof(WCHAR), "clrclass: got com name len %d\n", comclass->name_len);
1520 ok_(__FILE__, line)(comclass->name_offset > 0, "clrclass: got name offset %d\n", clrclass->name_offset);
1521
1522 ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + comclass->name_offset);
1523 ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoreeW), "clrclass: module name %s\n", wine_dbgstr_w(ptrW));
1524
1525 ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + clrclass->module_offset);
1526 ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoree2W), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW));
1527 }
1528 }
1529
1530 header = (struct guidsection_header*)data.lpSectionBase;
1531 ok_(__FILE__, line)(data.lpSectionGlobalData == ((BYTE*)header + header->names_offset), "data.lpSectionGlobalData == NULL\n");
1532 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%u\n",
1533 data.ulSectionGlobalDataLength);
1534 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1535 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1536 data.ulSectionTotalLength);
1537 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1538 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1539 data.ulAssemblyRosterIndex, exid);
1540
1541 /* generated guid for this class works as key guid in search */
1542 memset(&data2, 0xfe, sizeof(data2));
1543 data2.cbSize = sizeof(data2);
1544 ret = pFindActCtxSectionGuid(0, NULL,
1545 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1546 &comclass->alias, &data2);
1547 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1548
1549 comclass2 = (struct comclassredirect_data*)data2.lpData;
1550 ok_(__FILE__, line)(comclass->size == comclass2->size, "got wrong data length %d, expected %d\n", comclass2->size, comclass->size);
1551 ok_(__FILE__, line)(!memcmp(comclass, comclass2, comclass->size), "got wrong data\n");
1552}
1553
1555{
1557 BaseIface = 2
1559
1561{
1562 ULONG size;
1563 DWORD mask;
1564 GUID iid;
1566 GUID tlbid;
1567 GUID base;
1570};
1571
1572static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const GUID *tlbid, const GUID *base,
1573 const GUID *ps32, ULONG exid, int line)
1574{
1575 struct ifacepsredirect_data *ifaceps;
1576 ACTCTX_SECTION_KEYED_DATA data;
1577 BOOL ret;
1578
1579 memset(&data, 0xfe, sizeof(data));
1580 data.cbSize = sizeof(data);
1581
1582 ret = pFindActCtxSectionGuid(0, NULL,
1583 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION,
1584 iid, &data);
1585 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1586
1587 ifaceps = (struct ifacepsredirect_data*)data.lpData;
1588
1589 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1590 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1591 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1592 ok_(__FILE__, line)(ifaceps->size == sizeof(*ifaceps), "got %d for header size\n", ifaceps->size);
1593 if (data.lpData && ifaceps->size == sizeof(*ifaceps))
1594 {
1595 ULONG len;
1596
1597 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1598 if (ps32)
1599 {
1600 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, ps32), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
1601 }
1602 else
1603 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, iid), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
1604
1605 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->tlbid, tlbid), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps->tlbid));
1606 ok_(__FILE__, line)(ifaceps->name_len > 0, "got modulename len %d\n", ifaceps->name_len);
1607 ok_(__FILE__, line)(ifaceps->name_offset == ifaceps->size, "got progid offset %d\n", ifaceps->name_offset);
1608
1609 /* data length is simply header length + string data length including nulls */
1610 len = ifaceps->size + ifaceps->name_len + sizeof(WCHAR);
1611 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1612
1613 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1614 always has non-zero value for it */
1615 if (ifaceps->mask & NumMethods)
1616 ok_(__FILE__, line)(ifaceps->nummethods != 0, "got nummethods %d\n", ifaceps->nummethods);
1617 if (ifaceps->mask & BaseIface)
1618 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->base, base), "got base %s\n", wine_dbgstr_guid(&ifaceps->base));
1619 }
1620
1621 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1622 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1623 data.ulSectionGlobalDataLength);
1624 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1625 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1626 data.ulSectionTotalLength);
1627 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1628 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1629 data.ulAssemblyRosterIndex, exid);
1630}
1631
1633{
1641};
1642
1643static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *name, const WCHAR *version,
1644 ULONG exid, int line)
1645{
1646 struct clrsurrogate_data *surrogate;
1647 ACTCTX_SECTION_KEYED_DATA data;
1648 BOOL ret;
1649
1650 memset(&data, 0xfe, sizeof(data));
1651 data.cbSize = sizeof(data);
1652
1653 ret = pFindActCtxSectionGuid(0, NULL,
1654 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES,
1655 clsid, &data);
1656 if (!ret)
1657 {
1658 skip("surrogate sections are not supported\n");
1659 return;
1660 }
1661 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1662
1663 surrogate = (struct clrsurrogate_data*)data.lpData;
1664
1665 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1666 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1667 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1668 ok_(__FILE__, line)(surrogate->size == sizeof(*surrogate), "got %d for header size\n", surrogate->size);
1669 if (data.lpData && surrogate->size == sizeof(*surrogate))
1670 {
1671 WCHAR *ptrW;
1672 ULONG len;
1673
1674 ok_(__FILE__, line)(surrogate->res == 0, "invalid res value %d\n", surrogate->res);
1675 ok_(__FILE__, line)(IsEqualGUID(&surrogate->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate->clsid));
1676
1677 ok_(__FILE__, line)(surrogate->version_len == lstrlenW(version)*sizeof(WCHAR), "got version len %d\n", surrogate->version_len);
1678 ok_(__FILE__, line)(surrogate->version_offset == surrogate->size, "got version offset %d\n", surrogate->version_offset);
1679
1680 ok_(__FILE__, line)(surrogate->name_len == lstrlenW(name)*sizeof(WCHAR), "got name len %d\n", surrogate->name_len);
1681 ok_(__FILE__, line)(surrogate->name_offset > surrogate->version_offset, "got name offset %d\n", surrogate->name_offset);
1682
1683 len = surrogate->size + surrogate->name_len + surrogate->version_len + 2*sizeof(WCHAR);
1684 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1685
1686 ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->name_offset);
1687 ok(!lstrcmpW(ptrW, name), "got wrong name %s\n", wine_dbgstr_w(ptrW));
1688
1689 ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->version_offset);
1690 ok(!lstrcmpW(ptrW, version), "got wrong name %s\n", wine_dbgstr_w(ptrW));
1691 }
1692
1693 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1694 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1695 data.ulSectionGlobalDataLength);
1696 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1697 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1698 data.ulSectionTotalLength);
1699 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1700 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1701 data.ulAssemblyRosterIndex, exid);
1702}
1703
1704static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const char *progid, ULONG exid, int line)
1705{
1706 struct progidredirect_data *progiddata;
1707 struct comclassredirect_data *comclass;
1708 ACTCTX_SECTION_KEYED_DATA data, data2;
1709 struct strsection_header *header;
1710 BOOL ret;
1711
1712 memset(&data, 0xfe, sizeof(data));
1713 data.cbSize = sizeof(data);
1714
1715 ret = pFindActCtxSectionStringA(0, NULL,
1716 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION,
1717 progid, &data);
1718 ok_(__FILE__, line)(ret, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1719
1720 progiddata = (struct progidredirect_data*)data.lpData;
1721
1722 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1723 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1724 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1725 ok_(__FILE__, line)(progiddata->size == sizeof(*progiddata), "got %d for header size\n", progiddata->size);
1726 if (data.lpData && progiddata->size == sizeof(*progiddata))
1727 {
1728 GUID *guid;
1729
1730 ok_(__FILE__, line)(progiddata->reserved == 0, "got reserved as %d\n", progiddata->reserved);
1731 ok_(__FILE__, line)(progiddata->clsid_offset > 0, "got clsid_offset as %d\n", progiddata->clsid_offset);
1732
1733 /* progid data points to generated alias guid */
1734 guid = (GUID*)((BYTE*)data.lpSectionBase + progiddata->clsid_offset);
1735
1736 memset(&data2, 0, sizeof(data2));
1737 data2.cbSize = sizeof(data2);
1738 ret = pFindActCtxSectionGuid(0, NULL,
1739 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1740 guid, &data2);
1741 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1742
1743 comclass = (struct comclassredirect_data*)data2.lpData;
1744 ok_(__FILE__, line)(IsEqualGUID(guid, &comclass->alias), "got wrong alias referenced from progid %s, %s\n", progid, wine_dbgstr_guid(guid));
1745 ok_(__FILE__, line)(IsEqualGUID(clsid, &comclass->clsid), "got wrong class referenced from progid %s, %s\n", progid, wine_dbgstr_guid(clsid));
1746 }
1747
1748 header = (struct strsection_header*)data.lpSectionBase;
1749 ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE*)header + header->global_offset, "data.lpSectionGlobalData == NULL\n");
1750 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength);
1751 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1752 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
1753 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1754 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1755 data.ulAssemblyRosterIndex, exid);
1756}
1757
1758static void test_wndclass_section(void)
1759{
1760 static const WCHAR cls1W[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1761 ACTCTX_SECTION_KEYED_DATA data, data2;
1762 struct wndclass_redirect_data *classdata;
1763 struct strsection_header *section;
1765 HANDLE handle;
1766 WCHAR *ptrW;
1767 BOOL ret;
1768
1769 /* use two dependent manifests, each defines 2 window class redirects */
1770 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
1771 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
1772 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
1773
1774 handle = test_create("main_wndcls.manifest");
1775 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1776
1777 DeleteFileA("testdep1.manifest");
1778 DeleteFileA("testdep2.manifest");
1779 DeleteFileA("main_wndcls.manifest");
1780
1781 ret = pActivateActCtx(handle, &cookie);
1782 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
1783
1784 memset(&data, 0, sizeof(data));
1785 memset(&data2, 0, sizeof(data2));
1786 data.cbSize = sizeof(data);
1787 data2.cbSize = sizeof(data2);
1788
1789 /* get data for two classes from different assemblies */
1790 ret = pFindActCtxSectionStringW(0, NULL,
1791 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1792 wndClass1W, &data);
1793 ok(ret, "got %d\n", ret);
1794 ret = pFindActCtxSectionStringW(0, NULL,
1795 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1796 wndClass3W, &data2);
1797 ok(ret, "got %d\n", ret);
1798
1799 section = (struct strsection_header*)data.lpSectionBase;
1800 ok(section->count == 4, "got %d\n", section->count);
1801 ok(section->size == sizeof(*section), "got %d\n", section->size);
1802
1803 /* For both string same section is returned, meaning it's one wndclass section per context */
1804 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
1805 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
1806 data2.ulSectionTotalLength);
1807
1808 /* wndClass1 is versioned, wndClass3 is not */
1809 classdata = (struct wndclass_redirect_data*)data.lpData;
1810 ptrW = (WCHAR*)((BYTE*)data.lpData + classdata->name_offset);
1811 ok(!lstrcmpW(ptrW, cls1W), "got %s\n", wine_dbgstr_w(ptrW));
1812
1813 classdata = (struct wndclass_redirect_data*)data2.lpData;
1814 ptrW = (WCHAR*)((BYTE*)data2.lpData + classdata->name_offset);
1815 ok(!lstrcmpW(ptrW, wndClass3W), "got %s\n", wine_dbgstr_w(ptrW));
1816
1817 ret = pDeactivateActCtx(0, cookie);
1818 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
1819
1820 pReleaseActCtx(handle);
1821}
1822
1824{
1825 static const WCHAR testlib1W[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1826 static const WCHAR testlib2W[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1827 ACTCTX_SECTION_KEYED_DATA data, data2;
1828 struct strsection_header *section;
1830 HANDLE handle;
1831 BOOL ret;
1832
1833 /* use two dependent manifests, 4 'files' total */
1834 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
1835 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
1836 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
1837
1838 handle = test_create("main_wndcls.manifest");
1839 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1840
1841 DeleteFileA("testdep1.manifest");
1842 DeleteFileA("testdep2.manifest");
1843 DeleteFileA("main_wndcls.manifest");
1844
1845 ret = pActivateActCtx(handle, &cookie);
1846 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
1847
1848 memset(&data, 0, sizeof(data));
1849 memset(&data2, 0, sizeof(data2));
1850 data.cbSize = sizeof(data);
1851 data2.cbSize = sizeof(data2);
1852
1853 /* get data for two files from different assemblies */
1854 ret = pFindActCtxSectionStringW(0, NULL,
1855 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1856 testlib1W, &data);
1857 ok(ret, "got %d\n", ret);
1858 ret = pFindActCtxSectionStringW(0, NULL,
1859 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1860 testlib2W, &data2);
1861 ok(ret, "got %d\n", ret);
1862
1863 section = (struct strsection_header*)data.lpSectionBase;
1864 ok(section->count == 4, "got %d\n", section->count);
1865 ok(section->size == sizeof(*section), "got %d\n", section->size);
1866
1867 /* For both string same section is returned, meaning it's one dll redirect section per context */
1868 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
1869 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
1870 data2.ulSectionTotalLength);
1871
1872 ret = pDeactivateActCtx(0, cookie);
1873 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
1874
1875 pReleaseActCtx(handle);
1876}
1877
1878static void test_typelib_section(void)
1879{
1880 static const WCHAR helpW[] = {'h','e','l','p'};
1881 ACTCTX_SECTION_KEYED_DATA data, data2;
1883 struct tlibredirect_data *tlib;
1885 HANDLE handle;
1886 BOOL ret;
1887
1888 /* use two dependent manifests, 4 'files' total */
1889 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
1890 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
1891 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
1892
1893 handle = test_create("main_wndcls.manifest");
1894 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1895
1896 DeleteFileA("testdep1.manifest");
1897 DeleteFileA("testdep2.manifest");
1898 DeleteFileA("main_wndcls.manifest");
1899
1900 ret = pActivateActCtx(handle, &cookie);
1901 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
1902
1903 memset(&data, 0, sizeof(data));
1904 memset(&data2, 0, sizeof(data2));
1905 data.cbSize = sizeof(data);
1906 data2.cbSize = sizeof(data2);
1907
1908 /* get data for two typelibs from different assemblies */
1909 ret = pFindActCtxSectionGuid(0, NULL,
1910 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION,
1911 &IID_TlibTest, &data);
1912 ok(ret, "got %d\n", ret);
1913
1914 ret = pFindActCtxSectionGuid(0, NULL,
1915 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION,
1916 &IID_TlibTest4, &data2);
1917 ok(ret, "got %d\n", ret);
1918
1919 section = (struct guidsection_header*)data.lpSectionBase;
1920 ok(section->count == 4, "got %d\n", section->count);
1921 ok(section->size == sizeof(*section), "got %d\n", section->size);
1922
1923 /* For both GUIDs same section is returned */
1924 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
1925 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
1926 data2.ulSectionTotalLength);
1927
1928 ok(data.lpSectionGlobalData == ((BYTE*)section + section->names_offset), "data.lpSectionGlobalData == NULL\n");
1929 ok(data.ulSectionGlobalDataLength == section->names_len, "data.ulSectionGlobalDataLength=%u\n",
1930 data.ulSectionGlobalDataLength);
1931
1932 /* test some actual data */
1933 tlib = (struct tlibredirect_data*)data.lpData;
1934 ok(tlib->size == sizeof(*tlib), "got %d\n", tlib->size);
1935 ok(tlib->major_version == 1, "got %d\n", tlib->major_version);
1936 ok(tlib->minor_version == 0, "got %d\n", tlib->minor_version);
1937 ok(tlib->help_offset > 0, "got %d\n", tlib->help_offset);
1938 ok(tlib->help_len == sizeof(helpW), "got %d\n", tlib->help_len);
1939 ok(tlib->flags == (LIBFLAG_FHIDDEN|LIBFLAG_FCONTROL|LIBFLAG_FRESTRICTED), "got %x\n", tlib->flags);
1940
1941 ret = pDeactivateActCtx(0, cookie);
1942 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
1943
1944 pReleaseActCtx(handle);
1945}
1946
1948{
1949 HANDLE handle;
1950
1951 if (!create_manifest_file("test5.manifest", manifest5, -1, NULL, NULL)) {
1952 skip("Could not create manifest file\n");
1953 return;
1954 }
1955
1956 handle = test_create("test5.manifest");
1958 win_skip("allowDelayedBinding attribute is not supported.\n");
1959 return;
1960 }
1961
1962 DeleteFileA("test5.manifest");
1963 DeleteFileA("testdep.manifest");
1965 test_basic_info(handle, __LINE__);
1966 pReleaseActCtx(handle);
1967 }
1968}
1969
1970static void test_actctx(void)
1971{
1973 HANDLE handle;
1974 BOOL b;
1975
1976 trace("default actctx\n");
1977
1978 b = pGetCurrentActCtx(&handle);
1979 ok(handle == NULL, "handle = %p, expected NULL\n", handle);
1980 ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
1981 if(b) {
1982 test_basic_info(handle, __LINE__);
1985 pReleaseActCtx(handle);
1986 }
1987
1988 /* test for whitespace handling in Eq ::= S? '=' S? */
1989 create_manifest_file("test1_1.manifest", manifest1_1, -1, NULL, NULL);
1990 handle = test_create("test1_1.manifest");
1991 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1992 DeleteFileA("test1_1.manifest");
1993 pReleaseActCtx(handle);
1994
1995 if(!create_manifest_file("test1.manifest", manifest1, -1, NULL, NULL)) {
1996 skip("Could not create manifest file\n");
1997 return;
1998 }
1999
2000 trace("manifest1\n");
2001
2002 handle = test_create("test1.manifest");
2003 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2004 DeleteFileA("test1.manifest");
2006 test_basic_info(handle, __LINE__);
2009
2010 if (pIsDebuggerPresent && !pIsDebuggerPresent())
2011 {
2012 /* CloseHandle will generate an exception if a debugger is present */
2013 b = CloseHandle(handle);
2014 ok(!b, "CloseHandle succeeded\n");
2015 ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() == %u\n", GetLastError());
2016 }
2017
2018 pReleaseActCtx(handle);
2019 }
2020
2021 if(!create_manifest_file("test2.manifest", manifest2, -1, "testdep.manifest", testdep_manifest1)) {
2022 skip("Could not create manifest file\n");
2023 return;
2024 }
2025
2026 trace("manifest2 depmanifest1\n");
2027
2028 handle = test_create("test2.manifest");
2029 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2030 DeleteFileA("test2.manifest");
2031 DeleteFileA("testdep.manifest");
2033 test_basic_info(handle, __LINE__);
2037 pReleaseActCtx(handle);
2038 }
2039
2040 if(!create_manifest_file("test2-2.manifest", manifest2, -1, "testdep.manifest", testdep_manifest2)) {
2041 skip("Could not create manifest file\n");
2042 return;
2043 }
2044
2045 trace("manifest2 depmanifest2\n");
2046
2047 handle = test_create("test2-2.manifest");
2048 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2049 DeleteFileA("test2-2.manifest");
2050 DeleteFileA("testdep.manifest");
2052 test_basic_info(handle, __LINE__);
2056 test_file_info(handle, 1, 0, testlib_dll, __LINE__);
2057 test_file_info(handle, 1, 1, testlib2_dll, __LINE__);
2058
2059 b = pActivateActCtx(handle, &cookie);
2060 ok(b, "ActivateActCtx failed: %u\n", GetLastError());
2063 b = pDeactivateActCtx(0, cookie);
2064 ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
2065
2066 pReleaseActCtx(handle);
2067 }
2068
2069 trace("manifest2 depmanifest3\n");
2070
2071 if(!create_manifest_file("test2-3.manifest", manifest2, -1, "testdep.manifest", testdep_manifest3)) {
2072 skip("Could not create manifest file\n");
2073 return;
2074 }
2075
2076 handle = test_create("test2-3.manifest");
2077 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2078 DeleteFileA("test2-3.manifest");
2079 DeleteFileA("testdep.manifest");
2081 test_basic_info(handle, __LINE__);
2085 test_file_info(handle, 1, 0, testlib_dll, __LINE__);
2086 test_file_info(handle, 1, 1, testlib2_dll, __LINE__);
2087
2088 b = pActivateActCtx(handle, &cookie);
2089 ok(b, "ActivateActCtx failed: %u\n", GetLastError());
2094 b = pDeactivateActCtx(0, cookie);
2095 ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
2096
2097 pReleaseActCtx(handle);
2098 }
2099
2100 trace("manifest3\n");
2101
2102 if(!create_manifest_file("test3.manifest", manifest3, -1, NULL, NULL)) {
2103 skip("Could not create manifest file\n");
2104 return;
2105 }
2106
2107 handle = test_create("test3.manifest");
2108 ok(handle != INVALID_HANDLE_VALUE || broken(handle == INVALID_HANDLE_VALUE) /* XP pre-SP2, win2k3 w/o SP */,
2109 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2111 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
2112 DeleteFileA("test3.manifest");
2114 static const WCHAR nameW[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
2115 static const WCHAR versionW[] = {'v','2','.','0','.','5','0','7','2','7',0};
2116 static const WCHAR progidW[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
2117 static const WCHAR clrprogidW[] = {'c','l','r','p','r','o','g','i','d',0};
2118
2119 test_basic_info(handle, __LINE__);
2122 test_file_info(handle, 0, 0, testlib_dll, __LINE__);
2123
2124 b = pActivateActCtx(handle, &cookie);
2125 ok(b, "ActivateActCtx failed: %u\n", GetLastError());
2128 test_find_com_redirection(handle, &IID_CoTest, &IID_TlibTest, progidW, 1, __LINE__);
2129 test_find_com_redirection(handle, &IID_CoTest2, NULL, NULL, 1, __LINE__);
2130 test_find_com_redirection(handle, &CLSID_clrclass, &IID_TlibTest, clrprogidW, 1, __LINE__);
2131 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId", 1, __LINE__);
2132 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.1", 1, __LINE__);
2133 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.2", 1, __LINE__);
2134 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.3", 1, __LINE__);
2135 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.4", 1, __LINE__);
2136 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.5", 1, __LINE__);
2137 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.6", 1, __LINE__);
2138 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid", 1, __LINE__);
2139 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.1", 1, __LINE__);
2140 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.2", 1, __LINE__);
2141 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.3", 1, __LINE__);
2142 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.4", 1, __LINE__);
2143 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.5", 1, __LINE__);
2144 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.6", 1, __LINE__);
2145 test_find_surrogate(handle, &IID_Iiface, nameW, versionW, 1, __LINE__);
2146 test_find_ifaceps_redirection(handle, &IID_Iifaceps, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__);
2147 test_find_ifaceps_redirection(handle, &IID_Iifaceps2, &IID_TlibTest4, &IID_Ibifaceps, &IID_PS32, 1, __LINE__);
2148 test_find_ifaceps_redirection(handle, &IID_Iifaceps3, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__);
2150
2151 b = pDeactivateActCtx(0, cookie);
2152 ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
2153 pReleaseActCtx(handle);
2154 }
2155
2156 trace("manifest6\n");
2157
2158 if(create_manifest_file("test6.manifest", manifest6, -1, NULL, NULL)) {
2159 handle = test_create("test6.manifest");
2161 "Unexpected context handle %p.\n", handle);
2162 DeleteFileA("test6.manifest");
2163 DeleteFileA("testdep.manifest");
2165 {
2167 pReleaseActCtx(handle);
2168 }
2169 }
2170 else
2171 skip("Could not create manifest file 6\n");
2172
2173 trace("manifest7\n");
2174
2175 if(create_manifest_file("test7.manifest", manifest7, -1, NULL, NULL)) {
2176 handle = test_create("test7.manifest");
2177 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2178 DeleteFileA("test7.manifest");
2179 DeleteFileA("testdep.manifest");
2181 {
2183 pReleaseActCtx(handle);
2184 }
2185 }
2186 else
2187 skip("Could not create manifest file 7\n");
2188
2189 trace("manifest8\n");
2190
2191 if(create_manifest_file("test8.manifest", manifest8, -1, NULL, NULL)) {
2192 handle = test_create("test8.manifest");
2193 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2194 DeleteFileA("test8.manifest");
2195 DeleteFileA("testdep.manifest");
2197 {
2199 pReleaseActCtx(handle);
2200 }
2201 }
2202 else
2203 skip("Could not create manifest file 8\n");
2204
2205 trace("manifest9\n");
2206
2207 if(create_manifest_file("test9.manifest", manifest9, -1, NULL, NULL)) {
2208 handle = test_create("test9.manifest");
2209 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2210 DeleteFileA("test9.manifest");
2211 DeleteFileA("testdep.manifest");
2213 {
2215 pReleaseActCtx(handle);
2216 }
2217 }
2218 else
2219 skip("Could not create manifest file 9\n");
2220
2221 trace("manifest4\n");
2222
2223 if(!create_manifest_file("test4.manifest", manifest4, -1, NULL, NULL)) {
2224 skip("Could not create manifest file\n");
2225 return;
2226 }
2227
2228 handle = test_create("test4.manifest");
2229 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2230 DeleteFileA("test4.manifest");
2231 DeleteFileA("testdep.manifest");
2233 test_basic_info(handle, __LINE__);
2237 pReleaseActCtx(handle);
2238 }
2239
2240 trace("manifest1 in subdir\n");
2241
2244 {
2245 if(!create_manifest_file("..\\test1.manifest", manifest1, -1, NULL, NULL)) {
2246 skip("Could not create manifest file\n");
2247 return;
2248 }
2249 handle = test_create("..\\test1.manifest");
2250 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2251 DeleteFileA("..\\test1.manifest");
2253 test_basic_info(handle, __LINE__);
2256 pReleaseActCtx(handle);
2257 }
2259 }
2260 else
2261 skip("Couldn't change directory\n");
2263
2264 trace("UTF-16 manifest1, with BOM\n");
2265 if(!create_wide_manifest("test1.manifest", manifest1, TRUE, FALSE)) {
2266 skip("Could not create manifest file\n");
2267 return;
2268 }
2269
2270 handle = test_create("test1.manifest");
2271 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2272 DeleteFileA("test1.manifest");
2274 test_basic_info(handle, __LINE__);
2277 pReleaseActCtx(handle);
2278 }
2279
2280 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2281 if(!create_wide_manifest("test1.manifest", manifest1, TRUE, TRUE)) {
2282 skip("Could not create manifest file\n");
2283 return;
2284 }
2285
2286 handle = test_create("test1.manifest");
2287 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2288 DeleteFileA("test1.manifest");
2290 test_basic_info(handle, __LINE__);
2293 pReleaseActCtx(handle);
2294 }
2295
2300}
2301
2302static void test_app_manifest(void)
2303{
2304 HANDLE handle;
2305 BOOL b;
2306
2307 trace("child process manifest1\n");
2308
2309 b = pGetCurrentActCtx(&handle);
2310 ok(handle == NULL, "handle != NULL\n");
2311 ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
2312 if(b) {
2313 test_basic_info(handle, __LINE__);
2316 pReleaseActCtx(handle);
2317 }
2318}
2319
2320static HANDLE create_manifest(const char *filename, const char *data, int line)
2321{
2322 HANDLE handle;
2324
2326 ok_(__FILE__, line)(handle != INVALID_HANDLE_VALUE,
2327 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2328
2330 return handle;
2331}
2332
2333static void kernel32_find(ULONG section, const char *string_to_find, BOOL should_find, int line)
2334{
2335 UNICODE_STRING string_to_findW;
2336 ACTCTX_SECTION_KEYED_DATA data;
2337 BOOL ret;
2338 DWORD err;
2339
2340 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW, string_to_find);
2341
2342 memset(&data, 0xfe, sizeof(data));
2343 data.cbSize = sizeof(data);
2344
2345 SetLastError(0);
2346 ret = pFindActCtxSectionStringA(0, NULL, section, string_to_find, &data);
2347 err = GetLastError();
2348 ok_(__FILE__, line)(ret == should_find,
2349 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find, ret);
2350 ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND),
2351 "FindActCtxSectionStringA: unexpected error %u\n", err);
2352
2353 memset(&data, 0xfe, sizeof(data));
2354 data.cbSize = sizeof(data);
2355
2356 SetLastError(0);
2357 ret = pFindActCtxSectionStringW(0, NULL, section, string_to_findW.Buffer, &data);
2358 err = GetLastError();
2359 ok_(__FILE__, line)(ret == should_find,
2360 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find, ret);
2361 ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND),
2362 "FindActCtxSectionStringW: unexpected error %u\n", err);
2363
2364 SetLastError(0);
2365 ret = pFindActCtxSectionStringA(0, NULL, section, string_to_find, NULL);
2366 err = GetLastError();
2367 ok_(__FILE__, line)(!ret,
2368 "FindActCtxSectionStringA: expected failure, got %u\n", ret);
2369 ok_(__FILE__, line)(err == ERROR_INVALID_PARAMETER,
2370 "FindActCtxSectionStringA: unexpected error %u\n", err);
2371
2372 SetLastError(0);
2373 ret = pFindActCtxSectionStringW(0, NULL, section, string_to_findW.Buffer, NULL);
2374 err = GetLastError();
2375 ok_(__FILE__, line)(!ret,
2376 "FindActCtxSectionStringW: expected failure, got %u\n", ret);
2377 ok_(__FILE__, line)(err == ERROR_INVALID_PARAMETER,
2378 "FindActCtxSectionStringW: unexpected error %u\n", err);
2379
2380 pRtlFreeUnicodeString(&string_to_findW);
2381}
2382
2383static void ntdll_find(ULONG section, const char *string_to_find, BOOL should_find, int line)
2384{
2385 UNICODE_STRING string_to_findW;
2386 ACTCTX_SECTION_KEYED_DATA data;
2387 NTSTATUS ret;
2388
2389 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW, string_to_find);
2390
2391 memset(&data, 0xfe, sizeof(data));
2392 data.cbSize = sizeof(data);
2393
2394 ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, &data);
2395 ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND),
2396 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret);
2397
2398 ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, NULL);
2399 ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND),
2400 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret);
2401
2402 pRtlFreeUnicodeString(&string_to_findW);
2403}
2404
2405static void test_findsectionstring(void)
2406{
2407 HANDLE handle;
2408 BOOL ret;
2410
2411 handle = create_manifest("test.manifest", testdep_manifest3, __LINE__);
2412 ret = pActivateActCtx(handle, &cookie);
2413 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
2414
2415 /* first we show the parameter validation from kernel32 */
2416 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, __LINE__);
2417 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib.dll", TRUE, __LINE__);
2418 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib2.dll", TRUE, __LINE__);
2419 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib3.dll", FALSE, __LINE__);
2420 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass", TRUE, __LINE__);
2421 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass2", TRUE, __LINE__);
2422 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, __LINE__);
2423
2424 /* then we show that ntdll plays by different rules */
2425 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, __LINE__);
2426 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib.dll", TRUE, __LINE__);
2427 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib2.dll", TRUE, __LINE__);
2428 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, "testlib3.dll", FALSE, __LINE__);
2429 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass", TRUE, __LINE__);
2430 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass2", TRUE, __LINE__);
2431 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, __LINE__);
2432
2433 ret = pDeactivateActCtx(0, cookie);
2434 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
2435 pReleaseActCtx(handle);
2436}
2437
2438static void run_child_process(void)
2439{
2440 char cmdline[MAX_PATH];
2441 char path[MAX_PATH];
2442 char **argv;
2444 STARTUPINFOA si = { 0 };
2445 HANDLE file;
2446 FILETIME now;
2447 BOOL ret;
2448
2450 strcat(path, ".manifest");
2452 skip("Could not create manifest file\n");
2453 return;
2454 }
2455
2456 si.cb = sizeof(si);
2458 /* Vista+ seems to cache presence of .manifest files. Change last modified
2459 date to defeat the cache */
2461 NULL, OPEN_EXISTING, 0, NULL);
2462 if (file != INVALID_HANDLE_VALUE) {
2466 }
2467 sprintf(cmdline, "\"%s\" %s manifest1", argv[0], argv[1]);
2468 ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
2469 ok(ret, "Could not create process: %u\n", GetLastError());
2470 winetest_wait_child_process( pi.hProcess );
2471 CloseHandle(pi.hThread);
2472 CloseHandle(pi.hProcess);
2474}
2475
2476static void init_paths(void)
2477{
2478 LPWSTR ptr;
2479
2480 static const WCHAR dot_manifest[] = {'.','M','a','n','i','f','e','s','t',0};
2481 static const WCHAR backslash[] = {'\\',0};
2482 static const WCHAR subdir[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2483
2484 GetModuleFileNameW(NULL, exe_path, sizeof(exe_path)/sizeof(WCHAR));
2486 for(ptr=app_dir+lstrlenW(app_dir); *ptr != '\\' && *ptr != '/'; ptr--);
2487 ptr[1] = 0;
2488
2490 ptr = work_dir + lstrlenW( work_dir ) - 1;
2491 if (*ptr != '\\' && *ptr != '/')
2492 lstrcatW(work_dir, backslash);
2494 lstrcatW(work_dir_subdir, subdir);
2495
2498}
2499
2500static void write_manifest(const char *filename, const char *manifest)
2501{
2502 HANDLE file;
2503 DWORD size;
2505
2506 GetTempPathA(sizeof(path)/sizeof(CHAR), path);
2508
2510 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
2513}
2514
2515static void delete_manifest_file(const char *filename)
2516{
2518
2519 GetTempPathA(sizeof(path)/sizeof(CHAR), path);
2522}
2523
2524static void test_CreateActCtx(void)
2525{
2527 ACTCTXA actctx;
2528 HANDLE handle;
2529
2530 GetTempPathA(sizeof(path)/sizeof(CHAR), path);
2531 strcat(path, "main_wndcls.manifest");
2532
2533 write_manifest("testdep1.manifest", manifest_wndcls1);
2534 write_manifest("testdep2.manifest", manifest_wndcls2);
2535 write_manifest("main_wndcls.manifest", manifest_wndcls_main);
2536
2537 memset(&actctx, 0, sizeof(ACTCTXA));
2538 actctx.cbSize = sizeof(ACTCTXA);
2539 actctx.lpSource = path;
2540
2541 /* create using lpSource without specified directory */
2542 handle = pCreateActCtxA(&actctx);
2543 ok(handle != INVALID_HANDLE_VALUE, "failed to generate context, error %u\n", GetLastError());
2544 pReleaseActCtx(handle);
2545
2546 /* with specified directory, that doesn't contain dependent assembly */
2547 GetWindowsDirectoryA(dir, sizeof(dir)/sizeof(CHAR));
2548
2549 memset(&actctx, 0, sizeof(ACTCTXA));
2550 actctx.cbSize = sizeof(ACTCTXA);
2551 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
2552 actctx.lpAssemblyDirectory = dir;
2553 actctx.lpSource = path;
2554
2555 SetLastError(0xdeadbeef);
2556 handle = pCreateActCtxA(&actctx);
2557todo_wine {
2558 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2559 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "got error %d\n", GetLastError());
2560}
2561 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx(handle);
2562
2563 delete_manifest_file("main_wndcls.manifest");
2564 delete_manifest_file("testdep1.manifest");
2565 delete_manifest_file("testdep2.manifest");
2566
2567 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2568 memset(&actctx, 0, sizeof(ACTCTXA));
2569 actctx.cbSize = sizeof(ACTCTXA);
2570 actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID;
2571 SetLastError(0xdeadbeef);
2572 handle = pCreateActCtxA(&actctx);
2573 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2576 "got error %d\n", GetLastError());
2577
2578 /* create from HMODULE - resource doesn't exist, lpSource is set */
2579 memset(&actctx, 0, sizeof(ACTCTXA));
2580 actctx.cbSize = sizeof(ACTCTXA);
2581 actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
2582 actctx.lpSource = "dummyfile.dll";
2583 actctx.lpResourceName = MAKEINTRESOURCEA(20);
2584 actctx.hModule = GetModuleHandleA(NULL);
2585
2586 SetLastError(0xdeadbeef);
2587 handle = pCreateActCtxA(&actctx);
2588 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2589 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "got error %d\n", GetLastError());
2590
2591 /* load manifest from lpAssemblyDirectory directory */
2592 write_manifest("testdir.manifest", manifest1);
2593 GetTempPathA(sizeof(path)/sizeof(path[0]), path);
2595 strcat(path, "assembly_dir");
2596 strcpy(dir, path);
2597 strcat(path, "\\testdir.manifest");
2598
2599 memset(&actctx, 0, sizeof(actctx));
2600 actctx.cbSize = sizeof(actctx);
2601 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
2602 actctx.lpSource = "testdir.manifest";
2603 actctx.lpAssemblyDirectory = dir;
2604
2605 SetLastError(0xdeadbeef);
2606 handle = pCreateActCtxA(&actctx);
2607 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2610 "got error %d\n", GetLastError());
2611
2613 memset(&actctx, 0, sizeof(actctx));
2614 actctx.cbSize = sizeof(actctx);
2615 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
2616 actctx.lpSource = "testdir.manifest";
2617 actctx.lpAssemblyDirectory = dir;
2618
2619 SetLastError(0xdeadbeef);
2620 handle = pCreateActCtxA(&actctx);
2621 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2622 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %d\n", GetLastError());
2624
2625 write_manifest("assembly_dir\\testdir.manifest", manifest1);
2626 memset(&actctx, 0, sizeof(actctx));
2627 actctx.cbSize = sizeof(actctx);
2628 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
2629 actctx.lpSource = "testdir.manifest";
2630 actctx.lpAssemblyDirectory = dir;
2631
2632 handle = pCreateActCtxA(&actctx);
2633 ok(handle != INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2634 pReleaseActCtx(handle);
2635
2636 memset(&actctx, 0, sizeof(actctx));
2637 actctx.cbSize = sizeof(actctx);
2638 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
2639 actctx.lpSource = path;
2640 actctx.lpAssemblyDirectory = dir;
2641
2642 handle = pCreateActCtxA(&actctx);
2643 ok(handle != INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2644 pReleaseActCtx(handle);
2645
2646 delete_manifest_file("testdir.manifest");
2647 delete_manifest_file("assembly_dir\\testdir.manifest");
2649}
2650
2651static BOOL init_funcs(void)
2652{
2653 HMODULE hLibrary = GetModuleHandleA("kernel32.dll");
2654
2655#define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2664 X(QueryActCtxW);
2668
2669 hLibrary = GetModuleHandleA("ntdll.dll");
2673#undef X
2674
2675 return TRUE;
2676}
2677
2678static void test_ZombifyActCtx(void)
2679{
2680 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo;
2683 BOOL ret;
2684
2685 SetLastError(0xdeadbeef);
2686 ret = pZombifyActCtx(NULL);
2688 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
2689
2690 handle = create_manifest("test.manifest", testdep_manifest3, __LINE__);
2691
2692 ret = pGetCurrentActCtx(&current);
2693 ok(ret, "got %d, error %d\n", ret, GetLastError());
2694 ok(current == NULL, "got %p\n", current);
2695
2696 ret = pActivateActCtx(handle, &cookie);
2697 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
2698
2699 ret = pGetCurrentActCtx(&current);
2700 ok(ret, "got %d, error %d\n", ret, GetLastError());
2701 ok(handle == current, "got %p, %p\n", current, handle);
2702
2703 memset(&basicinfo, 0xff, sizeof(basicinfo));
2704 ret = pQueryActCtxW(0, handle, 0, ActivationContextBasicInformation,
2705 &basicinfo, sizeof(basicinfo), NULL);
2706 ok(ret, "got %d, error %d\n", ret, GetLastError());
2707 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
2708 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
2709
2710 memset(&basicinfo, 0xff, sizeof(basicinfo));
2711 ret = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, 0, ActivationContextBasicInformation,
2712 &basicinfo, sizeof(basicinfo), NULL);
2713 ok(ret, "got %d, error %d\n", ret, GetLastError());
2714 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
2715 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
2716
2717 ret = pZombifyActCtx(handle);
2719 ok(ret, "got %d\n", ret);
2720
2721 memset(&basicinfo, 0xff, sizeof(basicinfo));
2722 ret = pQueryActCtxW(0, handle, 0, ActivationContextBasicInformation,
2723 &basicinfo, sizeof(basicinfo), NULL);
2724 ok(ret, "got %d, error %d\n", ret, GetLastError());
2725 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
2726 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
2727
2728 memset(&basicinfo, 0xff, sizeof(basicinfo));
2729 ret = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, 0, ActivationContextBasicInformation,
2730 &basicinfo, sizeof(basicinfo), NULL);
2731 ok(ret, "got %d, error %d\n", ret, GetLastError());
2732 ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
2733 ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
2734
2735 ret = pGetCurrentActCtx(&current);
2736 ok(ret, "got %d, error %d\n", ret, GetLastError());
2737 ok(current == handle, "got %p\n", current);
2738
2739 /* one more time */
2740 ret = pZombifyActCtx(handle);
2742 ok(ret, "got %d\n", ret);
2743
2744 ret = pDeactivateActCtx(0, cookie);
2745 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
2746 pReleaseActCtx(handle);
2747}
2748
2749/* Test structure to verify alignment */
2752 COMPATIBILITY_CONTEXT_ELEMENT Elements[10];
2754
2756{
2757 test_act_ctx_compat_info compat_info;
2758 SIZE_T size;
2759 BOOL b;
2760
2761 memset(&compat_info, 0, sizeof(compat_info));
2762 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
2763 CompatibilityInformationInActivationContext, &compat_info,
2764 sizeof(compat_info), &size);
2765
2766 ok_(__FILE__, line)(b, "CompatibilityInformationInActivationContext failed\n");
2767 ok_(__FILE__, line)(size == sizeof(DWORD), "size mismatch (got %lu, expected 4)\n", size);
2768 ok_(__FILE__, line)(compat_info.ElementCount == 0, "unexpected ElementCount %u\n", compat_info.ElementCount);
2769}
2770
2771static void test_with_compat(HANDLE handle, DWORD num_compat, const GUID* expected_compat[], int line)
2772{
2773 test_act_ctx_compat_info compat_info;
2774 SIZE_T size;
2775 SIZE_T expected = sizeof(COMPATIBILITY_CONTEXT_ELEMENT) * num_compat + sizeof(DWORD);
2776 DWORD n;
2777 BOOL b;
2778
2779 memset(&compat_info, 0, sizeof(compat_info));
2780 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
2781 CompatibilityInformationInActivationContext, &compat_info,
2782 sizeof(compat_info), &size);
2783
2784 ok_(__FILE__, line)(b, "CompatibilityInformationInActivationContext failed\n");
2785 ok_(__FILE__, line)(size == expected, "size mismatch (got %lu, expected %lu)\n", size, expected);
2786 ok_(__FILE__, line)(compat_info.ElementCount == num_compat, "unexpected ElementCount %u\n", compat_info.ElementCount);
2787
2788 for (n = 0; n < num_compat; ++n)
2789 {
2790 ok_(__FILE__, line)(IsEqualGUID(&compat_info.Elements[n].Id, expected_compat[n]),
2791 "got wrong clsid %s, expected %s for %u\n",
2792 wine_dbgstr_guid(&compat_info.Elements[n].Id),
2793 wine_dbgstr_guid(expected_compat[n]),
2794 n);
2795 ok_(__FILE__, line)(compat_info.Elements[n].Type == ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
2796 "Wrong type, got %u for %u\n", (DWORD)compat_info.Elements[n].Type, n);
2797 }
2798}
2799
2800static void test_compatibility(void)
2801{
2802 HANDLE handle;
2803
2804 /* No compat results returned */
2805 trace("manifest1\n");
2806 if(!create_manifest_file("test1.manifest", manifest1, -1, NULL, NULL))
2807 {
2808 skip("Could not create manifest file\n");
2809 return;
2810 }
2811 handle = test_create("test1.manifest");
2812 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2813 DeleteFileA("test1.manifest");
2815 {
2816 char buffer[sizeof(COMPATIBILITY_CONTEXT_ELEMENT) * 2 + sizeof(DWORD)];
2817 SIZE_T size;
2818 BOOL b;
2819
2820 memset(buffer, 0, sizeof(buffer));
2821 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
2822 CompatibilityInformationInActivationContext, buffer,
2823 sizeof(buffer), &size);
2824
2826 {
2827 win_skip("CompatibilityInformationInActivationContext not supported.\n");
2828 pReleaseActCtx(handle);
2829 return;
2830 }
2831
2832 test_basic_info(handle, __LINE__);
2833 test_no_compat(handle, __LINE__);
2834 pReleaseActCtx(handle);
2835 }
2836
2837 /* Still no compat results returned */
2838 trace("no_supportedOs\n");
2839 if(!create_manifest_file("no_supportedOs.manifest", compat_manifest_no_supportedOs, -1, NULL, NULL))
2840 {
2841 skip("Could not create manifest file\n");
2842 return;
2843 }
2844 handle = test_create("no_supportedOs.manifest");
2845 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2846 DeleteFileA("no_supportedOs.manifest");
2848 {
2849 test_basic_info(handle, __LINE__);
2850 test_no_compat(handle, __LINE__);
2851 pReleaseActCtx(handle);
2852 }
2853
2854 /* Just one result returned */
2855 trace("manifest_vista\n");
2856 if(!create_manifest_file("manifest_vista.manifest", compat_manifest_vista, -1, NULL, NULL))
2857 {
2858 skip("Could not create manifest file\n");
2859 return;
2860 }
2861 handle = test_create("manifest_vista.manifest");
2862 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2863 DeleteFileA("manifest_vista.manifest");
2865 {
2866 static const GUID* expect_manifest[] =
2867 {
2868 &VISTA_COMPAT_GUID
2869 };
2870 test_basic_info(handle, __LINE__);
2871 test_with_compat(handle, 1, expect_manifest, __LINE__);
2872 pReleaseActCtx(handle);
2873 }
2874
2875 /* Show that the order is retained */
2876 trace("manifest_vista_7_8_10_81\n");
2877 if(!create_manifest_file("manifest_vista_7_8_10_81.manifest", compat_manifest_vista_7_8_10_81, -1, NULL, NULL))
2878 {
2879 skip("Could not create manifest file\n");
2880 return;
2881 }
2882 handle = test_create("manifest_vista_7_8_10_81.manifest");
2883 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2884 DeleteFileA("manifest_vista_7_8_10_81.manifest");
2886 {
2887 static const GUID* expect_manifest[] =
2888 {
2889 &VISTA_COMPAT_GUID,
2890 &WIN7_COMPAT_GUID,
2891 &WIN8_COMPAT_GUID,
2892 &WIN10_COMPAT_GUID,
2893 &WIN81_COMPAT_GUID,
2894 };
2895 test_basic_info(handle, __LINE__);
2896 test_with_compat(handle, 5, expect_manifest, __LINE__);
2897 pReleaseActCtx(handle);
2898 }
2899
2900 /* Show that even unknown GUID's are stored */
2901 trace("manifest_other_guid\n");
2902 if(!create_manifest_file("manifest_other_guid.manifest", compat_manifest_other_guid, -1, NULL, NULL))
2903 {
2904 skip("Could not create manifest file\n");
2905 return;
2906 }
2907 handle = test_create("manifest_other_guid.manifest");
2908 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2909 DeleteFileA("manifest_other_guid.manifest");
2911 {
2912 static const GUID* expect_manifest[] =
2913 {
2914 &OTHER_COMPAT_GUID,
2915 };
2916 test_basic_info(handle, __LINE__);
2917 test_with_compat(handle, 1, expect_manifest, __LINE__);
2918 pReleaseActCtx(handle);
2919 }
2920}
2921
2923{
2924 int argc;
2925 char **argv;
2926
2928
2929 if (!init_funcs())
2930 {
2931 win_skip("Needed functions are not available\n");
2932 return;
2933 }
2934 init_paths();
2935
2936 if(argc > 2 && !strcmp(argv[2], "manifest1")) {
2938 return;
2939 }
2940
2941 test_actctx();
2948}
static int argc
Definition: ServiceArgs.c:12
#define broken(x)
Definition: _sntprintf.h:21
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define VOID
Definition: acefi.h:82
unsigned int dir
Definition: maze.c:112
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR nameW[]
Definition: main.c:46
HMODULE hLibrary
Definition: odbccp32.c:12
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NTSTATUS
Definition: precomp.h:21
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
static const WCHAR version[]
Definition: asmname.c:66
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
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 DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI SetFileTime(IN HANDLE hFile, CONST FILETIME *lpCreationTime OPTIONAL, CONST FILETIME *lpLastAccessTime OPTIONAL, CONST FILETIME *lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:948
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2206
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4741
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCWSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:156
HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
Definition: actctx.c:28
BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:124
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:104
BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:183
comclass_miscfields
Definition: compobj.c:99
comclass_threadingmodel
Definition: compobj.c:90
static const WCHAR versionW[]
Definition: name.c:52
#define ULONG_PTR
Definition: config.h:101
#define progid(str)
Definition: exdisp.idl:31
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
time_t now
Definition: finger.c:65
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const WCHAR helpW[]
Definition: htmlevent.c:70
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG, const GUID *, ULONG, const UNICODE_STRING *, PVOID)
Definition: actctx.c:5815
const char * filename
Definition: ioapi.h:137
#define b
Definition: ke_i.h:79
#define actctx
Definition: kernel32.h:8
#define wine_dbgstr_w
Definition: kernel32.h:34
USHORT LANGID
Definition: mui.h:9
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
const GUID * guid
struct task_struct * current
Definition: linux.c:32
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static PVOID ptr
Definition: dispmode.c:27
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void test_create(void)
Definition: monthcal.c:1595
BOOL todo
Definition: filedlg.c:313
BOOL expected
Definition: store.c:2063
struct _test_act_ctx_compat_info test_act_ctx_compat_info
static const char wrong_manifest2[]
Definition: actctx.c:329
static void test_typelib_section(void)
Definition: actctx.c:1878
static void test_CreateActCtx(void)
Definition: actctx.c:2524
static const char wrong_manifest1[]
Definition: actctx.c:324
static const char wrong_manifest7[]
Definition: actctx.c:356
static WCHAR work_dir_subdir[MAX_PATH]
Definition: actctx.c:469
static void write_manifest(const char *filename, const char *manifest)
Definition: actctx.c:2500
static BOOL init_funcs(void)
Definition: actctx.c:2651
static const GUID LPCSTR
Definition: actctx.c:36
static void test_no_compat(HANDLE handle, int line)
Definition: actctx.c:2755
static const char manifest9[]
Definition: actctx.c:284
static WCHAR exe_path[MAX_PATH]
Definition: actctx.c:469
static const char manifest5[]
Definition: actctx.c:236
static void test_dllredirect_section(void)
Definition: actctx.c:1823
static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const char *progid, ULONG exid, int line)
Definition: actctx.c:1704
static const info_in_assembly manifest1_child_info
Definition: actctx.c:668
static const info_in_assembly manifest3_info
Definition: actctx.c:680
@ MiscStatusContent
Definition: actctx.c:1374
@ MiscStatusThumbnail
Definition: actctx.c:1375
@ MiscStatus
Definition: actctx.c:1372
@ MiscStatusDocPrint
Definition: actctx.c:1376
@ MiscStatusIcon
Definition: actctx.c:1373
static const char wrong_manifest9[]
Definition: actctx.c:368
static void test_find_string_fail(void)
Definition: actctx.c:1289
static WCHAR app_manifest_path[MAX_PATH]
Definition: actctx.c:470
static const char compat_manifest_no_supportedOs[]
Definition: actctx.c:405
static const char testdep_manifest3[]
Definition: actctx.c:314
static const runlevel_info_t runlevel_info9
Definition: actctx.c:894
static PCSZ
Definition: actctx.c:46
static const char manifest4[]
Definition: actctx.c:223
static const runlevel_info_t runlevel_info0
Definition: actctx.c:878
static void test_actctx(void)
Definition: actctx.c:1970
static BOOL create_manifest_file(const char *filename, const char *manifest, int manifest_len, const char *depfile, const char *depmanifest)
Definition: actctx.c:486
static const char manifest6[]
Definition: actctx.c:247
static const char manifest_wndcls1[]
Definition: actctx.c:183
static void test_compatibility(void)
Definition: actctx.c:2800
static const char wrong_manifest10[]
Definition: actctx.c:381
#define X(f)
static const char manifest3[]
Definition: actctx.c:107
static const char testdep_manifest2[]
Definition: actctx.c:307
static const char manifest1_1[]
Definition: actctx.c:76
static const WCHAR testlib_dll[]
Definition: actctx.c:456
static void init_paths(void)
Definition: actctx.c:2476
static const char manifest_wndcls2[]
Definition: actctx.c:194
static HANDLE
Definition: actctx.c:40
static const info_in_assembly depmanifest3_info
Definition: actctx.c:706
static const char manifest2[]
Definition: actctx.c:81
static const char testdep_manifest1[]
Definition: actctx.c:302
static const char manifest7[]
Definition: actctx.c:259
static WCHAR depmanifest_path[MAX_PATH]
Definition: actctx.c:470
static void test_create_and_fail(const char *manifest, const char *depmanifest, int todo, BOOL is_broken)
Definition: actctx.c:955
static void test_ZombifyActCtx(void)
Definition: actctx.c:2678
ifaceps_mask
Definition: actctx.c:1555
@ BaseIface
Definition: actctx.c:1557
@ NumMethods
Definition: actctx.c:1556
static HANDLE create_manifest(const char *filename, const char *data, int line)
Definition: actctx.c:2320
#define ARCH
Definition: actctx.c:68
static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid, int line)
Definition: actctx.c:1127
static const char wrong_manifest4[]
Definition: actctx.c:339
static BOOL create_wide_manifest(const char *filename, const char *manifest, BOOL fBOM, BOOL fReverse)
Definition: actctx.c:522
static void kernel32_find(ULONG section, const char *string_to_find, BOOL should_find, int line)
Definition: actctx.c:2333
static const char wrong_manifest6[]
Definition: actctx.c:351
static const runlevel_info_t runlevel_info7
Definition: actctx.c:886
static void test_create_fail(void)
Definition: actctx.c:1004
static void delete_manifest_file(const char *filename)
Definition: actctx.c:2515
static const info_in_assembly manifest1_info
Definition: actctx.c:662
static const char manifest_wndcls_main[]
Definition: actctx.c:208
static const info_in_assembly manifest_comctrl_info
Definition: actctx.c:712
static void test_findsectionstring(void)
Definition: actctx.c:2405
static void test_basic_info(HANDLE handle, int line)
Definition: actctx.c:1327
static const WCHAR testlib2_dll[]
Definition: actctx.c:458
static const GUID ULONG
Definition: actctx.c:36
static const info_in_assembly manifest2_info
Definition: actctx.c:674
static DWORD strlen_aw(const char *str)
Definition: actctx.c:481
static const info_in_assembly depmanifest2_info
Definition: actctx.c:699
static const char wrong_manifest5[]
Definition: actctx.c:345
static int strcmp_aw(LPCWSTR strw, const char *stra)
Definition: actctx.c:472
static void run_child_process(void)
Definition: actctx.c:2438
static void test_wndclass_section(void)
Definition: actctx.c:1758
static void test_with_compat(HANDLE handle, DWORD num_compat, const GUID *expected_compat[], int line)
Definition: actctx.c:2771