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 __x86_64__
44 #elif defined __aarch64__
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}\""
124 " <comInterfaceExternalProxyStub "
125 " name=\"Iifaceps2\""
126 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
127 " iid=\"{76666666-8888-7777-6666-555555555555}\""
128 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
130 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
132 " <comInterfaceExternalProxyStub "
133 " name=\"Iifaceps3\""
134 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
135 " iid=\"{86666666-8888-7777-6666-555555555555}\""
137 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
140 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
141 " name=\"testsurrogate\""
142 " runtimeVersion=\"v2.0.50727\""
145 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
147 " progid=\"clrprogid\""
148 " description=\"test description\""
149 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
150 " runtimeVersion=\"1.2.3.4\""
151 " threadingModel=\"Neutral\""
153 " <progid>clrprogid.1</progid>"
154 " <progid>clrprogid.2</progid>"
155 " <progid>clrprogid.3</progid>"
156 " <progid>clrprogid.4</progid>"
157 " <progid>clrprogid.5</progid>"
158 " <progid>clrprogid.6</progid>"
162 static const char manifest_wndcls1
[] =
163 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
164 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
165 "<file name=\"testlib1.dll\">"
166 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
167 "<windowClass>wndClass2</windowClass>"
168 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
170 "<file name=\"testlib1_2.dll\" />"
173 static const char manifest_wndcls2
[] =
174 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
175 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
176 "<file name=\"testlib2.dll\">"
177 " <windowClass versioned=\"no\">wndClass3</windowClass>"
178 " <windowClass>wndClass4</windowClass>"
179 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
180 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
181 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
182 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
184 "<file name=\"testlib2_2.dll\" />"
187 static const char manifest_wndcls_main
[] =
188 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
189 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
191 " <dependentAssembly>"
192 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
193 " </dependentAssembly>"
196 " <dependentAssembly>"
197 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
198 " </dependentAssembly>"
202 static const char manifest4
[] =
203 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
204 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
205 "</assemblyIdentity>"
207 "<dependentAssembly>"
208 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
209 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
210 "</assemblyIdentity>"
211 "</dependentAssembly>"
215 static const char manifest5
[] =
216 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
217 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
218 "</assemblyIdentity>"
220 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
221 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
222 " </dependentAssembly>"
226 static const char manifest6
[] =
227 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
228 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
229 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
231 " <requestedPrivileges>"
232 " <requestedExecutionLevel level=\"ASINVOKER\" uiAccess=\"false\"/>"
233 " </requestedPrivileges>"
238 static const char manifest7
[] =
239 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
240 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
241 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
243 " <requestedPrivileges>"
244 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"TRUE\"/>"
245 " </requestedPrivileges>"
250 static const char manifest8
[] =
251 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
252 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
253 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
255 " <requestedPrivileges>"
256 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\">"
257 " </requestedExecutionLevel>"
258 " </requestedPrivileges>"
263 static const char manifest9
[] =
264 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
265 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
266 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
268 " <requestedPrivileges>"
269 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
270 " </requestedPrivileges>"
273 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
275 " <requestedPrivileges>"
276 " </requestedPrivileges>"
281 static const char manifest10
[] =
282 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" xmlns:asmv2=\"urn:schemas-microsoft-com:asm.v2\" manifestVersion=\"1.0\">"
283 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
286 " <asmv2:requestedPrivileges>"
287 " <asmv2:requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\"></asmv2:requestedExecutionLevel>"
288 " </asmv2:requestedPrivileges>"
293 /* Empty <dependency> element */
294 static const char manifest11
[] =
295 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" xmlns:asmv2=\"urn:schemas-microsoft-com:asm.v2\" manifestVersion=\"1.0\">"
296 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
300 static const char testdep_manifest1
[] =
301 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
302 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
305 static const char testdep_manifest2
[] =
306 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
307 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
308 "<file name=\"testlib.dll\"></file>"
309 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
312 static const char testdep_manifest3
[] =
313 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
314 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
315 "<file name=\"testlib.dll\"/>"
316 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
317 "<windowClass>wndClass</windowClass>"
318 "<windowClass>wndClass2</windowClass>"
322 static const char wrong_manifest1
[] =
323 "<assembly manifestVersion=\"1.0\">"
324 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
327 static const char wrong_manifest2
[] =
328 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
329 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
332 static const char wrong_manifest3
[] =
333 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
334 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
337 static const char wrong_manifest4
[] =
338 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
339 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
343 static const char wrong_manifest5
[] =
344 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
345 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
349 static const char wrong_manifest6
[] =
350 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
351 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
354 static const char wrong_manifest7
[] =
355 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
356 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
357 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
360 static const char wrong_manifest8
[] =
361 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
362 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
366 static const char wrong_manifest9
[] =
367 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
368 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
369 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
371 " <requestedPrivileges>"
372 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
373 " <requestedExecutionLevel uiAccess=\"true\"/>"
374 " </requestedPrivileges>"
379 static const char wrong_manifest10
[] =
380 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
381 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
382 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
384 " <requestedPrivileges>"
385 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
386 " </requestedPrivileges>"
389 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
391 " <requestedPrivileges>"
392 " <requestedExecutionLevel uiAccess=\"true\"/>"
393 " </requestedPrivileges>"
398 static const char wrong_depmanifest1
[] =
399 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
400 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
403 static const char compat_manifest_no_supportedOs
[] =
404 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
405 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
406 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
412 static const char compat_manifest_vista
[] =
413 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
414 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
415 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
417 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" />" /* Windows Vista */
422 static const char compat_manifest_vista_7_8_10_81
[] =
423 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
424 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
425 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
427 " <supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" ></supportedOS>" /* Windows Vista */
428 " <supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" />" /* Windows 7 */
429 " <supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" ></supportedOS>" /* Windows 8 */
430 " <supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" />" /* Windows 10 */
431 " <supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" />" /* Windows 8.1 */
436 static const char compat_manifest_other_guid
[] =
437 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
438 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
439 " <compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">"
441 " <supportedOS Id=\"{12345566-1111-2222-3333-444444444444}\" />"
446 static const char settings_manifest
[] =
447 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
448 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
449 " <application xmlns=\"urn:schemas-microsoft-com:asm.v3\">"
451 " <dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true</dpiAware>"
452 " <dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">true</dpiAwareness>"
453 " </windowsSettings>"
457 static const char settings_manifest2
[] =
458 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
459 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
460 " <application xmlns=\"urn:schemas-microsoft-com:asm.v3\""
461 " xmlns:ws05=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\""
462 " xmlns:ws11=\"http://schemas.microsoft.com/SMI/2011/WindowsSettings\""
463 " xmlns:ws16=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\""
464 " xmlns:ws17=\"http://schemas.microsoft.com/SMI/2017/WindowsSettings\">"
466 " <ws05:autoElevate>true</ws05:autoElevate>"
467 " <ws05:disableTheming>true</ws05:disableTheming>"
468 " <ws11:disableWindowFiltering>true</ws11:disableWindowFiltering>"
469 " <ws05:dpiAware>true</ws05:dpiAware>"
470 " <ws16:dpiAwareness>true</ws16:dpiAwareness>"
471 " <ws17:gdiScaling>true</ws17:gdiScaling>"
472 " <ws17:highResolutionScrollingAware>true</ws17:highResolutionScrollingAware>"
473 " <ws16:longPathAware>true</ws16:longPathAware>"
474 " <ws17:magicFutureSetting>true</ws17:magicFutureSetting>"
475 " <ws11:printerDriverIsolation>true</ws11:printerDriverIsolation>"
476 " <ws17:ultraHighResolutionScrollingAware>true</ws17:ultraHighResolutionScrollingAware>"
477 " </windowsSettings>"
481 /* broken manifest found in some binaries: asmv3 namespace is used but not declared */
482 static const char settings_manifest3
[] =
483 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
484 " <assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
485 " <asmv3:application>"
486 " <asmv3:windowsSettings xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">"
487 " <dpiAware>true</dpiAware>"
488 " </asmv3:windowsSettings>"
489 " </asmv3:application>"
492 static const char two_dll_manifest_dll
[] =
493 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v3\" manifestVersion=\"1.0\">"
494 " <assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"0000000000000000\"/>"
495 " <file name=\"sxs_dll.dll\"></file>"
498 static const char two_dll_manifest_exe
[] =
499 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
501 " <dependentAssembly>"
502 " <assemblyIdentity type=\"win32\" name=\"sxs_dll\" version=\"1.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"0000000000000000\" language=\"*\"/>"
503 " </dependentAssembly>"
507 static const char builtin_dll_manifest
[] =
508 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
510 " <dependentAssembly>"
513 " name=\"microsoft.vc90.crt\""
514 " version=\"9.0.20718.0\""
515 " processorArchitecture=\"*\""
516 " publicKeyToken=\"1fc8b3b9a1e18e3b\""
519 " </dependentAssembly>"
524 DEFINE_GUID(VISTA_COMPAT_GUID
, 0xe2011457, 0x1546, 0x43c5, 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0);
525 DEFINE_GUID(WIN7_COMPAT_GUID
, 0x35138b9a, 0x5d96, 0x4fbd, 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a);
526 DEFINE_GUID(WIN8_COMPAT_GUID
, 0x4a2f28e3, 0x53b9, 0x4441, 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38);
527 DEFINE_GUID(WIN81_COMPAT_GUID
, 0x1f676c76, 0x80e1, 0x4239, 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78);
528 DEFINE_GUID(WIN10_COMPAT_GUID
, 0x8e0f7a12, 0xbfb3, 0x4fe8, 0xb9, 0xa5, 0x48, 0xfd, 0x50, 0xa1, 0x5a, 0x9a);
529 DEFINE_GUID(OTHER_COMPAT_GUID
, 0x12345566, 0x1111, 0x2222, 0x33, 0x33, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44);
532 static const WCHAR testlib_dll
[] =
533 {'t','e','s','t','l','i','b','.','d','l','l',0};
534 static const WCHAR testlib2_dll
[] =
535 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
536 static const WCHAR wndClassW
[] =
537 {'w','n','d','C','l','a','s','s',0};
538 static const WCHAR wndClass1W
[] =
539 {'w','n','d','C','l','a','s','s','1',0};
540 static const WCHAR wndClass2W
[] =
541 {'w','n','d','C','l','a','s','s','2',0};
542 static const WCHAR wndClass3W
[] =
543 {'w','n','d','C','l','a','s','s','3',0};
545 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
546 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
548 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
549 const char *depfile
, const char *depmanifest
)
553 WCHAR path
[MAX_PATH
];
555 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
556 GetFullPathNameW(path
, ARRAY_SIZE(manifest_path
), manifest_path
, NULL
);
558 if (manifest_len
== -1)
559 manifest_len
= strlen(manifest
);
561 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
562 FILE_ATTRIBUTE_NORMAL
, NULL
);
563 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
564 if(file
== INVALID_HANDLE_VALUE
)
566 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
571 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
572 GetFullPathNameW(path
, ARRAY_SIZE(depmanifest_path
), depmanifest_path
, NULL
);
573 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
574 FILE_ATTRIBUTE_NORMAL
, NULL
);
575 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
576 if(file
== INVALID_HANDLE_VALUE
)
578 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
584 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
586 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
588 int offset
= (fBOM
? 0 : 1);
590 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
591 wmanifest
[0] = 0xfeff;
595 for (i
= 0; i
< strlen(manifest
)+1; i
++)
596 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
598 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
599 HeapFree(GetProcessHeap(), 0, wmanifest
);
604 ULONG format_version
;
605 ULONG assembly_cnt_min
;
606 ULONG assembly_cnt_max
;
607 ULONG root_manifest_type
;
608 LPWSTR root_manifest_path
;
609 ULONG root_config_type
;
614 static const detailed_info_t detailed_info0
= {
615 0, 0, 0, 0, NULL
, 0, 0, NULL
618 static const detailed_info_t detailed_info1
= {
619 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
620 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
624 static const detailed_info_t detailed_info1_child
= {
625 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
626 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
630 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
631 static const detailed_info_t detailed_info2
= {
632 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
633 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
637 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
639 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
640 SIZE_T size
, exsize
, retsize
;
643 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
644 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
645 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
647 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
649 b
= QueryActCtxW(0, handle
, NULL
, ActivationContextDetailedInformation
, &detailed_info_tmp
,
650 sizeof(detailed_info_tmp
), &size
);
651 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
652 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
653 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
655 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
658 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
659 memset(detailed_info
, 0xfe, size
);
660 b
= QueryActCtxW(0, handle
, NULL
, ActivationContextDetailedInformation
, detailed_info
, size
, &retsize
);
661 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
662 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
664 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
665 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
666 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
667 exinfo
->format_version
);
668 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
669 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
670 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
671 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
672 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
673 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
674 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
675 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
676 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
677 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
678 detailed_info
->ulRootManifestPathChars
,
679 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
680 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
681 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
682 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
683 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
684 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
685 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
686 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
687 exinfo
->app_dir_type
);
688 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
689 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
690 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
691 if(exinfo
->root_manifest_path
) {
692 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
693 if(detailed_info
->lpRootManifestPath
)
694 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
695 "unexpected detailed_info->lpRootManifestPath\n");
697 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
699 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
700 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
701 if(exinfo
->app_dir
) {
702 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
703 if(detailed_info
->lpAppDirPath
)
704 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
705 "unexpected detailed_info->lpAppDirPath %s / %s\n",
706 wine_dbgstr_w(detailed_info
->lpAppDirPath
), wine_dbgstr_w( exinfo
->app_dir
));
708 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
711 HeapFree(GetProcessHeap(), 0, detailed_info
);
716 /* ULONG manifest_path_type; FIXME */
717 LPCWSTR manifest_path
;
718 LPCWSTR encoded_assembly_id
;
719 BOOL has_assembly_dir
;
722 static const info_in_assembly manifest1_info
= {
724 L
"Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
728 static const info_in_assembly manifest1_child_info
= {
729 1, app_manifest_path
,
730 L
"Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
734 static const info_in_assembly manifest2_info
= {
736 L
"Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
740 static const info_in_assembly manifest3_info
= {
742 L
"Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
746 static const info_in_assembly manifest4_info
= {
748 L
"Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
752 static const info_in_assembly depmanifest1_info
= {
753 0x10, depmanifest_path
,
754 L
"testdep,processorArchitecture=\"" ARCH
"\","
755 "type=\"win32\",version=\"6.5.4.3\"",
759 static const info_in_assembly depmanifest2_info
= {
760 0x10, depmanifest_path
,
761 L
"testdep,processorArchitecture=\"" ARCH
"\","
762 "type=\"win32\",version=\"6.5.4.3\"",
766 static const info_in_assembly depmanifest3_info
= {
767 0x10, depmanifest_path
,
768 L
"testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
772 static const info_in_assembly manifest_comctrl_info
= {
773 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
776 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
778 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
783 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
784 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
785 if (exinfo
->encoded_assembly_id
) exsize
+= (lstrlenW(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
788 b
= QueryActCtxW(0, handle
, &id
, AssemblyDetailedInformationInActivationContext
, &info_tmp
, sizeof(info_tmp
), &size
);
789 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
790 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
792 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
794 if (size
== 0xdeadbeef)
800 info
= HeapAlloc(GetProcessHeap(), 0, size
);
801 memset(info
, 0xfe, size
);
804 b
= QueryActCtxW(0, handle
, &id
, AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
805 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
806 if (!exinfo
->manifest_path
)
807 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
808 if (!exinfo
->encoded_assembly_id
)
809 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
810 if (exinfo
->has_assembly_dir
)
811 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
812 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
814 if (0) /* FIXME: flags meaning unknown */
816 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
817 info
->ulFlags
, exinfo
->flags
);
819 if(exinfo
->encoded_assembly_id
) {
820 len
= lstrlenW(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
821 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
822 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
823 info
->ulEncodedAssemblyIdentityLength
, len
);
825 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
826 "info->ulEncodedAssemblyIdentityLength == 0\n");
828 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
829 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
830 if(exinfo
->manifest_path
) {
831 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
832 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
833 info
->ulManifestPathLength
, len
);
835 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
838 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
839 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
840 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
841 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
842 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
843 info
->ulMetadataSatelliteRosterIndex
);
844 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
845 info
->ulManifestVersionMajor
);
846 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
847 info
->ulManifestVersionMinor
);
848 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
849 info
->ulPolicyVersionMajor
);
850 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
851 info
->ulPolicyVersionMinor
);
852 if(exinfo
->has_assembly_dir
)
853 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
854 "info->ulAssemblyDirectoryNameLength == 0\n");
856 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
857 "info->ulAssemblyDirectoryNameLength != 0\n");
859 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
860 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
861 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
862 ok_(__FILE__
, line
)(!lstrcmpW(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
863 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
864 wine_dbgstr_w(info
->lpAssemblyEncodedAssemblyIdentity
), wine_dbgstr_w(exinfo
->encoded_assembly_id
));
866 if(exinfo
->manifest_path
) {
867 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
868 if(info
->lpAssemblyManifestPath
)
869 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
870 "unexpected info->lpAssemblyManifestPath\n");
872 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
875 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
876 if(info
->lpAssemblyPolicyPath
)
877 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
878 if(exinfo
->has_assembly_dir
)
879 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
881 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
882 wine_dbgstr_w(info
->lpAssemblyDirectoryName
));
883 HeapFree(GetProcessHeap(), 0, info
);
886 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
888 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
889 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
893 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
894 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
897 b
= QueryActCtxW(0, handle
, &index
, FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
898 sizeof(info_tmp
), &size
);
899 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
900 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
901 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
903 if(size
== 0xdeadbeef)
909 info
= HeapAlloc(GetProcessHeap(), 0, size
);
910 memset(info
, 0xfe, size
);
912 b
= QueryActCtxW(0, handle
, &index
, FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
913 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
914 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
916 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
917 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
918 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
919 info
->ulFilenameLength
, lstrlenW(filename
));
920 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
921 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
923 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
924 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
925 HeapFree(GetProcessHeap(), 0, info
);
929 ACTCTX_REQUESTED_RUN_LEVEL run_level
;
933 static const runlevel_info_t runlevel_info0
= {
934 ACTCTX_RUN_LEVEL_UNSPECIFIED
, FALSE
,
937 static const runlevel_info_t runlevel_info6
= {
938 ACTCTX_RUN_LEVEL_AS_INVOKER
, FALSE
,
941 static const runlevel_info_t runlevel_info7
= {
942 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
945 static const runlevel_info_t runlevel_info8
= {
946 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
949 static const runlevel_info_t runlevel_info9
= {
950 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, FALSE
,
953 static void test_runlevel_info(HANDLE handle
, const runlevel_info_t
*exinfo
, int line
)
955 ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel_info
;
956 SIZE_T size
, retsize
;
959 size
= sizeof(runlevel_info
);
960 b
= QueryActCtxW(0, handle
, NULL
, RunlevelInformationInActivationContext
, &runlevel_info
,
961 sizeof(runlevel_info
), &retsize
);
962 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
964 win_skip("RunlevelInformationInActivationContext not supported.\n");
968 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
969 ok_(__FILE__
, line
)(retsize
== size
, "size=%ld, expected %ld\n", retsize
, size
);
971 ok_(__FILE__
, line
)(runlevel_info
.ulFlags
== 0, "runlevel_info.ulFlags=%x\n", runlevel_info
.ulFlags
);
972 ok_(__FILE__
, line
)(runlevel_info
.RunLevel
== exinfo
->run_level
,
973 "runlevel_info.RunLevel=%u, expected %u\n", runlevel_info
.RunLevel
, exinfo
->run_level
);
974 ok_(__FILE__
, line
)(runlevel_info
.UiAccess
== exinfo
->ui_access
,
975 "runlevel_info.UiAccess=%u, expected %u\n", runlevel_info
.UiAccess
, exinfo
->ui_access
);
978 static HANDLE
test_create(const char *file
)
982 WCHAR path
[MAX_PATH
];
984 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
985 memset(&actctx
, 0, sizeof(ACTCTXW
));
986 actctx
.cbSize
= sizeof(ACTCTXW
);
987 actctx
.lpSource
= path
;
989 handle
= CreateActCtxW(&actctx
);
990 /* to be tested outside of this helper, including last error */
991 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
993 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
994 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%d\n", actctx
.dwFlags
);
995 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
996 ok(actctx
.wProcessorArchitecture
== 0,
997 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
998 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
999 ok(actctx
.lpAssemblyDirectory
== NULL
,
1000 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
1001 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
1002 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
1003 actctx
.lpApplicationName
);
1004 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
1009 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
, BOOL is_broken
)
1013 WCHAR path
[MAX_PATH
];
1015 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
1016 memset(&actctx
, 0, sizeof(ACTCTXW
));
1017 actctx
.cbSize
= sizeof(ACTCTXW
);
1018 actctx
.lpSource
= path
;
1020 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
1021 handle
= CreateActCtxW(&actctx
);
1025 ok(broken(handle
!= INVALID_HANDLE_VALUE
) || handle
== INVALID_HANDLE_VALUE
,
1026 "Unexpected context handle %p.\n", handle
);
1028 ok(handle
== INVALID_HANDLE_VALUE
, "Unexpected context handle %p.\n", handle
);
1030 if (handle
== INVALID_HANDLE_VALUE
)
1031 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "Unexpected error %d.\n", GetLastError());
1033 if (handle
!= INVALID_HANDLE_VALUE
) ReleaseActCtx( handle
);
1034 DeleteFileA("bad.manifest");
1035 DeleteFileA("testdep.manifest");
1038 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
1042 WCHAR path
[MAX_PATH
];
1044 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
1045 memset(&actctx
, 0, sizeof(ACTCTXW
));
1046 actctx
.cbSize
= sizeof(ACTCTXW
);
1047 actctx
.lpSource
= path
;
1049 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
1050 handle
= CreateActCtxW(&actctx
);
1051 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
1052 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
1054 if (handle
!= INVALID_HANDLE_VALUE
) ReleaseActCtx( handle
);
1055 DeleteFileA("bad.manifest");
1058 static void test_create_fail(void)
1062 WCHAR path
[MAX_PATH
];
1064 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
1065 memset(&actctx
, 0, sizeof(ACTCTXW
));
1066 actctx
.cbSize
= sizeof(ACTCTXW
);
1067 actctx
.lpSource
= path
;
1069 handle
= CreateActCtxW(&actctx
);
1070 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
1071 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
1073 trace("wrong_manifest1\n");
1074 test_create_and_fail(wrong_manifest1
, NULL
, 0, FALSE
);
1075 trace("wrong_manifest2\n");
1076 test_create_and_fail(wrong_manifest2
, NULL
, 0, FALSE
);
1077 trace("wrong_manifest3\n");
1078 test_create_and_fail(wrong_manifest3
, NULL
, 1, FALSE
);
1079 trace("wrong_manifest4\n");
1080 test_create_and_fail(wrong_manifest4
, NULL
, 1, FALSE
);
1081 trace("wrong_manifest5\n");
1082 test_create_and_fail(wrong_manifest5
, NULL
, 0, FALSE
);
1083 trace("wrong_manifest6\n");
1084 test_create_and_fail(wrong_manifest6
, NULL
, 0, FALSE
);
1085 trace("wrong_manifest7\n");
1086 test_create_and_fail(wrong_manifest7
, NULL
, 1, FALSE
);
1087 trace("wrong_manifest8\n");
1088 test_create_and_fail(wrong_manifest8
, NULL
, 0, FALSE
);
1089 trace("wrong_manifest9\n");
1090 test_create_and_fail(wrong_manifest9
, NULL
, 0, TRUE
/* WinXP */);
1091 trace("wrong_manifest10\n");
1092 test_create_and_fail(wrong_manifest10
, NULL
, 0, TRUE
/* WinXP */);
1093 trace("UTF-16 manifest1 without BOM\n");
1094 test_create_wide_and_fail(manifest1
, FALSE
);
1095 trace("manifest2\n");
1096 test_create_and_fail(manifest2
, NULL
, 0, FALSE
);
1097 trace("manifest2+depmanifest1\n");
1098 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0, FALSE
);
1101 struct strsection_header
1109 ULONG global_offset
;
1123 struct guidsection_header
1143 struct wndclass_redirect_data
1148 ULONG name_offset
; /* versioned name offset */
1150 ULONG module_offset
;/* container name offset */
1153 struct dllredirect_data
1160 struct tlibredirect_data
1174 struct progidredirect_data
1181 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
1183 ACTCTX_SECTION_KEYED_DATA data
;
1186 memset(&data
, 0xfe, sizeof(data
));
1187 data
.cbSize
= sizeof(data
);
1189 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, libname
, &data
);
1190 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
1193 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1194 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1195 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1196 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
1200 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
1201 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
1202 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
1203 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
1204 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
1205 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
1208 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1209 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1210 data
.ulSectionGlobalDataLength
);
1211 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1212 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1213 data
.ulSectionTotalLength
);
1214 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1215 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1216 data
.ulAssemblyRosterIndex
, exid
);
1218 memset(&data
, 0xfe, sizeof(data
));
1219 data
.cbSize
= sizeof(data
);
1221 ret
= FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1222 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, libname
, &data
);
1223 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
1226 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1227 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1228 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1229 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
1230 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1231 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1232 data
.ulSectionGlobalDataLength
);
1233 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1234 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1235 data
.ulSectionTotalLength
);
1236 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1237 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1238 data
.ulAssemblyRosterIndex
, exid
);
1240 ReleaseActCtx(handle
);
1243 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
1245 struct wndclass_redirect_data
*wnddata
;
1246 struct strsection_header
*header
;
1247 ACTCTX_SECTION_KEYED_DATA data
;
1250 memset(&data
, 0xfe, sizeof(data
));
1251 data
.cbSize
= sizeof(data
);
1253 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, clsname
, &data
);
1254 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1255 wine_dbgstr_w(clsname
));
1258 header
= (struct strsection_header
*)data
.lpSectionBase
;
1259 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1261 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
1262 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
1263 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1264 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1265 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1266 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1267 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1269 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1274 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1275 /* redirect class name (versioned or not) is stored just after header data */
1276 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1277 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1279 /* expected versioned name */
1280 lstrcpyW(buff
, verW
);
1281 lstrcatW(buff
, clsname
);
1282 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1283 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1284 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1285 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1287 /* data length is simply header length + string data length including nulls */
1288 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1289 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1291 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1293 WCHAR
*modulename
, *sectionptr
;
1295 /* just compare pointers */
1296 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1297 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1298 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1302 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1303 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1304 data
.ulSectionGlobalDataLength
);
1305 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1306 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1307 data
.ulSectionTotalLength
);
1308 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1309 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1310 data
.ulAssemblyRosterIndex
, exid
);
1312 memset(&data
, 0xfe, sizeof(data
));
1313 data
.cbSize
= sizeof(data
);
1315 ret
= FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1316 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, clsname
, &data
);
1317 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1318 wine_dbgstr_w(clsname
));
1321 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1322 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1323 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1324 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1325 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1326 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1327 data
.ulSectionGlobalDataLength
);
1328 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1329 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1330 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1331 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1332 data
.ulAssemblyRosterIndex
, exid
);
1334 ReleaseActCtx(handle
);
1337 static void test_find_string_fail(void)
1339 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1342 ret
= FindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1343 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1344 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1346 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib2_dll
, &data
);
1347 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1348 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1350 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib_dll
, NULL
);
1351 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1352 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1354 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, NULL
, &data
);
1355 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1356 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1359 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib_dll
, &data
);
1360 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1361 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1364 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib_dll
, &data
);
1365 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1366 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1370 static void test_basic_info(HANDLE handle
, int line
)
1372 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1376 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, ActivationContextBasicInformation
, &basic
,
1377 sizeof(basic
), &size
);
1379 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1380 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1381 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1382 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1384 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
| QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1385 ActivationContextBasicInformation
, &basic
,
1386 sizeof(basic
), &size
);
1389 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1390 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1391 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1392 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1393 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1397 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1398 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1399 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1400 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1404 enum comclass_threadingmodel
{
1405 ThreadingModel_Apartment
= 1,
1406 ThreadingModel_Free
= 2,
1407 ThreadingModel_No
= 3,
1408 ThreadingModel_Both
= 4,
1409 ThreadingModel_Neutral
= 5
1412 enum comclass_miscfields
{
1415 MiscStatusContent
= 4,
1416 MiscStatusThumbnail
= 8,
1417 MiscStatusDocPrint
= 16
1420 struct comclassredirect_data
{
1431 ULONG progid_offset
;
1433 ULONG clrdata_offset
;
1435 DWORD miscstatuscontent
;
1436 DWORD miscstatusthumbnail
;
1437 DWORD miscstatusicon
;
1438 DWORD miscstatusdocprint
;
1441 struct clrclass_data
{
1445 ULONG module_offset
;
1449 ULONG version_offset
;
1453 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1455 struct comclassredirect_data
*comclass
, *comclass2
;
1456 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1457 struct guidsection_header
*header
;
1460 memset(&data
, 0xfe, sizeof(data
));
1461 data
.cbSize
= sizeof(data
);
1463 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
, clsid
, &data
);
1466 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1469 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1471 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1473 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1474 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1475 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1476 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1477 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1479 ULONG len
, miscmask
;
1482 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1483 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1484 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1486 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1487 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1491 len
= comclass
->size
+ comclass
->clrdata_len
;
1492 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1495 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1497 if (comclass
->progid_offset
)
1499 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1500 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1501 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1502 "got progid name length %d\n", comclass
->progid_len
);
1505 /* data length is simply header length + string data length including nulls */
1506 len
= comclass
->size
+ comclass
->clrdata_len
;
1507 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1508 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1510 /* keyed data structure doesn't include module name, it's available from section data */
1511 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1513 /* check misc fields are set */
1514 miscmask
= (comclass
->flags
>> 8) & 0xff;
1517 if (miscmask
& MiscStatus
)
1518 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1519 if (miscmask
& MiscStatusIcon
)
1520 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1521 if (miscmask
& MiscStatusContent
)
1522 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1523 if (miscmask
& MiscStatusThumbnail
)
1524 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1525 if (miscmask
& MiscStatusDocPrint
)
1526 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1528 ok_(__FILE__
, line
)(!(comclass
->flags
& 0xffff00ff), "Unexpected flags %#x.\n", comclass
->flags
);
1530 /* part used for clrClass only */
1531 if (comclass
->clrdata_len
)
1533 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1534 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1535 struct clrclass_data
*clrclass
;
1538 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1539 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1540 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1541 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1542 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1543 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1545 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1546 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1547 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1548 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1550 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1551 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1553 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1554 in lower case, clsclass subsection - in upper case */
1555 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1556 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1558 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1559 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1561 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1562 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1566 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1567 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1568 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1569 data
.ulSectionGlobalDataLength
);
1570 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1571 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1572 data
.ulSectionTotalLength
);
1573 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1574 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1575 data
.ulAssemblyRosterIndex
, exid
);
1577 /* generated guid for this class works as key guid in search */
1578 memset(&data2
, 0xfe, sizeof(data2
));
1579 data2
.cbSize
= sizeof(data2
);
1580 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
, &comclass
->alias
, &data2
);
1581 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1583 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1584 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1585 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1594 struct ifacepsredirect_data
1606 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1607 const GUID
*ps32
, ULONG exid
, int line
)
1609 struct ifacepsredirect_data
*ifaceps
;
1610 ACTCTX_SECTION_KEYED_DATA data
;
1613 memset(&data
, 0xfe, sizeof(data
));
1614 data
.cbSize
= sizeof(data
);
1616 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
, iid
, &data
);
1617 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1619 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1621 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1622 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1623 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1624 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1625 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1629 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1632 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1635 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1637 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1638 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1639 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1641 /* data length is simply header length + string data length including nulls */
1642 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1643 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1645 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1646 always has non-zero value for it */
1647 if (ifaceps
->mask
& NumMethods
)
1648 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1649 if (ifaceps
->mask
& BaseIface
)
1650 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1653 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1654 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1655 data
.ulSectionGlobalDataLength
);
1656 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1657 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1658 data
.ulSectionTotalLength
);
1659 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1660 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1661 data
.ulAssemblyRosterIndex
, exid
);
1664 struct clrsurrogate_data
1669 ULONG version_offset
;
1675 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1676 ULONG exid
, int line
)
1678 struct clrsurrogate_data
*surrogate
;
1679 ACTCTX_SECTION_KEYED_DATA data
;
1682 memset(&data
, 0xfe, sizeof(data
));
1683 data
.cbSize
= sizeof(data
);
1685 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
, clsid
, &data
);
1688 skip("surrogate sections are not supported\n");
1691 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1693 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1695 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1696 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1697 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1698 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1699 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1704 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1705 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1707 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1708 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1710 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1711 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1713 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1714 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1716 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1717 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1719 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1720 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1723 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1724 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1725 data
.ulSectionGlobalDataLength
);
1726 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1727 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1728 data
.ulSectionTotalLength
);
1729 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1730 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1731 data
.ulAssemblyRosterIndex
, exid
);
1734 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1736 struct progidredirect_data
*progiddata
;
1737 struct comclassredirect_data
*comclass
;
1738 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1739 struct strsection_header
*header
;
1742 memset(&data
, 0xfe, sizeof(data
));
1743 data
.cbSize
= sizeof(data
);
1745 ret
= FindActCtxSectionStringA(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
, progid
, &data
);
1746 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1748 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1750 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1751 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1752 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1753 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1754 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1758 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1759 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1761 /* progid data points to generated alias guid */
1762 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1764 memset(&data2
, 0, sizeof(data2
));
1765 data2
.cbSize
= sizeof(data2
);
1766 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
, guid
, &data2
);
1767 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1769 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1770 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1771 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1774 header
= (struct strsection_header
*)data
.lpSectionBase
;
1775 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1776 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1777 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1778 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1779 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1780 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1781 data
.ulAssemblyRosterIndex
, exid
);
1784 static void test_wndclass_section(void)
1786 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1787 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1788 struct wndclass_redirect_data
*classdata
;
1789 struct strsection_header
*section
;
1795 /* use two dependent manifests, each defines 2 window class redirects */
1796 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1797 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1798 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1800 handle
= test_create("main_wndcls.manifest");
1801 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1803 DeleteFileA("testdep1.manifest");
1804 DeleteFileA("testdep2.manifest");
1805 DeleteFileA("main_wndcls.manifest");
1807 ret
= ActivateActCtx(handle
, &cookie
);
1808 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1810 memset(&data
, 0, sizeof(data
));
1811 memset(&data2
, 0, sizeof(data2
));
1812 data
.cbSize
= sizeof(data
);
1813 data2
.cbSize
= sizeof(data2
);
1815 /* get data for two classes from different assemblies */
1816 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, wndClass1W
, &data
);
1817 ok(ret
, "got %d\n", ret
);
1818 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, wndClass3W
, &data2
);
1819 ok(ret
, "got %d\n", ret
);
1821 section
= (struct strsection_header
*)data
.lpSectionBase
;
1822 ok(section
->count
== 4, "got %d\n", section
->count
);
1823 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1825 /* For both string same section is returned, meaning it's one wndclass section per context */
1826 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1827 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1828 data2
.ulSectionTotalLength
);
1830 /* wndClass1 is versioned, wndClass3 is not */
1831 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1832 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1833 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1835 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1836 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1837 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1839 ret
= DeactivateActCtx(0, cookie
);
1840 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1842 ReleaseActCtx(handle
);
1845 static void test_dllredirect_section(void)
1847 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1848 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1849 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1850 struct strsection_header
*section
;
1855 /* use two dependent manifests, 4 'files' total */
1856 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1857 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1858 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1860 handle
= test_create("main_wndcls.manifest");
1861 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1863 DeleteFileA("testdep1.manifest");
1864 DeleteFileA("testdep2.manifest");
1865 DeleteFileA("main_wndcls.manifest");
1867 ret
= ActivateActCtx(handle
, &cookie
);
1868 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1870 memset(&data
, 0, sizeof(data
));
1871 memset(&data2
, 0, sizeof(data2
));
1872 data
.cbSize
= sizeof(data
);
1873 data2
.cbSize
= sizeof(data2
);
1875 /* get data for two files from different assemblies */
1876 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib1W
, &data
);
1877 ok(ret
, "got %d\n", ret
);
1878 ret
= FindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, testlib2W
, &data2
);
1879 ok(ret
, "got %d\n", ret
);
1881 section
= (struct strsection_header
*)data
.lpSectionBase
;
1882 ok(section
->count
== 4, "got %d\n", section
->count
);
1883 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1885 /* For both string same section is returned, meaning it's one dll redirect section per context */
1886 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1887 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1888 data2
.ulSectionTotalLength
);
1890 ret
= DeactivateActCtx(0, cookie
);
1891 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1893 ReleaseActCtx(handle
);
1896 static void test_typelib_section(void)
1898 static const WCHAR helpW
[] = {'h','e','l','p'};
1899 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1900 struct guidsection_header
*section
;
1901 struct tlibredirect_data
*tlib
;
1906 /* use two dependent manifests, 4 'files' total */
1907 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1908 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1909 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1911 handle
= test_create("main_wndcls.manifest");
1912 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1914 DeleteFileA("testdep1.manifest");
1915 DeleteFileA("testdep2.manifest");
1916 DeleteFileA("main_wndcls.manifest");
1918 ret
= ActivateActCtx(handle
, &cookie
);
1919 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1921 memset(&data
, 0, sizeof(data
));
1922 memset(&data2
, 0, sizeof(data2
));
1923 data
.cbSize
= sizeof(data
);
1924 data2
.cbSize
= sizeof(data2
);
1926 /* get data for two typelibs from different assemblies */
1927 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
, &IID_TlibTest
, &data
);
1928 ok(ret
, "got %d\n", ret
);
1930 ret
= FindActCtxSectionGuid(0, NULL
, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1931 &IID_TlibTest4
, &data2
);
1932 ok(ret
, "got %d\n", ret
);
1934 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1935 ok(section
->count
== 4, "got %d\n", section
->count
);
1936 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1938 /* For both GUIDs same section is returned */
1939 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1940 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1941 data2
.ulSectionTotalLength
);
1943 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1944 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1945 data
.ulSectionGlobalDataLength
);
1947 /* test some actual data */
1948 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1949 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1950 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1951 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1952 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1953 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1954 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1956 ret
= DeactivateActCtx(0, cookie
);
1957 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1959 ReleaseActCtx(handle
);
1962 static void test_allowDelayedBinding(void)
1966 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
1967 skip("Could not create manifest file\n");
1971 handle
= test_create("test5.manifest");
1972 if (handle
== INVALID_HANDLE_VALUE
) {
1973 win_skip("allowDelayedBinding attribute is not supported.\n");
1977 DeleteFileA("test5.manifest");
1978 DeleteFileA("testdep.manifest");
1979 if (handle
!= INVALID_HANDLE_VALUE
) {
1980 test_basic_info(handle
, __LINE__
);
1981 ReleaseActCtx(handle
);
1985 static void test_actctx(void)
1991 trace("default actctx\n");
1993 b
= GetCurrentActCtx(&handle
);
1994 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1995 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1997 test_basic_info(handle
, __LINE__
);
1998 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1999 test_runlevel_info(handle
, &runlevel_info0
, __LINE__
);
2000 ReleaseActCtx(handle
);
2003 /* test for whitespace handling in Eq ::= S? '=' S? */
2004 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
2005 handle
= test_create("test1_1.manifest");
2006 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2007 DeleteFileA("test1_1.manifest");
2008 ReleaseActCtx(handle
);
2010 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
2011 skip("Could not create manifest file\n");
2015 trace("manifest1\n");
2017 handle
= test_create("test1.manifest");
2018 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2019 DeleteFileA("test1.manifest");
2020 if(handle
!= INVALID_HANDLE_VALUE
) {
2021 test_basic_info(handle
, __LINE__
);
2022 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2023 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2025 if (!IsDebuggerPresent())
2027 /* CloseHandle will generate an exception if a debugger is present */
2028 b
= CloseHandle(handle
);
2029 ok(!b
, "CloseHandle succeeded\n");
2030 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
2033 ReleaseActCtx(handle
);
2036 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
2037 skip("Could not create manifest file\n");
2041 trace("manifest2 depmanifest1\n");
2043 handle
= test_create("test2.manifest");
2044 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2045 DeleteFileA("test2.manifest");
2046 DeleteFileA("testdep.manifest");
2047 if(handle
!= INVALID_HANDLE_VALUE
) {
2048 test_basic_info(handle
, __LINE__
);
2049 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2050 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2051 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
2052 ReleaseActCtx(handle
);
2055 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
2056 skip("Could not create manifest file\n");
2060 trace("manifest2 depmanifest2\n");
2062 handle
= test_create("test2-2.manifest");
2063 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2064 DeleteFileA("test2-2.manifest");
2065 DeleteFileA("testdep.manifest");
2066 if(handle
!= INVALID_HANDLE_VALUE
) {
2067 test_basic_info(handle
, __LINE__
);
2068 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2069 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2070 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
2071 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2072 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2074 b
= ActivateActCtx(handle
, &cookie
);
2075 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2076 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2077 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2078 b
= DeactivateActCtx(0, cookie
);
2079 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2081 ReleaseActCtx(handle
);
2084 trace("manifest2 depmanifest3\n");
2086 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
2087 skip("Could not create manifest file\n");
2091 handle
= test_create("test2-3.manifest");
2092 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2093 DeleteFileA("test2-3.manifest");
2094 DeleteFileA("testdep.manifest");
2095 if(handle
!= INVALID_HANDLE_VALUE
) {
2096 test_basic_info(handle
, __LINE__
);
2097 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2098 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2099 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
2100 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2101 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2103 b
= ActivateActCtx(handle
, &cookie
);
2104 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2105 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2106 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2107 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
2108 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
2109 b
= DeactivateActCtx(0, cookie
);
2110 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2112 ReleaseActCtx(handle
);
2115 trace("manifest3\n");
2117 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
2118 skip("Could not create manifest file\n");
2122 handle
= test_create("test3.manifest");
2123 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
2124 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2125 if (handle
== INVALID_HANDLE_VALUE
)
2126 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
2127 DeleteFileA("test3.manifest");
2128 if(handle
!= INVALID_HANDLE_VALUE
) {
2129 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
2130 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
2131 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
2132 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
2134 test_basic_info(handle
, __LINE__
);
2135 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2136 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
2137 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
2139 b
= ActivateActCtx(handle
, &cookie
);
2140 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2141 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2142 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2143 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
2144 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
2145 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
2146 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
2147 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
2148 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
2149 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
2150 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
2151 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
2152 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
2153 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
2154 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
2155 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
2156 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
2157 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
2158 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
2159 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
2160 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
2161 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
2162 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
2163 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
2164 test_find_string_fail();
2166 b
= DeactivateActCtx(0, cookie
);
2167 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2168 ReleaseActCtx(handle
);
2171 trace("manifest6\n");
2173 if(create_manifest_file("test6.manifest", manifest6
, -1, NULL
, NULL
)) {
2174 handle
= test_create("test6.manifest");
2175 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* WinXP */,
2176 "Unexpected context handle %p.\n", handle
);
2177 DeleteFileA("test6.manifest");
2178 DeleteFileA("testdep.manifest");
2179 if(handle
!= INVALID_HANDLE_VALUE
)
2181 test_runlevel_info(handle
, &runlevel_info6
, __LINE__
);
2182 ReleaseActCtx(handle
);
2186 skip("Could not create manifest file 6\n");
2188 trace("manifest7\n");
2190 if(create_manifest_file("test7.manifest", manifest7
, -1, NULL
, NULL
)) {
2191 handle
= test_create("test7.manifest");
2192 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2193 DeleteFileA("test7.manifest");
2194 DeleteFileA("testdep.manifest");
2195 if(handle
!= INVALID_HANDLE_VALUE
)
2197 test_runlevel_info(handle
, &runlevel_info7
, __LINE__
);
2198 ReleaseActCtx(handle
);
2202 skip("Could not create manifest file 7\n");
2204 trace("manifest8\n");
2206 if(create_manifest_file("test8.manifest", manifest8
, -1, NULL
, NULL
)) {
2207 handle
= test_create("test8.manifest");
2208 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2209 DeleteFileA("test8.manifest");
2210 DeleteFileA("testdep.manifest");
2211 if(handle
!= INVALID_HANDLE_VALUE
)
2213 test_runlevel_info(handle
, &runlevel_info8
, __LINE__
);
2214 ReleaseActCtx(handle
);
2218 skip("Could not create manifest file 8\n");
2220 trace("manifest9\n");
2222 if(create_manifest_file("test9.manifest", manifest9
, -1, NULL
, NULL
)) {
2223 handle
= test_create("test9.manifest");
2224 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2225 DeleteFileA("test9.manifest");
2226 DeleteFileA("testdep.manifest");
2227 if(handle
!= INVALID_HANDLE_VALUE
)
2229 test_runlevel_info(handle
, &runlevel_info9
, __LINE__
);
2230 ReleaseActCtx(handle
);
2234 skip("Could not create manifest file 9\n");
2236 if(create_manifest_file("test10.manifest", manifest10
, -1, NULL
, NULL
)) {
2237 handle
= test_create("test10.manifest");
2238 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2239 DeleteFileA("test10.manifest");
2240 DeleteFileA("testdep.manifest");
2241 if(handle
!= INVALID_HANDLE_VALUE
)
2243 test_runlevel_info(handle
, &runlevel_info8
, __LINE__
);
2244 ReleaseActCtx(handle
);
2248 skip("Could not create manifest file 10\n");
2250 if (create_manifest_file("test11.manifest", manifest11
, -1, NULL
, NULL
))
2252 handle
= test_create("test11.manifest");
2253 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to create activation context for %s, error %u\n",
2254 "manifest11", GetLastError());
2255 DeleteFileA("test11.manifest");
2256 if (handle
!= INVALID_HANDLE_VALUE
)
2257 ReleaseActCtx(handle
);
2260 skip("Could not create manifest file 11\n");
2262 trace("manifest4\n");
2264 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
2265 skip("Could not create manifest file\n");
2269 handle
= test_create("test4.manifest");
2270 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2271 DeleteFileA("test4.manifest");
2272 DeleteFileA("testdep.manifest");
2273 if(handle
!= INVALID_HANDLE_VALUE
) {
2274 test_basic_info(handle
, __LINE__
);
2275 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2276 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
2277 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
2278 ReleaseActCtx(handle
);
2281 trace("manifest1 in subdir\n");
2283 CreateDirectoryW(work_dir_subdir
, NULL
);
2284 if (SetCurrentDirectoryW(work_dir_subdir
))
2286 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
2287 skip("Could not create manifest file\n");
2290 handle
= test_create("..\\test1.manifest");
2291 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2292 DeleteFileA("..\\test1.manifest");
2293 if(handle
!= INVALID_HANDLE_VALUE
) {
2294 test_basic_info(handle
, __LINE__
);
2295 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2296 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2297 ReleaseActCtx(handle
);
2299 SetCurrentDirectoryW(work_dir
);
2302 skip("Couldn't change directory\n");
2303 RemoveDirectoryW(work_dir_subdir
);
2305 trace("UTF-16 manifest1, with BOM\n");
2306 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
2307 skip("Could not create manifest file\n");
2311 handle
= test_create("test1.manifest");
2312 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2313 DeleteFileA("test1.manifest");
2314 if (handle
!= INVALID_HANDLE_VALUE
) {
2315 test_basic_info(handle
, __LINE__
);
2316 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2317 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2318 ReleaseActCtx(handle
);
2321 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2322 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
2323 skip("Could not create manifest file\n");
2327 handle
= test_create("test1.manifest");
2328 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2329 DeleteFileA("test1.manifest");
2330 if (handle
!= INVALID_HANDLE_VALUE
) {
2331 test_basic_info(handle
, __LINE__
);
2332 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2333 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2334 ReleaseActCtx(handle
);
2337 test_wndclass_section();
2338 test_dllredirect_section();
2339 test_typelib_section();
2340 test_allowDelayedBinding();
2343 static void test_app_manifest(void)
2348 trace("child process manifest1\n");
2350 b
= GetCurrentActCtx(&handle
);
2351 ok(handle
== NULL
, "handle != NULL\n");
2352 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2354 test_basic_info(handle
, __LINE__
);
2355 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2356 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2357 ReleaseActCtx(handle
);
2361 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2364 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2366 handle
= test_create(filename
);
2367 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2368 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2370 DeleteFileA(filename
);
2374 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2376 UNICODE_STRING string_to_findW
;
2377 ACTCTX_SECTION_KEYED_DATA data
;
2381 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2383 memset(&data
, 0xfe, sizeof(data
));
2384 data
.cbSize
= sizeof(data
);
2387 ret
= FindActCtxSectionStringA(0, NULL
, section
, string_to_find
, &data
);
2388 err
= GetLastError();
2389 ok_(__FILE__
, line
)(ret
== should_find
,
2390 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find
, ret
);
2392 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2393 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2395 memset(&data
, 0xfe, sizeof(data
));
2396 data
.cbSize
= sizeof(data
);
2399 ret
= FindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2400 err
= GetLastError();
2401 ok_(__FILE__
, line
)(ret
== should_find
,
2402 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2404 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2405 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2408 ret
= FindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2409 err
= GetLastError();
2410 ok_(__FILE__
, line
)(!ret
,
2411 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2412 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2413 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2416 ret
= FindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2417 err
= GetLastError();
2418 ok_(__FILE__
, line
)(!ret
,
2419 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2420 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2421 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2423 pRtlFreeUnicodeString(&string_to_findW
);
2426 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2428 UNICODE_STRING string_to_findW
;
2429 ACTCTX_SECTION_KEYED_DATA data
;
2432 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2434 memset(&data
, 0xfe, sizeof(data
));
2435 data
.cbSize
= sizeof(data
);
2437 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2439 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2440 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2442 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2444 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2445 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2447 pRtlFreeUnicodeString(&string_to_findW
);
2450 static void test_findsectionstring(void)
2456 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2457 ret
= ActivateActCtx(handle
, &cookie
);
2458 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2460 /* first we show the parameter validation from kernel32 */
2461 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2462 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2463 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2464 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2465 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2466 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2467 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2469 /* then we show that ntdll plays by different rules */
2470 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2471 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2472 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2473 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2474 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2475 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2476 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2478 ret
= DeactivateActCtx(0, cookie
);
2479 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2480 ReleaseActCtx(handle
);
2483 static void run_child_process(void)
2485 char cmdline
[MAX_PATH
];
2486 char path
[MAX_PATH
];
2488 PROCESS_INFORMATION pi
;
2489 STARTUPINFOA si
= { 0 };
2494 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2495 strcat(path
, ".manifest");
2496 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2497 skip("Could not create manifest file\n");
2502 winetest_get_mainargs( &argv
);
2503 /* Vista+ seems to cache presence of .manifest files. Change last modified
2504 date to defeat the cache */
2505 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2506 NULL
, OPEN_EXISTING
, 0, NULL
);
2507 if (file
!= INVALID_HANDLE_VALUE
) {
2508 GetSystemTimeAsFileTime(&now
);
2509 SetFileTime(file
, NULL
, NULL
, &now
);
2512 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2513 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2514 ok(ret
, "Could not create process: %u\n", GetLastError());
2515 wait_child_process( pi
.hProcess
);
2516 CloseHandle(pi
.hThread
);
2517 CloseHandle(pi
.hProcess
);
2521 static void init_paths(void)
2525 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2526 static const WCHAR backslash
[] = {'\\',0};
2527 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2529 GetModuleFileNameW(NULL
, exe_path
, ARRAY_SIZE(exe_path
));
2530 lstrcpyW(app_dir
, exe_path
);
2531 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2534 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2535 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2536 if (*ptr
!= '\\' && *ptr
!= '/')
2537 lstrcatW(work_dir
, backslash
);
2538 lstrcpyW(work_dir_subdir
, work_dir
);
2539 lstrcatW(work_dir_subdir
, subdir
);
2541 GetModuleFileNameW(NULL
, app_manifest_path
, ARRAY_SIZE(app_manifest_path
));
2542 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2545 static void write_manifest(const char *filename
, const char *manifest
)
2549 CHAR path
[MAX_PATH
];
2551 GetTempPathA(ARRAY_SIZE(path
), path
);
2552 strcat(path
, filename
);
2554 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2555 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2556 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2560 static void delete_manifest_file(const char *filename
)
2562 CHAR path
[MAX_PATH
];
2564 GetTempPathA(ARRAY_SIZE(path
), path
);
2565 strcat(path
, filename
);
2569 static void extract_resource(const char *name
, const char *type
, const char *path
)
2576 file
= CreateFileA(path
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
2577 ok(file
!= INVALID_HANDLE_VALUE
, "file creation failed, at %s, error %d\n", path
, GetLastError());
2579 res
= FindResourceA(NULL
, name
, type
);
2580 ok( res
!= 0, "couldn't find resource\n" );
2581 ptr
= LockResource( LoadResource( GetModuleHandleA(NULL
), res
));
2582 WriteFile( file
, ptr
, SizeofResource( GetModuleHandleA(NULL
), res
), &written
, NULL
);
2583 ok( written
== SizeofResource( GetModuleHandleA(NULL
), res
), "couldn't write resource\n" );
2584 CloseHandle( file
);
2587 static void test_CreateActCtx(void)
2589 CHAR path
[MAX_PATH
], dir
[MAX_PATH
], dll
[MAX_PATH
];
2593 GetTempPathA(ARRAY_SIZE(path
), path
);
2594 strcat(path
, "main_wndcls.manifest");
2596 write_manifest("testdep1.manifest", manifest_wndcls1
);
2597 write_manifest("testdep2.manifest", manifest_wndcls2
);
2598 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2600 memset(&actctx
, 0, sizeof(ACTCTXA
));
2601 actctx
.cbSize
= sizeof(ACTCTXA
);
2602 actctx
.lpSource
= path
;
2604 /* create using lpSource without specified directory */
2605 handle
= CreateActCtxA(&actctx
);
2606 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2607 ReleaseActCtx(handle
);
2609 /* with specified directory, that doesn't contain dependent assembly */
2610 GetWindowsDirectoryA(dir
, ARRAY_SIZE(dir
));
2612 memset(&actctx
, 0, sizeof(ACTCTXA
));
2613 actctx
.cbSize
= sizeof(ACTCTXA
);
2614 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2615 actctx
.lpAssemblyDirectory
= dir
;
2616 actctx
.lpSource
= path
;
2618 SetLastError(0xdeadbeef);
2619 handle
= CreateActCtxA(&actctx
);
2621 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2622 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2624 if (handle
!= INVALID_HANDLE_VALUE
) ReleaseActCtx(handle
);
2626 /* with specified directory, that does contain dependent assembly */
2627 GetTempPathA(ARRAY_SIZE(dir
), dir
);
2628 actctx
.lpAssemblyDirectory
= dir
;
2629 handle
= CreateActCtxA(&actctx
);
2630 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2631 ReleaseActCtx(handle
);
2633 /* Should still work if we add a dll with the same name, but without manifest */
2635 strcat(dll
, "testdep1.dll");
2636 extract_resource("dummy.dll", "TESTDLL", dll
);
2637 handle
= CreateActCtxA(&actctx
);
2638 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
) , "got error %d\n", GetLastError());
2639 ReleaseActCtx(handle
);
2642 delete_manifest_file("main_wndcls.manifest");
2643 delete_manifest_file("testdep1.manifest");
2644 delete_manifest_file("testdep2.manifest");
2646 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2647 memset(&actctx
, 0, sizeof(ACTCTXA
));
2648 actctx
.cbSize
= sizeof(ACTCTXA
);
2649 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2650 SetLastError(0xdeadbeef);
2651 handle
= CreateActCtxA(&actctx
);
2652 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2654 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2655 "got error %d\n", GetLastError());
2657 /* create from HMODULE - resource doesn't exist, lpSource is set */
2658 memset(&actctx
, 0, sizeof(ACTCTXA
));
2659 actctx
.cbSize
= sizeof(ACTCTXA
);
2660 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2661 actctx
.lpSource
= "dummyfile.dll";
2662 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2663 actctx
.hModule
= GetModuleHandleA(NULL
);
2665 SetLastError(0xdeadbeef);
2666 handle
= CreateActCtxA(&actctx
);
2667 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2668 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2670 /* load manifest from lpAssemblyDirectory directory */
2671 write_manifest("testdir.manifest", manifest1
);
2672 GetTempPathA(ARRAY_SIZE(path
), path
);
2673 SetCurrentDirectoryA(path
);
2674 strcat(path
, "assembly_dir");
2676 strcat(path
, "\\testdir.manifest");
2678 memset(&actctx
, 0, sizeof(actctx
));
2679 actctx
.cbSize
= sizeof(actctx
);
2680 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2681 actctx
.lpSource
= "testdir.manifest";
2682 actctx
.lpAssemblyDirectory
= dir
;
2684 SetLastError(0xdeadbeef);
2685 handle
= CreateActCtxA(&actctx
);
2686 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2687 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2688 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2689 "got error %d\n", GetLastError());
2691 CreateDirectoryA(dir
, NULL
);
2692 memset(&actctx
, 0, sizeof(actctx
));
2693 actctx
.cbSize
= sizeof(actctx
);
2694 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2695 actctx
.lpSource
= "testdir.manifest";
2696 actctx
.lpAssemblyDirectory
= dir
;
2698 SetLastError(0xdeadbeef);
2699 handle
= CreateActCtxA(&actctx
);
2700 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2701 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %d\n", GetLastError());
2702 SetCurrentDirectoryW(work_dir
);
2704 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
2705 memset(&actctx
, 0, sizeof(actctx
));
2706 actctx
.cbSize
= sizeof(actctx
);
2707 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2708 actctx
.lpSource
= "testdir.manifest";
2709 actctx
.lpAssemblyDirectory
= dir
;
2711 handle
= CreateActCtxA(&actctx
);
2712 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2713 ReleaseActCtx(handle
);
2715 memset(&actctx
, 0, sizeof(actctx
));
2716 actctx
.cbSize
= sizeof(actctx
);
2717 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2718 actctx
.lpSource
= path
;
2719 actctx
.lpAssemblyDirectory
= dir
;
2721 handle
= CreateActCtxA(&actctx
);
2722 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2723 ReleaseActCtx(handle
);
2725 delete_manifest_file("testdir.manifest");
2726 delete_manifest_file("assembly_dir\\testdir.manifest");
2727 RemoveDirectoryA(dir
);
2730 static BOOL
init_funcs(void)
2732 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
2734 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2735 pQueryActCtxSettingsW
= (void *)GetProcAddress( hLibrary
, "QueryActCtxSettingsW" );
2737 hLibrary
= GetModuleHandleA("ntdll.dll");
2738 X(RtlFindActivationContextSectionString
);
2739 X(RtlCreateUnicodeStringFromAsciiz
);
2740 X(RtlFreeUnicodeString
);
2746 static void test_ZombifyActCtx(void)
2748 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
2750 HANDLE handle
, current
;
2753 SetLastError(0xdeadbeef);
2754 ret
= ZombifyActCtx(NULL
);
2756 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "got %d, error %d\n", ret
, GetLastError());
2758 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2760 ret
= GetCurrentActCtx(¤t
);
2761 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2762 ok(current
== NULL
, "got %p\n", current
);
2764 ret
= ActivateActCtx(handle
, &cookie
);
2765 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2767 ret
= GetCurrentActCtx(¤t
);
2768 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2769 ok(handle
== current
, "got %p, %p\n", current
, handle
);
2771 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2772 ret
= QueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
, &basicinfo
, sizeof(basicinfo
), NULL
);
2773 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2774 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2775 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2777 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2778 ret
= QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2779 &basicinfo
, sizeof(basicinfo
), NULL
);
2780 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2781 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2782 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2784 ret
= ZombifyActCtx(handle
);
2786 ok(ret
, "got %d\n", ret
);
2788 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2789 ret
= QueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
, &basicinfo
, sizeof(basicinfo
), NULL
);
2790 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2791 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2792 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2794 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2795 ret
= QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2796 &basicinfo
, sizeof(basicinfo
), NULL
);
2797 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2798 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2799 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2801 ret
= GetCurrentActCtx(¤t
);
2802 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2803 ok(current
== handle
, "got %p\n", current
);
2806 ret
= ZombifyActCtx(handle
);
2808 ok(ret
, "got %d\n", ret
);
2810 ret
= DeactivateActCtx(0, cookie
);
2811 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2812 ReleaseActCtx(handle
);
2815 /* Test structure to verify alignment */
2816 typedef struct _test_act_ctx_compat_info
{
2818 COMPATIBILITY_CONTEXT_ELEMENT Elements
[10];
2819 } test_act_ctx_compat_info
;
2821 static void test_no_compat(HANDLE handle
, int line
)
2823 test_act_ctx_compat_info compat_info
;
2827 memset(&compat_info
, 0, sizeof(compat_info
));
2828 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, CompatibilityInformationInActivationContext
,
2829 &compat_info
, sizeof(compat_info
), &size
);
2831 ok_(__FILE__
, line
)(b
, "CompatibilityInformationInActivationContext failed\n");
2832 ok_(__FILE__
, line
)(size
== sizeof(DWORD
), "size mismatch (got %lu, expected 4)\n", size
);
2833 ok_(__FILE__
, line
)(compat_info
.ElementCount
== 0, "unexpected ElementCount %u\n", compat_info
.ElementCount
);
2836 static void test_with_compat(HANDLE handle
, DWORD num_compat
, const GUID
* expected_compat
[], int line
)
2838 test_act_ctx_compat_info compat_info
;
2840 SIZE_T expected
= sizeof(COMPATIBILITY_CONTEXT_ELEMENT
) * num_compat
+ sizeof(DWORD
);
2844 memset(&compat_info
, 0, sizeof(compat_info
));
2845 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, CompatibilityInformationInActivationContext
,
2846 &compat_info
, sizeof(compat_info
), &size
);
2848 ok_(__FILE__
, line
)(b
, "CompatibilityInformationInActivationContext failed\n");
2849 ok_(__FILE__
, line
)(size
== expected
, "size mismatch (got %lu, expected %lu)\n", size
, expected
);
2850 ok_(__FILE__
, line
)(compat_info
.ElementCount
== num_compat
, "unexpected ElementCount %u\n", compat_info
.ElementCount
);
2852 for (n
= 0; n
< num_compat
; ++n
)
2854 ok_(__FILE__
, line
)(IsEqualGUID(&compat_info
.Elements
[n
].Id
, expected_compat
[n
]),
2855 "got wrong clsid %s, expected %s for %u\n",
2856 wine_dbgstr_guid(&compat_info
.Elements
[n
].Id
),
2857 wine_dbgstr_guid(expected_compat
[n
]),
2859 ok_(__FILE__
, line
)(compat_info
.Elements
[n
].Type
== ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
2860 "Wrong type, got %u for %u\n", (DWORD
)compat_info
.Elements
[n
].Type
, n
);
2864 static void test_compatibility(void)
2868 /* No compat results returned */
2869 trace("manifest1\n");
2870 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
))
2872 skip("Could not create manifest file\n");
2875 handle
= test_create("test1.manifest");
2876 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2877 DeleteFileA("test1.manifest");
2878 if(handle
!= INVALID_HANDLE_VALUE
)
2880 char buffer
[sizeof(COMPATIBILITY_CONTEXT_ELEMENT
) * 2 + sizeof(DWORD
)];
2884 memset(buffer
, 0, sizeof(buffer
));
2885 b
= QueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
, CompatibilityInformationInActivationContext
,
2886 buffer
, sizeof(buffer
), &size
);
2888 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
2890 win_skip("CompatibilityInformationInActivationContext not supported.\n");
2891 ReleaseActCtx(handle
);
2895 test_basic_info(handle
, __LINE__
);
2896 test_no_compat(handle
, __LINE__
);
2897 ReleaseActCtx(handle
);
2900 /* Still no compat results returned */
2901 trace("no_supportedOs\n");
2902 if(!create_manifest_file("no_supportedOs.manifest", compat_manifest_no_supportedOs
, -1, NULL
, NULL
))
2904 skip("Could not create manifest file\n");
2907 handle
= test_create("no_supportedOs.manifest");
2908 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2909 DeleteFileA("no_supportedOs.manifest");
2910 if(handle
!= INVALID_HANDLE_VALUE
)
2912 test_basic_info(handle
, __LINE__
);
2913 test_no_compat(handle
, __LINE__
);
2914 ReleaseActCtx(handle
);
2917 /* Just one result returned */
2918 trace("manifest_vista\n");
2919 if(!create_manifest_file("manifest_vista.manifest", compat_manifest_vista
, -1, NULL
, NULL
))
2921 skip("Could not create manifest file\n");
2924 handle
= test_create("manifest_vista.manifest");
2925 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2926 DeleteFileA("manifest_vista.manifest");
2927 if(handle
!= INVALID_HANDLE_VALUE
)
2929 static const GUID
* expect_manifest
[] =
2933 test_basic_info(handle
, __LINE__
);
2934 test_with_compat(handle
, 1, expect_manifest
, __LINE__
);
2935 ReleaseActCtx(handle
);
2938 /* Show that the order is retained */
2939 trace("manifest_vista_7_8_10_81\n");
2940 if(!create_manifest_file("manifest_vista_7_8_10_81.manifest", compat_manifest_vista_7_8_10_81
, -1, NULL
, NULL
))
2942 skip("Could not create manifest file\n");
2945 handle
= test_create("manifest_vista_7_8_10_81.manifest");
2946 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2947 DeleteFileA("manifest_vista_7_8_10_81.manifest");
2948 if(handle
!= INVALID_HANDLE_VALUE
)
2950 static const GUID
* expect_manifest
[] =
2958 test_basic_info(handle
, __LINE__
);
2959 test_with_compat(handle
, 5, expect_manifest
, __LINE__
);
2960 ReleaseActCtx(handle
);
2963 /* Show that even unknown GUID's are stored */
2964 trace("manifest_other_guid\n");
2965 if(!create_manifest_file("manifest_other_guid.manifest", compat_manifest_other_guid
, -1, NULL
, NULL
))
2967 skip("Could not create manifest file\n");
2970 handle
= test_create("manifest_other_guid.manifest");
2971 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2972 DeleteFileA("manifest_other_guid.manifest");
2973 if(handle
!= INVALID_HANDLE_VALUE
)
2975 static const GUID
* expect_manifest
[] =
2979 test_basic_info(handle
, __LINE__
);
2980 test_with_compat(handle
, 1, expect_manifest
, __LINE__
);
2981 ReleaseActCtx(handle
);
2985 static void test_settings(void)
2987 static const WCHAR dpiAwareW
[] = {'d','p','i','A','w','a','r','e',0};
2988 static const WCHAR dpiAwarenessW
[] = {'d','p','i','A','w','a','r','e','n','e','s','s',0};
2989 static const WCHAR dummyW
[] = {'d','u','m','m','y',0};
2990 static const WCHAR trueW
[] = {'t','r','u','e',0};
2991 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};
2992 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};
2998 if (!pQueryActCtxSettingsW
)
3000 win_skip( "QueryActCtxSettingsW is missing\n" );
3003 create_manifest_file( "manifest_settings.manifest", settings_manifest
, -1, NULL
, NULL
);
3004 handle
= test_create("manifest_settings.manifest");
3005 ok( handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError() );
3006 DeleteFileA( "manifest_settings.manifest" );
3008 SetLastError( 0xdeadbeef );
3009 ret
= pQueryActCtxSettingsW( 1, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3010 ok( !ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3011 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
3012 SetLastError( 0xdeadbeef );
3013 ret
= pQueryActCtxSettingsW( 0, handle
, dummyW
, dpiAwareW
, buffer
, 80, &size
);
3014 ok( !ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3015 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
3016 SetLastError( 0xdeadbeef );
3018 memset( buffer
, 0xcc, sizeof(buffer
) );
3019 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3020 ok( ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3021 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3022 ok( size
== lstrlenW( buffer
) + 1, "wrong len %lu\n", size
);
3023 SetLastError( 0xdeadbeef );
3025 memset( buffer
, 0xcc, sizeof(buffer
) );
3026 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dummyW
, buffer
, 80, &size
);
3027 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3028 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %u\n", GetLastError() );
3029 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3030 SetLastError( 0xdeadbeef );
3032 memset( buffer
, 0xcc, sizeof(buffer
) );
3033 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2005W
, dpiAwareW
, buffer
, 80, &size
);
3034 ok( ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3035 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3036 ok( size
== ARRAY_SIZE(trueW
), "wrong len %lu\n", size
);
3037 SetLastError( 0xdeadbeef );
3039 memset( buffer
, 0xcc, sizeof(buffer
) );
3040 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2005W
, dpiAwareW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3041 ok( ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3042 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3043 ok( size
== ARRAY_SIZE(trueW
), "wrong len %lu\n", size
);
3044 SetLastError( 0xdeadbeef );
3046 memset( buffer
, 0xcc, sizeof(buffer
) );
3047 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2016W
, dpiAwareW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3048 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3049 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
|| broken( GetLastError() == ERROR_INVALID_PARAMETER
),
3050 "wrong error %u\n", GetLastError() );
3051 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3052 SetLastError( 0xdeadbeef );
3054 memset( buffer
, 0xcc, sizeof(buffer
) );
3055 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwarenessW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3056 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3057 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %u\n", GetLastError() );
3058 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3059 SetLastError( 0xdeadbeef );
3061 memset( buffer
, 0xcc, sizeof(buffer
) );
3062 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2005W
, dpiAwarenessW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3063 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3064 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %u\n", GetLastError() );
3065 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3066 SetLastError( 0xdeadbeef );
3068 memset( buffer
, 0xcc, sizeof(buffer
) );
3069 ret
= pQueryActCtxSettingsW( 0, handle
, namespace2016W
, dpiAwarenessW
, buffer
, lstrlenW(trueW
) + 1, &size
);
3070 ok( ret
|| broken( GetLastError() == ERROR_INVALID_PARAMETER
),
3071 "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3074 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3075 ok( size
== ARRAY_SIZE(trueW
), "wrong len %lu\n", size
);
3077 else ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3078 SetLastError( 0xdeadbeef );
3080 memset( buffer
, 0xcc, sizeof(buffer
) );
3081 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, lstrlenW(trueW
), &size
);
3082 ok( ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3083 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3084 ok( size
== ARRAY_SIZE(trueW
), "wrong len %lu\n", size
);
3085 SetLastError( 0xdeadbeef );
3087 memset( buffer
, 0xcc, sizeof(buffer
) );
3088 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, lstrlenW(trueW
) - 1, &size
);
3089 ok( !ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3090 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "wrong error %u\n", GetLastError() );
3091 ok( buffer
[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer
) );
3092 ok( size
== ARRAY_SIZE(trueW
), "wrong len %lu\n", size
);
3093 ReleaseActCtx(handle
);
3095 create_manifest_file( "manifest_settings2.manifest", settings_manifest2
, -1, NULL
, NULL
);
3096 handle
= test_create("manifest_settings2.manifest");
3097 ok( handle
!= INVALID_HANDLE_VALUE
|| broken( handle
== INVALID_HANDLE_VALUE
), /* <= vista */
3098 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError() );
3099 DeleteFileA( "manifest_settings2.manifest" );
3100 if (handle
!= INVALID_HANDLE_VALUE
)
3102 SetLastError( 0xdeadbeef );
3104 memset( buffer
, 0xcc, sizeof(buffer
) );
3105 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3106 ok( ret
, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
3107 ok( !lstrcmpW( buffer
, trueW
), "got %s\n", wine_dbgstr_w(buffer
) );
3108 ok( size
== lstrlenW( buffer
) + 1, "wrong len %lu\n", size
);
3109 ReleaseActCtx(handle
);
3112 create_manifest_file( "manifest_settings3.manifest", settings_manifest3
, -1, NULL
, NULL
);
3113 handle
= test_create("manifest_settings3.manifest");
3114 ok( handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError() );
3115 DeleteFileA( "manifest_settings3.manifest" );
3116 SetLastError( 0xdeadbeef );
3118 memset( buffer
, 0xcc, sizeof(buffer
) );
3119 ret
= pQueryActCtxSettingsW( 0, handle
, NULL
, dpiAwareW
, buffer
, 80, &size
);
3120 ok( !ret
, "QueryActCtxSettingsW succeeded\n" );
3121 ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "wrong error %u\n", GetLastError() );
3122 ReleaseActCtx(handle
);
3127 char path_tmp
[MAX_PATH
];
3128 char path_dll
[MAX_PATH
+ 11];
3129 char path_manifest_exe
[MAX_PATH
+ 12];
3130 char path_manifest_dll
[MAX_PATH
+ 16];
3133 HANDLE handle_context
;
3135 void (WINAPI
*get_path
)(char *buffer
, int buffer_size
);
3138 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
)
3142 GetTempPathA(MAX_PATH
, info
->path_tmp
);
3143 strcat(info
->path_tmp
, temp
);
3144 strcat(info
->path_tmp
, "\\");
3145 CreateDirectoryA(info
->path_tmp
, NULL
);
3147 sprintf(info
->path_dll
, "%s%s", info
->path_tmp
, "sxs_dll.dll");
3148 extract_resource(path_dll
, "TESTDLL", info
->path_dll
);
3150 sprintf(info
->path_manifest_exe
, "%s%s", info
->path_tmp
, "exe.manifest");
3151 create_manifest_file(info
->path_manifest_exe
, exe_manifest
, -1, NULL
, NULL
);
3153 sprintf(info
->path_manifest_dll
, "%s%s", info
->path_tmp
, "sxs_dll.manifest");
3154 create_manifest_file(info
->path_manifest_dll
, dll_manifest
, -1, NULL
, NULL
);
3156 info
->context
.cbSize
= sizeof(ACTCTXA
);
3157 info
->context
.lpSource
= info
->path_manifest_exe
;
3158 info
->context
.lpAssemblyDirectory
= info
->path_tmp
;
3159 info
->context
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3161 info
->handle_context
= CreateActCtxA(&info
->context
);
3162 ok((info
->handle_context
!= NULL
&& info
->handle_context
!= INVALID_HANDLE_VALUE
)
3163 || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
), /* XP doesn't support manifests outside of PE files */
3164 "CreateActCtxA failed: %d\n", GetLastError());
3165 if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
)
3167 skip("Failed to create activation context.\n");
3173 success
= ActivateActCtx(info
->handle_context
, &info
->cookie
);
3174 ok(success
, "ActivateActCtx failed: %d\n", GetLastError());
3176 info
->module
= LoadLibraryA("sxs_dll.dll");
3177 ok(info
->module
!= NULL
, "LoadLibrary failed\n");
3179 info
->get_path
= (void *)GetProcAddress(info
->module
, "get_path");
3180 ok(info
->get_path
!= NULL
, "GetProcAddress failed\n");
3182 DeactivateActCtx(0, info
->cookie
);
3187 static void clean_sxs_info(sxs_info
*info
)
3189 if (info
->handle_context
)
3190 ReleaseActCtx(info
->handle_context
);
3191 if (*info
->path_dll
)
3193 BOOL ret
= DeleteFileA(info
->path_dll
);
3194 ok(ret
, "DeleteFileA failed for %s: %d\n", info
->path_dll
, GetLastError());
3196 if (*info
->path_manifest_exe
)
3198 BOOL ret
= DeleteFileA(info
->path_manifest_exe
);
3199 ok(ret
, "DeleteFileA failed for %s: %d\n", info
->path_manifest_exe
, GetLastError());
3201 if (*info
->path_manifest_dll
)
3203 BOOL ret
= DeleteFileA(info
->path_manifest_dll
);
3204 ok(ret
, "DeleteFileA failed for %s: %d\n", info
->path_manifest_dll
, GetLastError());
3206 if (*info
->path_tmp
)
3208 BOOL ret
= RemoveDirectoryA(info
->path_tmp
);
3209 ok(ret
, "RemoveDirectoryA failed for %s: %d\n", info
->path_tmp
, GetLastError());
3213 static void get_application_directory(char *buffer
, int buffer_size
)
3216 GetModuleFileNameA(NULL
, buffer
, buffer_size
);
3217 end
= strrchr(buffer
, '\\');
3221 /* Test loading two sxs dlls at the same time */
3222 static void test_two_dlls_at_same_time(void)
3226 char path1
[MAX_PATH
], path2
[MAX_PATH
];
3228 if (!fill_sxs_info(&dll_1
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3230 if (!fill_sxs_info(&dll_2
, "2", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3233 ok(dll_1
.module
!= dll_2
.module
, "Libraries are the same\n");
3234 dll_1
.get_path(path1
, sizeof(path1
));
3235 ok(strcmp(path1
, dll_1
.path_dll
) == 0, "Got '%s', expected '%s'\n", path1
, dll_1
.path_dll
);
3236 dll_2
.get_path(path2
, sizeof(path2
));
3237 ok(strcmp(path2
, dll_2
.path_dll
) == 0, "Got '%s', expected '%s'\n", path2
, dll_2
.path_dll
);
3241 FreeLibrary(dll_2
.module
);
3242 clean_sxs_info(&dll_2
);
3245 FreeLibrary(dll_1
.module
);
3246 clean_sxs_info(&dll_1
);
3249 /* Test loading a normal dll and then a sxs dll with the same name */
3250 static void test_one_sxs_and_one_local_1(void)
3253 char path_dll_local
[MAX_PATH
+ 11];
3254 char path_application
[MAX_PATH
];
3255 HMODULE module
= NULL
;
3256 char path1
[MAX_PATH
], path2
[MAX_PATH
];
3257 void (WINAPI
*get_path
)(char *buffer
, int buffer_size
);
3259 get_application_directory(path_application
, sizeof(path_application
));
3261 sprintf(path_dll_local
, "%s%s", path_application
, "sxs_dll.dll");
3262 extract_resource("dummy.dll", "TESTDLL", path_dll_local
);
3264 module
= LoadLibraryA(path_dll_local
);
3265 get_path
= (void *)GetProcAddress(module
, "get_path");
3267 if (!fill_sxs_info(&dll
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3270 ok(dll
.module
!= module
, "Libraries are the same\n");
3271 dll
.get_path(path1
, sizeof(path1
));
3272 ok(strcmp(path1
, dll
.path_dll
) == 0, "Got '%s', expected '%s'\n", path1
, dll
.path_dll
);
3273 get_path(path2
, sizeof(path2
));
3274 ok(strcmp(path2
, path_dll_local
) == 0, "Got '%s', expected '%s'\n", path2
, path_dll_local
);
3278 FreeLibrary(module
);
3280 FreeLibrary(dll
.module
);
3281 if (*path_dll_local
)
3283 BOOL success
= DeleteFileA(path_dll_local
);
3284 ok(success
, "DeleteFileA failed for %s: %d\n", path_dll_local
, GetLastError());
3286 clean_sxs_info(&dll
);
3289 /* Test if sxs dll has priority over normal dll */
3290 static void test_one_sxs_and_one_local_2(void)
3293 char path_dll_local
[MAX_PATH
+ 11];
3294 char path_application
[MAX_PATH
];
3295 HMODULE module
= NULL
;
3296 char path1
[MAX_PATH
], path2
[MAX_PATH
];
3297 void (WINAPI
*get_path
)(char *buffer
, int buffer_size
);
3299 get_application_directory(path_application
, sizeof(path_application
));
3301 sprintf(path_dll_local
, "%s%s", path_application
, "sxs_dll.dll");
3302 extract_resource("dummy.dll", "TESTDLL", path_dll_local
);
3304 if (!fill_sxs_info(&dll
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, TRUE
))
3307 module
= LoadLibraryA(path_dll_local
);
3308 get_path
= (void *)GetProcAddress(module
, "get_path");
3310 ok(dll
.module
!= module
, "Libraries are the same\n");
3311 dll
.get_path(path1
, sizeof(path1
));
3312 ok(strcmp(path1
, dll
.path_dll
) == 0, "Got '%s', expected '%s'\n", path1
, dll
.path_dll
);
3313 get_path(path2
, sizeof(path2
));
3314 ok(strcmp(path2
, path_dll_local
) == 0, "Got '%s', expected '%s'\n", path2
, path_dll_local
);
3318 FreeLibrary(module
);
3320 FreeLibrary(dll
.module
);
3321 if (*path_dll_local
)
3323 BOOL success
= DeleteFileA(path_dll_local
);
3324 ok(success
, "DeleteFileA failed for %s: %d\n", path_dll_local
, GetLastError());
3326 clean_sxs_info(&dll
);
3330 /* Test if we can get a module handle from loaded normal dll while context is active */
3331 static void test_one_with_sxs_and_GetModuleHandleA(void)
3334 char path_dll_local
[MAX_PATH
+ 11];
3335 char path_tmp
[MAX_PATH
];
3336 HMODULE module
= NULL
, module_temp
;
3339 GetTempPathA(sizeof(path_tmp
), path_tmp
);
3341 sprintf(path_dll_local
, "%s%s", path_tmp
, "sxs_dll.dll");
3342 extract_resource("dummy.dll", "TESTDLL", path_dll_local
);
3344 module
= LoadLibraryA(path_dll_local
);
3346 if (!fill_sxs_info(&dll
, "1", "dummy.dll", two_dll_manifest_exe
, two_dll_manifest_dll
, FALSE
))
3349 success
= ActivateActCtx(dll
.handle_context
, &dll
.cookie
);
3350 ok(success
, "ActivateActCtx failed: %d\n", GetLastError());
3352 module_temp
= GetModuleHandleA("sxs_dll.dll");
3353 ok (module_temp
== 0, "Expected 0, got %p\n", module_temp
);
3355 DeactivateActCtx(0, dll
.cookie
);
3359 FreeLibrary(module
);
3361 FreeLibrary(dll
.module
);
3362 if (*path_dll_local
)
3364 success
= DeleteFileA(path_dll_local
);
3365 ok(success
, "DeleteFileA failed for %s: %d\n", path_dll_local
, GetLastError());
3367 clean_sxs_info(&dll
);
3370 static void test_builtin_sxs(void)
3372 char path_manifest
[MAX_PATH
+ 12];
3373 char path_tmp
[MAX_PATH
];
3374 HMODULE module_msvcp
= 0, module_msvcr
= 0;
3375 char path_msvcp
[MAX_PATH
], path_msvcr
[MAX_PATH
];
3378 HANDLE handle_context
;
3380 static const char *expected_path
= "C:\\Windows\\WinSxS";
3382 GetTempPathA(sizeof(path_tmp
), path_tmp
);
3384 sprintf(path_manifest
, "%s%s", path_tmp
, "exe.manifest");
3385 create_manifest_file(path_manifest
, builtin_dll_manifest
, -1, NULL
, NULL
);
3387 context
.cbSize
= sizeof(ACTCTXA
);
3388 context
.lpSource
= path_manifest
;
3389 context
.lpAssemblyDirectory
= path_tmp
;
3390 context
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
3392 handle_context
= CreateActCtxA(&context
);
3393 ok((handle_context
!= NULL
&& handle_context
!= INVALID_HANDLE_VALUE
)
3394 || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
), /* XP doesn't support manifests outside of PE files */
3395 "CreateActCtxA failed: %d\n", GetLastError());
3396 if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
)
3398 skip("Failed to create activation context.\n");
3403 success
= ActivateActCtx(handle_context
, &cookie
);
3404 ok(success
, "ActivateActCtx failed: %d\n", GetLastError());
3406 module_msvcp
= LoadLibraryA("msvcp90.dll");
3407 ok (module_msvcp
!= 0 || broken(module_msvcp
== 0), "LoadLibraryA failed, %d\n", GetLastError());
3408 module_msvcr
= LoadLibraryA("msvcr90.dll");
3409 ok (module_msvcr
!= 0 || broken(module_msvcr
== 0), "LoadLibraryA failed, %d\n", GetLastError());
3410 if (!module_msvcp
|| !module_msvcr
)
3412 skip("Failed to find msvcp90 or msvcr90.\n");
3416 GetModuleFileNameA(module_msvcp
, path_msvcp
, sizeof(path_msvcp
));
3417 GetModuleFileNameA(module_msvcr
, path_msvcr
, sizeof(path_msvcr
));
3418 ok(strnicmp(expected_path
, path_msvcp
, strlen(expected_path
)) == 0, "Expected path to start with %s, got %s\n", expected_path
, path_msvcp
);
3419 ok(strnicmp(expected_path
, path_msvcr
, strlen(expected_path
)) == 0, "Expected path to start with %s, got %s\n", expected_path
, path_msvcr
);
3421 DeactivateActCtx(0, cookie
);
3425 FreeLibrary(module_msvcp
);
3427 FreeLibrary(module_msvcr
);
3430 success
= DeleteFileA(path_manifest
);
3431 ok(success
, "DeleteFileA failed for %s: %d\n", path_manifest
, GetLastError());
3435 static void run_sxs_test(int run
)
3440 test_two_dlls_at_same_time();
3443 test_one_sxs_and_one_local_1();
3446 test_one_sxs_and_one_local_2();
3449 test_one_with_sxs_and_GetModuleHandleA();
3457 static void run_child_process_two_dll(int run
)
3459 char cmdline
[MAX_PATH
];
3462 PROCESS_INFORMATION pi
;
3463 STARTUPINFOA si
= { 0 };
3466 winetest_get_mainargs( &argv
);
3468 if (strstr(argv
[0], ".exe"))
3469 sprintf(exe
, "%s", argv
[0]);
3471 sprintf(exe
, "%s.exe", argv
[0]);
3472 sprintf(cmdline
, "\"%s\" %s two_dll %d", argv
[0], argv
[1], run
);
3475 ret
= CreateProcessA(exe
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
3476 ok(ret
, "Could not create process: %u\n", GetLastError());
3478 wait_child_process( pi
.hProcess
);
3480 CloseHandle(pi
.hThread
);
3481 CloseHandle(pi
.hProcess
);
3489 argc
= winetest_get_mainargs(&argv
);
3493 win_skip("Needed functions are not available\n");
3498 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
3499 test_app_manifest();
3503 if (argc
> 2 && !strcmp(argv
[2], "two_dll"))
3505 int run
= atoi(argv
[3]);
3512 test_CreateActCtx();
3513 test_findsectionstring();
3514 test_ZombifyActCtx();
3515 run_child_process();
3516 test_compatibility();
3518 run_child_process_two_dll(1);
3519 run_child_process_two_dll(2);
3520 run_child_process_two_dll(3);
3521 run_child_process_two_dll(4);
3522 run_child_process_two_dll(5);