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
25 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
26 static HANDLE (WINAPI
*pCreateActCtxA
)(PCACTCTXA
);
27 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
28 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
29 static BOOL (WINAPI
*pFindActCtxSectionStringA
)(DWORD
,const GUID
*,ULONG
,LPCSTR
,PACTCTX_SECTION_KEYED_DATA
);
30 static BOOL (WINAPI
*pFindActCtxSectionStringW
)(DWORD
,const GUID
*,ULONG
,LPCWSTR
,PACTCTX_SECTION_KEYED_DATA
);
31 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
32 static BOOL (WINAPI
*pIsDebuggerPresent
)(void);
33 static BOOL (WINAPI
*pQueryActCtxW
)(DWORD
,HANDLE
,PVOID
,ULONG
,PVOID
,SIZE_T
,SIZE_T
*);
34 static VOID (WINAPI
*pReleaseActCtx
)(HANDLE
);
35 static BOOL (WINAPI
*pFindActCtxSectionGuid
)(DWORD
,const GUID
*,ULONG
,const GUID
*,PACTCTX_SECTION_KEYED_DATA
);
36 static BOOL (WINAPI
*pZombifyActCtx
)(HANDLE
);
38 static NTSTATUS(NTAPI
*pRtlFindActivationContextSectionString
)(DWORD
,const GUID
*,ULONG
,PUNICODE_STRING
,PACTCTX_SECTION_KEYED_DATA
);
39 static BOOLEAN (NTAPI
*pRtlCreateUnicodeStringFromAsciiz
)(PUNICODE_STRING
, PCSZ
);
40 static VOID (NTAPI
*pRtlFreeUnicodeString
)(PUNICODE_STRING
);
42 static const char* strw(LPCWSTR x
)
44 static char buffer
[1024];
47 if (!x
) return "(nil)";
48 else while ((*p
++ = *x
++));
54 #elif defined __x86_64__
58 #elif defined __aarch64__
64 static const char manifest1
[] =
65 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
66 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
69 static const char manifest1_1
[] =
70 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
71 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
74 static const char manifest2
[] =
75 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
76 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
80 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
82 "</dependentAssembly>"
86 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
87 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
88 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
89 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
90 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
91 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
92 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
93 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
94 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
95 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
96 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
97 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
98 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
100 static const char manifest3
[] =
101 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
102 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
103 " publicKeyToken=\"6595b6414666f1df\" />"
105 "<file name=\"testlib.dll\">"
106 "<windowClass>wndClass</windowClass>"
107 " <comClass description=\"Test com class\""
108 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
109 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
110 " threadingModel=\"Neutral\""
111 " progid=\"ProgId.ProgId\""
112 " miscStatus=\"cantlinkinside\""
113 " miscStatusIcon=\"recomposeonresize\""
114 " miscStatusContent=\"insideout\""
115 " miscStatusThumbnail=\"alignable\""
116 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
118 " <progid>ProgId.ProgId.1</progid>"
119 " <progid>ProgId.ProgId.2</progid>"
120 " <progid>ProgId.ProgId.3</progid>"
121 " <progid>ProgId.ProgId.4</progid>"
122 " <progid>ProgId.ProgId.5</progid>"
123 " <progid>ProgId.ProgId.6</progid>"
125 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
126 " <progid>ProgId.ProgId.7</progid>"
128 " <comInterfaceProxyStub "
130 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
131 " iid=\"{66666666-8888-7777-6666-555555555555}\""
132 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
133 " threadingModel=\"Free\""
135 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
138 " <comInterfaceExternalProxyStub "
139 " name=\"Iifaceps2\""
140 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
141 " iid=\"{76666666-8888-7777-6666-555555555555}\""
142 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
144 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
146 " <comInterfaceExternalProxyStub "
147 " name=\"Iifaceps3\""
148 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
149 " iid=\"{86666666-8888-7777-6666-555555555555}\""
151 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
154 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
155 " name=\"testsurrogate\""
156 " runtimeVersion=\"v2.0.50727\""
159 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
161 " progid=\"clrprogid\""
162 " description=\"test description\""
163 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
164 " runtimeVersion=\"1.2.3.4\""
165 " threadingModel=\"Neutral\""
167 " <progid>clrprogid.1</progid>"
168 " <progid>clrprogid.2</progid>"
169 " <progid>clrprogid.3</progid>"
170 " <progid>clrprogid.4</progid>"
171 " <progid>clrprogid.5</progid>"
172 " <progid>clrprogid.6</progid>"
176 static const char manifest_wndcls1
[] =
177 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
178 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
179 "<file name=\"testlib1.dll\">"
180 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
181 "<windowClass>wndClass2</windowClass>"
182 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
184 "<file name=\"testlib1_2.dll\" />"
187 static const char manifest_wndcls2
[] =
188 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
189 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
190 "<file name=\"testlib2.dll\">"
191 " <windowClass versioned=\"no\">wndClass3</windowClass>"
192 " <windowClass>wndClass4</windowClass>"
193 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
194 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
195 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
196 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
198 "<file name=\"testlib2_2.dll\" />"
201 static const char manifest_wndcls_main
[] =
202 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
203 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
205 " <dependentAssembly>"
206 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
207 " </dependentAssembly>"
210 " <dependentAssembly>"
211 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
212 " </dependentAssembly>"
216 static const char manifest4
[] =
217 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
218 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
219 "</assemblyIdentity>"
221 "<dependentAssembly>"
222 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
223 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
224 "</assemblyIdentity>"
225 "</dependentAssembly>"
229 static const char manifest5
[] =
230 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
231 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
232 "</assemblyIdentity>"
234 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
235 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
236 " </dependentAssembly>"
240 static const char manifest6
[] =
241 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
242 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
243 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
245 " <requestedPrivileges>"
246 " <requestedExecutionLevel level=\"ASINVOKER\" uiAccess=\"false\"/>"
247 " </requestedPrivileges>"
252 static const char manifest7
[] =
253 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
254 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
255 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
257 " <requestedPrivileges>"
258 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"TRUE\"/>"
259 " </requestedPrivileges>"
264 static const char manifest8
[] =
265 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
266 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
267 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
269 " <requestedPrivileges>"
270 " <requestedExecutionLevel level=\"requireAdministrator\" uiAccess=\"true\">"
271 " </requestedExecutionLevel>"
272 " </requestedPrivileges>"
277 static const char manifest9
[] =
278 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
279 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
280 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
282 " <requestedPrivileges>"
283 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
284 " </requestedPrivileges>"
287 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
289 " <requestedPrivileges>"
290 " </requestedPrivileges>"
295 static const char testdep_manifest1
[] =
296 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
297 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
300 static const char testdep_manifest2
[] =
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
"\" />"
303 "<file name=\"testlib.dll\"></file>"
304 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
307 static const char testdep_manifest3
[] =
308 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
309 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
310 "<file name=\"testlib.dll\"/>"
311 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
312 "<windowClass>wndClass</windowClass>"
313 "<windowClass>wndClass2</windowClass>"
317 static const char wrong_manifest1
[] =
318 "<assembly manifestVersion=\"1.0\">"
319 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
322 static const char wrong_manifest2
[] =
323 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
324 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
327 static const char wrong_manifest3
[] =
328 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
329 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
332 static const char wrong_manifest4
[] =
333 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
334 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
338 static const char wrong_manifest5
[] =
339 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
340 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
344 static const char wrong_manifest6
[] =
345 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
346 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
349 static const char wrong_manifest7
[] =
350 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
351 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
352 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
355 static const char wrong_manifest8
[] =
356 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
357 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
361 static const char wrong_manifest9
[] =
362 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
363 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
364 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
366 " <requestedPrivileges>"
367 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
368 " <requestedExecutionLevel uiAccess=\"true\"/>"
369 " </requestedPrivileges>"
374 static const char wrong_manifest10
[] =
375 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
376 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
377 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
379 " <requestedPrivileges>"
380 " <requestedExecutionLevel level=\"requireAdministrator\"/>"
381 " </requestedPrivileges>"
384 "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">"
386 " <requestedPrivileges>"
387 " <requestedExecutionLevel uiAccess=\"true\"/>"
388 " </requestedPrivileges>"
393 static const char wrong_depmanifest1
[] =
394 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
395 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
398 static const WCHAR testlib_dll
[] =
399 {'t','e','s','t','l','i','b','.','d','l','l',0};
400 static const WCHAR testlib2_dll
[] =
401 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
402 static const WCHAR wndClassW
[] =
403 {'w','n','d','C','l','a','s','s',0};
404 static const WCHAR wndClass1W
[] =
405 {'w','n','d','C','l','a','s','s','1',0};
406 static const WCHAR wndClass2W
[] =
407 {'w','n','d','C','l','a','s','s','2',0};
408 static const WCHAR wndClass3W
[] =
409 {'w','n','d','C','l','a','s','s','3',0};
411 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
412 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
414 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
419 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
420 return lstrcmpW(strw
, buf
);
423 static DWORD
strlen_aw(const char *str
)
425 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
428 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
429 const char *depfile
, const char *depmanifest
)
433 WCHAR path
[MAX_PATH
];
435 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
436 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
438 if (manifest_len
== -1)
439 manifest_len
= strlen(manifest
);
441 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
442 FILE_ATTRIBUTE_NORMAL
, NULL
);
443 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
444 if(file
== INVALID_HANDLE_VALUE
)
446 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
451 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
452 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
453 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
454 FILE_ATTRIBUTE_NORMAL
, NULL
);
455 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
456 if(file
== INVALID_HANDLE_VALUE
)
458 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
464 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
466 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
468 int offset
= (fBOM
? 0 : 1);
470 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
471 wmanifest
[0] = 0xfeff;
475 for (i
= 0; i
< strlen(manifest
)+1; i
++)
476 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
478 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
479 HeapFree(GetProcessHeap(), 0, wmanifest
);
484 ULONG format_version
;
485 ULONG assembly_cnt_min
;
486 ULONG assembly_cnt_max
;
487 ULONG root_manifest_type
;
488 LPWSTR root_manifest_path
;
489 ULONG root_config_type
;
494 static const detailed_info_t detailed_info0
= {
495 0, 0, 0, 0, NULL
, 0, 0, NULL
498 static const detailed_info_t detailed_info1
= {
499 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
500 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
504 static const detailed_info_t detailed_info1_child
= {
505 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
506 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
510 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
511 static const detailed_info_t detailed_info2
= {
512 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
513 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
517 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
519 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
520 SIZE_T size
, exsize
, retsize
;
523 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
524 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
525 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
527 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
529 b
= pQueryActCtxW(0, handle
, NULL
,
530 ActivationContextDetailedInformation
, &detailed_info_tmp
,
531 sizeof(detailed_info_tmp
), &size
);
532 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
533 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
534 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
536 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
539 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
540 memset(detailed_info
, 0xfe, size
);
541 b
= pQueryActCtxW(0, handle
, NULL
,
542 ActivationContextDetailedInformation
, detailed_info
,
544 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
545 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
547 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
548 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
549 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
550 exinfo
->format_version
);
551 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
552 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
553 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
554 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
555 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
556 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
557 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
558 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
559 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
560 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
561 detailed_info
->ulRootManifestPathChars
,
562 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
563 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
564 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
565 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
566 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
567 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
568 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
569 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
570 exinfo
->app_dir_type
);
571 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
572 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
573 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
574 if(exinfo
->root_manifest_path
) {
575 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
576 if(detailed_info
->lpRootManifestPath
)
577 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
578 "unexpected detailed_info->lpRootManifestPath\n");
580 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
582 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
583 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
584 if(exinfo
->app_dir
) {
585 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
586 if(detailed_info
->lpAppDirPath
)
587 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
588 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
590 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
593 HeapFree(GetProcessHeap(), 0, detailed_info
);
598 /* ULONG manifest_path_type; FIXME */
599 LPCWSTR manifest_path
;
600 LPCSTR encoded_assembly_id
;
601 BOOL has_assembly_dir
;
604 static const info_in_assembly manifest1_info
= {
606 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
610 static const info_in_assembly manifest1_child_info
= {
611 1, app_manifest_path
,
612 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
616 static const info_in_assembly manifest2_info
= {
618 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
622 static const info_in_assembly manifest3_info
= {
624 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
628 static const info_in_assembly manifest4_info
= {
630 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
634 static const info_in_assembly depmanifest1_info
= {
635 0x10, depmanifest_path
,
636 "testdep,processorArchitecture=\"" ARCH
"\","
637 "type=\"win32\",version=\"6.5.4.3\"",
641 static const info_in_assembly depmanifest2_info
= {
642 0x10, depmanifest_path
,
643 "testdep,processorArchitecture=\"" ARCH
"\","
644 "type=\"win32\",version=\"6.5.4.3\"",
648 static const info_in_assembly depmanifest3_info
= {
649 0x10, depmanifest_path
,
650 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
654 static const info_in_assembly manifest_comctrl_info
= {
655 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
658 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
660 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
665 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
666 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
667 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
670 b
= pQueryActCtxW(0, handle
, &id
,
671 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
672 sizeof(info_tmp
), &size
);
673 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
674 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
676 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
678 if (size
== 0xdeadbeef)
684 info
= HeapAlloc(GetProcessHeap(), 0, size
);
685 memset(info
, 0xfe, size
);
688 b
= pQueryActCtxW(0, handle
, &id
,
689 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
690 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
691 if (!exinfo
->manifest_path
)
692 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
693 if (!exinfo
->encoded_assembly_id
)
694 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
695 if (exinfo
->has_assembly_dir
)
696 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
697 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
699 if (0) /* FIXME: flags meaning unknown */
701 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
702 info
->ulFlags
, exinfo
->flags
);
704 if(exinfo
->encoded_assembly_id
) {
705 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
706 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
707 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
708 info
->ulEncodedAssemblyIdentityLength
, len
);
710 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
711 "info->ulEncodedAssemblyIdentityLength == 0\n");
713 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
714 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
715 if(exinfo
->manifest_path
) {
716 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
717 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
718 info
->ulManifestPathLength
, len
);
720 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
723 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
724 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
725 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
726 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
727 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
728 info
->ulMetadataSatelliteRosterIndex
);
729 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
730 info
->ulManifestVersionMajor
);
731 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
732 info
->ulManifestVersionMinor
);
733 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
734 info
->ulPolicyVersionMajor
);
735 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
736 info
->ulPolicyVersionMinor
);
737 if(exinfo
->has_assembly_dir
)
738 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
739 "info->ulAssemblyDirectoryNameLength == 0\n");
741 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
742 "info->ulAssemblyDirectoryNameLength != 0\n");
744 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
745 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
746 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
747 ok_(__FILE__
, line
)(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
748 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
749 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
751 if(exinfo
->manifest_path
) {
752 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
753 if(info
->lpAssemblyManifestPath
)
754 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
755 "unexpected info->lpAssemblyManifestPath\n");
757 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
760 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
761 if(info
->lpAssemblyPolicyPath
)
762 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
763 if(exinfo
->has_assembly_dir
)
764 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
766 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
767 strw(info
->lpAssemblyDirectoryName
));
768 HeapFree(GetProcessHeap(), 0, info
);
771 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
773 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
774 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
778 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
779 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
782 b
= pQueryActCtxW(0, handle
, &index
,
783 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
784 sizeof(info_tmp
), &size
);
785 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
786 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
787 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
789 if(size
== 0xdeadbeef)
795 info
= HeapAlloc(GetProcessHeap(), 0, size
);
796 memset(info
, 0xfe, size
);
798 b
= pQueryActCtxW(0, handle
, &index
,
799 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
800 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
801 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
803 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
804 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
805 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
806 info
->ulFilenameLength
, lstrlenW(filename
));
807 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
808 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
810 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
811 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
812 HeapFree(GetProcessHeap(), 0, info
);
816 ACTCTX_REQUESTED_RUN_LEVEL run_level
;
820 static const runlevel_info_t runlevel_info0
= {
821 ACTCTX_RUN_LEVEL_UNSPECIFIED
, FALSE
,
824 static const runlevel_info_t runlevel_info6
= {
825 ACTCTX_RUN_LEVEL_AS_INVOKER
, FALSE
,
828 static const runlevel_info_t runlevel_info7
= {
829 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
832 static const runlevel_info_t runlevel_info8
= {
833 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, TRUE
,
836 static const runlevel_info_t runlevel_info9
= {
837 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
, FALSE
,
840 static void test_runlevel_info(HANDLE handle
, const runlevel_info_t
*exinfo
, int line
)
842 ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel_info
;
843 SIZE_T size
, retsize
;
846 size
= sizeof(runlevel_info
);
847 b
= pQueryActCtxW(0, handle
, NULL
,
848 RunlevelInformationInActivationContext
, &runlevel_info
,
849 sizeof(runlevel_info
), &retsize
);
850 if (!b
&& GetLastError() == ERROR_INVALID_PARAMETER
)
852 win_skip("RunlevelInformationInActivationContext not supported.\n");
856 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
857 ok_(__FILE__
, line
)(retsize
== size
, "size=%ld, expected %ld\n", retsize
, size
);
859 ok_(__FILE__
, line
)(runlevel_info
.ulFlags
== 0, "runlevel_info.ulFlags=%x\n", runlevel_info
.ulFlags
);
860 ok_(__FILE__
, line
)(runlevel_info
.RunLevel
== exinfo
->run_level
,
861 "runlevel_info.RunLevel=%u, expected %u\n", runlevel_info
.RunLevel
, exinfo
->run_level
);
862 ok_(__FILE__
, line
)(runlevel_info
.UiAccess
== exinfo
->ui_access
,
863 "runlevel_info.UiAccess=%u, expected %u\n", runlevel_info
.UiAccess
, exinfo
->ui_access
);
866 static HANDLE
test_create(const char *file
)
870 WCHAR path
[MAX_PATH
];
872 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
873 memset(&actctx
, 0, sizeof(ACTCTXW
));
874 actctx
.cbSize
= sizeof(ACTCTXW
);
875 actctx
.lpSource
= path
;
877 handle
= pCreateActCtxW(&actctx
);
878 /* to be tested outside of this helper, including last error */
879 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
881 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
882 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%d\n", actctx
.dwFlags
);
883 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
884 ok(actctx
.wProcessorArchitecture
== 0,
885 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
886 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
887 ok(actctx
.lpAssemblyDirectory
== NULL
,
888 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
889 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
890 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
891 actctx
.lpApplicationName
);
892 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
897 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
901 WCHAR path
[MAX_PATH
];
903 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
904 memset(&actctx
, 0, sizeof(ACTCTXW
));
905 actctx
.cbSize
= sizeof(ACTCTXW
);
906 actctx
.lpSource
= path
;
908 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
909 handle
= pCreateActCtxW(&actctx
);
912 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
913 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
915 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
916 DeleteFileA("bad.manifest");
917 DeleteFileA("testdep.manifest");
920 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
924 WCHAR path
[MAX_PATH
];
926 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
927 memset(&actctx
, 0, sizeof(ACTCTXW
));
928 actctx
.cbSize
= sizeof(ACTCTXW
);
929 actctx
.lpSource
= path
;
931 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
932 handle
= pCreateActCtxW(&actctx
);
933 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
934 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
936 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
937 DeleteFileA("bad.manifest");
940 static void test_create_fail(void)
944 WCHAR path
[MAX_PATH
];
946 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
947 memset(&actctx
, 0, sizeof(ACTCTXW
));
948 actctx
.cbSize
= sizeof(ACTCTXW
);
949 actctx
.lpSource
= path
;
951 handle
= pCreateActCtxW(&actctx
);
952 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
953 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
955 trace("wrong_manifest1\n");
956 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
957 trace("wrong_manifest2\n");
958 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
959 trace("wrong_manifest3\n");
960 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
961 trace("wrong_manifest4\n");
962 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
963 trace("wrong_manifest5\n");
964 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
965 trace("wrong_manifest6\n");
966 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
967 trace("wrong_manifest7\n");
968 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
969 trace("wrong_manifest8\n");
970 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
971 trace("wrong_manifest9\n");
972 test_create_and_fail(wrong_manifest9
, NULL
, 0 );
973 trace("wrong_manifest10\n");
974 test_create_and_fail(wrong_manifest10
, NULL
, 0 );
975 trace("UTF-16 manifest1 without BOM\n");
976 test_create_wide_and_fail(manifest1
, FALSE
);
977 trace("manifest2\n");
978 test_create_and_fail(manifest2
, NULL
, 0 );
979 trace("manifest2+depmanifest1\n");
980 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
983 struct strsection_header
1005 struct guidsection_header
1025 struct wndclass_redirect_data
1030 ULONG name_offset
; /* versioned name offset */
1032 ULONG module_offset
;/* container name offset */
1035 struct dllredirect_data
1042 struct tlibredirect_data
1056 struct progidredirect_data
1063 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
1065 ACTCTX_SECTION_KEYED_DATA data
;
1068 memset(&data
, 0xfe, sizeof(data
));
1069 data
.cbSize
= sizeof(data
);
1071 ret
= pFindActCtxSectionStringW(0, NULL
,
1072 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1074 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
1077 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1078 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1079 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1080 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
1084 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
1085 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
1086 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
1087 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
1088 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
1089 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
1092 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1093 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1094 data
.ulSectionGlobalDataLength
);
1095 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1096 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1097 data
.ulSectionTotalLength
);
1098 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1099 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1100 data
.ulAssemblyRosterIndex
, exid
);
1102 memset(&data
, 0xfe, sizeof(data
));
1103 data
.cbSize
= sizeof(data
);
1105 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1106 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1108 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
1111 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1112 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1113 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1114 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
1115 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1116 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1117 data
.ulSectionGlobalDataLength
);
1118 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1119 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1120 data
.ulSectionTotalLength
);
1121 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1122 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1123 data
.ulAssemblyRosterIndex
, exid
);
1125 pReleaseActCtx(handle
);
1128 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
1130 struct wndclass_redirect_data
*wnddata
;
1131 struct strsection_header
*header
;
1132 ACTCTX_SECTION_KEYED_DATA data
;
1135 memset(&data
, 0xfe, sizeof(data
));
1136 data
.cbSize
= sizeof(data
);
1138 ret
= pFindActCtxSectionStringW(0, NULL
,
1139 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1141 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1142 wine_dbgstr_w(clsname
));
1145 header
= (struct strsection_header
*)data
.lpSectionBase
;
1146 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1148 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
1149 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
1150 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1151 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1152 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1153 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1154 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1156 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1161 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1162 /* redirect class name (versioned or not) is stored just after header data */
1163 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1164 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1166 /* expected versioned name */
1167 lstrcpyW(buff
, verW
);
1168 lstrcatW(buff
, clsname
);
1169 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1170 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1171 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1172 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1174 /* data length is simply header length + string data length including nulls */
1175 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1176 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1178 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1180 WCHAR
*modulename
, *sectionptr
;
1182 /* just compare pointers */
1183 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1184 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1185 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1189 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1190 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1191 data
.ulSectionGlobalDataLength
);
1192 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1193 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1194 data
.ulSectionTotalLength
);
1195 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1196 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1197 data
.ulAssemblyRosterIndex
, exid
);
1199 memset(&data
, 0xfe, sizeof(data
));
1200 data
.cbSize
= sizeof(data
);
1202 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1203 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1205 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1206 wine_dbgstr_w(clsname
));
1209 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1210 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1211 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1212 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1213 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1214 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1215 data
.ulSectionGlobalDataLength
);
1216 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1217 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1218 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1219 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1220 data
.ulAssemblyRosterIndex
, exid
);
1222 pReleaseActCtx(handle
);
1225 static void test_find_string_fail(void)
1227 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1230 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1231 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1232 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1234 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1235 testlib2_dll
, &data
);
1236 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1237 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1239 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1241 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1242 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1244 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1246 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1247 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1250 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1251 testlib_dll
, &data
);
1252 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1253 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1256 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1257 testlib_dll
, &data
);
1258 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1259 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1263 static void test_basic_info(HANDLE handle
, int line
)
1265 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1269 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1270 ActivationContextBasicInformation
, &basic
,
1271 sizeof(basic
), &size
);
1273 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1274 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1275 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1276 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1278 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1279 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1280 ActivationContextBasicInformation
, &basic
,
1281 sizeof(basic
), &size
);
1284 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1285 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1286 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1287 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1288 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1292 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1293 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1294 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1295 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1299 enum comclass_threadingmodel
{
1300 ThreadingModel_Apartment
= 1,
1301 ThreadingModel_Free
= 2,
1302 ThreadingModel_No
= 3,
1303 ThreadingModel_Both
= 4,
1304 ThreadingModel_Neutral
= 5
1307 enum comclass_miscfields
{
1310 MiscStatusContent
= 4,
1311 MiscStatusThumbnail
= 8,
1312 MiscStatusDocPrint
= 16
1315 struct comclassredirect_data
{
1328 ULONG progid_offset
;
1330 ULONG clrdata_offset
;
1332 DWORD miscstatuscontent
;
1333 DWORD miscstatusthumbnail
;
1334 DWORD miscstatusicon
;
1335 DWORD miscstatusdocprint
;
1338 struct clrclass_data
{
1342 ULONG module_offset
;
1346 ULONG version_offset
;
1350 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1352 struct comclassredirect_data
*comclass
, *comclass2
;
1353 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1354 struct guidsection_header
*header
;
1357 memset(&data
, 0xfe, sizeof(data
));
1358 data
.cbSize
= sizeof(data
);
1360 ret
= pFindActCtxSectionGuid(0, NULL
,
1361 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1365 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1368 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1370 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1372 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1373 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1374 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1375 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1376 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1381 ok_(__FILE__
, line
)(comclass
->res
== 0, "got res as %d\n", comclass
->res
);
1382 ok_(__FILE__
, line
)(comclass
->res1
[0] == 0, "got res1[0] as %02x\n", comclass
->res1
[0]);
1383 ok_(__FILE__
, line
)(comclass
->res1
[1] == 0, "got res1[1] as %02x\n", comclass
->res1
[1]);
1384 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1385 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1386 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1388 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1389 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1393 len
= comclass
->size
+ comclass
->clrdata_len
;
1394 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1397 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1399 if (comclass
->progid_offset
)
1401 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1402 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1403 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1404 "got progid name length %d\n", comclass
->progid_len
);
1407 /* data length is simply header length + string data length including nulls */
1408 len
= comclass
->size
+ comclass
->clrdata_len
;
1409 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1410 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1412 /* keyed data structure doesn't include module name, it's available from section data */
1413 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1415 /* check misc fields are set */
1416 if (comclass
->miscmask
)
1418 if (comclass
->miscmask
& MiscStatus
)
1419 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1420 if (comclass
->miscmask
& MiscStatusIcon
)
1421 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1422 if (comclass
->miscmask
& MiscStatusContent
)
1423 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1424 if (comclass
->miscmask
& MiscStatusThumbnail
)
1425 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1426 if (comclass
->miscmask
& MiscStatusDocPrint
)
1427 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1430 /* part used for clrClass only */
1431 if (comclass
->clrdata_len
)
1433 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1434 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1435 struct clrclass_data
*clrclass
;
1438 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1439 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1440 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1441 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1442 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1443 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1445 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1446 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1447 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1448 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1450 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1451 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1453 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1454 in lower case, clsclass subsection - in upper case */
1455 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1456 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1458 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1459 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1461 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1462 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1466 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1467 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1468 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1469 data
.ulSectionGlobalDataLength
);
1470 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1471 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1472 data
.ulSectionTotalLength
);
1473 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1474 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1475 data
.ulAssemblyRosterIndex
, exid
);
1477 /* generated guid for this class works as key guid in search */
1478 memset(&data2
, 0xfe, sizeof(data2
));
1479 data2
.cbSize
= sizeof(data2
);
1480 ret
= pFindActCtxSectionGuid(0, NULL
,
1481 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1482 &comclass
->alias
, &data2
);
1483 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1485 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1486 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1487 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1496 struct ifacepsredirect_data
1508 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1509 const GUID
*ps32
, ULONG exid
, int line
)
1511 struct ifacepsredirect_data
*ifaceps
;
1512 ACTCTX_SECTION_KEYED_DATA data
;
1515 memset(&data
, 0xfe, sizeof(data
));
1516 data
.cbSize
= sizeof(data
);
1518 ret
= pFindActCtxSectionGuid(0, NULL
,
1519 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1521 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1523 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1525 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1526 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1527 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1528 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1529 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1533 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1536 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1539 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1541 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1542 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1543 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1545 /* data length is simply header length + string data length including nulls */
1546 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1547 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1549 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1550 always has non-zero value for it */
1551 if (ifaceps
->mask
& NumMethods
)
1552 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1553 if (ifaceps
->mask
& BaseIface
)
1554 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1557 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1558 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1559 data
.ulSectionGlobalDataLength
);
1560 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1561 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1562 data
.ulSectionTotalLength
);
1563 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1564 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1565 data
.ulAssemblyRosterIndex
, exid
);
1568 struct clrsurrogate_data
1573 ULONG version_offset
;
1579 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1580 ULONG exid
, int line
)
1582 struct clrsurrogate_data
*surrogate
;
1583 ACTCTX_SECTION_KEYED_DATA data
;
1586 memset(&data
, 0xfe, sizeof(data
));
1587 data
.cbSize
= sizeof(data
);
1589 ret
= pFindActCtxSectionGuid(0, NULL
,
1590 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1594 skip("surrogate sections are not supported\n");
1597 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1599 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1601 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1602 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1603 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1604 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1605 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1610 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1611 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1613 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1614 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1616 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1617 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1619 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1620 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1622 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1623 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1625 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1626 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1629 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1630 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1631 data
.ulSectionGlobalDataLength
);
1632 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1633 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1634 data
.ulSectionTotalLength
);
1635 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1636 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1637 data
.ulAssemblyRosterIndex
, exid
);
1640 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1642 struct progidredirect_data
*progiddata
;
1643 struct comclassredirect_data
*comclass
;
1644 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1645 struct strsection_header
*header
;
1648 memset(&data
, 0xfe, sizeof(data
));
1649 data
.cbSize
= sizeof(data
);
1651 ret
= pFindActCtxSectionStringA(0, NULL
,
1652 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1654 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1656 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1658 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1659 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1660 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1661 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1662 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1666 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1667 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1669 /* progid data points to generated alias guid */
1670 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1672 memset(&data2
, 0, sizeof(data2
));
1673 data2
.cbSize
= sizeof(data2
);
1674 ret
= pFindActCtxSectionGuid(0, NULL
,
1675 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1677 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1679 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1680 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1681 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1684 header
= (struct strsection_header
*)data
.lpSectionBase
;
1685 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1686 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1687 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1688 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1689 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1690 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1691 data
.ulAssemblyRosterIndex
, exid
);
1694 static void test_wndclass_section(void)
1696 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1697 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1698 struct wndclass_redirect_data
*classdata
;
1699 struct strsection_header
*section
;
1705 /* use two dependent manifests, each defines 2 window class redirects */
1706 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1707 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1708 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1710 handle
= test_create("main_wndcls.manifest");
1711 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1713 DeleteFileA("testdep1.manifest");
1714 DeleteFileA("testdep2.manifest");
1715 DeleteFileA("main_wndcls.manifest");
1717 ret
= pActivateActCtx(handle
, &cookie
);
1718 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1720 memset(&data
, 0, sizeof(data
));
1721 memset(&data2
, 0, sizeof(data2
));
1722 data
.cbSize
= sizeof(data
);
1723 data2
.cbSize
= sizeof(data2
);
1725 /* get data for two classes from different assemblies */
1726 ret
= pFindActCtxSectionStringW(0, NULL
,
1727 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1729 ok(ret
, "got %d\n", ret
);
1730 ret
= pFindActCtxSectionStringW(0, NULL
,
1731 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1732 wndClass3W
, &data2
);
1733 ok(ret
, "got %d\n", ret
);
1735 section
= (struct strsection_header
*)data
.lpSectionBase
;
1736 ok(section
->count
== 4, "got %d\n", section
->count
);
1737 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1739 /* For both string same section is returned, meaning it's one wndclass section per context */
1740 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1741 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1742 data2
.ulSectionTotalLength
);
1744 /* wndClass1 is versioned, wndClass3 is not */
1745 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1746 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1747 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1749 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1750 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1751 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1753 ret
= pDeactivateActCtx(0, cookie
);
1754 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1756 pReleaseActCtx(handle
);
1759 static void test_dllredirect_section(void)
1761 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1762 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1763 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1764 struct strsection_header
*section
;
1769 /* use two dependent manifests, 4 'files' total */
1770 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1771 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1772 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1774 handle
= test_create("main_wndcls.manifest");
1775 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1777 DeleteFileA("testdep1.manifest");
1778 DeleteFileA("testdep2.manifest");
1779 DeleteFileA("main_wndcls.manifest");
1781 ret
= pActivateActCtx(handle
, &cookie
);
1782 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1784 memset(&data
, 0, sizeof(data
));
1785 memset(&data2
, 0, sizeof(data2
));
1786 data
.cbSize
= sizeof(data
);
1787 data2
.cbSize
= sizeof(data2
);
1789 /* get data for two files from different assemblies */
1790 ret
= pFindActCtxSectionStringW(0, NULL
,
1791 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1793 ok(ret
, "got %d\n", ret
);
1794 ret
= pFindActCtxSectionStringW(0, NULL
,
1795 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1797 ok(ret
, "got %d\n", ret
);
1799 section
= (struct strsection_header
*)data
.lpSectionBase
;
1800 ok(section
->count
== 4, "got %d\n", section
->count
);
1801 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1803 /* For both string same section is returned, meaning it's one dll redirect section per context */
1804 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1805 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1806 data2
.ulSectionTotalLength
);
1808 ret
= pDeactivateActCtx(0, cookie
);
1809 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1811 pReleaseActCtx(handle
);
1814 static void test_typelib_section(void)
1816 static const WCHAR helpW
[] = {'h','e','l','p'};
1817 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1818 struct guidsection_header
*section
;
1819 struct tlibredirect_data
*tlib
;
1824 /* use two dependent manifests, 4 'files' total */
1825 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1826 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1827 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1829 handle
= test_create("main_wndcls.manifest");
1830 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1832 DeleteFileA("testdep1.manifest");
1833 DeleteFileA("testdep2.manifest");
1834 DeleteFileA("main_wndcls.manifest");
1836 ret
= pActivateActCtx(handle
, &cookie
);
1837 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1839 memset(&data
, 0, sizeof(data
));
1840 memset(&data2
, 0, sizeof(data2
));
1841 data
.cbSize
= sizeof(data
);
1842 data2
.cbSize
= sizeof(data2
);
1844 /* get data for two typelibs from different assemblies */
1845 ret
= pFindActCtxSectionGuid(0, NULL
,
1846 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1847 &IID_TlibTest
, &data
);
1848 ok(ret
, "got %d\n", ret
);
1850 ret
= pFindActCtxSectionGuid(0, NULL
,
1851 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1852 &IID_TlibTest4
, &data2
);
1853 ok(ret
, "got %d\n", ret
);
1855 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1856 ok(section
->count
== 4, "got %d\n", section
->count
);
1857 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1859 /* For both GUIDs same section is returned */
1860 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1861 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1862 data2
.ulSectionTotalLength
);
1864 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1865 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1866 data
.ulSectionGlobalDataLength
);
1868 /* test some actual data */
1869 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1870 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1871 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1872 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1873 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1874 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1875 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1877 ret
= pDeactivateActCtx(0, cookie
);
1878 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1880 pReleaseActCtx(handle
);
1883 static void test_allowDelayedBinding(void)
1887 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
1888 skip("Could not create manifest file\n");
1892 handle
= test_create("test5.manifest");
1893 if (handle
== INVALID_HANDLE_VALUE
) {
1894 win_skip("allowDelayedBinding attribute is not supported.\n");
1898 DeleteFileA("test5.manifest");
1899 DeleteFileA("testdep.manifest");
1900 if (handle
!= INVALID_HANDLE_VALUE
) {
1901 test_basic_info(handle
, __LINE__
);
1902 pReleaseActCtx(handle
);
1906 static void test_actctx(void)
1914 trace("default actctx\n");
1916 b
= pGetCurrentActCtx(&handle
);
1917 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1918 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1920 test_basic_info(handle
, __LINE__
);
1921 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1922 test_runlevel_info(handle
, &runlevel_info0
, __LINE__
);
1923 pReleaseActCtx(handle
);
1926 /* test for whitespace handling in Eq ::= S? '=' S? */
1927 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
1928 handle
= test_create("test1_1.manifest");
1929 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1930 DeleteFileA("test1_1.manifest");
1931 pReleaseActCtx(handle
);
1933 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1934 skip("Could not create manifest file\n");
1938 trace("manifest1\n");
1940 handle
= test_create("test1.manifest");
1941 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1942 DeleteFileA("test1.manifest");
1943 if(handle
!= INVALID_HANDLE_VALUE
) {
1944 test_basic_info(handle
, __LINE__
);
1945 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1946 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1948 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
1950 /* CloseHandle will generate an exception if a debugger is present */
1951 b
= CloseHandle(handle
);
1952 ok(!b
, "CloseHandle succeeded\n");
1953 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
1956 pReleaseActCtx(handle
);
1959 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
1960 skip("Could not create manifest file\n");
1964 trace("manifest2 depmanifest1\n");
1966 handle
= test_create("test2.manifest");
1967 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1968 DeleteFileA("test2.manifest");
1969 DeleteFileA("testdep.manifest");
1970 if(handle
!= INVALID_HANDLE_VALUE
) {
1971 test_basic_info(handle
, __LINE__
);
1972 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1973 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1974 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
1975 pReleaseActCtx(handle
);
1978 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
1979 skip("Could not create manifest file\n");
1983 trace("manifest2 depmanifest2\n");
1985 handle
= test_create("test2-2.manifest");
1986 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1987 DeleteFileA("test2-2.manifest");
1988 DeleteFileA("testdep.manifest");
1989 if(handle
!= INVALID_HANDLE_VALUE
) {
1990 test_basic_info(handle
, __LINE__
);
1991 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1992 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1993 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
1994 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1995 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1997 b
= pActivateActCtx(handle
, &cookie
);
1998 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1999 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2000 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2001 b
= pDeactivateActCtx(0, cookie
);
2002 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2004 pReleaseActCtx(handle
);
2007 trace("manifest2 depmanifest3\n");
2009 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
2010 skip("Could not create manifest file\n");
2014 handle
= test_create("test2-3.manifest");
2015 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2016 DeleteFileA("test2-3.manifest");
2017 DeleteFileA("testdep.manifest");
2018 if(handle
!= INVALID_HANDLE_VALUE
) {
2019 test_basic_info(handle
, __LINE__
);
2020 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2021 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
2022 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
2023 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
2024 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
2026 b
= pActivateActCtx(handle
, &cookie
);
2027 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2028 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
2029 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
2030 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
2031 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
2032 b
= pDeactivateActCtx(0, cookie
);
2033 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2035 pReleaseActCtx(handle
);
2038 trace("manifest3\n");
2040 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
2041 skip("Could not create manifest file\n");
2045 handle
= test_create("test3.manifest");
2046 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
2047 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2048 if (handle
== INVALID_HANDLE_VALUE
)
2049 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
2050 DeleteFileA("test3.manifest");
2051 if(handle
!= INVALID_HANDLE_VALUE
) {
2052 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
2053 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
2054 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
2055 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
2057 test_basic_info(handle
, __LINE__
);
2058 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2059 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
2060 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
2062 b
= pActivateActCtx(handle
, &cookie
);
2063 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
2064 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2065 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
2066 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
2067 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
2068 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
2069 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
2070 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
2071 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
2072 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
2073 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
2074 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
2075 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
2076 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
2077 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
2078 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
2079 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
2080 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
2081 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
2082 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
2083 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
2084 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
2085 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
2086 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
2087 test_find_string_fail();
2089 b
= pDeactivateActCtx(0, cookie
);
2090 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
2091 pReleaseActCtx(handle
);
2094 trace("manifest6\n");
2096 if(create_manifest_file("test6.manifest", manifest6
, -1, NULL
, NULL
)) {
2097 handle
= test_create("test6.manifest");
2098 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2099 DeleteFileA("test6.manifest");
2100 DeleteFileA("testdep.manifest");
2101 if(handle
!= INVALID_HANDLE_VALUE
)
2103 test_runlevel_info(handle
, &runlevel_info6
, __LINE__
);
2104 pReleaseActCtx(handle
);
2108 skip("Could not create manifest file 6\n");
2110 trace("manifest7\n");
2112 if(create_manifest_file("test7.manifest", manifest7
, -1, NULL
, NULL
)) {
2113 handle
= test_create("test7.manifest");
2114 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2115 DeleteFileA("test7.manifest");
2116 DeleteFileA("testdep.manifest");
2117 if(handle
!= INVALID_HANDLE_VALUE
)
2119 test_runlevel_info(handle
, &runlevel_info7
, __LINE__
);
2120 pReleaseActCtx(handle
);
2124 skip("Could not create manifest file 7\n");
2126 trace("manifest8\n");
2128 if(create_manifest_file("test8.manifest", manifest8
, -1, NULL
, NULL
)) {
2129 handle
= test_create("test8.manifest");
2130 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2131 DeleteFileA("test8.manifest");
2132 DeleteFileA("testdep.manifest");
2133 if(handle
!= INVALID_HANDLE_VALUE
)
2135 test_runlevel_info(handle
, &runlevel_info8
, __LINE__
);
2136 pReleaseActCtx(handle
);
2140 skip("Could not create manifest file 8\n");
2142 trace("manifest9\n");
2144 if(create_manifest_file("test9.manifest", manifest9
, -1, NULL
, NULL
)) {
2145 handle
= test_create("test9.manifest");
2146 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2147 DeleteFileA("test9.manifest");
2148 DeleteFileA("testdep.manifest");
2149 if(handle
!= INVALID_HANDLE_VALUE
)
2151 test_runlevel_info(handle
, &runlevel_info9
, __LINE__
);
2152 pReleaseActCtx(handle
);
2156 skip("Could not create manifest file 9\n");
2158 trace("manifest4\n");
2160 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
2161 skip("Could not create manifest file\n");
2165 handle
= test_create("test4.manifest");
2166 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2167 DeleteFileA("test4.manifest");
2168 DeleteFileA("testdep.manifest");
2169 if(handle
!= INVALID_HANDLE_VALUE
) {
2170 test_basic_info(handle
, __LINE__
);
2171 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
2172 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
2173 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
2174 pReleaseActCtx(handle
);
2177 trace("manifest1 in subdir\n");
2179 CreateDirectoryW(work_dir_subdir
, NULL
);
2180 if (SetCurrentDirectoryW(work_dir_subdir
))
2182 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
2183 skip("Could not create manifest file\n");
2186 handle
= test_create("..\\test1.manifest");
2187 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2188 DeleteFileA("..\\test1.manifest");
2189 if(handle
!= INVALID_HANDLE_VALUE
) {
2190 test_basic_info(handle
, __LINE__
);
2191 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2192 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2193 pReleaseActCtx(handle
);
2195 SetCurrentDirectoryW(work_dir
);
2198 skip("Couldn't change directory\n");
2199 RemoveDirectoryW(work_dir_subdir
);
2201 trace("UTF-16 manifest1, with BOM\n");
2202 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
2203 skip("Could not create manifest file\n");
2207 handle
= test_create("test1.manifest");
2208 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2209 DeleteFileA("test1.manifest");
2210 if (handle
!= INVALID_HANDLE_VALUE
) {
2211 test_basic_info(handle
, __LINE__
);
2212 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2213 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2214 pReleaseActCtx(handle
);
2217 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2218 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
2219 skip("Could not create manifest file\n");
2223 handle
= test_create("test1.manifest");
2224 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2225 DeleteFileA("test1.manifest");
2226 if (handle
!= INVALID_HANDLE_VALUE
) {
2227 test_basic_info(handle
, __LINE__
);
2228 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2229 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2230 pReleaseActCtx(handle
);
2233 test_wndclass_section();
2234 test_dllredirect_section();
2235 test_typelib_section();
2236 test_allowDelayedBinding();
2239 static void test_app_manifest(void)
2244 trace("child process manifest1\n");
2246 b
= pGetCurrentActCtx(&handle
);
2247 ok(handle
== NULL
, "handle != NULL\n");
2248 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2250 test_basic_info(handle
, __LINE__
);
2251 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2252 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2253 pReleaseActCtx(handle
);
2257 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2260 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2262 handle
= test_create(filename
);
2263 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2264 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2266 DeleteFileA(filename
);
2270 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, int line
)
2272 UNICODE_STRING string_to_findW
;
2273 ACTCTX_SECTION_KEYED_DATA data
;
2277 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2279 memset(&data
, 0xfe, sizeof(data
));
2280 data
.cbSize
= sizeof(data
);
2283 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, &data
);
2284 err
= GetLastError();
2285 ok_(__FILE__
, line
)(ret
== should_find
,
2286 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find
, ret
);
2287 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2288 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2290 memset(&data
, 0xfe, sizeof(data
));
2291 data
.cbSize
= sizeof(data
);
2294 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2295 err
= GetLastError();
2296 ok_(__FILE__
, line
)(ret
== should_find
,
2297 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2298 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2299 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2302 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2303 err
= GetLastError();
2304 ok_(__FILE__
, line
)(!ret
,
2305 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2306 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2307 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2310 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2311 err
= GetLastError();
2312 ok_(__FILE__
, line
)(!ret
,
2313 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2314 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2315 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2317 pRtlFreeUnicodeString(&string_to_findW
);
2320 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, int line
)
2322 UNICODE_STRING string_to_findW
;
2323 ACTCTX_SECTION_KEYED_DATA data
;
2326 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2328 memset(&data
, 0xfe, sizeof(data
));
2329 data
.cbSize
= sizeof(data
);
2331 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2332 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2333 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2335 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2336 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2337 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2339 pRtlFreeUnicodeString(&string_to_findW
);
2342 static void test_findsectionstring(void)
2348 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2349 ret
= pActivateActCtx(handle
, &cookie
);
2350 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2352 /* first we show the parameter validation from kernel32 */
2353 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, __LINE__
);
2354 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, __LINE__
);
2355 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, __LINE__
);
2356 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, __LINE__
);
2357 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, __LINE__
);
2358 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, __LINE__
);
2359 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, __LINE__
);
2361 /* then we show that ntdll plays by different rules */
2362 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, __LINE__
);
2363 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, __LINE__
);
2364 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, __LINE__
);
2365 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, __LINE__
);
2366 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, __LINE__
);
2367 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, __LINE__
);
2368 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, __LINE__
);
2370 ret
= pDeactivateActCtx(0, cookie
);
2371 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2372 pReleaseActCtx(handle
);
2375 static void run_child_process(void)
2377 char cmdline
[MAX_PATH
];
2378 char path
[MAX_PATH
];
2380 PROCESS_INFORMATION pi
;
2381 STARTUPINFOA si
= { 0 };
2386 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2387 strcat(path
, ".manifest");
2388 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2389 skip("Could not create manifest file\n");
2394 winetest_get_mainargs( &argv
);
2395 /* Vista+ seems to cache presence of .manifest files. Change last modified
2396 date to defeat the cache */
2397 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2398 NULL
, OPEN_EXISTING
, 0, NULL
);
2399 if (file
!= INVALID_HANDLE_VALUE
) {
2400 GetSystemTimeAsFileTime(&now
);
2401 SetFileTime(file
, NULL
, NULL
, &now
);
2404 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2405 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2406 ok(ret
, "Could not create process: %u\n", GetLastError());
2407 winetest_wait_child_process( pi
.hProcess
);
2408 CloseHandle(pi
.hThread
);
2409 CloseHandle(pi
.hProcess
);
2413 static void init_paths(void)
2417 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2418 static const WCHAR backslash
[] = {'\\',0};
2419 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2421 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2422 lstrcpyW(app_dir
, exe_path
);
2423 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2426 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2427 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2428 if (*ptr
!= '\\' && *ptr
!= '/')
2429 lstrcatW(work_dir
, backslash
);
2430 lstrcpyW(work_dir_subdir
, work_dir
);
2431 lstrcatW(work_dir_subdir
, subdir
);
2433 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2434 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2437 static void write_manifest(const char *filename
, const char *manifest
)
2441 CHAR path
[MAX_PATH
];
2443 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2444 strcat(path
, filename
);
2446 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2447 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2448 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2452 static void delete_manifest_file(const char *filename
)
2454 CHAR path
[MAX_PATH
];
2456 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2457 strcat(path
, filename
);
2461 static void test_CreateActCtx(void)
2463 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2467 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2468 strcat(path
, "main_wndcls.manifest");
2470 write_manifest("testdep1.manifest", manifest_wndcls1
);
2471 write_manifest("testdep2.manifest", manifest_wndcls2
);
2472 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2474 memset(&actctx
, 0, sizeof(ACTCTXA
));
2475 actctx
.cbSize
= sizeof(ACTCTXA
);
2476 actctx
.lpSource
= path
;
2478 /* create using lpSource without specified directory */
2479 handle
= pCreateActCtxA(&actctx
);
2480 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2481 pReleaseActCtx(handle
);
2483 /* with specified directory, that doesn't contain dependent assembly */
2484 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2486 memset(&actctx
, 0, sizeof(ACTCTXA
));
2487 actctx
.cbSize
= sizeof(ACTCTXA
);
2488 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2489 actctx
.lpAssemblyDirectory
= dir
;
2490 actctx
.lpSource
= path
;
2492 SetLastError(0xdeadbeef);
2493 handle
= pCreateActCtxA(&actctx
);
2495 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2496 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2498 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2500 delete_manifest_file("main_wndcls.manifest");
2501 delete_manifest_file("testdep1.manifest");
2502 delete_manifest_file("testdep2.manifest");
2504 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2505 memset(&actctx
, 0, sizeof(ACTCTXA
));
2506 actctx
.cbSize
= sizeof(ACTCTXA
);
2507 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2508 SetLastError(0xdeadbeef);
2509 handle
= pCreateActCtxA(&actctx
);
2510 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2512 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2513 "got error %d\n", GetLastError());
2515 /* create from HMODULE - resource doesn't exist, lpSource is set */
2516 memset(&actctx
, 0, sizeof(ACTCTXA
));
2517 actctx
.cbSize
= sizeof(ACTCTXA
);
2518 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2519 actctx
.lpSource
= "dummyfile.dll";
2520 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2521 actctx
.hModule
= GetModuleHandleA(NULL
);
2523 SetLastError(0xdeadbeef);
2524 handle
= pCreateActCtxA(&actctx
);
2525 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2526 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2528 /* load manifest from lpAssemblyDirectory directory */
2529 write_manifest("testdir.manifest", manifest1
);
2530 GetTempPathA(sizeof(path
)/sizeof(path
[0]), path
);
2531 SetCurrentDirectoryA(path
);
2532 strcat(path
, "assembly_dir");
2534 strcat(path
, "\\testdir.manifest");
2536 memset(&actctx
, 0, sizeof(actctx
));
2537 actctx
.cbSize
= sizeof(actctx
);
2538 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2539 actctx
.lpSource
= "testdir.manifest";
2540 actctx
.lpAssemblyDirectory
= dir
;
2542 SetLastError(0xdeadbeef);
2543 handle
= pCreateActCtxA(&actctx
);
2544 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2545 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2546 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2547 "got error %d\n", GetLastError());
2549 CreateDirectoryA(dir
, NULL
);
2550 memset(&actctx
, 0, sizeof(actctx
));
2551 actctx
.cbSize
= sizeof(actctx
);
2552 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2553 actctx
.lpSource
= "testdir.manifest";
2554 actctx
.lpAssemblyDirectory
= dir
;
2556 SetLastError(0xdeadbeef);
2557 handle
= pCreateActCtxA(&actctx
);
2558 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2559 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %d\n", GetLastError());
2560 SetCurrentDirectoryW(work_dir
);
2562 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
2563 memset(&actctx
, 0, sizeof(actctx
));
2564 actctx
.cbSize
= sizeof(actctx
);
2565 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2566 actctx
.lpSource
= "testdir.manifest";
2567 actctx
.lpAssemblyDirectory
= dir
;
2569 handle
= pCreateActCtxA(&actctx
);
2570 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2571 pReleaseActCtx(handle
);
2573 memset(&actctx
, 0, sizeof(actctx
));
2574 actctx
.cbSize
= sizeof(actctx
);
2575 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2576 actctx
.lpSource
= path
;
2577 actctx
.lpAssemblyDirectory
= dir
;
2579 handle
= pCreateActCtxA(&actctx
);
2580 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2581 pReleaseActCtx(handle
);
2583 delete_manifest_file("testdir.manifest");
2584 delete_manifest_file("assembly_dir\\testdir.manifest");
2585 RemoveDirectoryA(dir
);
2588 static BOOL
init_funcs(void)
2590 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
2592 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2596 X(DeactivateActCtx
);
2597 X(FindActCtxSectionStringA
);
2598 X(FindActCtxSectionStringW
);
2599 X(GetCurrentActCtx
);
2600 X(IsDebuggerPresent
);
2603 X(FindActCtxSectionGuid
);
2606 hLibrary
= GetModuleHandleA("ntdll.dll");
2607 X(RtlFindActivationContextSectionString
);
2608 X(RtlCreateUnicodeStringFromAsciiz
);
2609 X(RtlFreeUnicodeString
);
2615 static void test_ZombifyActCtx(void)
2617 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
2619 HANDLE handle
, current
;
2622 SetLastError(0xdeadbeef);
2623 ret
= pZombifyActCtx(NULL
);
2625 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "got %d, error %d\n", ret
, GetLastError());
2627 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2629 ret
= pGetCurrentActCtx(¤t
);
2630 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2631 ok(current
== NULL
, "got %p\n", current
);
2633 ret
= pActivateActCtx(handle
, &cookie
);
2634 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2636 ret
= pGetCurrentActCtx(¤t
);
2637 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2638 ok(handle
== current
, "got %p, %p\n", current
, handle
);
2640 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2641 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2642 &basicinfo
, sizeof(basicinfo
), NULL
);
2643 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2644 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2645 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2647 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2648 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2649 &basicinfo
, sizeof(basicinfo
), NULL
);
2650 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2651 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2652 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2654 ret
= pZombifyActCtx(handle
);
2656 ok(ret
, "got %d\n", ret
);
2658 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2659 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2660 &basicinfo
, sizeof(basicinfo
), NULL
);
2661 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2662 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2663 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2665 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2666 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2667 &basicinfo
, sizeof(basicinfo
), NULL
);
2668 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2669 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2670 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2672 ret
= pGetCurrentActCtx(¤t
);
2673 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2674 ok(current
== handle
, "got %p\n", current
);
2677 ret
= pZombifyActCtx(handle
);
2679 ok(ret
, "got %d\n", ret
);
2681 ret
= pDeactivateActCtx(0, cookie
);
2682 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2683 pReleaseActCtx(handle
);
2691 argc
= winetest_get_mainargs(&argv
);
2695 win_skip("Needed functions are not available\n");
2700 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2701 test_app_manifest();
2706 test_CreateActCtx();
2707 test_findsectionstring();
2708 test_ZombifyActCtx();
2709 run_child_process();