2 * Copyright 2007 Jacek Caban for CodeWeavers
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.
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.
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
20 #define WIN32_NO_STATUS
21 #include "wine/test.h"
32 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
33 static HANDLE (WINAPI
*pCreateActCtxA
)(PCACTCTXA
);
34 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
35 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
36 static BOOL (WINAPI
*pFindActCtxSectionStringA
)(DWORD
,const GUID
*,ULONG
,LPCSTR
,PACTCTX_SECTION_KEYED_DATA
);
37 static BOOL (WINAPI
*pFindActCtxSectionStringW
)(DWORD
,const GUID
*,ULONG
,LPCWSTR
,PACTCTX_SECTION_KEYED_DATA
);
38 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
39 static BOOL (WINAPI
*pIsDebuggerPresent
)(void);
40 static BOOL (WINAPI
*pQueryActCtxW
)(DWORD
,HANDLE
,PVOID
,ULONG
,PVOID
,SIZE_T
,SIZE_T
*);
41 static VOID (WINAPI
*pReleaseActCtx
)(HANDLE
);
42 static BOOL (WINAPI
*pFindActCtxSectionGuid
)(DWORD
,const GUID
*,ULONG
,const GUID
*,PACTCTX_SECTION_KEYED_DATA
);
43 static BOOL (WINAPI
*pZombifyActCtx
)(HANDLE
);
45 static NTSTATUS(NTAPI
*pRtlFindActivationContextSectionString
)(DWORD
,const GUID
*,ULONG
,PUNICODE_STRING
,PACTCTX_SECTION_KEYED_DATA
);
46 static BOOLEAN (NTAPI
*pRtlCreateUnicodeStringFromAsciiz
)(PUNICODE_STRING
, PCSZ
);
47 static VOID (NTAPI
*pRtlFreeUnicodeString
)(PUNICODE_STRING
);
49 static const char* strw(LPCWSTR x
)
51 static char buffer
[1024];
54 if (!x
) return "(nil)";
55 else while ((*p
++ = *x
++));
61 #elif defined __x86_64__
65 #elif defined __aarch64__
71 static 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>"
76 static 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>"
81 static 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\">"
87 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
89 "</dependentAssembly>"
93 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
94 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
95 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
96 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
97 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
98 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
99 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
100 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
101 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
102 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
103 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
104 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
105 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
107 static 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\" />"
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\""
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>"
132 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
133 " <progid>ProgId.ProgId.7</progid>"
135 " <comInterfaceProxyStub "
137 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
138 " iid=\"{66666666-8888-7777-6666-555555555555}\""
139 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
140 " threadingModel=\"Free\""
142 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
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}\""
151 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
153 " <comInterfaceExternalProxyStub "
154 " name=\"Iifaceps3\""
155 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
156 " iid=\"{86666666-8888-7777-6666-555555555555}\""
158 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
161 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
162 " name=\"testsurrogate\""
163 " runtimeVersion=\"v2.0.50727\""
166 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
168 " progid=\"clrprogid\""
169 " description=\"test description\""
170 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
171 " runtimeVersion=\"1.2.3.4\""
172 " threadingModel=\"Neutral\""
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>"
183 static 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=\"\" />"
191 "<file name=\"testlib1_2.dll\" />"
194 static 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=\"\" />"
205 "<file name=\"testlib2_2.dll\" />"
208 static 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\" />"
212 " <dependentAssembly>"
213 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
214 " </dependentAssembly>"
217 " <dependentAssembly>"
218 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
219 " </dependentAssembly>"
223 static 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>"
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>"
236 static 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>"
241 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
242 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
243 " </dependentAssembly>"
247 static 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\">"
252 " <requestedPrivileges>"
253 " <requestedExecutionLevel level=\"ASINVOKER\" uiAccess=\"false\"/>"
254 " </requestedPrivileges>"
259 static 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\">"
264 " <requestedPrivileges>"
265 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"TRUE\"/>"
266 " </requestedPrivileges>"
271 static 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\">"
276 " <requestedPrivileges>"
277 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\">"
278 " </requestedExecutionLevel>"
279 " </requestedPrivileges>"
284 static 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\">"
289 " <requestedPrivileges>"
290 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
291 " </requestedPrivileges>"
294 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
296 " <requestedPrivileges>"
297 " </requestedPrivileges>"
302 static 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
"\"/>"
307 static 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\" />"
314 static 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>"
324 static const char wrong_manifest1
[] =
325 "<assembly manifestVersion=\"1.0\">"
326 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
329 static 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>"
334 static 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>"
339 static 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>"
345 static 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>"
351 static 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>"
356 static 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\" />"
362 static 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>"
368 static 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\">"
373 " <requestedPrivileges>"
374 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
375 " <requestedExecutionLevel uiAccess=\"true\"/>"
376 " </requestedPrivileges>"
381 static 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\">"
386 " <requestedPrivileges>"
387 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
388 " </requestedPrivileges>"
391 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
393 " <requestedPrivileges>"
394 " <requestedExecutionLevel uiAccess=\"true\"/>"
395 " </requestedPrivileges>"
400 static 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
"\" />"
405 static const char compat_manifest_no_supportedOs
[] =
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\">"
414 static 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\">"
419 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */
424 static const char compat_manifest_vista_7_8_10_81
[] =
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\">"
429 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */
430 " <supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" />" /* Windows 7 */
431 " <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" />" /* Windows 8 */
432 " <supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" />" /* Windows 10 */
433 " <supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" />" /* Windows 8.1 */
438 static 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\">"
443 " <supportedOS Id=\"{12345566-1111-2222-3333-444444444444}\" />"
448 DEFINE_GUID(VISTA_COMPAT_GUID
, 0xe2011457, 0x1546, 0x43c5, 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0);
449 DEFINE_GUID(WIN7_COMPAT_GUID
, 0x35138b9a, 0x5d96, 0x4fbd, 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a);
450 DEFINE_GUID(WIN8_COMPAT_GUID
, 0x4a2f28e3, 0x53b9, 0x4441, 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38);
451 DEFINE_GUID(WIN81_COMPAT_GUID
, 0x1f676c76, 0x80e1, 0x4239, 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78);
452 DEFINE_GUID(WIN10_COMPAT_GUID
, 0x8e0f7a12, 0xbfb3, 0x4fe8, 0xb9, 0xa5, 0x48, 0xfd, 0x50, 0xa1, 0x5a, 0x9a);
453 DEFINE_GUID(OTHER_COMPAT_GUID
, 0x12345566, 0x1111, 0x2222, 0x33, 0x33, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44);
456 static const WCHAR testlib_dll
[] =
457 {'t','e','s','t','l','i','b','.','d','l','l',0};
458 static const WCHAR testlib2_dll
[] =
459 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
460 static const WCHAR wndClassW
[] =
461 {'w','n','d','C','l','a','s','s',0};
462 static const WCHAR wndClass1W
[] =
463 {'w','n','d','C','l','a','s','s','1',0};
464 static const WCHAR wndClass2W
[] =
465 {'w','n','d','C','l','a','s','s','2',0};
466 static const WCHAR wndClass3W
[] =
467 {'w','n','d','C','l','a','s','s','3',0};
469 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
470 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
472 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
477 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
478 return lstrcmpW(strw
, buf
);
481 static DWORD
strlen_aw(const char *str
)
483 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
486 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
487 const char *depfile
, const char *depmanifest
)
491 WCHAR path
[MAX_PATH
];
493 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
494 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
496 if (manifest_len
== -1)
497 manifest_len
= strlen(manifest
);
499 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
500 FILE_ATTRIBUTE_NORMAL
, NULL
);
501 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
502 if(file
== INVALID_HANDLE_VALUE
)
504 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
509 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
510 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
511 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
512 FILE_ATTRIBUTE_NORMAL
, NULL
);
513 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
514 if(file
== INVALID_HANDLE_VALUE
)
516 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
522 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
524 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
526 int offset
= (fBOM
? 0 : 1);
528 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
529 wmanifest
[0] = 0xfeff;
533 for (i
= 0; i
< strlen(manifest
)+1; i
++)
534 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
536 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
537 HeapFree(GetProcessHeap(), 0, wmanifest
);
542 ULONG format_version
;
543 ULONG assembly_cnt_min
;
544 ULONG assembly_cnt_max
;
545 ULONG root_manifest_type
;
546 LPWSTR root_manifest_path
;
547 ULONG root_config_type
;
552 static const detailed_info_t detailed_info0
= {
553 0, 0, 0, 0, NULL
, 0, 0, NULL
556 static const detailed_info_t detailed_info1
= {
557 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
558 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
562 static const detailed_info_t detailed_info1_child
= {
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
,
568 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
569 static const detailed_info_t detailed_info2
= {
570 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
571 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
575 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
577 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
578 SIZE_T size
, exsize
, retsize
;
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);
585 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
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
);
594 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
597 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
598 memset(detailed_info
, 0xfe, size
);
599 b
= pQueryActCtxW(0, handle
, NULL
,
600 ActivationContextDetailedInformation
, detailed_info
,
602 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
603 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
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");
638 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
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
));
648 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
651 HeapFree(GetProcessHeap(), 0, detailed_info
);
656 /* ULONG manifest_path_type; FIXME */
657 LPCWSTR manifest_path
;
658 LPCSTR encoded_assembly_id
;
659 BOOL has_assembly_dir
;
662 static const info_in_assembly manifest1_info
= {
664 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
668 static const info_in_assembly manifest1_child_info
= {
669 1, app_manifest_path
,
670 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
674 static const info_in_assembly manifest2_info
= {
676 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
680 static const info_in_assembly manifest3_info
= {
682 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
686 static const info_in_assembly manifest4_info
= {
688 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
692 static const info_in_assembly depmanifest1_info
= {
693 0x10, depmanifest_path
,
694 "testdep,processorArchitecture=\"" ARCH
"\","
695 "type=\"win32\",version=\"6.5.4.3\"",
699 static const info_in_assembly depmanifest2_info
= {
700 0x10, depmanifest_path
,
701 "testdep,processorArchitecture=\"" ARCH
"\","
702 "type=\"win32\",version=\"6.5.4.3\"",
706 static const info_in_assembly depmanifest3_info
= {
707 0x10, depmanifest_path
,
708 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
712 static const info_in_assembly manifest_comctrl_info
= {
713 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
716 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
718 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
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
);
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());
734 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
736 if (size
== 0xdeadbeef)
742 info
= HeapAlloc(GetProcessHeap(), 0, size
);
743 memset(info
, 0xfe, size
);
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
);
757 if (0) /* FIXME: flags meaning unknown */
759 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
760 info
->ulFlags
, exinfo
->flags
);
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
);
768 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
769 "info->ulEncodedAssemblyIdentityLength == 0\n");
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
);
778 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
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");
799 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
800 "info->ulAssemblyDirectoryNameLength != 0\n");
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
);
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");
815 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
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");
824 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
825 strw(info
->lpAssemblyDirectoryName
));
826 HeapFree(GetProcessHeap(), 0, info
);
829 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
831 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
832 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
836 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
837 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
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
);
847 if(size
== 0xdeadbeef)
853 info
= HeapAlloc(GetProcessHeap(), 0, size
);
854 memset(info
, 0xfe, size
);
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
);
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");
868 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
869 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
870 HeapFree(GetProcessHeap(), 0, info
);
874 ACTCTX_REQUESTED_RUN_LEVEL run_level
;
878 static const runlevel_info_t runlevel_info0
= {
879 ACTCTX_RUN_LEVEL_UNSPECIFIED
, FALSE
,
882 static const runlevel_info_t runlevel_info6
= {
883 ACTCTX_RUN_LEVEL_AS_INVOKER
, FALSE
,
886 static const runlevel_info_t runlevel_info7
= {
887 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
890 static const runlevel_info_t runlevel_info8
= {
891 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
894 static const runlevel_info_t runlevel_info9
= {
895 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, FALSE
,
898 static void test_runlevel_info(HANDLE handle
, const runlevel_info_t
*exinfo
, int line
)
900 ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel_info
;
901 SIZE_T size
, retsize
;
904 size
= sizeof(runlevel_info
);
905 b
= pQueryActCtxW(0, handle
, NULL
,
906 RunlevelInformationInActivationContext
, &runlevel_info
,
907 sizeof(runlevel_info
), &retsize
);
908 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
910 win_skip("RunlevelInformationInActivationContext not supported.\n");
914 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
915 ok_(__FILE__
, line
)(retsize
== size
, "size=%ld, expected %ld\n", retsize
, size
);
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
);
924 static HANDLE
test_create(const char *file
)
928 WCHAR path
[MAX_PATH
];
930 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
931 memset(&actctx
, 0, sizeof(ACTCTXW
));
932 actctx
.cbSize
= sizeof(ACTCTXW
);
933 actctx
.lpSource
= path
;
935 handle
= pCreateActCtxW(&actctx
);
936 /* to be tested outside of this helper, including last error */
937 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
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
);
955 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
, BOOL is_broken
)
959 WCHAR path
[MAX_PATH
];
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
;
966 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
967 handle
= pCreateActCtxW(&actctx
);
971 ok(broken(handle
!= INVALID_HANDLE_VALUE
) || handle
== INVALID_HANDLE_VALUE
,
972 "Unexpected context handle %p.\n", handle
);
974 ok(handle
== INVALID_HANDLE_VALUE
, "Unexpected context handle %p.\n", handle
);
976 if (handle
== INVALID_HANDLE_VALUE
)
977 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "Unexpected error %d.\n", GetLastError());
979 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
980 DeleteFileA("bad.manifest");
981 DeleteFileA("testdep.manifest");
984 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
988 WCHAR path
[MAX_PATH
];
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
;
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());
1000 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
1001 DeleteFileA("bad.manifest");
1004 static void test_create_fail(void)
1008 WCHAR path
[MAX_PATH
];
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
;
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());
1019 trace("wrong_manifest1\n");
1020 test_create_and_fail(wrong_manifest1
, NULL
, 0, FALSE
);
1021 trace("wrong_manifest2\n");
1022 test_create_and_fail(wrong_manifest2
, NULL
, 0, FALSE
);
1023 trace("wrong_manifest3\n");
1024 test_create_and_fail(wrong_manifest3
, NULL
, 1, FALSE
);
1025 trace("wrong_manifest4\n");
1026 test_create_and_fail(wrong_manifest4
, NULL
, 1, FALSE
);
1027 trace("wrong_manifest5\n");
1028 test_create_and_fail(wrong_manifest5
, NULL
, 0, FALSE
);
1029 trace("wrong_manifest6\n");
1030 test_create_and_fail(wrong_manifest6
, NULL
, 0, FALSE
);
1031 trace("wrong_manifest7\n");
1032 test_create_and_fail(wrong_manifest7
, NULL
, 1, FALSE
);
1033 trace("wrong_manifest8\n");
1034 test_create_and_fail(wrong_manifest8
, NULL
, 0, FALSE
);
1035 trace("wrong_manifest9\n");
1036 test_create_and_fail(wrong_manifest9
, NULL
, 0, TRUE
/* WinXP */);
1037 trace("wrong_manifest10\n");
1038 test_create_and_fail(wrong_manifest10
, NULL
, 0, TRUE
/* WinXP */);
1039 trace("UTF-16 manifest1 without BOM\n");
1040 test_create_wide_and_fail(manifest1
, FALSE
);
1041 trace("manifest2\n");
1042 test_create_and_fail(manifest2
, NULL
, 0, FALSE
);
1043 trace("manifest2+depmanifest1\n");
1044 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0, FALSE
);
1047 struct strsection_header
1055 ULONG global_offset
;
1069 struct guidsection_header
1089 struct wndclass_redirect_data
1094 ULONG name_offset
; /* versioned name offset */
1096 ULONG module_offset
;/* container name offset */
1099 struct dllredirect_data
1106 struct tlibredirect_data
1120 struct progidredirect_data
1127 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
1129 ACTCTX_SECTION_KEYED_DATA data
;
1132 memset(&data
, 0xfe, sizeof(data
));
1133 data
.cbSize
= sizeof(data
);
1135 ret
= pFindActCtxSectionStringW(0, NULL
,
1136 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1138 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
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
);
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]);
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
);
1166 memset(&data
, 0xfe, sizeof(data
));
1167 data
.cbSize
= sizeof(data
);
1169 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1170 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1172 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
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
);
1189 pReleaseActCtx(handle
);
1192 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
1194 struct wndclass_redirect_data
*wnddata
;
1195 struct strsection_header
*header
;
1196 ACTCTX_SECTION_KEYED_DATA data
;
1199 memset(&data
, 0xfe, sizeof(data
));
1200 data
.cbSize
= sizeof(data
);
1202 ret
= pFindActCtxSectionStringW(0, NULL
,
1203 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1205 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1206 wine_dbgstr_w(clsname
));
1209 header
= (struct strsection_header
*)data
.lpSectionBase
;
1210 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
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
))
1220 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
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
);
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
));
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
);
1242 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1244 WCHAR
*modulename
, *sectionptr
;
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
);
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
);
1263 memset(&data
, 0xfe, sizeof(data
));
1264 data
.cbSize
= sizeof(data
);
1266 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1267 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1269 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1270 wine_dbgstr_w(clsname
));
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
);
1286 pReleaseActCtx(handle
);
1289 static void test_find_string_fail(void)
1291 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
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());
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());
1303 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1305 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1306 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1308 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1310 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1311 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
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());
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());
1327 static void test_basic_info(HANDLE handle
, int line
)
1329 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1333 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1334 ActivationContextBasicInformation
, &basic
,
1335 sizeof(basic
), &size
);
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");
1342 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1343 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1344 ActivationContextBasicInformation
, &basic
,
1345 sizeof(basic
), &size
);
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");
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");
1363 enum comclass_threadingmodel
{
1364 ThreadingModel_Apartment
= 1,
1365 ThreadingModel_Free
= 2,
1366 ThreadingModel_No
= 3,
1367 ThreadingModel_Both
= 4,
1368 ThreadingModel_Neutral
= 5
1371 enum comclass_miscfields
{
1374 MiscStatusContent
= 4,
1375 MiscStatusThumbnail
= 8,
1376 MiscStatusDocPrint
= 16
1379 struct comclassredirect_data
{
1392 ULONG progid_offset
;
1394 ULONG clrdata_offset
;
1396 DWORD miscstatuscontent
;
1397 DWORD miscstatusthumbnail
;
1398 DWORD miscstatusicon
;
1399 DWORD miscstatusdocprint
;
1402 struct clrclass_data
{
1406 ULONG module_offset
;
1410 ULONG version_offset
;
1414 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1416 struct comclassredirect_data
*comclass
, *comclass2
;
1417 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1418 struct guidsection_header
*header
;
1421 memset(&data
, 0xfe, sizeof(data
));
1422 data
.cbSize
= sizeof(data
);
1424 ret
= pFindActCtxSectionGuid(0, NULL
,
1425 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1429 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1432 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1434 comclass
= (struct comclassredirect_data
*)data
.lpData
;
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
))
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
));
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
);
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
);
1461 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1463 if (comclass
->progid_offset
)
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
);
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
);
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
);
1479 /* check misc fields are set */
1480 if (comclass
->miscmask
)
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
);
1494 /* part used for clrClass only */
1495 if (comclass
->clrdata_len
)
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
;
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
);
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
);
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]);
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
);
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
));
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
));
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
);
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());
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");
1560 struct ifacepsredirect_data
1572 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1573 const GUID
*ps32
, ULONG exid
, int line
)
1575 struct ifacepsredirect_data
*ifaceps
;
1576 ACTCTX_SECTION_KEYED_DATA data
;
1579 memset(&data
, 0xfe, sizeof(data
));
1580 data
.cbSize
= sizeof(data
);
1582 ret
= pFindActCtxSectionGuid(0, NULL
,
1583 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1585 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1587 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
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
))
1597 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1600 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1603 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
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
);
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
);
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
));
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
);
1632 struct clrsurrogate_data
1637 ULONG version_offset
;
1643 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1644 ULONG exid
, int line
)
1646 struct clrsurrogate_data
*surrogate
;
1647 ACTCTX_SECTION_KEYED_DATA data
;
1650 memset(&data
, 0xfe, sizeof(data
));
1651 data
.cbSize
= sizeof(data
);
1653 ret
= pFindActCtxSectionGuid(0, NULL
,
1654 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1658 skip("surrogate sections are not supported\n");
1661 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1663 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
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
))
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
));
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
);
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
);
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
);
1686 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1687 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1689 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1690 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
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
);
1704 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1706 struct progidredirect_data
*progiddata
;
1707 struct comclassredirect_data
*comclass
;
1708 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1709 struct strsection_header
*header
;
1712 memset(&data
, 0xfe, sizeof(data
));
1713 data
.cbSize
= sizeof(data
);
1715 ret
= pFindActCtxSectionStringA(0, NULL
,
1716 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1718 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1720 progiddata
= (struct progidredirect_data
*)data
.lpData
;
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
))
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
);
1733 /* progid data points to generated alias guid */
1734 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1736 memset(&data2
, 0, sizeof(data2
));
1737 data2
.cbSize
= sizeof(data2
);
1738 ret
= pFindActCtxSectionGuid(0, NULL
,
1739 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1741 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
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
));
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
);
1758 static void test_wndclass_section(void)
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
;
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
);
1774 handle
= test_create("main_wndcls.manifest");
1775 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1777 DeleteFileA("testdep1.manifest");
1778 DeleteFileA("testdep2.manifest");
1779 DeleteFileA("main_wndcls.manifest");
1781 ret
= pActivateActCtx(handle
, &cookie
);
1782 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1784 memset(&data
, 0, sizeof(data
));
1785 memset(&data2
, 0, sizeof(data2
));
1786 data
.cbSize
= sizeof(data
);
1787 data2
.cbSize
= sizeof(data2
);
1789 /* get data for two classes from different assemblies */
1790 ret
= pFindActCtxSectionStringW(0, NULL
,
1791 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
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
);
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
);
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
);
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
));
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
));
1817 ret
= pDeactivateActCtx(0, cookie
);
1818 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1820 pReleaseActCtx(handle
);
1823 static void test_dllredirect_section(void)
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
;
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
);
1838 handle
= test_create("main_wndcls.manifest");
1839 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1841 DeleteFileA("testdep1.manifest");
1842 DeleteFileA("testdep2.manifest");
1843 DeleteFileA("main_wndcls.manifest");
1845 ret
= pActivateActCtx(handle
, &cookie
);
1846 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1848 memset(&data
, 0, sizeof(data
));
1849 memset(&data2
, 0, sizeof(data2
));
1850 data
.cbSize
= sizeof(data
);
1851 data2
.cbSize
= sizeof(data2
);
1853 /* get data for two files from different assemblies */
1854 ret
= pFindActCtxSectionStringW(0, NULL
,
1855 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1857 ok(ret
, "got %d\n", ret
);
1858 ret
= pFindActCtxSectionStringW(0, NULL
,
1859 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1861 ok(ret
, "got %d\n", ret
);
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
);
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
);
1872 ret
= pDeactivateActCtx(0, cookie
);
1873 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1875 pReleaseActCtx(handle
);
1878 static void test_typelib_section(void)
1880 static const WCHAR helpW
[] = {'h','e','l','p'};
1881 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1882 struct guidsection_header
*section
;
1883 struct tlibredirect_data
*tlib
;
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
);
1893 handle
= test_create("main_wndcls.manifest");
1894 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1896 DeleteFileA("testdep1.manifest");
1897 DeleteFileA("testdep2.manifest");
1898 DeleteFileA("main_wndcls.manifest");
1900 ret
= pActivateActCtx(handle
, &cookie
);
1901 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1903 memset(&data
, 0, sizeof(data
));
1904 memset(&data2
, 0, sizeof(data2
));
1905 data
.cbSize
= sizeof(data
);
1906 data2
.cbSize
= sizeof(data2
);
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
);
1914 ret
= pFindActCtxSectionGuid(0, NULL
,
1915 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1916 &IID_TlibTest4
, &data2
);
1917 ok(ret
, "got %d\n", ret
);
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
);
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
);
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
);
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
);
1941 ret
= pDeactivateActCtx(0, cookie
);
1942 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1944 pReleaseActCtx(handle
);
1947 static void test_allowDelayedBinding(void)
1951 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
1952 skip("Could not create manifest file\n");
1956 handle
= test_create("test5.manifest");
1957 if (handle
== INVALID_HANDLE_VALUE
) {
1958 win_skip("allowDelayedBinding attribute is not supported.\n");
1962 DeleteFileA("test5.manifest");
1963 DeleteFileA("testdep.manifest");
1964 if (handle
!= INVALID_HANDLE_VALUE
) {
1965 test_basic_info(handle
, __LINE__
);
1966 pReleaseActCtx(handle
);
1970 static void test_actctx(void)
1976 trace("default actctx\n");
1978 b
= pGetCurrentActCtx(&handle
);
1979 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1980 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1982 test_basic_info(handle
, __LINE__
);
1983 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1984 test_runlevel_info(handle
, &runlevel_info0
, __LINE__
);
1985 pReleaseActCtx(handle
);
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
);
1995 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1996 skip("Could not create manifest file\n");
2000 trace("manifest1\n");
2002 handle
= test_create("test1.manifest");
2003 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2004 DeleteFileA("test1.manifest");
2005 if(handle
!= INVALID_HANDLE_VALUE
) {
2006 test_basic_info(handle
, __LINE__
);
2007 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2008 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2010 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
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());
2018 pReleaseActCtx(handle
);
2021 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
2022 skip("Could not create manifest file\n");
2026 trace("manifest2 depmanifest1\n");
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");
2032 if(handle
!= INVALID_HANDLE_VALUE
) {
2033 test_basic_info(handle
, __LINE__
);
2034 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2035 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2036 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
2037 pReleaseActCtx(handle
);
2040 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
2041 skip("Could not create manifest file\n");
2045 trace("manifest2 depmanifest2\n");
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");
2051 if(handle
!= INVALID_HANDLE_VALUE
) {
2052 test_basic_info(handle
, __LINE__
);
2053 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2054 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2055 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
2056 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2057 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2059 b
= pActivateActCtx(handle
, &cookie
);
2060 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2061 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2062 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2063 b
= pDeactivateActCtx(0, cookie
);
2064 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2066 pReleaseActCtx(handle
);
2069 trace("manifest2 depmanifest3\n");
2071 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
2072 skip("Could not create manifest file\n");
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");
2080 if(handle
!= INVALID_HANDLE_VALUE
) {
2081 test_basic_info(handle
, __LINE__
);
2082 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2083 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2084 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
2085 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2086 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2088 b
= pActivateActCtx(handle
, &cookie
);
2089 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2090 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2091 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2092 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
2093 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
2094 b
= pDeactivateActCtx(0, cookie
);
2095 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2097 pReleaseActCtx(handle
);
2100 trace("manifest3\n");
2102 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
2103 skip("Could not create manifest file\n");
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());
2110 if (handle
== INVALID_HANDLE_VALUE
)
2111 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
2112 DeleteFileA("test3.manifest");
2113 if(handle
!= INVALID_HANDLE_VALUE
) {
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};
2119 test_basic_info(handle
, __LINE__
);
2120 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2121 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
2122 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
2124 b
= pActivateActCtx(handle
, &cookie
);
2125 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2126 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2127 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
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__
);
2149 test_find_string_fail();
2151 b
= pDeactivateActCtx(0, cookie
);
2152 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2153 pReleaseActCtx(handle
);
2156 trace("manifest6\n");
2158 if(create_manifest_file("test6.manifest", manifest6
, -1, NULL
, NULL
)) {
2159 handle
= test_create("test6.manifest");
2160 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* WinXP */,
2161 "Unexpected context handle %p.\n", handle
);
2162 DeleteFileA("test6.manifest");
2163 DeleteFileA("testdep.manifest");
2164 if(handle
!= INVALID_HANDLE_VALUE
)
2166 test_runlevel_info(handle
, &runlevel_info6
, __LINE__
);
2167 pReleaseActCtx(handle
);
2171 skip("Could not create manifest file 6\n");
2173 trace("manifest7\n");
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");
2180 if(handle
!= INVALID_HANDLE_VALUE
)
2182 test_runlevel_info(handle
, &runlevel_info7
, __LINE__
);
2183 pReleaseActCtx(handle
);
2187 skip("Could not create manifest file 7\n");
2189 trace("manifest8\n");
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");
2196 if(handle
!= INVALID_HANDLE_VALUE
)
2198 test_runlevel_info(handle
, &runlevel_info8
, __LINE__
);
2199 pReleaseActCtx(handle
);
2203 skip("Could not create manifest file 8\n");
2205 trace("manifest9\n");
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");
2212 if(handle
!= INVALID_HANDLE_VALUE
)
2214 test_runlevel_info(handle
, &runlevel_info9
, __LINE__
);
2215 pReleaseActCtx(handle
);
2219 skip("Could not create manifest file 9\n");
2221 trace("manifest4\n");
2223 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
2224 skip("Could not create manifest file\n");
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");
2232 if(handle
!= INVALID_HANDLE_VALUE
) {
2233 test_basic_info(handle
, __LINE__
);
2234 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2235 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
2236 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
2237 pReleaseActCtx(handle
);
2240 trace("manifest1 in subdir\n");
2242 CreateDirectoryW(work_dir_subdir
, NULL
);
2243 if (SetCurrentDirectoryW(work_dir_subdir
))
2245 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
2246 skip("Could not create manifest file\n");
2249 handle
= test_create("..\\test1.manifest");
2250 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2251 DeleteFileA("..\\test1.manifest");
2252 if(handle
!= INVALID_HANDLE_VALUE
) {
2253 test_basic_info(handle
, __LINE__
);
2254 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2255 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2256 pReleaseActCtx(handle
);
2258 SetCurrentDirectoryW(work_dir
);
2261 skip("Couldn't change directory\n");
2262 RemoveDirectoryW(work_dir_subdir
);
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");
2270 handle
= test_create("test1.manifest");
2271 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2272 DeleteFileA("test1.manifest");
2273 if (handle
!= INVALID_HANDLE_VALUE
) {
2274 test_basic_info(handle
, __LINE__
);
2275 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2276 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2277 pReleaseActCtx(handle
);
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");
2286 handle
= test_create("test1.manifest");
2287 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2288 DeleteFileA("test1.manifest");
2289 if (handle
!= INVALID_HANDLE_VALUE
) {
2290 test_basic_info(handle
, __LINE__
);
2291 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2292 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2293 pReleaseActCtx(handle
);
2296 test_wndclass_section();
2297 test_dllredirect_section();
2298 test_typelib_section();
2299 test_allowDelayedBinding();
2302 static void test_app_manifest(void)
2307 trace("child process manifest1\n");
2309 b
= pGetCurrentActCtx(&handle
);
2310 ok(handle
== NULL
, "handle != NULL\n");
2311 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2313 test_basic_info(handle
, __LINE__
);
2314 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2315 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2316 pReleaseActCtx(handle
);
2320 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2323 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2325 handle
= test_create(filename
);
2326 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2327 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2329 DeleteFileA(filename
);
2333 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2335 UNICODE_STRING string_to_findW
;
2336 ACTCTX_SECTION_KEYED_DATA data
;
2340 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2342 memset(&data
, 0xfe, sizeof(data
));
2343 data
.cbSize
= sizeof(data
);
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
);
2351 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2352 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2354 memset(&data
, 0xfe, sizeof(data
));
2355 data
.cbSize
= sizeof(data
);
2358 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2359 err
= GetLastError();
2360 ok_(__FILE__
, line
)(ret
== should_find
,
2361 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2363 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2364 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2367 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2368 err
= GetLastError();
2369 ok_(__FILE__
, line
)(!ret
,
2370 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2371 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2372 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2375 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2376 err
= GetLastError();
2377 ok_(__FILE__
, line
)(!ret
,
2378 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2379 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2380 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2382 pRtlFreeUnicodeString(&string_to_findW
);
2385 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2387 UNICODE_STRING string_to_findW
;
2388 ACTCTX_SECTION_KEYED_DATA data
;
2391 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2393 memset(&data
, 0xfe, sizeof(data
));
2394 data
.cbSize
= sizeof(data
);
2396 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2398 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2399 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2401 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2403 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2404 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2406 pRtlFreeUnicodeString(&string_to_findW
);
2409 static void test_findsectionstring(void)
2415 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2416 ret
= pActivateActCtx(handle
, &cookie
);
2417 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2419 /* first we show the parameter validation from kernel32 */
2420 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2421 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2422 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2423 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2424 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2425 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2426 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2428 /* then we show that ntdll plays by different rules */
2429 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2430 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2431 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2432 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2433 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2434 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2435 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2437 ret
= pDeactivateActCtx(0, cookie
);
2438 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2439 pReleaseActCtx(handle
);
2442 static void run_child_process(void)
2444 char cmdline
[MAX_PATH
];
2445 char path
[MAX_PATH
];
2447 PROCESS_INFORMATION pi
;
2448 STARTUPINFOA si
= { 0 };
2453 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2454 strcat(path
, ".manifest");
2455 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2456 skip("Could not create manifest file\n");
2461 winetest_get_mainargs( &argv
);
2462 /* Vista+ seems to cache presence of .manifest files. Change last modified
2463 date to defeat the cache */
2464 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2465 NULL
, OPEN_EXISTING
, 0, NULL
);
2466 if (file
!= INVALID_HANDLE_VALUE
) {
2467 GetSystemTimeAsFileTime(&now
);
2468 SetFileTime(file
, NULL
, NULL
, &now
);
2471 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2472 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2473 ok(ret
, "Could not create process: %u\n", GetLastError());
2474 winetest_wait_child_process( pi
.hProcess
);
2475 CloseHandle(pi
.hThread
);
2476 CloseHandle(pi
.hProcess
);
2480 static void init_paths(void)
2484 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2485 static const WCHAR backslash
[] = {'\\',0};
2486 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2488 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2489 lstrcpyW(app_dir
, exe_path
);
2490 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2493 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2494 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2495 if (*ptr
!= '\\' && *ptr
!= '/')
2496 lstrcatW(work_dir
, backslash
);
2497 lstrcpyW(work_dir_subdir
, work_dir
);
2498 lstrcatW(work_dir_subdir
, subdir
);
2500 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2501 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2504 static void write_manifest(const char *filename
, const char *manifest
)
2508 CHAR path
[MAX_PATH
];
2510 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2511 strcat(path
, filename
);
2513 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2514 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2515 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2519 static void delete_manifest_file(const char *filename
)
2521 CHAR path
[MAX_PATH
];
2523 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2524 strcat(path
, filename
);
2528 static void test_CreateActCtx(void)
2530 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2534 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2535 strcat(path
, "main_wndcls.manifest");
2537 write_manifest("testdep1.manifest", manifest_wndcls1
);
2538 write_manifest("testdep2.manifest", manifest_wndcls2
);
2539 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2541 memset(&actctx
, 0, sizeof(ACTCTXA
));
2542 actctx
.cbSize
= sizeof(ACTCTXA
);
2543 actctx
.lpSource
= path
;
2545 /* create using lpSource without specified directory */
2546 handle
= pCreateActCtxA(&actctx
);
2547 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2548 pReleaseActCtx(handle
);
2550 /* with specified directory, that doesn't contain dependent assembly */
2551 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2553 memset(&actctx
, 0, sizeof(ACTCTXA
));
2554 actctx
.cbSize
= sizeof(ACTCTXA
);
2555 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2556 actctx
.lpAssemblyDirectory
= dir
;
2557 actctx
.lpSource
= path
;
2559 SetLastError(0xdeadbeef);
2560 handle
= pCreateActCtxA(&actctx
);
2562 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2563 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2565 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2567 delete_manifest_file("main_wndcls.manifest");
2568 delete_manifest_file("testdep1.manifest");
2569 delete_manifest_file("testdep2.manifest");
2571 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2572 memset(&actctx
, 0, sizeof(ACTCTXA
));
2573 actctx
.cbSize
= sizeof(ACTCTXA
);
2574 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2575 SetLastError(0xdeadbeef);
2576 handle
= pCreateActCtxA(&actctx
);
2577 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2579 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2580 "got error %d\n", GetLastError());
2582 /* create from HMODULE - resource doesn't exist, lpSource is set */
2583 memset(&actctx
, 0, sizeof(ACTCTXA
));
2584 actctx
.cbSize
= sizeof(ACTCTXA
);
2585 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2586 actctx
.lpSource
= "dummyfile.dll";
2587 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2588 actctx
.hModule
= GetModuleHandleA(NULL
);
2590 SetLastError(0xdeadbeef);
2591 handle
= pCreateActCtxA(&actctx
);
2592 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2593 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2595 /* load manifest from lpAssemblyDirectory directory */
2596 write_manifest("testdir.manifest", manifest1
);
2597 GetTempPathA(sizeof(path
)/sizeof(path
[0]), path
);
2598 SetCurrentDirectoryA(path
);
2599 strcat(path
, "assembly_dir");
2601 strcat(path
, "\\testdir.manifest");
2603 memset(&actctx
, 0, sizeof(actctx
));
2604 actctx
.cbSize
= sizeof(actctx
);
2605 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2606 actctx
.lpSource
= "testdir.manifest";
2607 actctx
.lpAssemblyDirectory
= dir
;
2609 SetLastError(0xdeadbeef);
2610 handle
= pCreateActCtxA(&actctx
);
2611 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2612 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2613 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2614 "got error %d\n", GetLastError());
2616 CreateDirectoryA(dir
, NULL
);
2617 memset(&actctx
, 0, sizeof(actctx
));
2618 actctx
.cbSize
= sizeof(actctx
);
2619 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2620 actctx
.lpSource
= "testdir.manifest";
2621 actctx
.lpAssemblyDirectory
= dir
;
2623 SetLastError(0xdeadbeef);
2624 handle
= pCreateActCtxA(&actctx
);
2625 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2626 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %d\n", GetLastError());
2627 SetCurrentDirectoryW(work_dir
);
2629 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
2630 memset(&actctx
, 0, sizeof(actctx
));
2631 actctx
.cbSize
= sizeof(actctx
);
2632 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2633 actctx
.lpSource
= "testdir.manifest";
2634 actctx
.lpAssemblyDirectory
= dir
;
2636 handle
= pCreateActCtxA(&actctx
);
2637 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2638 pReleaseActCtx(handle
);
2640 memset(&actctx
, 0, sizeof(actctx
));
2641 actctx
.cbSize
= sizeof(actctx
);
2642 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2643 actctx
.lpSource
= path
;
2644 actctx
.lpAssemblyDirectory
= dir
;
2646 handle
= pCreateActCtxA(&actctx
);
2647 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2648 pReleaseActCtx(handle
);
2650 delete_manifest_file("testdir.manifest");
2651 delete_manifest_file("assembly_dir\\testdir.manifest");
2652 RemoveDirectoryA(dir
);
2655 static BOOL
init_funcs(void)
2657 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
2659 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2663 X(DeactivateActCtx
);
2664 X(FindActCtxSectionStringA
);
2665 X(FindActCtxSectionStringW
);
2666 X(GetCurrentActCtx
);
2667 X(IsDebuggerPresent
);
2670 X(FindActCtxSectionGuid
);
2673 hLibrary
= GetModuleHandleA("ntdll.dll");
2674 X(RtlFindActivationContextSectionString
);
2675 X(RtlCreateUnicodeStringFromAsciiz
);
2676 X(RtlFreeUnicodeString
);
2682 static void test_ZombifyActCtx(void)
2684 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
2686 HANDLE handle
, current
;
2689 SetLastError(0xdeadbeef);
2690 ret
= pZombifyActCtx(NULL
);
2692 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "got %d, error %d\n", ret
, GetLastError());
2694 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2696 ret
= pGetCurrentActCtx(¤t
);
2697 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2698 ok(current
== NULL
, "got %p\n", current
);
2700 ret
= pActivateActCtx(handle
, &cookie
);
2701 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2703 ret
= pGetCurrentActCtx(¤t
);
2704 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2705 ok(handle
== current
, "got %p, %p\n", current
, handle
);
2707 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2708 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2709 &basicinfo
, sizeof(basicinfo
), NULL
);
2710 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2711 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2712 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2714 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2715 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2716 &basicinfo
, sizeof(basicinfo
), NULL
);
2717 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2718 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2719 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2721 ret
= pZombifyActCtx(handle
);
2723 ok(ret
, "got %d\n", ret
);
2725 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2726 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2727 &basicinfo
, sizeof(basicinfo
), NULL
);
2728 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2729 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2730 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2732 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2733 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2734 &basicinfo
, sizeof(basicinfo
), NULL
);
2735 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2736 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2737 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2739 ret
= pGetCurrentActCtx(¤t
);
2740 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2741 ok(current
== handle
, "got %p\n", current
);
2744 ret
= pZombifyActCtx(handle
);
2746 ok(ret
, "got %d\n", ret
);
2748 ret
= pDeactivateActCtx(0, cookie
);
2749 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2750 pReleaseActCtx(handle
);
2753 /* Test structure to verify alignment */
2754 typedef struct _test_act_ctx_compat_info
{
2756 COMPATIBILITY_CONTEXT_ELEMENT Elements
[10];
2757 } test_act_ctx_compat_info
;
2759 static void test_no_compat(HANDLE handle
, int line
)
2761 test_act_ctx_compat_info compat_info
;
2765 memset(&compat_info
, 0, sizeof(compat_info
));
2766 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
2767 CompatibilityInformationInActivationContext
, &compat_info
,
2768 sizeof(compat_info
), &size
);
2770 ok_(__FILE__
, line
)(b
, "CompatibilityInformationInActivationContext failed\n");
2771 ok_(__FILE__
, line
)(size
== sizeof(DWORD
), "size mismatch (got %lu, expected 4)\n", size
);
2772 ok_(__FILE__
, line
)(compat_info
.ElementCount
== 0, "unexpected ElementCount %u\n", compat_info
.ElementCount
);
2775 static void test_with_compat(HANDLE handle
, DWORD num_compat
, const GUID
* expected_compat
[], int line
)
2777 test_act_ctx_compat_info compat_info
;
2779 SIZE_T expected
= sizeof(COMPATIBILITY_CONTEXT_ELEMENT
) * num_compat
+ sizeof(DWORD
);
2783 memset(&compat_info
, 0, sizeof(compat_info
));
2784 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
2785 CompatibilityInformationInActivationContext
, &compat_info
,
2786 sizeof(compat_info
), &size
);
2788 ok_(__FILE__
, line
)(b
, "CompatibilityInformationInActivationContext failed\n");
2789 ok_(__FILE__
, line
)(size
== expected
, "size mismatch (got %lu, expected %lu)\n", size
, expected
);
2790 ok_(__FILE__
, line
)(compat_info
.ElementCount
== num_compat
, "unexpected ElementCount %u\n", compat_info
.ElementCount
);
2792 for (n
= 0; n
< num_compat
; ++n
)
2794 ok_(__FILE__
, line
)(IsEqualGUID(&compat_info
.Elements
[n
].Id
, expected_compat
[n
]),
2795 "got wrong clsid %s, expected %s for %u\n",
2796 wine_dbgstr_guid(&compat_info
.Elements
[n
].Id
),
2797 wine_dbgstr_guid(expected_compat
[n
]),
2799 ok_(__FILE__
, line
)(compat_info
.Elements
[n
].Type
== ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS
,
2800 "Wrong type, got %u for %u\n", (DWORD
)compat_info
.Elements
[n
].Type
, n
);
2804 static void test_compatibility(void)
2808 /* No compat results returned */
2809 trace("manifest1\n");
2810 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
))
2812 skip("Could not create manifest file\n");
2815 handle
= test_create("test1.manifest");
2816 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2817 DeleteFileA("test1.manifest");
2818 if(handle
!= INVALID_HANDLE_VALUE
)
2820 char buffer
[sizeof(COMPATIBILITY_CONTEXT_ELEMENT
) * 2 + sizeof(DWORD
)];
2824 memset(buffer
, 0, sizeof(buffer
));
2825 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
2826 CompatibilityInformationInActivationContext
, buffer
,
2827 sizeof(buffer
), &size
);
2829 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
2831 win_skip("CompatibilityInformationInActivationContext not supported.\n");
2832 pReleaseActCtx(handle
);
2836 test_basic_info(handle
, __LINE__
);
2837 test_no_compat(handle
, __LINE__
);
2838 pReleaseActCtx(handle
);
2841 /* Still no compat results returned */
2842 trace("no_supportedOs\n");
2843 if(!create_manifest_file("no_supportedOs.manifest", compat_manifest_no_supportedOs
, -1, NULL
, NULL
))
2845 skip("Could not create manifest file\n");
2848 handle
= test_create("no_supportedOs.manifest");
2849 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2850 DeleteFileA("no_supportedOs.manifest");
2851 if(handle
!= INVALID_HANDLE_VALUE
)
2853 test_basic_info(handle
, __LINE__
);
2854 test_no_compat(handle
, __LINE__
);
2855 pReleaseActCtx(handle
);
2858 /* Just one result returned */
2859 trace("manifest_vista\n");
2860 if(!create_manifest_file("manifest_vista.manifest", compat_manifest_vista
, -1, NULL
, NULL
))
2862 skip("Could not create manifest file\n");
2865 handle
= test_create("manifest_vista.manifest");
2866 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2867 DeleteFileA("manifest_vista.manifest");
2868 if(handle
!= INVALID_HANDLE_VALUE
)
2870 static const GUID
* expect_manifest
[] =
2874 test_basic_info(handle
, __LINE__
);
2875 test_with_compat(handle
, 1, expect_manifest
, __LINE__
);
2876 pReleaseActCtx(handle
);
2879 /* Show that the order is retained */
2880 trace("manifest_vista_7_8_10_81\n");
2881 if(!create_manifest_file("manifest_vista_7_8_10_81.manifest", compat_manifest_vista_7_8_10_81
, -1, NULL
, NULL
))
2883 skip("Could not create manifest file\n");
2886 handle
= test_create("manifest_vista_7_8_10_81.manifest");
2887 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2888 DeleteFileA("manifest_vista_7_8_10_81.manifest");
2889 if(handle
!= INVALID_HANDLE_VALUE
)
2891 static const GUID
* expect_manifest
[] =
2899 test_basic_info(handle
, __LINE__
);
2900 test_with_compat(handle
, 5, expect_manifest
, __LINE__
);
2901 pReleaseActCtx(handle
);
2904 /* Show that even unknown GUID's are stored */
2905 trace("manifest_other_guid\n");
2906 if(!create_manifest_file("manifest_other_guid.manifest", compat_manifest_other_guid
, -1, NULL
, NULL
))
2908 skip("Could not create manifest file\n");
2911 handle
= test_create("manifest_other_guid.manifest");
2912 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2913 DeleteFileA("manifest_other_guid.manifest");
2914 if(handle
!= INVALID_HANDLE_VALUE
)
2916 static const GUID
* expect_manifest
[] =
2920 test_basic_info(handle
, __LINE__
);
2921 test_with_compat(handle
, 1, expect_manifest
, __LINE__
);
2922 pReleaseActCtx(handle
);
2931 argc
= winetest_get_mainargs(&argv
);
2935 win_skip("Needed functions are not available\n");
2940 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2941 test_app_manifest();
2947 test_CreateActCtx();
2948 test_findsectionstring();
2949 test_ZombifyActCtx();
2950 run_child_process();
2951 test_compatibility();