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
*pQueryActCtxSettingsW
)(DWORD
,HANDLE
,LPCWSTR
,LPCWSTR
,LPWSTR
,SIZE_T
,SIZE_T
*);
34 static NTSTATUS(NTAPI
*pRtlFindActivationContextSectionString
)(DWORD
,const GUID
*,ULONG
,PUNICODE_STRING
,PACTCTX_SECTION_KEYED_DATA
);
35 static BOOLEAN (NTAPI
*pRtlCreateUnicodeStringFromAsciiz
)(PUNICODE_STRING
, PCSZ
);
36 static VOID (NTAPI
*pRtlFreeUnicodeString
)(PUNICODE_STRING
);
40 #elif defined __aarch64__ || defined__arm64ec__
42 #elif defined __x86_64__
50 static const char manifest1
[] =
51 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
52 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
55 static const char manifest1_1
[] =
56 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
57 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
60 static const char manifest2
[] =
61 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
62 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
66 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
68 "</dependentAssembly>"
72 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
73 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
74 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
75 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
76 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
77 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
78 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
79 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
80 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
81 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
82 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
83 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
84 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
86 static const char manifest3
[] =
87 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
88 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
89 " publicKeyToken=\"6595b6414666f1df\" />"
91 "<file name=\"testlib.dll\">"
92 "<windowClass>wndClass</windowClass>"
93 " <comClass description=\"Test com class\""
94 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
95 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
96 " threadingModel=\"Neutral\""
97 " progid=\"ProgId.ProgId\""
98 " miscStatus=\"cantlinkinside\""
99 " miscStatusIcon=\"recomposeonresize\""
100 " miscStatusContent=\"insideout\""
101 " miscStatusThumbnail=\"alignable\""
102 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
104 " <progid>ProgId.ProgId.1</progid>"
105 " <progid>ProgId.ProgId.2</progid>"
106 " <progid>ProgId.ProgId.3</progid>"
107 " <progid>ProgId.ProgId.4</progid>"
108 " <progid>ProgId.ProgId.5</progid>"
109 " <progid>ProgId.ProgId.6</progid>"
111 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
112 " <progid>ProgId.ProgId.7</progid>"
114 " <comInterfaceProxyStub "
116 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
117 " iid=\"{66666666-8888-7777-6666-555555555555}\""
118 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
119 " threadingModel=\"Free\""
121 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
123 " <activatableClass name=\"Wine.Test.Class1\" threadingModel=\"mta\" xmlns=\"urn:schemas-microsoft-com:winrt.v1\"/>"
124 " <activatableClass name=\"Wine.Test.Class2\" threadingModel=\"both\" xmlns=\"urn:schemas-microsoft-com:winrt.v1\"/>"
125 " <activatableClass name=\"Wine.Test.Class3\" threadingModel=\"sta\" xmlns=\"urn:schemas-microsoft-com:winrt.v1\"/>"
127 "<file name=\"Wine.Test.dll\">"
128 " <activatableClass name=\"Wine.Test.Class4\" threadingModel=\"sta\" xmlns=\"urn:schemas-microsoft-com:winrt.v1\"/>"
130 " <comInterfaceExternalProxyStub "
131 " name=\"Iifaceps2\""
132 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
133 " iid=\"{76666666-8888-7777-6666-555555555555}\""
134 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
136 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
138 " <comInterfaceExternalProxyStub "
139 " name=\"Iifaceps3\""
140 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
141 " iid=\"{86666666-8888-7777-6666-555555555555}\""
143 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
146 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
147 " name=\"testsurrogate\""
148 " runtimeVersion=\"v2.0.50727\""
151 " clsid=\"{96666666-8888-7777-6666-555555555556}\""
152 " name=\"testsurrogate\""
153 " runtimeVersion=\"v2.0.50728\""
156 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
158 " progid=\"clrprogid\""
159 " description=\"test description\""
160 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
161 " runtimeVersion=\"1.2.3.4\""
162 " threadingModel=\"Neutral\""
164 " <progid>clrprogid.1</progid>"
165 " <progid>clrprogid.2</progid>"
166 " <progid>clrprogid.3</progid>"
167 " <progid>clrprogid.4</progid>"
168 " <progid>clrprogid.5</progid>"
169 " <progid>clrprogid.6</progid>"
173 static const char manifest_wndcls1
[] =
174 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
175 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
176 "<file name=\"testlib1.dll\">"
177 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
178 "<windowClass>wndClass2</windowClass>"
179 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
181 "<file name=\"testlib1_2.dll\" />"
184 static const char manifest_wndcls2
[] =
185 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
186 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
187 "<file name=\"testlib2.dll\">"
188 " <windowClass versioned=\"no\">wndClass3</windowClass>"
189 " <windowClass>wndClass4</windowClass>"
190 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
191 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
192 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
193 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
195 "<file name=\"testlib2_2.dll\" />"
198 static const char manifest_wndcls_main
[] =
199 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
200 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
202 " <dependentAssembly>"
203 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
204 " </dependentAssembly>"
207 " <dependentAssembly>"
208 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
209 " </dependentAssembly>"
213 static const char manifest4
[] =
214 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
215 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
216 "</assemblyIdentity>"
218 "<dependentAssembly>"
219 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
220 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
221 "</assemblyIdentity>"
222 "</dependentAssembly>"
226 static const char manifest5
[] =
227 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
228 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
229 "</assemblyIdentity>"
231 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
232 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
233 " </dependentAssembly>"
237 static const char manifest6
[] =
238 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
239 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
240 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
242 " <requestedPrivileges>"
243 " <requestedExecutionLevel level=\"ASINVOKER\" uiAccess=\"false\"/>"
244 " </requestedPrivileges>"
249 static const char manifest7
[] =
250 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
251 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
252 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
254 " <requestedPrivileges>"
255 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"TRUE\"/>"
256 " </requestedPrivileges>"
261 static const char manifest8
[] =
262 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
263 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
264 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
266 " <requestedPrivileges>"
267 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\">"
268 " </requestedExecutionLevel>"
269 " </requestedPrivileges>"
274 static const char manifest9
[] =
275 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
276 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
277 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
279 " <requestedPrivileges>"
280 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
281 " </requestedPrivileges>"
284 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
286 " <requestedPrivileges>"
287 " </requestedPrivileges>"
292 static const char manifest10
[] =
293 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" xmlns:asmv2=\"urn:schemas-microsoft-com:asm.v2\" manifestVersion=\"1.0\">"
294 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
297 " <asmv2:requestedPrivileges>"
298 " <asmv2:requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\"></asmv2:requestedExecutionLevel>"
299 " </asmv2:requestedPrivileges>"
304 /* Empty <dependency> element */
305 static const char manifest11
[] =
306 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" xmlns:asmv2=\"urn:schemas-microsoft-com:asm.v2\" manifestVersion=\"1.0\">"
307 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
311 static const char testdep_manifest1
[] =
312 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
313 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
316 static const char testdep_manifest2
[] =
317 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
318 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
319 "<file name=\"testlib.dll\"></file>"
320 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
323 static const char testdep_manifest3
[] =
324 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
325 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
326 "<file name=\"testlib.dll\"/>"
327 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
328 "<windowClass>wndClass</windowClass>"
329 "<windowClass>wndClass2</windowClass>"
333 static const char wrong_manifest1
[] =
334 "<assembly manifestVersion=\"1.0\">"
335 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
338 static const char wrong_manifest2
[] =
339 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
340 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
343 static const char wrong_manifest3
[] =
344 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
345 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
348 static const char wrong_manifest4
[] =
349 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
350 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
354 static const char wrong_manifest5
[] =
355 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
356 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
360 static const char wrong_manifest6
[] =
361 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
362 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
365 static const char wrong_manifest7
[] =
366 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
367 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
368 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
371 static const char wrong_manifest8
[] =
372 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
373 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
377 static const char wrong_manifest9
[] =
378 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
379 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
380 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
382 " <requestedPrivileges>"
383 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
384 " <requestedExecutionLevel uiAccess=\"true\"/>"
385 " </requestedPrivileges>"
390 static const char wrong_manifest10
[] =
391 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
392 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
393 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
395 " <requestedPrivileges>"
396 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
397 " </requestedPrivileges>"
400 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
402 " <requestedPrivileges>"
403 " <requestedExecutionLevel uiAccess=\"true\"/>"
404 " </requestedPrivileges>"
409 /* activatableClass with the wrong xmlns is invalid */
410 static const char wrong_manifest11
[] =
411 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
412 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\" />"
413 "<file name=\"testlib.dll\">"
414 " <activatableClass name=\"Wine.Test.Class1\" threadingModel=\"both\" />"
418 static const char wrong_depmanifest1
[] =
419 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
420 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
423 static const char compat_manifest_no_supportedOs
[] =
424 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
425 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
426 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
432 static const char compat_manifest_vista
[] =
433 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
434 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
435 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
437 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */
442 static const char compat_manifest_vista_7_8_10_81
[] =
443 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
444 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
445 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
447 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" ></supportedOS>" /* Windows Vista */
448 " <supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" />" /* Windows 7 */
449 " <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" ></supportedOS>" /* Windows 8 */
450 " <supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" />" /* Windows 10 */
451 " <supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" />" /* Windows 8.1 */
452 " <maxversiontested Id=\"10.0.18358\" />"
453 " <maxversiontested Id=\"2.3.4.5\" />"
458 static const char compat_manifest_other_guid
[] =
459 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
460 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
461 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
463 " <supportedOS Id=\"{12345566-1111-2222-3333-444444444444}\" />"
468 static const char settings_manifest
[] =
469 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
470 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
471 " <application xmlns=\"urn:schemas-microsoft-com:asm.v3\">"
473 " <dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true</dpiAware>"
474 " <dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">true</dpiAwareness>"
475 " </windowsSettings>"
479 static const char settings_manifest2
[] =
480 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
481 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
482 " <application xmlns=\"urn:schemas-microsoft-com:asm.v3\""
483 " xmlns:ws05=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\""
484 " xmlns:ws11=\"http://schemas.microsoft.com/SMI/2011/WindowsSettings\""
485 " xmlns:ws16=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\""
486 " xmlns:ws17=\"http://schemas.microsoft.com/SMI/2017/WindowsSettings\">"
488 " <ws05:autoElevate>true</ws05:autoElevate>"
489 " <ws05:disableTheming>true</ws05:disableTheming>"
490 " <ws11:disableWindowFiltering>true</ws11:disableWindowFiltering>"
491 " <ws05:dpiAware>true</ws05:dpiAware>"
492 " <ws16:dpiAwareness>true</ws16:dpiAwareness>"
493 " <ws17:gdiScaling>true</ws17:gdiScaling>"
494 " <ws17:highResolutionScrollingAware>true</ws17:highResolutionScrollingAware>"
495 " <ws16:longPathAware>true</ws16:longPathAware>"
496 " <ws17:magicFutureSetting>true</ws17:magicFutureSetting>"
497 " <ws11:printerDriverIsolation>true</ws11:printerDriverIsolation>"
498 " <ws17:ultraHighResolutionScrollingAware>true</ws17:ultraHighResolutionScrollingAware>"
499 " </windowsSettings>"
503 /* broken manifest found in some binaries: asmv3 namespace is used but not declared */
504 static const char settings_manifest3
[] =
505 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
506 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
507 " <asmv3:application>"
508 " <asmv3:windowsSettings xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">"
509 " <dpiAware>true</dpiAware>"
510 " </asmv3:windowsSettings>"
511 " </asmv3:application>"
514 static const char settings_manifest4
[] =
515 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
516 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
518 " <application xmlns=\"urn:schemas-microsoft-com:asm.v3\">"
520 " <dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true</dpiAware>"
521 " </windowsSettings>"
524 " <application xmlns=\"urn:schemas-microsoft-com:asm.v3\">"
526 " <dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">true</dpiAwareness>"
527 " </windowsSettings>"
531 static const char two_dll_manifest_dll
[] =
532 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v3\" manifestVersion=\"1.0\">"
533 " <assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"0000000000000000\"/>"
534 " <file name=\"sxs_dll.dll\"></file>"
537 static const char two_dll_manifest_exe
[] =
538 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
540 " <dependentAssembly>"
541 " <assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"0000000000000000\" language=\"*\"/>"
542 " </dependentAssembly>"
546 static const char builtin_dll_manifest
[] =
547 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
549 " <dependentAssembly>"
552 " name=\"microsoft.vc90.crt\""
553 " version=\"9.0.20718.0\""
554 " processorArchitecture=\"*\""
555 " publicKeyToken=\"1fc8b3b9a1e18e3b\""
558 " </dependentAssembly>"
562 static const char empty_assembly_manifest
[] =
563 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\" />";
565 DEFINE_GUID(VISTA_COMPAT_GUID
, 0xe2011457, 0x1546, 0x43c5, 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0);
566 DEFINE_GUID(WIN7_COMPAT_GUID
, 0x35138b9a, 0x5d96, 0x4fbd, 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a);
567 DEFINE_GUID(WIN8_COMPAT_GUID
, 0x4a2f28e3, 0x53b9, 0x4441, 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38);
568 DEFINE_GUID(WIN81_COMPAT_GUID
, 0x1f676c76, 0x80e1, 0x4239, 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78);
569 DEFINE_GUID(WIN10_COMPAT_GUID
, 0x8e0f7a12, 0xbfb3, 0x4fe8, 0xb9, 0xa5, 0x48, 0xfd, 0x50, 0xa1, 0x5a, 0x9a);
570 DEFINE_GUID(OTHER_COMPAT_GUID
, 0x12345566, 0x1111, 0x2222, 0x33, 0x33, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44);
573 static const WCHAR testlib_dll
[] =
574 {'t','e','s','t','l','i','b','.','d','l','l',0};
575 static const WCHAR testlib2_dll
[] =
576 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
577 static const WCHAR wndClassW
[] =
578 {'w','n','d','C','l','a','s','s',0};
579 static const WCHAR wndClass1W
[] =
580 {'w','n','d','C','l','a','s','s','1',0};
581 static const WCHAR wndClass2W
[] =
582 {'w','n','d','C','l','a','s','s','2',0};
583 static const WCHAR wndClass3W
[] =
584 {'w','n','d','C','l','a','s','s','3',0};
586 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
587 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
589 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
590 const char *depfile
, const char *depmanifest
)
594 WCHAR path
[MAX_PATH
];
596 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
597 GetFullPathNameW(path
, ARRAY_SIZE(manifest_path
), manifest_path
, NULL
);
599 if (manifest_len
== -1)
600 manifest_len
= strlen(manifest
);
602 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
603 FILE_ATTRIBUTE_NORMAL
, NULL
);
604 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %lu\n", GetLastError());
605 if(file
== INVALID_HANDLE_VALUE
)
607 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
612 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
613 GetFullPathNameW(path
, ARRAY_SIZE(depmanifest_path
), depmanifest_path
, NULL
);
614 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
615 FILE_ATTRIBUTE_NORMAL
, NULL
);
616 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %lu\n", GetLastError());
617 if(file
== INVALID_HANDLE_VALUE
)
619 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
625 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
627 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
629 int offset
= (fBOM
? 0 : 1);
631 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
632 wmanifest
[0] = 0xfeff;
636 for (i
= 0; i
< strlen(manifest
)+1; i
++)
637 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
639 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
640 HeapFree(GetProcessHeap(), 0, wmanifest
);
644 static HANDLE
create_temp_manifest_file(const char *manifest
, WCHAR
*pathname
)
646 WCHAR tmp_path
[MAX_PATH
];
647 DWORD size
, tmp_path_len
;
651 tmp_path_len
= GetTempPathW(ARRAY_SIZE(tmp_path
), tmp_path
);
652 ok(tmp_path_len
!= 0, "GetTempPathW returned error %lu\n", GetLastError());
653 ok(tmp_path_len
< ARRAY_SIZE(tmp_path
), "GetTempPathW return value %lu should be less than %Iu\n",
654 tmp_path_len
, ARRAY_SIZE(tmp_path
));
656 memset(pathname
, 0, MAX_PATH
* sizeof(WCHAR
));
657 unique
= GetTempFileNameW(tmp_path
, L
"tst", 0, pathname
);
658 ok(unique
!= 0, "GetTempFileNameW returned error %lu\n", GetLastError());
660 /* Open file handle that will be deleted on close or process termination */
661 file
= CreateFileW(pathname
,
662 GENERIC_READ
| DELETE
,
663 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
666 FILE_ATTRIBUTE_NORMAL
| FILE_FLAG_DELETE_ON_CLOSE
,
668 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile returned error %lu\n", GetLastError());
670 /* Re-open file with write access */
671 file_w
= CreateFileW(pathname
,
673 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
676 FILE_ATTRIBUTE_NORMAL
,
678 ok(file_w
!= INVALID_HANDLE_VALUE
, "CreateFile returned error %lu\n", GetLastError());
680 WriteFile(file_w
, manifest
, strlen(manifest
), &size
, NULL
);
682 /* Close file handle that was open for write to avoid sharing violation */
689 ULONG format_version
;
690 ULONG assembly_cnt_min
;
691 ULONG assembly_cnt_max
;
692 ULONG root_manifest_type
;
693 LPWSTR root_manifest_path
;
694 ULONG root_config_type
;
699 static const detailed_info_t detailed_info0
= {
700 0, 0, 0, 0, NULL
, 0, 0, NULL
703 static const detailed_info_t detailed_info1
= {
704 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
705 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
709 static const detailed_info_t detailed_info1_child
= {
710 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
711 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
715 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
716 static const detailed_info_t detailed_info2
= {
717 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
718 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
722 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
724 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
725 SIZE_T size
, exsize
, retsize
;
728 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
729 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
730 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
732 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
734 b
= QueryActCtxW(0, handle
, NULL
, ActivationContextDetailedInformation
, &detailed_info_tmp
,
735 sizeof(detailed_info_tmp
), &size
);
736 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
737 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %lu\n", GetLastError());
738 ok_(__FILE__
, line
)(size
== exsize
, "size=%Id, expected %Id\n", size
, exsize
);
740 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
743 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
744 memset(detailed_info
, 0xfe, size
);
745 b
= QueryActCtxW(0, handle
, NULL
, ActivationContextDetailedInformation
, detailed_info
, size
, &retsize
);
746 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %lu\n", GetLastError());
747 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%Id, expected %Id\n", retsize
, exsize
);
749 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%lx\n", detailed_info
->dwFlags
);
750 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
751 "detailed_info->ulFormatVersion=%lu, expected %lu\n", detailed_info
->ulFormatVersion
,
752 exinfo
->format_version
);
753 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
754 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
755 "detailed_info->ulAssemblyCount=%lu, expected between %lu and %lu\n", detailed_info
->ulAssemblyCount
,
756 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
757 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
758 "detailed_info->ulRootManifestPathType=%lu, expected %lu\n",
759 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
760 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
761 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
762 "detailed_info->ulRootManifestPathChars=%lu, expected %u\n",
763 detailed_info
->ulRootManifestPathChars
,
764 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
765 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
766 "detailed_info->ulRootConfigurationPathType=%lu, expected %lu\n",
767 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
768 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
769 "detailed_info->ulRootConfigurationPathChars=%ld\n", detailed_info
->ulRootConfigurationPathChars
);
770 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
771 "detailed_info->ulAppDirPathType=%lu, expected %lu\n", detailed_info
->ulAppDirPathType
,
772 exinfo
->app_dir_type
);
773 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
774 "detailed_info->ulAppDirPathChars=%lu, expected %u\n",
775 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
776 if(exinfo
->root_manifest_path
) {
777 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
778 if(detailed_info
->lpRootManifestPath
)
779 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
780 "unexpected detailed_info->lpRootManifestPath %s\n", wine_dbgstr_w(detailed_info
->lpRootManifestPath
));
782 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
784 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
785 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
786 if(exinfo
->app_dir
) {
787 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
788 if(detailed_info
->lpAppDirPath
)
789 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
790 "unexpected detailed_info->lpAppDirPath %s / %s\n",
791 wine_dbgstr_w(detailed_info
->lpAppDirPath
), wine_dbgstr_w( exinfo
->app_dir
));
793 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
796 HeapFree(GetProcessHeap(), 0, detailed_info
);
801 /* ULONG manifest_path_type; FIXME */
802 LPCWSTR manifest_path
;
803 LPCWSTR encoded_assembly_id
;
804 BOOL has_assembly_dir
;
807 static const info_in_assembly manifest1_info
= {
809 L
"Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
813 static const info_in_assembly manifest1_child_info
= {
814 1, app_manifest_path
,
815 L
"Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
819 static const info_in_assembly manifest2_info
= {
821 L
"Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
825 static const info_in_assembly manifest3_info
= {
827 L
"Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
831 static const info_in_assembly manifest4_info
= {
833 L
"Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
837 static const info_in_assembly depmanifest1_info
= {
838 0x10, depmanifest_path
,
839 L
"testdep,processorArchitecture=\"" ARCH
"\","
840 "type=\"win32\",version=\"6.5.4.3\"",
844 static const info_in_assembly depmanifest2_info
= {
845 0x10, depmanifest_path
,
846 L
"testdep,processorArchitecture=\"" ARCH
"\","
847 "type=\"win32\",version=\"6.5.4.3\"",
851 static const info_in_assembly depmanifest3_info
= {
852 0x10, depmanifest_path
,
853 L
"testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
857 static const info_in_assembly manifest_comctrl_info
= {
858 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
861 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
863 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
868 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
869 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
870 if (exinfo
->encoded_assembly_id
) exsize
+= (lstrlenW(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
873 b
= QueryActCtxW(0, handle
, &id
, AssemblyDetailedInformationInActivationContext
, &info_tmp
, sizeof(info_tmp
), &size
);
874 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
875 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %lu\n", GetLastError());
877 ok_(__FILE__
, line
)(size
>= exsize
, "size=%Iu, expected %Iu\n", size
, exsize
);
879 if (size
== 0xdeadbeef)
885 info
= HeapAlloc(GetProcessHeap(), 0, size
);
886 memset(info
, 0xfe, size
);
889 b
= QueryActCtxW(0, handle
, &id
, AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
890 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %lu\n", GetLastError());
891 if (!exinfo
->manifest_path
)
892 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
893 if (!exinfo
->encoded_assembly_id
)
894 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
895 if (exinfo
->has_assembly_dir
)
896 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
897 ok_(__FILE__
, line
)(size
== exsize
, "size=%Iu, expected %Iu\n", size
, exsize
);
899 if (0) /* FIXME: flags meaning unknown */
901 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %lx, expected %lx\n",
902 info
->ulFlags
, exinfo
->flags
);
904 if(exinfo
->encoded_assembly_id
) {
905 len
= lstrlenW(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
906 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
907 "info->ulEncodedAssemblyIdentityLength = %lu, expected %lu\n",
908 info
->ulEncodedAssemblyIdentityLength
, len
);
910 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
911 "info->ulEncodedAssemblyIdentityLength == 0\n");
913 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
914 "info->ulManifestPathType = %lx\n", info
->ulManifestPathType
);
915 if(exinfo
->manifest_path
) {
916 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
917 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %lu, expected %lu\n",
918 info
->ulManifestPathLength
, len
);
920 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
923 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
924 "info->ulPolicyPathType = %lx\n", info
->ulPolicyPathType
);
925 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
926 "info->ulPolicyPathLength = %lu, expected 0\n", info
->ulPolicyPathLength
);
927 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %lx\n",
928 info
->ulMetadataSatelliteRosterIndex
);
929 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %lx\n",
930 info
->ulManifestVersionMajor
);
931 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %lx\n",
932 info
->ulManifestVersionMinor
);
933 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %lx\n",
934 info
->ulPolicyVersionMajor
);
935 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %lx\n",
936 info
->ulPolicyVersionMinor
);
937 if(exinfo
->has_assembly_dir
)
938 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
939 "info->ulAssemblyDirectoryNameLength == 0\n");
941 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
942 "info->ulAssemblyDirectoryNameLength != 0\n");
944 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
945 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
946 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
947 ok_(__FILE__
, line
)(!lstrcmpW(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
948 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
949 wine_dbgstr_w(info
->lpAssemblyEncodedAssemblyIdentity
), wine_dbgstr_w(exinfo
->encoded_assembly_id
));
951 if(exinfo
->manifest_path
) {
952 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
953 if(info
->lpAssemblyManifestPath
)
954 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
955 "unexpected info->lpAssemblyManifestPath\n");
957 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
960 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
961 if(info
->lpAssemblyPolicyPath
)
962 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
963 if(exinfo
->has_assembly_dir
)
964 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
966 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
967 wine_dbgstr_w(info
->lpAssemblyDirectoryName
));
968 HeapFree(GetProcessHeap(), 0, info
);
971 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
973 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
974 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
978 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
979 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
982 b
= QueryActCtxW(0, handle
, &index
, FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
983 sizeof(info_tmp
), &size
);
984 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
985 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %lu\n", GetLastError());
986 ok_(__FILE__
, line
)(size
== exsize
, "size=%Iu, expected %Iu\n", size
, exsize
);
988 if(size
== 0xdeadbeef)
994 info
= HeapAlloc(GetProcessHeap(), 0, size
);
995 memset(info
, 0xfe, size
);
997 b
= QueryActCtxW(0, handle
, &index
, FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
998 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %lu\n", GetLastError());
999 ok_(__FILE__
, line
)(!size
, "size=%Iu, expected 0\n", size
);
1001 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%lx, expected 2\n", info
->ulFlags
);
1002 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
1003 "info->ulFilenameLength=%lu, expected %u*sizeof(WCHAR)\n",
1004 info
->ulFilenameLength
, lstrlenW(filename
));
1005 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%lu\n", info
->ulPathLength
);
1006 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
1007 if(info
->lpFileName
)
1008 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
1009 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
1010 HeapFree(GetProcessHeap(), 0, info
);
1014 ACTCTX_REQUESTED_RUN_LEVEL run_level
;
1018 static const runlevel_info_t runlevel_info0
= {
1019 ACTCTX_RUN_LEVEL_UNSPECIFIED
, FALSE
,
1022 static const runlevel_info_t runlevel_info6
= {
1023 ACTCTX_RUN_LEVEL_AS_INVOKER
, FALSE
,
1026 static const runlevel_info_t runlevel_info7
= {
1027 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
1030 static const runlevel_info_t runlevel_info8
= {
1031 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
1034 static const runlevel_info_t runlevel_info9
= {
1035 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, FALSE
,
1038 static void test_runlevel_info(HANDLE handle
, const runlevel_info_t
*exinfo
, int line
)
1040 ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel_info
;
1041 SIZE_T size
, retsize
;
1044 size
= sizeof(runlevel_info
);
1045 b
= QueryActCtxW(0, handle
, NULL
, RunlevelInformationInActivationContext
, &runlevel_info
,
1046 sizeof(runlevel_info
), &retsize
);
1047 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
1049 win_skip("RunlevelInformationInActivationContext not supported.\n");
1053 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %lu\n", GetLastError());
1054 ok_(__FILE__
, line
)(retsize
== size
, "size=%Id, expected %Id\n", retsize
, size
);
1056 ok_(__FILE__
, line
)(runlevel_info
.ulFlags
== 0, "runlevel_info.ulFlags=%lx\n", runlevel_info
.ulFlags
);
1057 ok_(__FILE__
, line
)(runlevel_info
.RunLevel
== exinfo
->run_level
,
1058 "runlevel_info.RunLevel=%u, expected %u\n", runlevel_info
.RunLevel
, exinfo
->run_level
);
1059 ok_(__FILE__
, line
)(runlevel_info
.UiAccess
== exinfo
->ui_access
,
1060 "runlevel_info.UiAccess=%lu, expected %lu\n", runlevel_info
.UiAccess
, exinfo
->ui_access
);
1063 static HANDLE
test_create(const char *file
)
1067 WCHAR path
[MAX_PATH
];
1069 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
1070 memset(&actctx
, 0, sizeof(ACTCTXW
));
1071 actctx
.cbSize
= sizeof(ACTCTXW
);
1072 actctx
.lpSource
= path
;
1074 handle
= CreateActCtxW(&actctx
);
1075 /* to be tested outside of this helper, including last error */
1076 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
1078 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%ld\n", actctx
.cbSize
);
1079 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%ld\n", actctx
.dwFlags
);
1080 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
1081 ok(actctx
.wProcessorArchitecture
== 0,
1082 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
1083 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
1084 ok(actctx
.lpAssemblyDirectory
== NULL
,
1085 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
1086 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
1087 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
1088 actctx
.lpApplicationName
);
1089 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
1094 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
, BOOL is_broken
)
1098 WCHAR path
[MAX_PATH
];
1100 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
1101 memset(&actctx
, 0, sizeof(ACTCTXW
));
1102 actctx
.cbSize
= sizeof(ACTCTXW
);
1103 actctx
.lpSource
= path
;
1105 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
1106 handle
= CreateActCtxW(&actctx
);
1110 ok(broken(handle
!= INVALID_HANDLE_VALUE
) || handle
== INVALID_HANDLE_VALUE
,
1111 "Unexpected context handle %p.\n", handle
);
1113 ok(handle
== INVALID_HANDLE_VALUE
, "Unexpected context handle %p.\n", handle
);
1115 if (handle
== INVALID_HANDLE_VALUE
)
1116 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "Unexpected error %ld.\n", GetLastError());
1118 if (handle
!= INVALID_HANDLE_VALUE
) ReleaseActCtx( handle
);
1119 DeleteFileA("bad.manifest");
1120 DeleteFileA("testdep.manifest");
1123 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
1127 WCHAR path
[MAX_PATH
];
1129 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
1130 memset(&actctx
, 0, sizeof(ACTCTXW
));
1131 actctx
.cbSize
= sizeof(ACTCTXW
);
1132 actctx
.lpSource
= path
;
1134 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
1135 handle
= CreateActCtxW(&actctx
);
1136 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
1137 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %lu\n", GetLastError());
1139 if (handle
!= INVALID_HANDLE_VALUE
) ReleaseActCtx( handle
);
1140 DeleteFileA("bad.manifest");
1143 static void test_create_fail(void)
1147 WCHAR path
[MAX_PATH
];
1149 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
1150 memset(&actctx
, 0, sizeof(ACTCTXW
));
1151 actctx
.cbSize
= sizeof(ACTCTXW
);
1152 actctx
.lpSource
= path
;
1154 handle
= CreateActCtxW(&actctx
);
1155 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
1156 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %lu\n", GetLastError());
1158 trace("wrong_manifest1\n");
1159 test_create_and_fail(wrong_manifest1
, NULL
, 0, FALSE
);
1160 trace("wrong_manifest2\n");
1161 test_create_and_fail(wrong_manifest2
, NULL
, 0, FALSE
);
1162 trace("wrong_manifest3\n");
1163 test_create_and_fail(wrong_manifest3
, NULL
, 1, FALSE
);
1164 trace("wrong_manifest4\n");
1165 test_create_and_fail(wrong_manifest4
, NULL
, 1, FALSE
);
1166 trace("wrong_manifest5\n");
1167 test_create_and_fail(wrong_manifest5
, NULL
, 0, FALSE
);
1168 trace("wrong_manifest6\n");
1169 test_create_and_fail(wrong_manifest6
, NULL
, 0, FALSE
);
1170 trace("wrong_manifest7\n");
1171 test_create_and_fail(wrong_manifest7
, NULL
, 1, FALSE
);
1172 trace("wrong_manifest8\n");
1173 test_create_and_fail(wrong_manifest8
, NULL
, 0, FALSE
);
1174 trace("wrong_manifest9\n");
1175 test_create_and_fail(wrong_manifest9
, NULL
, 0, TRUE
/* WinXP */);
1176 trace("wrong_manifest10\n");
1177 test_create_and_fail(wrong_manifest10
, NULL
, 0, TRUE
/* WinXP */);
1178 trace("wrong_manifest11\n");
1179 test_create_and_fail(wrong_manifest11
, NULL
, 1, TRUE
/* w1064v1909 */);
1180 trace("UTF-16 manifest1 without BOM\n");
1181 test_create_wide_and_fail(manifest1
, FALSE
);
1182 trace("manifest2\n");
1183 test_create_and_fail(manifest2
, NULL
, 0, FALSE
);
1184 trace("manifest2+depmanifest1\n");
1185 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0, FALSE
);
1188 struct strsection_header
1196 ULONG global_offset
;
1210 struct guidsection_header
1230 struct wndclass_redirect_data
1235 ULONG name_offset
; /* versioned name offset */
1237 ULONG module_offset
;/* container name offset */
1240 struct dllredirect_data_path
1246 struct dllredirect_data
1253 struct dllredirect_data_path paths
[1];
1256 #define DLL_REDIRECT_PATH_INCLUDES_BASE_NAME 1
1257 #define DLL_REDIRECT_PATH_OMITS_ASSEMBLY_ROOT 2
1258 #define DLL_REDIRECT_PATH_EXPAND 4
1259 #define DLL_REDIRECT_PATH_SYSTEM_DEFAULT_REDIRECTED_SYSTEM32_DLL 8
1261 struct tlibredirect_data
1275 struct progidredirect_data
1282 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
1284 ACTCTX_SECTION_KEYED_DATA data
;
1287 memset(&data
, 0xfe, sizeof(data
));
1288 data
.cbSize
= sizeof(data
);
1290 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, libname
, &data
);
1291 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %lu\n", GetLastError());
1294 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1295 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1296 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1297 ok_(__FILE__
, line
)(data
.ulLength
== offsetof( struct dllredirect_data
, paths
[0]), "data.ulLength=%lu\n", data
.ulLength
);
1301 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
1302 ok_(__FILE__
, line
)(dlldata
->size
== offsetof( struct dllredirect_data
, paths
[dlldata
->paths_count
]),
1303 "got wrong size %ld\n", dlldata
->size
);
1304 ok_(__FILE__
, line
)(dlldata
->flags
== DLL_REDIRECT_PATH_OMITS_ASSEMBLY_ROOT
,
1305 "got wrong flags value %lx\n", dlldata
->flags
);
1306 ok_(__FILE__
, line
)(dlldata
->total_len
== 0, "got wrong total len value %ld\n", dlldata
->total_len
);
1307 ok_(__FILE__
, line
)(dlldata
->paths_count
== 0, "got wrong paths count value %ld\n", dlldata
->paths_count
);
1308 ok_(__FILE__
, line
)(dlldata
->paths_offset
== 0, "got wrong paths offset value %ld\n", dlldata
->paths_offset
);
1311 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1312 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%lu\n",
1313 data
.ulSectionGlobalDataLength
);
1314 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1315 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n",
1316 data
.ulSectionTotalLength
);
1317 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1318 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1319 data
.ulAssemblyRosterIndex
, exid
);
1321 memset(&data
, 0xfe, sizeof(data
));
1322 data
.cbSize
= sizeof(data
);
1324 ret
= FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1325 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, libname
, &data
);
1326 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %lu\n", GetLastError());
1329 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1330 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1331 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1332 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%lu\n", data
.ulLength
);
1333 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1334 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%lu\n",
1335 data
.ulSectionGlobalDataLength
);
1336 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1337 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n",
1338 data
.ulSectionTotalLength
);
1339 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1340 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1341 data
.ulAssemblyRosterIndex
, exid
);
1343 ReleaseActCtx(handle
);
1346 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
1348 struct wndclass_redirect_data
*wnddata
;
1349 struct strsection_header
*header
;
1350 ACTCTX_SECTION_KEYED_DATA data
;
1353 memset(&data
, 0xfe, sizeof(data
));
1354 data
.cbSize
= sizeof(data
);
1356 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, clsname
, &data
);
1357 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %lu, class %s\n", GetLastError(),
1358 wine_dbgstr_w(clsname
));
1361 header
= (struct strsection_header
*)data
.lpSectionBase
;
1362 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1364 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08lx\n", header
->magic
);
1365 ok_(__FILE__
, line
)(header
->count
> 0, "got count %ld\n", header
->count
);
1366 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1367 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1368 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1369 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %ld for header size\n", wnddata
->size
);
1370 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1372 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1377 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %ld\n", wnddata
->res
);
1378 /* redirect class name (versioned or not) is stored just after header data */
1379 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %ld\n", wnddata
->name_offset
);
1380 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %ld\n", wnddata
->module_len
);
1382 /* expected versioned name */
1383 lstrcpyW(buff
, verW
);
1384 lstrcatW(buff
, clsname
);
1385 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1386 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1387 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1388 "got wrong class name length %ld, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1390 /* data length is simply header length + string data length including nulls */
1391 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1392 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %ld, expected %ld\n", data
.ulLength
, len
);
1394 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1396 WCHAR
*modulename
, *sectionptr
;
1398 /* just compare pointers */
1399 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1400 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1401 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1405 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1406 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%lu\n",
1407 data
.ulSectionGlobalDataLength
);
1408 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1409 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n",
1410 data
.ulSectionTotalLength
);
1411 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1412 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1413 data
.ulAssemblyRosterIndex
, exid
);
1415 memset(&data
, 0xfe, sizeof(data
));
1416 data
.cbSize
= sizeof(data
);
1418 ret
= FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1419 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, clsname
, &data
);
1420 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %lu, class %s\n", GetLastError(),
1421 wine_dbgstr_w(clsname
));
1424 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1425 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1426 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1427 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%lu\n", data
.ulLength
);
1428 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1429 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%lu\n",
1430 data
.ulSectionGlobalDataLength
);
1431 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1432 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n", data
.ulSectionTotalLength
);
1433 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1434 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1435 data
.ulAssemblyRosterIndex
, exid
);
1437 ReleaseActCtx(handle
);
1440 enum winrt_threading_model
1442 WINRT_THREADING_MODEL_BOTH
= 0,
1443 WINRT_THREADING_MODEL_STA
= 1,
1444 WINRT_THREADING_MODEL_MTA
= 2,
1447 struct activatable_class_data
1452 DWORD module_offset
;
1453 DWORD threading_model
;
1456 static void test_find_activatable_class(HANDLE handle
, const WCHAR
*classid
, enum winrt_threading_model threading_model
,
1457 const WCHAR
*file
, ULONG exid
, int line
)
1459 struct activatable_class_data
*activatable_class
;
1460 struct strsection_header
*header
;
1461 ACTCTX_SECTION_KEYED_DATA data
;
1465 memset(&data
, 0xfe, sizeof(data
));
1466 data
.cbSize
= sizeof(data
);
1468 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINRT_ACTIVATABLE_CLASSES
, classid
, &data
);
1469 ok_(__FILE__
, line
)(ret
|| broken(!ret
) /* <= Win10 v1809 */, "FindActCtxSectionStringW failed, error %lu\n", GetLastError());
1472 ok_(__FILE__
, line
)(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "got error %lu\n", GetLastError());
1476 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "got cbSize %lu\n", data
.cbSize
);
1477 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "got ulDataFormatVersion %lu\n", data
.ulDataFormatVersion
);
1478 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "got lpData %p\n", data
.lpData
);
1480 header
= (struct strsection_header
*)data
.lpSectionBase
;
1481 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "got lpSectionBase %p\n", data
.lpSectionBase
);
1482 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08lx\n", header
->magic
);
1483 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "got ulSectionTotalLength %lu\n", data
.ulSectionTotalLength
);
1484 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
,
1485 "got lpSectionGlobalData %p\n", data
.lpSectionGlobalData
);
1486 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
,
1487 "got ulSectionGlobalDataLength %lu\n", data
.ulSectionGlobalDataLength
);
1488 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "got hActCtx %p\n", data
.hActCtx
);
1489 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "got ulAssemblyRosterIndex %lu\n", data
.ulAssemblyRosterIndex
);
1491 activatable_class
= (struct activatable_class_data
*)data
.lpData
;
1492 ok_(__FILE__
, line
)(activatable_class
->size
== sizeof(*activatable_class
), "got size %lu\n",
1493 activatable_class
->size
);
1494 ok_(__FILE__
, line
)(activatable_class
->threading_model
== threading_model
, "got threading_model %lu\n",
1495 activatable_class
->threading_model
);
1497 ptr
= (BYTE
*)header
+ activatable_class
->module_offset
;
1498 ok_(__FILE__
, line
)(wcslen(ptr
) * sizeof(WCHAR
) == activatable_class
->module_len
,
1499 "got module_len %lu\n", activatable_class
->module_len
);
1500 ok_(__FILE__
, line
)(!wcscmp(ptr
, file
), "got data.lpSectionGlobalData %s\n", debugstr_w(ptr
));
1503 static void test_find_string_fail(void)
1505 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1508 ret
= FindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1509 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1510 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%lu\n", GetLastError());
1512 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib2_dll
, &data
);
1513 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1514 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%lu\n", GetLastError());
1516 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib_dll
, NULL
);
1517 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1518 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%lu\n", GetLastError());
1520 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, NULL
, &data
);
1521 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1522 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%lu\n", GetLastError());
1525 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib_dll
, &data
);
1526 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1527 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%lu\n", GetLastError());
1530 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib_dll
, &data
);
1531 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1532 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%lu\n", GetLastError());
1536 static void test_basic_info(HANDLE handle
, int line
)
1538 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1542 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, ActivationContextBasicInformation
, &basic
,
1543 sizeof(basic
), &size
);
1545 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1546 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1547 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %lx\n",basic
.dwFlags
);
1548 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1550 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
| QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1551 ActivationContextBasicInformation
, &basic
,
1552 sizeof(basic
), &size
);
1555 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1556 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1557 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1558 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %lx\n",basic
.dwFlags
);
1559 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1563 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1564 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1565 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %lx\n",basic
.dwFlags
);
1566 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1570 enum comclass_threadingmodel
{
1571 ThreadingModel_Apartment
= 1,
1572 ThreadingModel_Free
= 2,
1573 ThreadingModel_No
= 3,
1574 ThreadingModel_Both
= 4,
1575 ThreadingModel_Neutral
= 5
1578 enum comclass_miscfields
{
1581 MiscStatusContent
= 4,
1582 MiscStatusThumbnail
= 8,
1583 MiscStatusDocPrint
= 16
1586 struct comclassredirect_data
{
1597 ULONG progid_offset
;
1599 ULONG clrdata_offset
;
1601 DWORD miscstatuscontent
;
1602 DWORD miscstatusthumbnail
;
1603 DWORD miscstatusicon
;
1604 DWORD miscstatusdocprint
;
1607 struct clrclass_data
{
1611 ULONG module_offset
;
1615 ULONG version_offset
;
1619 static void validate_guid_index(const ACTCTX_SECTION_KEYED_DATA
*data
, int line
)
1621 #define GUIDSECTION_MAGIC 0x64487347 /* dHsG */
1622 struct guidsection_header
*header
;
1623 struct guid_index
*index
;
1626 header
= (struct guidsection_header
*)data
->lpSectionBase
;
1628 ok_(__FILE__
, line
)(header
->magic
== GUIDSECTION_MAGIC
, "Unexpected magic %#lx.\n", header
->magic
);
1629 ok_(__FILE__
, line
)(header
->size
== sizeof(*header
), "Unexpected size %ld.\n", header
->size
);
1630 ok_(__FILE__
, line
)(header
->index_offset
>= sizeof(*header
), "Unexpected index offset %lu.\n", header
->index_offset
);
1632 index
= (struct guid_index
*)((BYTE
*)data
->lpSectionBase
+ header
->index_offset
);
1633 for (i
= 0; i
< header
->count
; ++i
)
1635 ok_(__FILE__
, line
)(index
[i
].data_len
<= data
->ulSectionTotalLength
, "Unexpected data length.\n");
1636 ok_(__FILE__
, line
)(index
[i
].data_offset
<= data
->ulSectionTotalLength
- index
[i
].data_len
,
1637 "Unexpected data offset %ld, section total length %lu, data length %lu.\n",
1638 index
[i
].data_offset
, data
->ulSectionTotalLength
, index
[i
].data_len
);
1642 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1644 struct comclassredirect_data
*comclass
, *comclass2
;
1645 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1646 struct guidsection_header
*header
;
1649 memset(&data
, 0xfe, sizeof(data
));
1650 data
.cbSize
= sizeof(data
);
1652 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
, clsid
, &data
);
1655 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1658 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
1660 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1662 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1663 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1664 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1665 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %ld for header size\n", comclass
->size
);
1666 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1668 ULONG len
, miscmask
;
1671 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %ld\n", comclass
->model
);
1672 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1673 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1675 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1676 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %ld\n", comclass
->name_len
);
1680 len
= comclass
->size
+ comclass
->clrdata_len
;
1681 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %ld, expected %ld\n", comclass
->progid_offset
, len
);
1684 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %ld, expected 0\n", comclass
->progid_offset
);
1686 if (comclass
->progid_offset
)
1688 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1689 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1690 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1691 "got progid name length %ld\n", comclass
->progid_len
);
1694 /* data length is simply header length + string data length including nulls */
1695 len
= comclass
->size
+ comclass
->clrdata_len
;
1696 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1697 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %ld, expected %ld\n", data
.ulLength
, len
);
1699 /* keyed data structure doesn't include module name, it's available from section data */
1700 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %ld\n", comclass
->name_offset
);
1702 /* check misc fields are set */
1703 miscmask
= (comclass
->flags
>> 8) & 0xff;
1706 if (miscmask
& MiscStatus
)
1707 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08lx\n", comclass
->miscstatus
);
1708 if (miscmask
& MiscStatusIcon
)
1709 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08lx\n", comclass
->miscstatusicon
);
1710 if (miscmask
& MiscStatusContent
)
1711 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08lx\n", comclass
->miscstatuscontent
);
1712 if (miscmask
& MiscStatusThumbnail
)
1713 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08lx\n", comclass
->miscstatusthumbnail
);
1714 if (miscmask
& MiscStatusDocPrint
)
1715 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08lx\n", comclass
->miscstatusdocprint
);
1717 ok_(__FILE__
, line
)(!(comclass
->flags
& 0xffff00ff), "Unexpected flags %#lx.\n", comclass
->flags
);
1719 /* part used for clrClass only */
1720 if (comclass
->clrdata_len
)
1722 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1723 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1724 struct clrclass_data
*clrclass
;
1727 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1728 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %ld\n", clrclass
->size
);
1729 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08lx\n", clrclass
->res
[0]);
1730 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08lx\n", clrclass
->res
[1]);
1731 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %ld\n", clrclass
->module_len
);
1732 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %ld\n", clrclass
->module_offset
);
1734 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %ld\n", clrclass
->name_len
);
1735 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %ld\n", clrclass
->name_offset
);
1736 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %ld\n", clrclass
->version_len
);
1737 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %ld\n", clrclass
->version_offset
);
1739 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08lx\n", clrclass
->res2
[0]);
1740 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08lx\n", clrclass
->res2
[1]);
1742 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1743 in lower case, clsclass subsection - in upper case */
1744 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %ld\n", comclass
->name_len
);
1745 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %ld\n", clrclass
->name_offset
);
1747 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1748 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1750 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1751 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1755 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1756 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1757 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1758 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%lu\n",
1759 data
.ulSectionGlobalDataLength
);
1760 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n",
1761 data
.ulSectionTotalLength
);
1762 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1763 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1764 data
.ulAssemblyRosterIndex
, exid
);
1765 validate_guid_index(&data
, line
);
1767 /* generated guid for this class works as key guid in search */
1768 memset(&data2
, 0xfe, sizeof(data2
));
1769 data2
.cbSize
= sizeof(data2
);
1770 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
, &comclass
->alias
, &data2
);
1771 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
1773 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1774 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %ld, expected %ld\n", comclass2
->size
, comclass
->size
);
1775 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1784 struct ifacepsredirect_data
1796 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1797 const GUID
*ps32
, ULONG exid
, int line
)
1799 struct ifacepsredirect_data
*ifaceps
;
1800 ACTCTX_SECTION_KEYED_DATA data
;
1803 memset(&data
, 0xfe, sizeof(data
));
1804 data
.cbSize
= sizeof(data
);
1806 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
, iid
, &data
);
1807 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
1809 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1811 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1812 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1813 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1814 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %ld for header size\n", ifaceps
->size
);
1815 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1819 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1822 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1825 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1827 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1828 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %ld\n", ifaceps
->name_len
);
1829 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %ld\n", ifaceps
->name_offset
);
1831 /* data length is simply header length + string data length including nulls */
1832 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1833 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %ld, expected %ld\n", data
.ulLength
, len
);
1835 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1836 always has non-zero value for it */
1837 if (ifaceps
->mask
& NumMethods
)
1838 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %ld\n", ifaceps
->nummethods
);
1839 if (ifaceps
->mask
& BaseIface
)
1840 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1843 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1844 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%lu\n",
1845 data
.ulSectionGlobalDataLength
);
1846 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1847 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n",
1848 data
.ulSectionTotalLength
);
1849 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1850 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1851 data
.ulAssemblyRosterIndex
, exid
);
1853 validate_guid_index(&data
, line
);
1856 struct clrsurrogate_data
1861 ULONG version_offset
;
1867 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1868 ULONG exid
, int line
)
1870 struct clrsurrogate_data
*surrogate
;
1871 ACTCTX_SECTION_KEYED_DATA data
;
1874 memset(&data
, 0xfe, sizeof(data
));
1875 data
.cbSize
= sizeof(data
);
1877 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
, clsid
, &data
);
1880 skip("surrogate sections are not supported\n");
1883 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
1885 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1887 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1888 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1889 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1890 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %ld for header size\n", surrogate
->size
);
1891 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1896 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %ld\n", surrogate
->res
);
1897 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1899 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %ld\n", surrogate
->version_len
);
1900 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %ld\n", surrogate
->version_offset
);
1902 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %ld\n", surrogate
->name_len
);
1903 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %ld\n", surrogate
->name_offset
);
1905 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1906 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %ld, expected %ld\n", data
.ulLength
, len
);
1908 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1909 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1911 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1912 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1915 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1916 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%lu\n",
1917 data
.ulSectionGlobalDataLength
);
1918 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1919 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n",
1920 data
.ulSectionTotalLength
);
1921 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1922 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1923 data
.ulAssemblyRosterIndex
, exid
);
1925 validate_guid_index(&data
, line
);
1928 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1930 struct progidredirect_data
*progiddata
;
1931 struct comclassredirect_data
*comclass
;
1932 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1933 struct strsection_header
*header
;
1936 memset(&data
, 0xfe, sizeof(data
));
1937 data
.cbSize
= sizeof(data
);
1939 ret
= FindActCtxSectionStringA(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
, progid
, &data
);
1940 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %lu\n", GetLastError());
1942 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1944 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%lu\n", data
.cbSize
);
1945 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%lu\n", data
.ulDataFormatVersion
);
1946 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1947 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %ld for header size\n", progiddata
->size
);
1948 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1952 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %ld\n", progiddata
->reserved
);
1953 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %ld\n", progiddata
->clsid_offset
);
1955 /* progid data points to generated alias guid */
1956 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1958 memset(&data2
, 0, sizeof(data2
));
1959 data2
.cbSize
= sizeof(data2
);
1960 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
, guid
, &data2
);
1961 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
1963 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1964 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1965 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1967 validate_guid_index(&data2
, line
);
1970 header
= (struct strsection_header
*)data
.lpSectionBase
;
1971 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1972 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1973 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%lu\n", data
.ulSectionGlobalDataLength
);
1974 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%lu\n", data
.ulSectionTotalLength
);
1975 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1976 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
1977 data
.ulAssemblyRosterIndex
, exid
);
1980 static void test_wndclass_section(void)
1982 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1983 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1984 struct wndclass_redirect_data
*classdata
;
1985 struct strsection_header
*section
;
1991 /* use two dependent manifests, each defines 2 window class redirects */
1992 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1993 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1994 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1996 handle
= test_create("main_wndcls.manifest");
1997 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
1999 DeleteFileA("testdep1.manifest");
2000 DeleteFileA("testdep2.manifest");
2001 DeleteFileA("main_wndcls.manifest");
2003 ret
= ActivateActCtx(handle
, &cookie
);
2004 ok(ret
, "ActivateActCtx failed: %lu\n", GetLastError());
2006 memset(&data
, 0, sizeof(data
));
2007 memset(&data2
, 0, sizeof(data2
));
2008 data
.cbSize
= sizeof(data
);
2009 data2
.cbSize
= sizeof(data2
);
2011 /* get data for two classes from different assemblies */
2012 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, wndClass1W
, &data
);
2013 ok(ret
, "got %d\n", ret
);
2014 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, wndClass3W
, &data2
);
2015 ok(ret
, "got %d\n", ret
);
2017 section
= (struct strsection_header
*)data
.lpSectionBase
;
2018 ok(section
->count
== 4, "got %ld\n", section
->count
);
2019 ok(section
->size
== sizeof(*section
), "got %ld\n", section
->size
);
2021 /* For both string same section is returned, meaning it's one wndclass section per context */
2022 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
2023 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %lu, %lu\n", data
.ulSectionTotalLength
,
2024 data2
.ulSectionTotalLength
);
2026 /* wndClass1 is versioned, wndClass3 is not */
2027 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
2028 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
2029 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
2031 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
2032 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
2033 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
2035 ret
= DeactivateActCtx(0, cookie
);
2036 ok(ret
, "DeactivateActCtx failed: %lu\n", GetLastError());
2038 ReleaseActCtx(handle
);
2041 static void test_dllredirect_section(void)
2043 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
2044 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
2045 ACTCTX_SECTION_KEYED_DATA data
, data2
;
2046 struct strsection_header
*section
;
2051 /* use two dependent manifests, 4 'files' total */
2052 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
2053 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
2054 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
2056 handle
= test_create("main_wndcls.manifest");
2057 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2059 DeleteFileA("testdep1.manifest");
2060 DeleteFileA("testdep2.manifest");
2061 DeleteFileA("main_wndcls.manifest");
2063 ret
= ActivateActCtx(handle
, &cookie
);
2064 ok(ret
, "ActivateActCtx failed: %lu\n", GetLastError());
2066 memset(&data
, 0, sizeof(data
));
2067 memset(&data2
, 0, sizeof(data2
));
2068 data
.cbSize
= sizeof(data
);
2069 data2
.cbSize
= sizeof(data2
);
2071 /* get data for two files from different assemblies */
2072 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib1W
, &data
);
2073 ok(ret
, "got %d\n", ret
);
2074 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib2W
, &data2
);
2075 ok(ret
, "got %d\n", ret
);
2077 section
= (struct strsection_header
*)data
.lpSectionBase
;
2078 ok(section
->count
== 4, "got %ld\n", section
->count
);
2079 ok(section
->size
== sizeof(*section
), "got %ld\n", section
->size
);
2081 /* For both string same section is returned, meaning it's one dll redirect section per context */
2082 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
2083 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %lu, %lu\n", data
.ulSectionTotalLength
,
2084 data2
.ulSectionTotalLength
);
2086 ret
= DeactivateActCtx(0, cookie
);
2087 ok(ret
, "DeactivateActCtx failed: %lu\n", GetLastError());
2089 ReleaseActCtx(handle
);
2092 static void test_typelib_section(void)
2094 static const WCHAR helpW
[] = {'h','e','l','p'};
2095 ACTCTX_SECTION_KEYED_DATA data
, data2
;
2096 struct guidsection_header
*section
;
2097 struct tlibredirect_data
*tlib
;
2102 /* use two dependent manifests, 4 'files' total */
2103 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
2104 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
2105 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
2107 handle
= test_create("main_wndcls.manifest");
2108 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2110 DeleteFileA("testdep1.manifest");
2111 DeleteFileA("testdep2.manifest");
2112 DeleteFileA("main_wndcls.manifest");
2114 ret
= ActivateActCtx(handle
, &cookie
);
2115 ok(ret
, "ActivateActCtx failed: %lu\n", GetLastError());
2117 memset(&data
, 0, sizeof(data
));
2118 memset(&data2
, 0, sizeof(data2
));
2119 data
.cbSize
= sizeof(data
);
2120 data2
.cbSize
= sizeof(data2
);
2122 /* get data for two typelibs from different assemblies */
2123 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
, &IID_TlibTest
, &data
);
2124 ok(ret
, "got %d\n", ret
);
2126 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
2127 &IID_TlibTest4
, &data2
);
2128 ok(ret
, "got %d\n", ret
);
2130 section
= (struct guidsection_header
*)data
.lpSectionBase
;
2131 ok(section
->count
== 4, "got %ld\n", section
->count
);
2132 ok(section
->size
== sizeof(*section
), "got %ld\n", section
->size
);
2133 validate_guid_index(&data
, __LINE__
);
2135 /* For both GUIDs same section is returned */
2136 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
2137 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %lu, %lu\n", data
.ulSectionTotalLength
,
2138 data2
.ulSectionTotalLength
);
2140 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
2141 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%lu\n",
2142 data
.ulSectionGlobalDataLength
);
2144 /* test some actual data */
2145 tlib
= (struct tlibredirect_data
*)data
.lpData
;
2146 ok(tlib
->size
== sizeof(*tlib
), "got %ld\n", tlib
->size
);
2147 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
2148 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
2149 ok(tlib
->help_offset
> 0, "got %ld\n", tlib
->help_offset
);
2150 ok(tlib
->help_len
== sizeof(helpW
), "got %ld\n", tlib
->help_len
);
2151 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
2153 ret
= DeactivateActCtx(0, cookie
);
2154 ok(ret
, "DeactivateActCtx failed: %lu\n", GetLastError());
2156 ReleaseActCtx(handle
);
2159 static void test_allowDelayedBinding(void)
2163 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
2164 skip("Could not create manifest file\n");
2168 handle
= test_create("test5.manifest");
2169 if (handle
== INVALID_HANDLE_VALUE
) {
2170 win_skip("allowDelayedBinding attribute is not supported.\n");
2174 DeleteFileA("test5.manifest");
2175 DeleteFileA("testdep.manifest");
2176 if (handle
!= INVALID_HANDLE_VALUE
) {
2177 test_basic_info(handle
, __LINE__
);
2178 ReleaseActCtx(handle
);
2182 static void test_actctx(void)
2188 trace("default actctx\n");
2190 b
= GetCurrentActCtx(&handle
);
2191 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
2192 ok(b
, "GetCurrentActCtx failed: %lu\n", GetLastError());
2194 test_basic_info(handle
, __LINE__
);
2195 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
2196 test_runlevel_info(handle
, &runlevel_info0
, __LINE__
);
2197 ReleaseActCtx(handle
);
2200 /* test for whitespace handling in Eq ::= S? '=' S? */
2201 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
2202 handle
= test_create("test1_1.manifest");
2203 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2204 DeleteFileA("test1_1.manifest");
2205 ReleaseActCtx(handle
);
2207 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
2208 skip("Could not create manifest file\n");
2212 trace("manifest1\n");
2214 handle
= test_create("test1.manifest");
2215 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2216 DeleteFileA("test1.manifest");
2217 if(handle
!= INVALID_HANDLE_VALUE
) {
2218 test_basic_info(handle
, __LINE__
);
2219 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2220 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2222 if (!IsDebuggerPresent())
2224 /* CloseHandle will generate an exception if a debugger is present */
2225 b
= CloseHandle(handle
);
2226 ok(!b
, "CloseHandle succeeded\n");
2227 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %lu\n", GetLastError());
2230 ReleaseActCtx(handle
);
2233 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
2234 skip("Could not create manifest file\n");
2238 trace("manifest2 depmanifest1\n");
2240 handle
= test_create("test2.manifest");
2241 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2242 DeleteFileA("test2.manifest");
2243 DeleteFileA("testdep.manifest");
2244 if(handle
!= INVALID_HANDLE_VALUE
) {
2245 test_basic_info(handle
, __LINE__
);
2246 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2247 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2248 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
2249 ReleaseActCtx(handle
);
2252 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
2253 skip("Could not create manifest file\n");
2257 trace("manifest2 depmanifest2\n");
2259 handle
= test_create("test2-2.manifest");
2260 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2261 DeleteFileA("test2-2.manifest");
2262 DeleteFileA("testdep.manifest");
2263 if(handle
!= INVALID_HANDLE_VALUE
) {
2264 test_basic_info(handle
, __LINE__
);
2265 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2266 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2267 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
2268 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2269 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2271 b
= ActivateActCtx(handle
, &cookie
);
2272 ok(b
, "ActivateActCtx failed: %lu\n", GetLastError());
2273 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2274 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2275 b
= DeactivateActCtx(0, cookie
);
2276 ok(b
, "DeactivateActCtx failed: %lu\n", GetLastError());
2278 ReleaseActCtx(handle
);
2281 trace("manifest2 depmanifest3\n");
2283 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
2284 skip("Could not create manifest file\n");
2288 handle
= test_create("test2-3.manifest");
2289 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2290 DeleteFileA("test2-3.manifest");
2291 DeleteFileA("testdep.manifest");
2292 if(handle
!= INVALID_HANDLE_VALUE
) {
2293 test_basic_info(handle
, __LINE__
);
2294 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2295 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2296 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
2297 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2298 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2300 b
= ActivateActCtx(handle
, &cookie
);
2301 ok(b
, "ActivateActCtx failed: %lu\n", GetLastError());
2302 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2303 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2304 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
2305 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
2306 b
= DeactivateActCtx(0, cookie
);
2307 ok(b
, "DeactivateActCtx failed: %lu\n", GetLastError());
2309 ReleaseActCtx(handle
);
2312 trace("manifest3\n");
2314 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
2315 skip("Could not create manifest file\n");
2319 handle
= test_create("test3.manifest");
2320 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
2321 "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2322 if (handle
== INVALID_HANDLE_VALUE
)
2323 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
2324 DeleteFileA("test3.manifest");
2325 if(handle
!= INVALID_HANDLE_VALUE
) {
2326 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
2327 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
2328 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
2329 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
2331 test_basic_info(handle
, __LINE__
);
2332 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2333 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
2334 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
2336 b
= ActivateActCtx(handle
, &cookie
);
2337 ok(b
, "ActivateActCtx failed: %lu\n", GetLastError());
2338 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2339 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2340 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
2341 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
2342 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
2343 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
2344 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
2345 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
2346 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
2347 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
2348 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
2349 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
2350 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
2351 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
2352 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
2353 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
2354 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
2355 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
2356 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
2357 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
2358 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
2359 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
2360 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
2361 test_find_string_fail();
2362 test_find_activatable_class(handle
, L
"Wine.Test.Class1", WINRT_THREADING_MODEL_MTA
, L
"testlib.dll", 1, __LINE__
);
2363 test_find_activatable_class(handle
, L
"Wine.Test.Class2", WINRT_THREADING_MODEL_BOTH
, L
"testlib.dll", 1, __LINE__
);
2364 test_find_activatable_class(handle
, L
"Wine.Test.Class3", WINRT_THREADING_MODEL_STA
, L
"testlib.dll", 1, __LINE__
);
2365 test_find_activatable_class(handle
, L
"Wine.Test.Class4", WINRT_THREADING_MODEL_STA
, L
"Wine.Test.dll", 1, __LINE__
);
2367 b
= DeactivateActCtx(0, cookie
);
2368 ok(b
, "DeactivateActCtx failed: %lu\n", GetLastError());
2369 ReleaseActCtx(handle
);
2372 trace("manifest6\n");
2374 if(create_manifest_file("test6.manifest", manifest6
, -1, NULL
, NULL
)) {
2375 handle
= test_create("test6.manifest");
2376 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* WinXP */,
2377 "Unexpected context handle %p.\n", handle
);
2378 DeleteFileA("test6.manifest");
2379 DeleteFileA("testdep.manifest");
2380 if(handle
!= INVALID_HANDLE_VALUE
)
2382 test_runlevel_info(handle
, &runlevel_info6
, __LINE__
);
2383 ReleaseActCtx(handle
);
2387 skip("Could not create manifest file 6\n");
2389 trace("manifest7\n");
2391 if(create_manifest_file("test7.manifest", manifest7
, -1, NULL
, NULL
)) {
2392 handle
= test_create("test7.manifest");
2393 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2394 DeleteFileA("test7.manifest");
2395 DeleteFileA("testdep.manifest");
2396 if(handle
!= INVALID_HANDLE_VALUE
)
2398 test_runlevel_info(handle
, &runlevel_info7
, __LINE__
);
2399 ReleaseActCtx(handle
);
2403 skip("Could not create manifest file 7\n");
2405 trace("manifest8\n");
2407 if(create_manifest_file("test8.manifest", manifest8
, -1, NULL
, NULL
)) {
2408 handle
= test_create("test8.manifest");
2409 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2410 DeleteFileA("test8.manifest");
2411 DeleteFileA("testdep.manifest");
2412 if(handle
!= INVALID_HANDLE_VALUE
)
2414 test_runlevel_info(handle
, &runlevel_info8
, __LINE__
);
2415 ReleaseActCtx(handle
);
2419 skip("Could not create manifest file 8\n");
2421 trace("manifest9\n");
2423 if(create_manifest_file("test9.manifest", manifest9
, -1, NULL
, NULL
)) {
2424 handle
= test_create("test9.manifest");
2425 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2426 DeleteFileA("test9.manifest");
2427 DeleteFileA("testdep.manifest");
2428 if(handle
!= INVALID_HANDLE_VALUE
)
2430 test_runlevel_info(handle
, &runlevel_info9
, __LINE__
);
2431 ReleaseActCtx(handle
);
2435 skip("Could not create manifest file 9\n");
2437 if(create_manifest_file("test10.manifest", manifest10
, -1, NULL
, NULL
)) {
2438 handle
= test_create("test10.manifest");
2439 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2440 DeleteFileA("test10.manifest");
2441 DeleteFileA("testdep.manifest");
2442 if(handle
!= INVALID_HANDLE_VALUE
)
2444 test_runlevel_info(handle
, &runlevel_info8
, __LINE__
);
2445 ReleaseActCtx(handle
);
2449 skip("Could not create manifest file 10\n");
2451 if (create_manifest_file("test11.manifest", manifest11
, -1, NULL
, NULL
))
2453 handle
= test_create("test11.manifest");
2454 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to create activation context for %s, error %lu\n",
2455 "manifest11", GetLastError());
2456 DeleteFileA("test11.manifest");
2457 if (handle
!= INVALID_HANDLE_VALUE
)
2458 ReleaseActCtx(handle
);
2461 skip("Could not create manifest file 11\n");
2463 trace("manifest4\n");
2465 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
2466 skip("Could not create manifest file\n");
2470 handle
= test_create("test4.manifest");
2471 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2472 DeleteFileA("test4.manifest");
2473 DeleteFileA("testdep.manifest");
2474 if(handle
!= INVALID_HANDLE_VALUE
) {
2475 test_basic_info(handle
, __LINE__
);
2476 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2477 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
2478 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
2479 ReleaseActCtx(handle
);
2482 trace("manifest1 in subdir\n");
2484 CreateDirectoryW(work_dir_subdir
, NULL
);
2485 if (SetCurrentDirectoryW(work_dir_subdir
))
2487 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
2488 skip("Could not create manifest file\n");
2491 handle
= test_create("..\\test1.manifest");
2492 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2493 DeleteFileA("..\\test1.manifest");
2494 if(handle
!= INVALID_HANDLE_VALUE
) {
2495 test_basic_info(handle
, __LINE__
);
2496 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2497 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2498 ReleaseActCtx(handle
);
2500 SetCurrentDirectoryW(work_dir
);
2503 skip("Couldn't change directory\n");
2504 RemoveDirectoryW(work_dir_subdir
);
2506 trace("UTF-16 manifest1, with BOM\n");
2507 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
2508 skip("Could not create manifest file\n");
2512 handle
= test_create("test1.manifest");
2513 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2514 DeleteFileA("test1.manifest");
2515 if (handle
!= INVALID_HANDLE_VALUE
) {
2516 test_basic_info(handle
, __LINE__
);
2517 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2518 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2519 ReleaseActCtx(handle
);
2522 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2523 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
2524 skip("Could not create manifest file\n");
2528 handle
= test_create("test1.manifest");
2529 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2530 DeleteFileA("test1.manifest");
2531 if (handle
!= INVALID_HANDLE_VALUE
) {
2532 test_basic_info(handle
, __LINE__
);
2533 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2534 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2535 ReleaseActCtx(handle
);
2538 /* Empty <assembly/> element. */
2539 create_manifest_file("empty_assembly.manifest", empty_assembly_manifest
, -1, NULL
, NULL
);
2540 handle
= test_create("empty_assembly.manifest");
2541 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to create activation context.\n");
2542 DeleteFileA("empty_assembly.manifest");
2543 if (handle
!= INVALID_HANDLE_VALUE
)
2545 test_basic_info(handle
, __LINE__
);
2546 ReleaseActCtx(handle
);
2549 test_wndclass_section();
2550 test_dllredirect_section();
2551 test_typelib_section();
2552 test_allowDelayedBinding();
2555 static void test_app_manifest(void)
2560 trace("child process manifest1\n");
2562 b
= GetCurrentActCtx(&handle
);
2563 ok(handle
== NULL
, "handle != NULL\n");
2564 ok(b
, "GetCurrentActCtx failed: %lu\n", GetLastError());
2566 test_basic_info(handle
, __LINE__
);
2567 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2568 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2569 ReleaseActCtx(handle
);
2573 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2576 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2578 handle
= test_create(filename
);
2579 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2580 "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
2582 DeleteFileA(filename
);
2586 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2588 UNICODE_STRING string_to_findW
;
2589 ACTCTX_SECTION_KEYED_DATA data
;
2593 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2595 memset(&data
, 0xfe, sizeof(data
));
2596 data
.cbSize
= sizeof(data
);
2599 ret
= FindActCtxSectionStringA(0, NULL
, section
, string_to_find
, &data
);
2600 err
= GetLastError();
2601 ok_(__FILE__
, line
)(ret
== should_find
,
2602 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find
, ret
);
2604 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2605 "FindActCtxSectionStringA: unexpected error %lu\n", err
);
2607 memset(&data
, 0xfe, sizeof(data
));
2608 data
.cbSize
= sizeof(data
);
2611 ret
= FindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2612 err
= GetLastError();
2613 ok_(__FILE__
, line
)(ret
== should_find
,
2614 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2616 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2617 "FindActCtxSectionStringW: unexpected error %lu\n", err
);
2620 ret
= FindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2621 err
= GetLastError();
2622 ok_(__FILE__
, line
)(!ret
,
2623 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2624 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2625 "FindActCtxSectionStringA: unexpected error %lu\n", err
);
2628 ret
= FindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2629 err
= GetLastError();
2630 ok_(__FILE__
, line
)(!ret
,
2631 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2632 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2633 "FindActCtxSectionStringW: unexpected error %lu\n", err
);
2635 pRtlFreeUnicodeString(&string_to_findW
);
2638 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2640 UNICODE_STRING string_to_findW
;
2641 ACTCTX_SECTION_KEYED_DATA data
;
2644 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2646 memset(&data
, 0xfe, sizeof(data
));
2647 data
.cbSize
= sizeof(data
);
2649 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2651 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2652 "RtlFindActivationContextSectionString: unexpected status 0x%lx\n", ret
);
2654 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2656 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2657 "RtlFindActivationContextSectionString: unexpected status 0x%lx\n", ret
);
2659 pRtlFreeUnicodeString(&string_to_findW
);
2662 static void test_findsectionstring(void)
2668 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2669 ret
= ActivateActCtx(handle
, &cookie
);
2670 ok(ret
, "ActivateActCtx failed: %lu\n", GetLastError());
2672 /* first we show the parameter validation from kernel32 */
2673 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2674 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2675 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2676 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2677 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2678 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2679 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2681 /* then we show that ntdll plays by different rules */
2682 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2683 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2684 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2685 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2686 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2687 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2688 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2690 ret
= DeactivateActCtx(0, cookie
);
2691 ok(ret
, "DeactivateActCtx failed: %lu\n", GetLastError());
2692 ReleaseActCtx(handle
);
2695 static void run_child_process(void)
2697 char cmdline
[MAX_PATH
];
2698 char path
[MAX_PATH
];
2700 PROCESS_INFORMATION pi
;
2701 STARTUPINFOA si
= { 0 };
2706 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2707 strcat(path
, ".manifest");
2708 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2709 skip("Could not create manifest file\n");
2714 winetest_get_mainargs( &argv
);
2715 /* Vista+ seems to cache presence of .manifest files. Change last modified
2716 date to defeat the cache */
2717 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2718 NULL
, OPEN_EXISTING
, 0, NULL
);
2719 if (file
!= INVALID_HANDLE_VALUE
) {
2720 GetSystemTimeAsFileTime(&now
);
2721 SetFileTime(file
, NULL
, NULL
, &now
);
2724 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2725 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2726 ok(ret
, "Could not create process: %lu\n", GetLastError());
2727 wait_child_process( pi
.hProcess
);
2728 CloseHandle(pi
.hThread
);
2729 CloseHandle(pi
.hProcess
);
2733 static void init_paths(void)
2737 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2738 static const WCHAR backslash
[] = {'\\',0};
2739 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2741 GetModuleFileNameW(NULL
, exe_path
, ARRAY_SIZE(exe_path
));
2742 lstrcpyW(app_dir
, exe_path
);
2743 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2746 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2747 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2748 if (*ptr
!= '\\' && *ptr
!= '/')
2749 lstrcatW(work_dir
, backslash
);
2750 lstrcpyW(work_dir_subdir
, work_dir
);
2751 lstrcatW(work_dir_subdir
, subdir
);
2753 GetModuleFileNameW(NULL
, app_manifest_path
, ARRAY_SIZE(app_manifest_path
));
2754 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2757 static void write_manifest(const char *filename
, const char *manifest
)
2761 CHAR path
[MAX_PATH
];
2763 GetTempPathA(ARRAY_SIZE(path
), path
);
2764 strcat(path
, filename
);
2766 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2767 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %lu\n", GetLastError());
2768 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2772 static void delete_manifest_file(const char *filename
)
2774 CHAR path
[MAX_PATH
];
2776 GetTempPathA(ARRAY_SIZE(path
), path
);
2777 strcat(path
, filename
);
2781 static void extract_resource(const char *name
, const char *type
, const char *path
)
2788 file
= CreateFileA(path
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
2789 ok(file
!= INVALID_HANDLE_VALUE
, "file creation failed, at %s, error %ld\n", path
, GetLastError());
2791 res
= FindResourceA(NULL
, name
, type
);
2792 ok( res
!= 0, "couldn't find resource\n" );
2793 ptr
= LockResource( LoadResource( GetModuleHandleA(NULL
), res
));
2794 WriteFile( file
, ptr
, SizeofResource( GetModuleHandleA(NULL
), res
), &written
, NULL
);
2795 ok( written
== SizeofResource( GetModuleHandleA(NULL
), res
), "couldn't write resource\n" );
2796 CloseHandle( file
);
2799 static void test_CreateActCtx(void)
2801 static const DWORD flags
[] = {LOAD_LIBRARY_AS_DATAFILE
, LOAD_LIBRARY_AS_IMAGE_RESOURCE
,
2802 LOAD_LIBRARY_AS_IMAGE_RESOURCE
| LOAD_LIBRARY_AS_DATAFILE
};
2805 DWORD size
, flags
, error
;
2808 { FIELD_OFFSET(ACTCTXW
, lpSource
), 0, ERROR_INVALID_PARAMETER
},
2809 { FIELD_OFFSET(ACTCTXW
, wProcessorArchitecture
), 0, 0 },
2810 { FIELD_OFFSET(ACTCTXW
, lpAssemblyDirectory
), ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
, ERROR_INVALID_PARAMETER
},
2811 { FIELD_OFFSET(ACTCTXW
, lpResourceName
), ACTCTX_FLAG_RESOURCE_NAME_VALID
, ERROR_INVALID_PARAMETER
},
2812 { FIELD_OFFSET(ACTCTXW
, hModule
), ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
, ERROR_INVALID_PARAMETER
},
2814 char path
[MAX_PATH
], dir
[MAX_PATH
], dll
[MAX_PATH
], source
[MAX_PATH
];
2815 WCHAR pathW
[MAX_PATH
], dirW
[MAX_PATH
], sourceW
[MAX_PATH
];
2821 GetTempPathA(ARRAY_SIZE(path
), path
);
2823 strcat(path
, "main_wndcls.manifest");
2825 write_manifest("testdep1.manifest", manifest_wndcls1
);
2826 write_manifest("testdep2.manifest", manifest_wndcls2
);
2827 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2829 GetModuleFileNameA(NULL
, source
, ARRAY_SIZE(source
));
2830 GetModuleFileNameW(NULL
, sourceW
, ARRAY_SIZE(sourceW
));
2832 GetTempPathW(ARRAY_SIZE(pathW
), pathW
);
2833 wcscpy(dirW
, pathW
);
2834 wcscat(pathW
, L
"main_wndcls.manifest");
2836 memset(&ctxW
, 0, sizeof(ctxW
));
2837 ctxW
.cbSize
= sizeof(ctxW
);
2838 ctxW
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
| ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2839 ctxW
.lpSource
= pathW
;
2840 ctxW
.lpAssemblyDirectory
= dirW
;
2841 ctxW
.lpResourceName
= (LPWSTR
)124;
2842 ctxW
.hModule
= GetModuleHandleW(NULL
);
2843 handle
= CreateActCtxW(&ctxW
);
2844 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
2845 ReleaseActCtx(handle
);
2847 for (i
= 0; i
< ARRAY_SIZE(test
); i
++)
2849 winetest_push_context("%i", i
);
2850 ctxW
.cbSize
= test
[i
].size
;
2851 ctxW
.dwFlags
= test
[i
].flags
;
2852 SetLastError(0xdeadbeef);
2853 handle
= CreateActCtxW(&ctxW
);
2856 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
2857 ReleaseActCtx(handle
);
2861 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtx should fail\n");
2862 ok(test
[i
].error
== GetLastError(), "expected %lu, got %lu\n", test
[i
].error
, GetLastError());
2865 ctxW
.cbSize
+= sizeof(void *);
2866 if ((ctxW
.dwFlags
& (ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
)) == ACTCTX_FLAG_RESOURCE_NAME_VALID
)
2867 ctxW
.lpSource
= sourceW
; /* source without hModule must point to valid PE */
2868 SetLastError(0xdeadbeef);
2869 handle
= CreateActCtxW(&ctxW
);
2870 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
2871 ReleaseActCtx(handle
);
2873 winetest_pop_context();
2876 memset(&actctx
, 0, sizeof(actctx
));
2877 actctx
.cbSize
= sizeof(actctx
);
2878 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
| ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2879 actctx
.lpSource
= path
;
2880 actctx
.lpAssemblyDirectory
= dir
;
2881 actctx
.lpResourceName
= (LPSTR
)124;
2882 actctx
.hModule
= GetModuleHandleW(NULL
);
2883 handle
= CreateActCtxA(&actctx
);
2884 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
2885 ReleaseActCtx(handle
);
2887 for (i
= 0; i
< ARRAY_SIZE(test
); i
++)
2889 winetest_push_context("%i", i
);
2890 actctx
.cbSize
= test
[i
].size
;
2891 actctx
.dwFlags
= test
[i
].flags
;
2892 SetLastError(0xdeadbeef);
2893 handle
= CreateActCtxA(&actctx
);
2896 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
2897 ReleaseActCtx(handle
);
2901 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtx should fail\n");
2902 ok(test
[i
].error
== GetLastError(), "expected %lu, got %lu\n", test
[i
].error
, GetLastError());
2905 actctx
.cbSize
+= sizeof(void *);
2906 if ((actctx
.dwFlags
& (ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
)) == ACTCTX_FLAG_RESOURCE_NAME_VALID
)
2907 actctx
.lpSource
= source
; /* source without hModule must point to valid PE */
2908 SetLastError(0xdeadbeef);
2909 handle
= CreateActCtxA(&actctx
);
2910 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
2911 ReleaseActCtx(handle
);
2913 winetest_pop_context();
2916 memset(&actctx
, 0, sizeof(ACTCTXA
));
2917 actctx
.cbSize
= sizeof(ACTCTXA
);
2918 actctx
.lpSource
= path
;
2920 /* create using lpSource without specified directory */
2921 handle
= CreateActCtxA(&actctx
);
2922 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %lu\n", GetLastError());
2923 ReleaseActCtx(handle
);
2925 /* with specified directory, that doesn't contain dependent assembly */
2926 GetWindowsDirectoryA(dir
, ARRAY_SIZE(dir
));
2928 memset(&actctx
, 0, sizeof(ACTCTXA
));
2929 actctx
.cbSize
= sizeof(ACTCTXA
);
2930 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2931 actctx
.lpAssemblyDirectory
= dir
;
2932 actctx
.lpSource
= path
;
2934 SetLastError(0xdeadbeef);
2935 handle
= CreateActCtxA(&actctx
);
2937 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2938 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %ld\n", GetLastError());
2940 if (handle
!= INVALID_HANDLE_VALUE
) ReleaseActCtx(handle
);
2942 /* with specified directory, that does contain dependent assembly */
2943 GetTempPathA(ARRAY_SIZE(dir
), dir
);
2944 actctx
.lpAssemblyDirectory
= dir
;
2945 handle
= CreateActCtxA(&actctx
);
2946 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2947 ReleaseActCtx(handle
);
2949 /* Should still work if we add a dll with the same name, but without manifest */
2951 strcat(dll
, "testdep1.dll");
2952 extract_resource("dummy.dll", "TESTDLL", dll
);
2953 handle
= CreateActCtxA(&actctx
);
2954 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
) , "got error %ld\n", GetLastError());
2955 ReleaseActCtx(handle
);
2958 delete_manifest_file("main_wndcls.manifest");
2959 delete_manifest_file("testdep1.manifest");
2960 delete_manifest_file("testdep2.manifest");
2962 /* create from HMODULE - resource doesn't exist, lpSource is set */
2963 memset(&actctx
, 0, sizeof(ACTCTXA
));
2964 actctx
.cbSize
= sizeof(ACTCTXA
);
2965 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2966 actctx
.lpSource
= "dummyfile.dll";
2967 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2968 actctx
.hModule
= GetModuleHandleA(NULL
);
2970 SetLastError(0xdeadbeef);
2971 handle
= CreateActCtxA(&actctx
);
2972 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2973 ok(GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND
, "got error %ld\n", GetLastError());
2975 /* load manifest from lpAssemblyDirectory directory */
2976 write_manifest("testdir.manifest", manifest1
);
2977 GetTempPathA(ARRAY_SIZE(path
), path
);
2978 SetCurrentDirectoryA(path
);
2979 strcat(path
, "assembly_dir");
2981 strcat(path
, "\\testdir.manifest");
2983 memset(&actctx
, 0, sizeof(actctx
));
2984 actctx
.cbSize
= sizeof(actctx
);
2985 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2986 actctx
.lpSource
= "testdir.manifest";
2987 actctx
.lpAssemblyDirectory
= dir
;
2989 SetLastError(0xdeadbeef);
2990 handle
= CreateActCtxA(&actctx
);
2991 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2992 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2993 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2994 "got error %ld\n", GetLastError());
2996 CreateDirectoryA(dir
, NULL
);
2997 memset(&actctx
, 0, sizeof(actctx
));
2998 actctx
.cbSize
= sizeof(actctx
);
2999 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3000 actctx
.lpSource
= "testdir.manifest";
3001 actctx
.lpAssemblyDirectory
= dir
;
3003 SetLastError(0xdeadbeef);
3004 handle
= CreateActCtxA(&actctx
);
3005 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
3006 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %ld\n", GetLastError());
3007 SetCurrentDirectoryW(work_dir
);
3009 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
3010 memset(&actctx
, 0, sizeof(actctx
));
3011 actctx
.cbSize
= sizeof(actctx
);
3012 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3013 actctx
.lpSource
= "testdir.manifest";
3014 actctx
.lpAssemblyDirectory
= dir
;
3016 handle
= CreateActCtxA(&actctx
);
3017 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
3018 ReleaseActCtx(handle
);
3020 memset(&actctx
, 0, sizeof(actctx
));
3021 actctx
.cbSize
= sizeof(actctx
);
3022 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3023 actctx
.lpSource
= path
;
3024 actctx
.lpAssemblyDirectory
= dir
;
3026 handle
= CreateActCtxA(&actctx
);
3027 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
3028 ReleaseActCtx(handle
);
3030 delete_manifest_file("testdir.manifest");
3031 delete_manifest_file("assembly_dir\\testdir.manifest");
3032 RemoveDirectoryA(dir
);
3034 /* create using lpSource with a DLL relative name */
3035 memset(&actctx
, 0, sizeof(actctx
));
3036 actctx
.cbSize
= sizeof(actctx
);
3037 actctx
.lpSource
= "shell32.dll";
3038 actctx
.lpResourceName
= MAKEINTRESOURCEA(124);
3039 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
;
3040 handle
= CreateActCtxA(&actctx
);
3041 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtxA succeeded\n");
3043 /* create from module loaded as data file */
3044 memset(&actctx
, 0, sizeof(actctx
));
3045 actctx
.cbSize
= sizeof(actctx
);
3046 actctx
.lpResourceName
= MAKEINTRESOURCEA(1);
3047 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
| ACTCTX_FLAG_RESOURCE_NAME_VALID
;
3048 for (i
= 0; i
< ARRAY_SIZE(flags
); ++i
)
3050 winetest_push_context("%lu", flags
[i
]);
3052 /* use explorer.exe because using modules already loaded has a different behavior */
3053 actctx
.hModule
= LoadLibraryExA("C:\\windows\\explorer.exe", NULL
, flags
[i
]);
3054 ok(actctx
.hModule
!= NULL
, "LoadLibraryExA failed, error %lu\n", GetLastError());
3055 handle
= CreateActCtxA(&actctx
);
3056 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtxA succeeded\n");
3057 FreeLibrary(actctx
.hModule
);
3059 winetest_pop_context();
3063 static void test_CreateActCtx_share_mode(void)
3065 WCHAR tmp_manifest_pathname
[MAX_PATH
];
3066 HANDLE handle
, manifest_file
;
3069 manifest_file
= create_temp_manifest_file(manifest1
, tmp_manifest_pathname
);
3071 memset(&actctx
, 0, sizeof(ACTCTXW
));
3072 actctx
.cbSize
= sizeof(ACTCTXW
);
3073 actctx
.lpSource
= tmp_manifest_pathname
;
3075 handle
= CreateActCtxW(&actctx
);
3076 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtxW returned error %lu\n", GetLastError());
3077 ok(handle
!= NULL
, "CreateActCtxW returned %p\n", handle
);
3079 ReleaseActCtx(handle
);
3081 CloseHandle(manifest_file
);
3084 static BOOL
init_funcs(void)
3086 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
3088 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
3089 pQueryActCtxSettingsW
= (void *)GetProcAddress( hLibrary
, "QueryActCtxSettingsW" );
3091 hLibrary
= GetModuleHandleA("ntdll.dll");
3092 X(RtlFindActivationContextSectionString
);
3093 X(RtlCreateUnicodeStringFromAsciiz
);
3094 X(RtlFreeUnicodeString
);
3100 static void test_ZombifyActCtx(void)
3102 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
3104 HANDLE handle
, current
;
3107 SetLastError(0xdeadbeef);
3108 ret
= ZombifyActCtx(NULL
);
3110 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "got %d, error %ld\n", ret
, GetLastError());
3112 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
3114 ret
= GetCurrentActCtx(¤t
);
3115 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3116 ok(current
== NULL
, "got %p\n", current
);
3118 ret
= ActivateActCtx(handle
, &cookie
);
3119 ok(ret
, "ActivateActCtx failed: %lu\n", GetLastError());
3121 ret
= GetCurrentActCtx(¤t
);
3122 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3123 ok(handle
== current
, "got %p, %p\n", current
, handle
);
3125 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
3126 ret
= QueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
, &basicinfo
, sizeof(basicinfo
), NULL
);
3127 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3128 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
3129 ok(basicinfo
.dwFlags
== 0, "got %lx\n", basicinfo
.dwFlags
);
3131 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
3132 ret
= QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
3133 &basicinfo
, sizeof(basicinfo
), NULL
);
3134 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3135 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
3136 ok(basicinfo
.dwFlags
== 0, "got %lx\n", basicinfo
.dwFlags
);
3138 ret
= ZombifyActCtx(handle
);
3140 ok(ret
, "got %d\n", ret
);
3142 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
3143 ret
= QueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
, &basicinfo
, sizeof(basicinfo
), NULL
);
3144 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3145 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
3146 ok(basicinfo
.dwFlags
== 0, "got %lx\n", basicinfo
.dwFlags
);
3148 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
3149 ret
= QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
3150 &basicinfo
, sizeof(basicinfo
), NULL
);
3151 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3152 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
3153 ok(basicinfo
.dwFlags
== 0, "got %lx\n", basicinfo
.dwFlags
);
3155 ret
= GetCurrentActCtx(¤t
);
3156 ok(ret
, "got %d, error %ld\n", ret
, GetLastError());
3157 ok(current
== handle
, "got %p\n", current
);
3160 ret
= ZombifyActCtx(handle
);
3162 ok(ret
, "got %d\n", ret
);
3164 ret
= DeactivateActCtx(0, cookie
);
3165 ok(ret
, "DeactivateActCtx failed: %lu\n", GetLastError());
3166 ReleaseActCtx(handle
);
3169 /* Test structure to verify alignment */
3170 typedef struct _test_act_ctx_compat_info
{
3172 COMPATIBILITY_CONTEXT_ELEMENT Elements
[10];
3173 } test_act_ctx_compat_info
;
3175 /* Win10 versions before 1909 don't have the MaxVersionTested field */
3179 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type
;
3180 } old_win10_COMPATIBILITY_CONTEXT_ELEMENT
;
3185 old_win10_COMPATIBILITY_CONTEXT_ELEMENT Elements
[10];
3186 } old_win10_test_act_ctx_compat_info
;
3189 static void test_no_compat(HANDLE handle
, int line
)
3191 test_act_ctx_compat_info compat_info
;
3195 memset(&compat_info
, 0, sizeof(compat_info
));
3196 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, CompatibilityInformationInActivationContext
,
3197 &compat_info
, sizeof(compat_info
), &size
);
3199 ok_(__FILE__
, line
)(b
, "CompatibilityInformationInActivationContext failed\n");
3200 ok_(__FILE__
, line
)(size
== offsetof(test_act_ctx_compat_info
,Elements
[0]) ||
3201 broken(size
== offsetof(old_win10_test_act_ctx_compat_info
,Elements
[0])),
3202 "size mismatch got %Iu\n", size
);
3203 ok_(__FILE__
, line
)(compat_info
.ElementCount
== 0, "unexpected ElementCount %lu\n", compat_info
.ElementCount
);
3206 static void test_with_compat(HANDLE handle
, DWORD num_compat
, DWORD num_version
,
3207 const GUID
*expected_compat
[], const ULONGLONG expected_version
[], int line
)
3209 test_act_ctx_compat_info compat_info
;
3214 memset(&compat_info
, 0, sizeof(compat_info
));
3215 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, CompatibilityInformationInActivationContext
,
3216 &compat_info
, sizeof(compat_info
), &size
);
3218 ok_(__FILE__
, line
)(b
, "CompatibilityInformationInActivationContext failed\n");
3219 ok_(__FILE__
, line
)(size
== offsetof(test_act_ctx_compat_info
,Elements
[num_compat
+ num_version
]) ||
3220 broken(size
== offsetof(old_win10_test_act_ctx_compat_info
,Elements
[num_compat
])),
3221 "size mismatch got %Iu\n", size
);
3222 ok_(__FILE__
, line
)(compat_info
.ElementCount
== num_compat
+ num_version
||
3223 broken(compat_info
.ElementCount
== num_compat
),
3224 "unexpected ElementCount %lu\n", compat_info
.ElementCount
);
3226 if (size
== offsetof(old_win10_test_act_ctx_compat_info
,Elements
[num_compat
]))
3228 for (n
= 0; n
< num_compat
; ++n
)
3230 old_win10_test_act_ctx_compat_info
*info
= (old_win10_test_act_ctx_compat_info
*)&compat_info
;
3231 ok_(__FILE__
, line
)(IsEqualGUID(&info
->Elements
[n
].Id
, expected_compat
[n
]),
3232 "got wrong clsid %s, expected %s for %lu\n",
3233 wine_dbgstr_guid(&info
->Elements
[n
].Id
),
3234 wine_dbgstr_guid(expected_compat
[n
]),
3236 ok_(__FILE__
, line
)(info
->Elements
[n
].Type
== ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
3237 "Wrong type, got %lu for %lu\n", (DWORD
)info
->Elements
[n
].Type
, n
);
3242 for (n
= 0; n
< num_compat
; ++n
)
3244 ok_(__FILE__
, line
)(IsEqualGUID(&compat_info
.Elements
[n
].Id
, expected_compat
[n
]),
3245 "got wrong clsid %s, expected %s for %lu\n",
3246 wine_dbgstr_guid(&compat_info
.Elements
[n
].Id
),
3247 wine_dbgstr_guid(expected_compat
[n
]),
3249 ok_(__FILE__
, line
)(compat_info
.Elements
[n
].Type
== ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
3250 "Wrong type, got %lu for %lu\n", (DWORD
)compat_info
.Elements
[n
].Type
, n
);
3252 for (; n
< num_compat
+ num_version
; ++n
)
3254 ok_(__FILE__
, line
)(compat_info
.Elements
[n
].Type
== ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
,
3255 "Wrong type, got %lu for %lu\n", (DWORD
)compat_info
.Elements
[n
].Type
, n
);
3256 ok_(__FILE__
, line
)(compat_info
.Elements
[n
].MaxVersionTested
== expected_version
[n
- num_compat
],
3257 "Wrong version, got %s for %lu\n", wine_dbgstr_longlong(compat_info
.Elements
[n
].MaxVersionTested
), n
);
3262 static void test_compatibility(void)
3266 /* No compat results returned */
3267 trace("manifest1\n");
3268 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
))
3270 skip("Could not create manifest file\n");
3273 handle
= test_create("test1.manifest");
3274 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
3275 DeleteFileA("test1.manifest");
3276 if(handle
!= INVALID_HANDLE_VALUE
)
3278 char buffer
[sizeof(COMPATIBILITY_CONTEXT_ELEMENT
) * 2 + sizeof(DWORD
)];
3282 memset(buffer
, 0, sizeof(buffer
));
3283 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, CompatibilityInformationInActivationContext
,
3284 buffer
, sizeof(buffer
), &size
);
3286 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
3288 win_skip("CompatibilityInformationInActivationContext not supported.\n");
3289 ReleaseActCtx(handle
);
3293 test_basic_info(handle
, __LINE__
);
3294 test_no_compat(handle
, __LINE__
);
3295 ReleaseActCtx(handle
);
3298 /* Still no compat results returned */
3299 trace("no_supportedOs\n");
3300 if(!create_manifest_file("no_supportedOs.manifest", compat_manifest_no_supportedOs
, -1, NULL
, NULL
))
3302 skip("Could not create manifest file\n");
3305 handle
= test_create("no_supportedOs.manifest");
3306 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
3307 DeleteFileA("no_supportedOs.manifest");
3308 if(handle
!= INVALID_HANDLE_VALUE
)
3310 test_basic_info(handle
, __LINE__
);
3311 test_no_compat(handle
, __LINE__
);
3312 ReleaseActCtx(handle
);
3315 /* Just one result returned */
3316 trace("manifest_vista\n");
3317 if(!create_manifest_file("manifest_vista.manifest", compat_manifest_vista
, -1, NULL
, NULL
))
3319 skip("Could not create manifest file\n");
3322 handle
= test_create("manifest_vista.manifest");
3323 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
3324 DeleteFileA("manifest_vista.manifest");
3325 if(handle
!= INVALID_HANDLE_VALUE
)
3327 static const GUID
* expect_manifest
[] =
3331 test_basic_info(handle
, __LINE__
);
3332 test_with_compat(handle
, 1, 0, expect_manifest
, NULL
, __LINE__
);
3333 ReleaseActCtx(handle
);
3336 /* Show that the order is retained */
3337 trace("manifest_vista_7_8_10_81\n");
3338 if(!create_manifest_file("manifest_vista_7_8_10_81.manifest", compat_manifest_vista_7_8_10_81
, -1, NULL
, NULL
))
3340 skip("Could not create manifest file\n");
3343 handle
= test_create("manifest_vista_7_8_10_81.manifest");
3344 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
3345 DeleteFileA("manifest_vista_7_8_10_81.manifest");
3346 if(handle
!= INVALID_HANDLE_VALUE
)
3348 static const GUID
* expect_manifest
[] =
3356 static const ULONGLONG expect_version
[] =
3358 0x000a000047b60000ull
, /* 10.0.18358.0 */
3359 0x0002000300040005ull
, /* 2.3.4.5 */
3361 test_basic_info(handle
, __LINE__
);
3362 test_with_compat(handle
, 5, 2, expect_manifest
, expect_version
, __LINE__
);
3363 ReleaseActCtx(handle
);
3366 /* Show that even unknown GUID's are stored */
3367 trace("manifest_other_guid\n");
3368 if(!create_manifest_file("manifest_other_guid.manifest", compat_manifest_other_guid
, -1, NULL
, NULL
))
3370 skip("Could not create manifest file\n");
3373 handle
= test_create("manifest_other_guid.manifest");
3374 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
3375 DeleteFileA("manifest_other_guid.manifest");
3376 if(handle
!= INVALID_HANDLE_VALUE
)
3378 static const GUID
* expect_manifest
[] =
3382 test_basic_info(handle
, __LINE__
);
3383 test_with_compat(handle
, 1, 0, expect_manifest
, NULL
, __LINE__
);
3384 ReleaseActCtx(handle
);
3388 static void test_settings(void)
3390 static const WCHAR dpiAwareW
[] = {'d','p','i','A','w','a','r','e',0};
3391 static const WCHAR dpiAwarenessW
[] = {'d','p','i','A','w','a','r','e','n','e','s','s',0};
3392 static const WCHAR dummyW
[] = {'d','u','m','m','y',0};
3393 static const WCHAR trueW
[] = {'t','r','u','e',0};
3394 static const WCHAR namespace2005W
[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0','0','5','/','W','i','n','d','o','w','s','S','e','t','t','i','n','g','s',0};
3395 static const WCHAR namespace2016W
[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0','1','6','/','W','i','n','d','o','w','s','S','e','t','t','i','n','g','s',0};
3401 if (!pQueryActCtxSettingsW
)
3403 win_skip( "QueryActCtxSettingsW is missing\n" );
3406 create_manifest_file( "manifest_settings.manifest", settings_manifest
, -1, NULL
, NULL
);
3407 handle
= test_create("manifest_settings.manifest");
3408 ok( handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
3409 DeleteFileA( "manifest_settings.manifest" );
3411 SetLastError( 0xdeadbeef );
3412 ret
= pQueryActCtxSettingsW( 1, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3413 ok( !ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3414 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %lu\n", GetLastError() );
3415 SetLastError( 0xdeadbeef );
3416 ret
= pQueryActCtxSettingsW( 0, handle
, dummyW
, dpiAwareW
, buffer
, 80, &size
);
3417 ok( !ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3418 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %lu\n", GetLastError() );
3419 SetLastError( 0xdeadbeef );
3421 memset( buffer
, 0xcc, sizeof(buffer
) );
3422 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3423 ok( ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3424 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3425 ok( size
== lstrlenW( buffer
) + 1, "wrong len %Iu\n", size
);
3426 SetLastError( 0xdeadbeef );
3428 memset( buffer
, 0xcc, sizeof(buffer
) );
3429 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dummyW
, buffer
, 80, &size
);
3430 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3431 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %lu\n", GetLastError() );
3432 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3433 SetLastError( 0xdeadbeef );
3435 memset( buffer
, 0xcc, sizeof(buffer
) );
3436 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2005W
, dpiAwareW
, buffer
, 80, &size
);
3437 ok( ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3438 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3439 ok( size
== ARRAY_SIZE(trueW
), "wrong len %Iu\n", size
);
3440 SetLastError( 0xdeadbeef );
3442 memset( buffer
, 0xcc, sizeof(buffer
) );
3443 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2005W
, dpiAwareW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3444 ok( ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3445 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3446 ok( size
== ARRAY_SIZE(trueW
), "wrong len %Iu\n", size
);
3447 SetLastError( 0xdeadbeef );
3449 memset( buffer
, 0xcc, sizeof(buffer
) );
3450 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2016W
, dpiAwareW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3451 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3452 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
|| broken( GetLastError() == ERROR_INVALID_PARAMETER
),
3453 "wrong error %lu\n", GetLastError() );
3454 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3455 SetLastError( 0xdeadbeef );
3457 memset( buffer
, 0xcc, sizeof(buffer
) );
3458 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwarenessW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3459 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3460 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %lu\n", GetLastError() );
3461 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3462 SetLastError( 0xdeadbeef );
3464 memset( buffer
, 0xcc, sizeof(buffer
) );
3465 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2005W
, dpiAwarenessW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3466 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3467 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %lu\n", GetLastError() );
3468 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3469 SetLastError( 0xdeadbeef );
3471 memset( buffer
, 0xcc, sizeof(buffer
) );
3472 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2016W
, dpiAwarenessW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3473 ok( ret
|| broken( GetLastError() == ERROR_INVALID_PARAMETER
),
3474 "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3477 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3478 ok( size
== ARRAY_SIZE(trueW
), "wrong len %Iu\n", size
);
3480 else ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3481 SetLastError( 0xdeadbeef );
3483 memset( buffer
, 0xcc, sizeof(buffer
) );
3484 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, lstrlenW(trueW
), &size
);
3485 ok( ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3486 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3487 ok( size
== ARRAY_SIZE(trueW
), "wrong len %Iu\n", size
);
3488 SetLastError( 0xdeadbeef );
3490 memset( buffer
, 0xcc, sizeof(buffer
) );
3491 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, lstrlenW(trueW
) - 1, &size
);
3492 ok( !ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3493 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "wrong error %lu\n", GetLastError() );
3494 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3495 ok( size
== ARRAY_SIZE(trueW
), "wrong len %Iu\n", size
);
3496 ReleaseActCtx(handle
);
3498 create_manifest_file( "manifest_settings2.manifest", settings_manifest2
, -1, NULL
, NULL
);
3499 handle
= test_create("manifest_settings2.manifest");
3500 ok( handle
!= INVALID_HANDLE_VALUE
|| broken( handle
== INVALID_HANDLE_VALUE
), /* <= vista */
3501 "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
3502 DeleteFileA( "manifest_settings2.manifest" );
3503 if (handle
!= INVALID_HANDLE_VALUE
)
3505 SetLastError( 0xdeadbeef );
3507 memset( buffer
, 0xcc, sizeof(buffer
) );
3508 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3509 ok( ret
, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
3510 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3511 ok( size
== lstrlenW( buffer
) + 1, "wrong len %Iu\n", size
);
3512 ReleaseActCtx(handle
);
3515 create_manifest_file( "manifest_settings3.manifest", settings_manifest3
, -1, NULL
, NULL
);
3516 handle
= test_create("manifest_settings3.manifest");
3517 ok( handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
3518 DeleteFileA( "manifest_settings3.manifest" );
3519 SetLastError( 0xdeadbeef );
3521 memset( buffer
, 0xcc, sizeof(buffer
) );
3522 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3523 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3524 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %lu\n", GetLastError() );
3525 ReleaseActCtx(handle
);
3527 /* lookup occurs in first non empty node */
3528 create_manifest_file( "manifest_settings4.manifest", settings_manifest4
, -1, NULL
, NULL
);
3529 handle
= test_create("manifest_settings4.manifest");
3530 ok( handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
3531 DeleteFileA( "manifest_settings4.manifest" );
3532 SetLastError( 0xdeadbeef );
3534 memset( buffer
, 0xcc, sizeof(buffer
) );
3535 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3536 ok( ret
, "QueryActCtxSettingsW failed\n" );
3537 SetLastError( 0xdeadbeef );
3539 memset( buffer
, 0xcc, sizeof(buffer
) );
3540 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwarenessW
, buffer
, 80, &size
);
3541 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3542 ReleaseActCtx(handle
);
3547 char path_tmp
[MAX_PATH
];
3548 char path_dll
[MAX_PATH
+ 11];
3549 char path_manifest_exe
[MAX_PATH
+ 12];
3550 char path_manifest_dll
[MAX_PATH
+ 16];
3553 HANDLE handle_context
;
3555 void (WINAPI
*get_path
)(char *buffer
, int buffer_size
);
3558 static BOOL
fill_sxs_info(sxs_info
*info
, const char *temp
, const char *path_dll
, const char *exe_manifest
, const char *dll_manifest
, BOOL do_load
)
3562 GetTempPathA(MAX_PATH
, info
->path_tmp
);
3563 strcat(info
->path_tmp
, temp
);
3564 strcat(info
->path_tmp
, "\\");
3565 CreateDirectoryA(info
->path_tmp
, NULL
);
3567 sprintf(info
->path_dll
, "%s%s", info
->path_tmp
, "sxs_dll.dll");
3568 extract_resource(path_dll
, "TESTDLL", info
->path_dll
);
3570 sprintf(info
->path_manifest_exe
, "%s%s", info
->path_tmp
, "exe.manifest");
3571 create_manifest_file(info
->path_manifest_exe
, exe_manifest
, -1, NULL
, NULL
);
3573 sprintf(info
->path_manifest_dll
, "%s%s", info
->path_tmp
, "sxs_dll.manifest");
3574 create_manifest_file(info
->path_manifest_dll
, dll_manifest
, -1, NULL
, NULL
);
3576 info
->context
.cbSize
= sizeof(ACTCTXA
);
3577 info
->context
.lpSource
= info
->path_manifest_exe
;
3578 info
->context
.lpAssemblyDirectory
= info
->path_tmp
;
3579 info
->context
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3581 info
->handle_context
= CreateActCtxA(&info
->context
);
3582 ok((info
->handle_context
!= NULL
&& info
->handle_context
!= INVALID_HANDLE_VALUE
)
3583 || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
), /* XP doesn't support manifests outside of PE files */
3584 "CreateActCtxA failed: %ld\n", GetLastError());
3585 if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
)
3587 skip("Failed to create activation context.\n");
3593 success
= ActivateActCtx(info
->handle_context
, &info
->cookie
);
3594 ok(success
, "ActivateActCtx failed: %ld\n", GetLastError());
3596 info
->module
= LoadLibraryA("sxs_dll.dll");
3597 ok(info
->module
!= NULL
, "LoadLibrary failed\n");
3599 info
->get_path
= (void *)GetProcAddress(info
->module
, "get_path");
3600 ok(info
->get_path
!= NULL
, "GetProcAddress failed\n");
3602 DeactivateActCtx(0, info
->cookie
);
3607 static void clean_sxs_info(sxs_info
*info
)
3609 if (info
->handle_context
)
3610 ReleaseActCtx(info
->handle_context
);
3611 if (*info
->path_dll
)
3613 BOOL ret
= DeleteFileA(info
->path_dll
);
3614 ok(ret
, "DeleteFileA failed for %s: %ld\n", info
->path_dll
, GetLastError());
3616 if (*info
->path_manifest_exe
)
3618 BOOL ret
= DeleteFileA(info
->path_manifest_exe
);
3619 ok(ret
, "DeleteFileA failed for %s: %ld\n", info
->path_manifest_exe
, GetLastError());
3621 if (*info
->path_manifest_dll
)
3623 BOOL ret
= DeleteFileA(info
->path_manifest_dll
);
3624 ok(ret
, "DeleteFileA failed for %s: %ld\n", info
->path_manifest_dll
, GetLastError());
3626 if (*info
->path_tmp
)
3628 BOOL ret
= RemoveDirectoryA(info
->path_tmp
);
3629 ok(ret
, "RemoveDirectoryA failed for %s: %ld\n", info
->path_tmp
, GetLastError());
3633 static void get_application_directory(char *buffer
, int buffer_size
)
3636 GetModuleFileNameA(NULL
, buffer
, buffer_size
);
3637 end
= strrchr(buffer
, '\\');
3641 /* Test loading two sxs dlls at the same time */
3642 static void test_two_dlls_at_same_time(void)
3646 char path1
[MAX_PATH
], path2
[MAX_PATH
];
3648 if (!fill_sxs_info(&dll_1
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3650 if (!fill_sxs_info(&dll_2
, "2", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3653 ok(dll_1
.module
!= dll_2
.module
, "Libraries are the same\n");
3654 dll_1
.get_path(path1
, sizeof(path1
));
3655 ok(strcmp(path1
, dll_1
.path_dll
) == 0, "Got '%s', expected '%s'\n", path1
, dll_1
.path_dll
);
3656 dll_2
.get_path(path2
, sizeof(path2
));
3657 ok(strcmp(path2
, dll_2
.path_dll
) == 0, "Got '%s', expected '%s'\n", path2
, dll_2
.path_dll
);
3661 FreeLibrary(dll_2
.module
);
3662 clean_sxs_info(&dll_2
);
3665 FreeLibrary(dll_1
.module
);
3666 clean_sxs_info(&dll_1
);
3669 /* Test loading a normal dll and then a sxs dll with the same name */
3670 static void test_one_sxs_and_one_local_1(void)
3673 char path_dll_local
[MAX_PATH
+ 11];
3674 char path_application
[MAX_PATH
];
3675 HMODULE module
= NULL
;
3676 char path1
[MAX_PATH
], path2
[MAX_PATH
];
3677 void (WINAPI
*get_path
)(char *buffer
, int buffer_size
);
3679 get_application_directory(path_application
, sizeof(path_application
));
3681 sprintf(path_dll_local
, "%s%s", path_application
, "sxs_dll.dll");
3682 extract_resource("dummy.dll", "TESTDLL", path_dll_local
);
3684 module
= LoadLibraryA(path_dll_local
);
3685 get_path
= (void *)GetProcAddress(module
, "get_path");
3687 if (!fill_sxs_info(&dll
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3690 ok(dll
.module
!= module
, "Libraries are the same\n");
3691 dll
.get_path(path1
, sizeof(path1
));
3692 ok(strcmp(path1
, dll
.path_dll
) == 0, "Got '%s', expected '%s'\n", path1
, dll
.path_dll
);
3693 get_path(path2
, sizeof(path2
));
3694 ok(strcmp(path2
, path_dll_local
) == 0, "Got '%s', expected '%s'\n", path2
, path_dll_local
);
3698 FreeLibrary(module
);
3700 FreeLibrary(dll
.module
);
3701 if (*path_dll_local
)
3703 BOOL success
= DeleteFileA(path_dll_local
);
3704 ok(success
, "DeleteFileA failed for %s: %ld\n", path_dll_local
, GetLastError());
3706 clean_sxs_info(&dll
);
3709 /* Test if sxs dll has priority over normal dll */
3710 static void test_one_sxs_and_one_local_2(void)
3713 char path_dll_local
[MAX_PATH
+ 11];
3714 char path_application
[MAX_PATH
];
3715 HMODULE module
= NULL
;
3716 char path1
[MAX_PATH
], path2
[MAX_PATH
];
3717 void (WINAPI
*get_path
)(char *buffer
, int buffer_size
);
3719 get_application_directory(path_application
, sizeof(path_application
));
3721 sprintf(path_dll_local
, "%s%s", path_application
, "sxs_dll.dll");
3722 extract_resource("dummy.dll", "TESTDLL", path_dll_local
);
3724 if (!fill_sxs_info(&dll
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3727 module
= LoadLibraryA(path_dll_local
);
3728 get_path
= (void *)GetProcAddress(module
, "get_path");
3730 ok(dll
.module
!= module
, "Libraries are the same\n");
3731 dll
.get_path(path1
, sizeof(path1
));
3732 ok(strcmp(path1
, dll
.path_dll
) == 0, "Got '%s', expected '%s'\n", path1
, dll
.path_dll
);
3733 get_path(path2
, sizeof(path2
));
3734 ok(strcmp(path2
, path_dll_local
) == 0, "Got '%s', expected '%s'\n", path2
, path_dll_local
);
3738 FreeLibrary(module
);
3740 FreeLibrary(dll
.module
);
3741 if (*path_dll_local
)
3743 BOOL success
= DeleteFileA(path_dll_local
);
3744 ok(success
, "DeleteFileA failed for %s: %ld\n", path_dll_local
, GetLastError());
3746 clean_sxs_info(&dll
);
3750 /* Test if we can get a module handle from loaded normal dll while context is active */
3751 static void test_one_with_sxs_and_GetModuleHandleA(void)
3754 char path_dll_local
[MAX_PATH
+ 11];
3755 char path_tmp
[MAX_PATH
];
3756 HMODULE module
= NULL
, module_temp
;
3759 GetTempPathA(sizeof(path_tmp
), path_tmp
);
3761 sprintf(path_dll_local
, "%s%s", path_tmp
, "sxs_dll.dll");
3762 extract_resource("dummy.dll", "TESTDLL", path_dll_local
);
3764 module
= LoadLibraryA(path_dll_local
);
3766 if (!fill_sxs_info(&dll
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, FALSE
))
3769 success
= ActivateActCtx(dll
.handle_context
, &dll
.cookie
);
3770 ok(success
, "ActivateActCtx failed: %ld\n", GetLastError());
3772 module_temp
= GetModuleHandleA("sxs_dll.dll");
3773 ok (module_temp
== 0, "Expected 0, got %p\n", module_temp
);
3775 DeactivateActCtx(0, dll
.cookie
);
3779 FreeLibrary(module
);
3781 FreeLibrary(dll
.module
);
3782 if (*path_dll_local
)
3784 success
= DeleteFileA(path_dll_local
);
3785 ok(success
, "DeleteFileA failed for %s: %ld\n", path_dll_local
, GetLastError());
3787 clean_sxs_info(&dll
);
3790 static void test_builtin_sxs(void)
3792 char path_manifest
[MAX_PATH
+ 12];
3793 char path_tmp
[MAX_PATH
];
3794 HMODULE module_msvcp
= 0, module_msvcr
= 0;
3795 char path_msvcp
[MAX_PATH
], path_msvcr
[MAX_PATH
];
3798 HANDLE handle_context
;
3800 static const char *expected_path
= "C:\\Windows\\WinSxS";
3802 GetTempPathA(sizeof(path_tmp
), path_tmp
);
3804 sprintf(path_manifest
, "%s%s", path_tmp
, "exe.manifest");
3805 create_manifest_file(path_manifest
, builtin_dll_manifest
, -1, NULL
, NULL
);
3807 context
.cbSize
= sizeof(ACTCTXA
);
3808 context
.lpSource
= path_manifest
;
3809 context
.lpAssemblyDirectory
= path_tmp
;
3810 context
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3812 handle_context
= CreateActCtxA(&context
);
3813 ok((handle_context
!= NULL
&& handle_context
!= INVALID_HANDLE_VALUE
)
3814 || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
), /* XP doesn't support manifests outside of PE files */
3815 "CreateActCtxA failed: %ld\n", GetLastError());
3816 if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
)
3818 skip("Failed to create activation context.\n");
3823 success
= ActivateActCtx(handle_context
, &cookie
);
3824 ok(success
, "ActivateActCtx failed: %ld\n", GetLastError());
3826 module_msvcp
= LoadLibraryA("msvcp90.dll");
3827 ok (module_msvcp
!= 0 || broken(module_msvcp
== 0), "LoadLibraryA failed, %ld\n", GetLastError());
3828 module_msvcr
= LoadLibraryA("msvcr90.dll");
3829 ok (module_msvcr
!= 0 || broken(module_msvcr
== 0), "LoadLibraryA failed, %ld\n", GetLastError());
3830 if (!module_msvcp
|| !module_msvcr
)
3832 skip("Failed to find msvcp90 or msvcr90.\n");
3836 GetModuleFileNameA(module_msvcp
, path_msvcp
, sizeof(path_msvcp
));
3837 GetModuleFileNameA(module_msvcr
, path_msvcr
, sizeof(path_msvcr
));
3838 ok(strnicmp(expected_path
, path_msvcp
, strlen(expected_path
)) == 0, "Expected path to start with %s, got %s\n", expected_path
, path_msvcp
);
3839 ok(strnicmp(expected_path
, path_msvcr
, strlen(expected_path
)) == 0, "Expected path to start with %s, got %s\n", expected_path
, path_msvcr
);
3841 DeactivateActCtx(0, cookie
);
3845 FreeLibrary(module_msvcp
);
3847 FreeLibrary(module_msvcr
);
3850 success
= DeleteFileA(path_manifest
);
3851 ok(success
, "DeleteFileA failed for %s: %ld\n", path_manifest
, GetLastError());
3855 struct manifest_res_spec
3859 const char *override_manifest
;
3862 struct manifest_res_spec_list
3865 const struct manifest_res_spec
*items
;
3868 static void add_sxs_dll_manifest(const char *pathname
,
3869 const struct manifest_res_spec_list
*res_lists
,
3871 const char *manifest
)
3877 update_h
= BeginUpdateResourceA(pathname
, FALSE
);
3878 ok(update_h
!= NULL
, "BeginUpdateResourceA returned error %lu.\n", GetLastError());
3880 for (i
= 0; i
< num_lists
; i
++)
3882 for (j
= 0; j
< res_lists
[i
].count
; j
++)
3884 const struct manifest_res_spec
*res_spec
= &res_lists
[i
].items
[j
];
3885 const char *cur_manifest
= res_spec
->override_manifest
? res_spec
->override_manifest
: manifest
;
3886 ret
= UpdateResourceA(update_h
,
3887 MAKEINTRESOURCEA(RT_MANIFEST
),
3890 (void *)cur_manifest
,
3891 strlen(cur_manifest
));
3892 ok(ret
, "UpdateResourceA returned error %lu.\n", GetLastError());
3896 ret
= EndUpdateResourceA(update_h
, FALSE
);
3897 ok(ret
, "EndUpdateResourceA returned error %lu.\n", GetLastError());
3900 struct multiple_manifest_test
3902 struct manifest_res_spec manifest_inline
; /* optional */
3903 const struct manifest_res_spec
*manifests
; /* optional */
3904 DWORD expected_error
;
3907 #define subtest_manifest_res(d,e,t,l) subtest_manifest_res_(__LINE__,d,e,t,l)
3908 static DWORD
subtest_manifest_res_(int line
, const char *manifest_exe
, const char *manifest_dll
,
3909 const struct multiple_manifest_test
*test_data
, LANGID lang
)
3911 char path_tmp
[MAX_PATH
] = "", path_dll
[MAX_PATH
] = "", path_manifest_exe
[MAX_PATH
] = "";
3912 static const char path_tmp_suffix
[] = "winek32t\\";
3913 WCHAR locale_name
[LOCALE_NAME_MAX_LENGTH
] = {0};
3914 struct manifest_res_spec_list res_lists
[2];
3915 char path_tmp_lang
[MAX_PATH
] = "";
3916 static volatile LONG last_uniqid
;
3917 DWORD err
, prefix_len
;
3923 prefix_len
= GetTempPathA(MAX_PATH
- ARRAY_SIZE(path_tmp_suffix
), path_tmp
);
3924 ok_(__FILE__
, line
)(prefix_len
> 0, "GetTempPathA returned error %lu.\n", GetLastError());
3926 memcpy(&path_tmp
[prefix_len
], path_tmp_suffix
, sizeof(path_tmp_suffix
) - sizeof(*path_tmp_suffix
));
3927 ret
= CreateDirectoryA(path_tmp
, NULL
);
3928 ok_(__FILE__
, line
)(ret
|| GetLastError() == ERROR_ALREADY_EXISTS
,
3929 "CreateDirectoryA returned error %lu.\n", GetLastError());
3933 r
= LCIDToLocaleName(MAKELCID(lang
, SORT_DEFAULT
),
3934 locale_name
, ARRAY_SIZE(locale_name
), LOCALE_ALLOW_NEUTRAL_NAMES
);
3935 ok(r
> 0, "lang 0x%04x, error %lu.\n", lang
, GetLastError());
3940 r
= snprintf(path_tmp_lang
, ARRAY_SIZE(path_tmp_lang
), "%s%ls\\", path_tmp
, locale_name
);
3941 ok_(__FILE__
, line
)(r
> 0 && r
< ARRAY_SIZE(path_tmp_lang
), "got %d\n", r
);
3943 ret
= CreateDirectoryA(path_tmp_lang
, NULL
);
3944 ok_(__FILE__
, line
)(ret
|| GetLastError() == ERROR_ALREADY_EXISTS
,
3945 "CreateDirectoryA returned error %lu.\n", GetLastError());
3949 r
= snprintf(path_tmp_lang
, ARRAY_SIZE(path_tmp_lang
), "%s", path_tmp
);
3950 ok_(__FILE__
, line
)(r
> 0 && r
< ARRAY_SIZE(path_tmp_lang
), "got %d\n", r
);
3953 r
= snprintf(path_dll
, ARRAY_SIZE(path_dll
), "%s%s", path_tmp_lang
, "sxs_dll.dll");
3954 ok_(__FILE__
, line
)(r
> 0 && r
< ARRAY_SIZE(path_dll
), "got %d\n", r
);
3956 r
= snprintf(path_manifest_exe
, ARRAY_SIZE(path_manifest_exe
), "%sexe%08lx.manifest",
3957 path_tmp
, InterlockedIncrement(&last_uniqid
));
3958 ok_(__FILE__
, line
)(r
> 0 && r
< ARRAY_SIZE(path_manifest_exe
), "got %d\n", r
);
3959 create_manifest_file(path_manifest_exe
, manifest_exe
, -1, NULL
, NULL
);
3961 extract_resource("dummy.dll", "TESTDLL", path_dll
);
3963 res_lists
[0].count
= test_data
->manifest_inline
.name
? 1 : 0;
3964 res_lists
[0].items
= &test_data
->manifest_inline
;
3966 if (test_data
->manifests
)
3970 while (test_data
->manifests
[n
].name
)
3973 res_lists
[1].count
= n
;
3974 res_lists
[1].items
= test_data
->manifests
;
3978 res_lists
[1].count
= 0;
3979 res_lists
[1].items
= NULL
;
3982 add_sxs_dll_manifest(path_dll
, res_lists
, ARRAY_SIZE(res_lists
), manifest_dll
);
3984 memset(&actctx
, 0, sizeof(actctx
));
3985 actctx
.cbSize
= sizeof(actctx
);
3986 actctx
.lpSource
= path_manifest_exe
;
3987 actctx
.lpAssemblyDirectory
= path_tmp
;
3988 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3990 SetLastError(0xccccccccUL
);
3991 handle
= CreateActCtxA(&actctx
);
3992 if (handle
== INVALID_HANDLE_VALUE
)
3994 err
= GetLastError();
3995 ok_(__FILE__
, line
)(err
!= ERROR_SUCCESS
, "got %#lx.\n", err
);
3999 err
= ERROR_SUCCESS
;
4000 ok_(__FILE__
, line
)(handle
!= NULL
, "CreateActCtxA returned %p (error %lu)\n", handle
, err
);
4001 ReleaseActCtx(handle
);
4003 ok_(__FILE__
, line
)(err
== test_data
->expected_error
,
4004 "expected error %lu, got %lu\n", test_data
->expected_error
, err
);
4006 ret
= DeleteFileA(path_manifest_exe
);
4007 ok_(__FILE__
, line
)(ret
, "DeleteFileA(%s) returned error %lu\n.",
4008 debugstr_a(path_manifest_exe
), GetLastError());
4010 ret
= DeleteFileA(path_dll
);
4011 ok_(__FILE__
, line
)(ret
, "DeleteFileA(%s) returned error %lu\n.", debugstr_a(path_dll
), GetLastError());
4015 ret
= RemoveDirectoryA(path_tmp_lang
);
4016 ok_(__FILE__
, line
)(ret
, "RemoveDirectoryA(%s) returned error %lu\n.",
4017 debugstr_a(path_tmp_lang
), GetLastError());
4020 ret
= RemoveDirectoryA(path_tmp
);
4021 ok_(__FILE__
, line
)(ret
, "RemoveDirectoryA(%s) returned error %lu %s\n.",
4022 debugstr_a(path_tmp
), GetLastError(), debugstr_a(path_tmp_lang
));
4027 /* Test loading DLL with dependency assembly in manifest resource */
4028 static void test_manifest_resources(void)
4030 static const struct manifest_res_spec wrong_manifest_resources_numbered
[] = {
4031 { (char *)2, MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
), wrong_manifest1
},
4032 { (char *)2, MAKELANGID(LANG_FRENCH
,SUBLANG_DEFAULT
), wrong_manifest1
},
4033 { (char *)3, 0, wrong_manifest1
},
4034 { (char *)0x1234, 0, wrong_manifest1
},
4037 static const struct manifest_res_spec correct_manifest_resources_numbered
[] = {
4038 { (char *)2, MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
) },
4039 { (char *)2, MAKELANGID(LANG_FRENCH
,SUBLANG_DEFAULT
) },
4041 { (char *)0x1234, 0 },
4044 static const struct manifest_res_spec wrong_manifest_resources_gte_3
[] = {
4045 { (char *)3, 0, wrong_manifest1
},
4046 { (char *)3, MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
), wrong_manifest1
},
4049 static const struct manifest_res_spec correct_manifest_resources_gte_3
[] = {
4051 { (char *)3, MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
) },
4054 static const struct manifest_res_spec wrong_manifest_resources_named
[] = {
4055 { "foo", 0, wrong_manifest1
},
4056 { "bar", MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
), wrong_manifest1
},
4059 static const struct manifest_res_spec correct_manifest_resources_named
[] = {
4061 { "bar", MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
) },
4064 struct multiple_manifest_test tests
[] = {
4065 /* Test well-known manifest resource IDs */
4066 { { (char *)CREATEPROCESS_MANIFEST_RESOURCE_ID
}, NULL
, ERROR_SUCCESS
},
4067 { { (char *)ISOLATIONAWARE_MANIFEST_RESOURCE_ID
}, NULL
, ERROR_SUCCESS
},
4068 { { (char *)ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID
}, NULL
, ERROR_SUCCESS
},
4070 /* Test remaining reserved manifest resource IDs */
4071 { { (char *)4 }, NULL
, ERROR_SUCCESS
},
4072 { { (char *)5 }, NULL
, ERROR_SUCCESS
},
4073 { { (char *)6 }, NULL
, ERROR_SUCCESS
},
4074 { { (char *)7 }, NULL
, ERROR_SUCCESS
},
4075 { { (char *)8 }, NULL
, ERROR_SUCCESS
},
4076 { { (char *)9 }, NULL
, ERROR_SUCCESS
},
4077 { { (char *)10 }, NULL
, ERROR_SUCCESS
},
4078 { { (char *)11 }, NULL
, ERROR_SUCCESS
},
4079 { { (char *)12 }, NULL
, ERROR_SUCCESS
},
4080 { { (char *)13 }, NULL
, ERROR_SUCCESS
},
4081 { { (char *)14 }, NULL
, ERROR_SUCCESS
},
4082 { { (char *)15 }, NULL
, ERROR_SUCCESS
},
4083 { { (char *)MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID
}, NULL
, ERROR_SUCCESS
},
4085 /* Test arbitrary resource IDs */
4086 { { (char *)0x1234 }, NULL
, ERROR_SUCCESS
},
4087 { { (char *)0x89ab }, NULL
, ERROR_SUCCESS
},
4088 { { (char *)0xffff }, NULL
, ERROR_SUCCESS
},
4090 /* Test arbitrary LANGID */
4091 { { (char *)2, MAKELANGID(LANG_ENGLISH
,SUBLANG_DEFAULT
) }, NULL
, ERROR_SUCCESS
},
4092 { { (char *)2, MAKELANGID(LANG_FRENCH
,SUBLANG_DEFAULT
) }, NULL
, ERROR_SUCCESS
},
4093 { { (char *)2, 0x1234 }, NULL
, ERROR_SUCCESS
},
4094 { { (char *)2, 0xffff }, NULL
, ERROR_SUCCESS
},
4096 /* Test multiple manifest resources coexisting inside a module */
4097 { { (char *)2, 0 }, wrong_manifest_resources_numbered
, ERROR_SUCCESS
},
4098 { { (char *)2, 0, wrong_manifest1
}, correct_manifest_resources_numbered
,
4099 ERROR_SXS_CANT_GEN_ACTCTX
},
4101 /* Test that smaller resource ID takes precedence regardless of language ID */
4102 { { (char *)2, MAKELANGID(LANG_INVARIANT
,SUBLANG_NEUTRAL
) },
4103 wrong_manifest_resources_gte_3
, ERROR_SUCCESS
},
4104 { { (char *)2, MAKELANGID(LANG_INVARIANT
,SUBLANG_NEUTRAL
), wrong_manifest1
},
4105 correct_manifest_resources_gte_3
, ERROR_SXS_CANT_GEN_ACTCTX
},
4107 /* Test multiple manifest resources (ID / name) coexisting inside a module */
4108 { { (char *)2, 0 }, wrong_manifest_resources_named
, ERROR_SUCCESS
},
4109 { { (char *)2, 0, wrong_manifest1
},
4110 correct_manifest_resources_named
, ERROR_SXS_CANT_GEN_ACTCTX
},
4112 /* Test name-only RT_MANIFEST resources */
4113 { { NULL
}, correct_manifest_resources_named
, ERROR_SXS_CANT_GEN_ACTCTX
},
4117 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++)
4119 winetest_push_context("tests[%Iu] (%p 0x%04x)", i
,
4120 tests
[i
].manifest_inline
.name
, tests
[i
].manifest_inline
.lang
);
4121 subtest_manifest_res(two_dll_manifest_exe
, two_dll_manifest_dll
, &tests
[i
], 0);
4122 winetest_pop_context();
4126 #define LANGID_PREC_MAX_COUNT 5
4128 static void get_langid_precedence(LANGID
*langs_arr
, size_t *lang_count
)
4130 LANGID src_langs
[LANGID_PREC_MAX_COUNT
];
4131 LANGID user_ui_lang
;
4134 user_ui_lang
= GetUserDefaultUILanguage();
4136 src_langs
[0] = MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
);
4137 src_langs
[1] = user_ui_lang
;
4138 src_langs
[2] = MAKELANGID(PRIMARYLANGID(user_ui_lang
), SUBLANG_NEUTRAL
);
4139 src_langs
[3] = MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
);
4140 src_langs
[4] = 0x1; /* least number that is a valid LANGID */
4142 for (i
= 0; i
< ARRAY_SIZE(src_langs
); i
++)
4144 LANGID item
= src_langs
[i
];
4145 BOOL is_item_duplicate
= FALSE
;
4147 for (j
= 0; j
< n
; j
++)
4149 if (langs_arr
[j
] == item
)
4151 is_item_duplicate
= TRUE
;
4156 if (!is_item_duplicate
)
4158 langs_arr
[n
++] = item
;
4165 static void subtest_valid_manifest_resources_locale(LANGID actctx_lang
)
4167 static const char manifest_exe_fmt
[] =
4168 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
4170 "<dependentAssembly>"
4171 "<assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\""
4172 " processorArchitecture=\"" ARCH
"\" publicKeyToken=\"0000000000000000\" language=\"%ls\"/>"
4173 "</dependentAssembly>"
4176 static const char manifest_dll_fmt
[] =
4177 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v3\" manifestVersion=\"1.0\">"
4178 "<assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\""
4179 " processorArchitecture=\"" ARCH
"\" publicKeyToken=\"0000000000000000\" language=\"%ls\"/>"
4181 static const char manifest_dll_nofmt
[] =
4182 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v3\" manifestVersion=\"1.0\">"
4183 "<assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\""
4184 " processorArchitecture=\"" ARCH
"\" publicKeyToken=\"0000000000000000\"/>"
4186 char manifest_exe
[1024], manifest_dll
[1024];
4187 WCHAR locale_name
[LOCALE_NAME_MAX_LENGTH
];
4188 UINT16 langs_arr
[LANGID_PREC_MAX_COUNT
];
4189 size_t lang_count
= 0, i
, j
;
4192 if (actctx_lang
== MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
))
4194 wcscpy(locale_name
, L
"*");
4195 strcpy(manifest_dll
, manifest_dll_nofmt
);
4199 actctx_lang
= ConvertDefaultLocale(actctx_lang
);
4200 ok(actctx_lang
!= MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
),
4201 "unexpected neutral locale\n");
4202 ret
= LCIDToLocaleName(MAKELCID(actctx_lang
, SORT_DEFAULT
),
4203 locale_name
, ARRAY_SIZE(locale_name
), LOCALE_ALLOW_NEUTRAL_NAMES
);
4204 ok(ret
> 0, "error %lu.\n", GetLastError());
4206 ret
= snprintf(manifest_dll
, ARRAY_SIZE(manifest_dll
), manifest_dll_fmt
, locale_name
);
4207 ok(ret
> 0 && ret
< ARRAY_SIZE(manifest_dll
), "ret %d.\n", ret
);
4210 ret
= snprintf(manifest_exe
, ARRAY_SIZE(manifest_exe
), manifest_exe_fmt
, locale_name
);
4211 ok(ret
> 0 && ret
< ARRAY_SIZE(manifest_exe
), "ret %d.\n", ret
);
4213 get_langid_precedence(langs_arr
, &lang_count
);
4215 for (i
= 0; i
< lang_count
; i
++)
4217 struct manifest_res_spec specs
[ARRAY_SIZE(langs_arr
) + 1];
4218 struct multiple_manifest_test test
= { { NULL
} };
4222 winetest_push_context("langs[%Id:]", i
);
4224 /* Generate manifest spec list from language IDs.
4226 * All manifest spec items point to the wrong manifest, expect for the
4227 * current language ID.
4230 for (j
= i
; j
< lang_count
; j
++)
4232 struct manifest_res_spec spec
= {(char *)2};
4233 spec
.lang
= langs_arr
[j
];
4234 if (j
!= i
) spec
.override_manifest
= wrong_manifest1
;
4235 ok(num_specs
< ARRAY_SIZE(specs
), "overrun\n");
4236 specs
[num_specs
++] = spec
;
4238 memset(&specs
[num_specs
++], 0, sizeof(*specs
));
4240 test
.manifests
= specs
;
4241 test
.expected_error
= ERROR_SUCCESS
;
4242 err
= subtest_manifest_res(manifest_exe
, manifest_dll
, &test
, actctx_lang
);
4244 if (winetest_debug
> 1 && err
!= ERROR_SUCCESS
)
4246 for (j
= 0; j
< lang_count
; j
++)
4248 trace("langs[%Id] = 0x%04x %c\n", j
, langs_arr
[j
], j
== i
? '<' : ' ');
4252 winetest_pop_context();
4256 static void test_valid_manifest_resources_locale(void)
4258 static const LANGID langs
[] = {
4259 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
),
4260 MAKELANGID(LANG_INVARIANT
, SUBLANG_NEUTRAL
),
4264 for (i
= 0; i
< ARRAY_SIZE(langs
); i
++)
4266 winetest_push_context("[%Iu]lang=0x%04x", i
, langs
[i
]);
4267 subtest_valid_manifest_resources_locale(langs
[i
]);
4268 winetest_pop_context();
4272 static void run_sxs_test(int run
)
4277 test_two_dlls_at_same_time();
4280 test_one_sxs_and_one_local_1();
4283 test_one_sxs_and_one_local_2();
4286 test_one_with_sxs_and_GetModuleHandleA();
4294 static void run_child_process_two_dll(int run
)
4296 char cmdline
[MAX_PATH
];
4299 PROCESS_INFORMATION pi
;
4300 STARTUPINFOA si
= { 0 };
4303 winetest_get_mainargs( &argv
);
4305 if (strstr(argv
[0], ".exe"))
4306 sprintf(exe
, "%s", argv
[0]);
4308 sprintf(exe
, "%s.exe", argv
[0]);
4309 sprintf(cmdline
, "\"%s\" %s two_dll %d", argv
[0], argv
[1], run
);
4312 ret
= CreateProcessA(exe
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
4313 ok(ret
, "Could not create process: %lu\n", GetLastError());
4315 wait_child_process( pi
.hProcess
);
4317 CloseHandle(pi
.hThread
);
4318 CloseHandle(pi
.hProcess
);
4321 static const detailed_info_t detailed_info3
=
4323 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, exe_path
,
4324 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
4328 static void test_manifest_in_module(void)
4333 memset(&ctx
, 0, sizeof(ctx
));
4334 ctx
.cbSize
= sizeof(ctx
);
4335 ctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
| ACTCTX_FLAG_RESOURCE_NAME_VALID
;
4336 ctx
.lpResourceName
= (LPWSTR
)124;
4337 ctx
.hModule
= GetModuleHandleW(NULL
);
4338 handle
= CreateActCtxW(&ctx
);
4339 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateActCtx error %lu\n", GetLastError());
4341 test_basic_info(handle
, __LINE__
);
4342 test_detailed_info(handle
, &detailed_info3
, __LINE__
);
4344 ReleaseActCtx(handle
);
4347 static void test_manifest_resource_name_omitted(void)
4349 WCHAR pathbuf
[MAX_PATH
];
4354 memset(&ctx
, 0, sizeof(ctx
));
4355 ctx
.cbSize
= sizeof(ctx
);
4356 ctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
4357 ctx
.hModule
= GetModuleHandleW(NULL
);
4358 handle
= CreateActCtxW(&ctx
);
4359 err
= GetLastError();
4360 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtxW shall fail\n");
4362 ok(err
== ERROR_RESOURCE_TYPE_NOT_FOUND
, "got %lu\n", err
);
4364 memset(&ctx
, 0, sizeof(ctx
));
4365 ctx
.cbSize
= sizeof(ctx
);
4366 ctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
| ACTCTX_FLAG_RESOURCE_NAME_VALID
;
4367 ctx
.hModule
= GetModuleHandleW(NULL
);
4368 ctx
.lpResourceName
= NULL
;
4369 handle
= CreateActCtxW(&ctx
);
4370 err
= GetLastError();
4371 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtxW shall fail\n");
4372 ok(err
== ERROR_INVALID_PARAMETER
, "got %lu\n", err
);
4374 len
= GetModuleFileNameW(NULL
, pathbuf
, ARRAY_SIZE(pathbuf
));
4375 ok(len
> 0 && len
< ARRAY_SIZE(pathbuf
), "GetModuleFileNameW returned error %lu\n", GetLastError());
4377 memset(&ctx
, 0, sizeof(ctx
));
4378 ctx
.cbSize
= sizeof(ctx
);
4379 ctx
.lpSource
= pathbuf
;
4381 handle
= CreateActCtxW(&ctx
);
4382 err
= GetLastError();
4383 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtxW shall fail\n");
4385 ok(err
== ERROR_RESOURCE_TYPE_NOT_FOUND
, "got %lu\n", err
);
4387 memset(&ctx
, 0, sizeof(ctx
));
4388 ctx
.cbSize
= sizeof(ctx
);
4389 ctx
.lpSource
= pathbuf
;
4390 ctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
;
4391 ctx
.lpResourceName
= NULL
;
4392 handle
= CreateActCtxW(&ctx
);
4393 err
= GetLastError();
4394 ok(handle
== INVALID_HANDLE_VALUE
, "CreateActCtxW shall fail\n");
4395 ok(err
== ERROR_INVALID_PARAMETER
, "got %lu\n", err
);
4403 argc
= winetest_get_mainargs(&argv
);
4407 win_skip("Needed functions are not available\n");
4412 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
4413 test_app_manifest();
4417 if (argc
> 2 && !strcmp(argv
[2], "two_dll"))
4419 int run
= atoi(argv
[3]);
4424 test_manifest_in_module();
4425 test_manifest_resource_name_omitted();
4426 test_manifest_resources();
4427 test_valid_manifest_resources_locale();
4430 test_CreateActCtx();
4431 test_CreateActCtx_share_mode();
4432 test_findsectionstring();
4433 test_ZombifyActCtx();
4434 run_child_process();
4435 test_compatibility();
4437 run_child_process_two_dll(1);
4438 run_child_process_two_dll(2);
4439 run_child_process_two_dll(3);
4440 run_child_process_two_dll(4);
4441 run_child_process_two_dll(5);