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
19 #include <wine/test.h>
30 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
31 static HANDLE (WINAPI
*pCreateActCtxA
)(PCACTCTXA
);
32 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
33 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
34 static BOOL (WINAPI
*pFindActCtxSectionStringA
)(DWORD
,const GUID
*,ULONG
,LPCSTR
,PACTCTX_SECTION_KEYED_DATA
);
35 static BOOL (WINAPI
*pFindActCtxSectionStringW
)(DWORD
,const GUID
*,ULONG
,LPCWSTR
,PACTCTX_SECTION_KEYED_DATA
);
36 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
37 static BOOL (WINAPI
*pIsDebuggerPresent
)(void);
38 static BOOL (WINAPI
*pQueryActCtxW
)(DWORD
,HANDLE
,PVOID
,ULONG
,PVOID
,SIZE_T
,SIZE_T
*);
39 static VOID (WINAPI
*pReleaseActCtx
)(HANDLE
);
40 static BOOL (WINAPI
*pFindActCtxSectionGuid
)(DWORD
,const GUID
*,ULONG
,const GUID
*,PACTCTX_SECTION_KEYED_DATA
);
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__
60 static const char manifest1
[] =
61 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
62 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
65 static const char manifest1_1
[] =
66 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
67 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
70 static const char manifest2
[] =
71 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
72 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
76 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
78 "</dependentAssembly>"
82 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
83 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
84 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
85 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
86 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
87 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
88 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
89 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
90 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
91 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
92 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
93 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
94 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
96 static const char manifest3
[] =
97 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
98 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
99 " publicKeyToken=\"6595b6414666f1df\" />"
100 "<file name=\"testlib.dll\">"
101 "<windowClass>wndClass</windowClass>"
102 " <comClass description=\"Test com class\""
103 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
104 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
105 " threadingModel=\"Neutral\""
106 " progid=\"ProgId.ProgId\""
107 " miscStatus=\"cantlinkinside\""
108 " miscStatusIcon=\"recomposeonresize\""
109 " miscStatusContent=\"insideout\""
110 " miscStatusThumbnail=\"alignable\""
111 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
113 " <progid>ProgId.ProgId.1</progid>"
114 " <progid>ProgId.ProgId.2</progid>"
115 " <progid>ProgId.ProgId.3</progid>"
116 " <progid>ProgId.ProgId.4</progid>"
117 " <progid>ProgId.ProgId.5</progid>"
118 " <progid>ProgId.ProgId.6</progid>"
120 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
121 " <progid>ProgId.ProgId.7</progid>"
123 " <comInterfaceProxyStub "
125 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
126 " iid=\"{66666666-8888-7777-6666-555555555555}\""
127 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
128 " threadingModel=\"Free\""
130 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
133 " <comInterfaceExternalProxyStub "
134 " name=\"Iifaceps2\""
135 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
136 " iid=\"{76666666-8888-7777-6666-555555555555}\""
137 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
139 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
141 " <comInterfaceExternalProxyStub "
142 " name=\"Iifaceps3\""
143 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
144 " iid=\"{86666666-8888-7777-6666-555555555555}\""
146 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
149 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
150 " name=\"testsurrogate\""
151 " runtimeVersion=\"v2.0.50727\""
154 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
156 " progid=\"clrprogid\""
157 " description=\"test description\""
158 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
159 " runtimeVersion=\"1.2.3.4\""
160 " threadingModel=\"Neutral\""
162 " <progid>clrprogid.1</progid>"
163 " <progid>clrprogid.2</progid>"
164 " <progid>clrprogid.3</progid>"
165 " <progid>clrprogid.4</progid>"
166 " <progid>clrprogid.5</progid>"
167 " <progid>clrprogid.6</progid>"
171 static const char manifest_wndcls1
[] =
172 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
173 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
174 "<file name=\"testlib1.dll\">"
175 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
176 "<windowClass>wndClass2</windowClass>"
177 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
179 "<file name=\"testlib1_2.dll\" />"
182 static const char manifest_wndcls2
[] =
183 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
184 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
185 "<file name=\"testlib2.dll\">"
186 " <windowClass versioned=\"no\">wndClass3</windowClass>"
187 " <windowClass>wndClass4</windowClass>"
188 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
189 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
190 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
191 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
193 "<file name=\"testlib2_2.dll\" />"
196 static const char manifest_wndcls_main
[] =
197 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
198 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
200 " <dependentAssembly>"
201 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
202 " </dependentAssembly>"
205 " <dependentAssembly>"
206 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
207 " </dependentAssembly>"
211 static const char manifest4
[] =
212 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
213 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
214 "</assemblyIdentity>"
216 "<dependentAssembly>"
217 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
218 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
219 "</assemblyIdentity>"
220 "</dependentAssembly>"
224 static const char testdep_manifest1
[] =
225 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
226 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
229 static const char testdep_manifest2
[] =
230 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
231 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
232 "<file name=\"testlib.dll\"></file>"
233 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
236 static const char testdep_manifest3
[] =
237 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
238 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
239 "<file name=\"testlib.dll\"/>"
240 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
241 "<windowClass>wndClass</windowClass>"
242 "<windowClass>wndClass2</windowClass>"
246 static const char wrong_manifest1
[] =
247 "<assembly manifestVersion=\"1.0\">"
248 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
251 static const char wrong_manifest2
[] =
252 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
253 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
256 static const char wrong_manifest3
[] =
257 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
258 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
261 static const char wrong_manifest4
[] =
262 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
263 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
267 static const char wrong_manifest5
[] =
268 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
269 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
273 static const char wrong_manifest6
[] =
274 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
275 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
278 static const char wrong_manifest7
[] =
279 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
280 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
281 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
284 static const char wrong_manifest8
[] =
285 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
286 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
290 static const char wrong_depmanifest1
[] =
291 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
292 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
295 static const WCHAR testlib_dll
[] =
296 {'t','e','s','t','l','i','b','.','d','l','l',0};
297 static const WCHAR testlib2_dll
[] =
298 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
299 static const WCHAR wndClassW
[] =
300 {'w','n','d','C','l','a','s','s',0};
301 static const WCHAR wndClass1W
[] =
302 {'w','n','d','C','l','a','s','s','1',0};
303 static const WCHAR wndClass2W
[] =
304 {'w','n','d','C','l','a','s','s','2',0};
305 static const WCHAR wndClass3W
[] =
306 {'w','n','d','C','l','a','s','s','3',0};
307 static const WCHAR acr_manifest
[] =
308 {'a','c','r','.','m','a','n','i','f','e','s','t',0};
310 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
311 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
313 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
318 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
319 return lstrcmpW(strw
, buf
);
322 static DWORD
strlen_aw(const char *str
)
324 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
327 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
328 const char *depfile
, const char *depmanifest
)
332 WCHAR path
[MAX_PATH
];
334 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
335 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
337 if (manifest_len
== -1)
338 manifest_len
= strlen(manifest
);
340 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
341 FILE_ATTRIBUTE_NORMAL
, NULL
);
342 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
343 if(file
== INVALID_HANDLE_VALUE
)
345 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
350 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
351 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
352 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
353 FILE_ATTRIBUTE_NORMAL
, NULL
);
354 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
355 if(file
== INVALID_HANDLE_VALUE
)
357 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
363 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
365 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
367 int offset
= (fBOM
? 0 : 1);
369 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
370 wmanifest
[0] = 0xfeff;
374 for (i
= 0; i
< strlen(manifest
)+1; i
++)
375 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
377 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
378 HeapFree(GetProcessHeap(), 0, wmanifest
);
383 ULONG format_version
;
384 ULONG assembly_cnt_min
;
385 ULONG assembly_cnt_max
;
386 ULONG root_manifest_type
;
387 LPWSTR root_manifest_path
;
388 ULONG root_config_type
;
393 static const detailed_info_t detailed_info0
= {
394 0, 0, 0, 0, NULL
, 0, 0, NULL
397 static const detailed_info_t detailed_info1
= {
398 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
399 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
403 static const detailed_info_t detailed_info1_child
= {
404 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
405 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
409 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
410 static const detailed_info_t detailed_info2
= {
411 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
412 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
416 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
418 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
419 SIZE_T size
, exsize
, retsize
;
422 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
423 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
424 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
426 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
428 b
= pQueryActCtxW(0, handle
, NULL
,
429 ActivationContextDetailedInformation
, &detailed_info_tmp
,
430 sizeof(detailed_info_tmp
), &size
);
431 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
432 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
433 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
435 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
438 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
439 memset(detailed_info
, 0xfe, size
);
440 b
= pQueryActCtxW(0, handle
, NULL
,
441 ActivationContextDetailedInformation
, detailed_info
,
443 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
444 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
446 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
447 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
448 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
449 exinfo
->format_version
);
450 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
451 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
452 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
453 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
454 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
455 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
456 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
457 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
458 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
459 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
460 detailed_info
->ulRootManifestPathChars
,
461 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
462 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
463 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
464 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
465 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
466 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
467 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
468 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
469 exinfo
->app_dir_type
);
470 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
471 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
472 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
473 if(exinfo
->root_manifest_path
) {
474 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
475 if(detailed_info
->lpRootManifestPath
)
476 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
477 "unexpected detailed_info->lpRootManifestPath\n");
479 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
481 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
482 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
483 if(exinfo
->app_dir
) {
484 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
485 if(detailed_info
->lpAppDirPath
)
486 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
487 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
489 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
492 HeapFree(GetProcessHeap(), 0, detailed_info
);
497 /* ULONG manifest_path_type; FIXME */
498 LPCWSTR manifest_path
;
499 LPCSTR encoded_assembly_id
;
500 BOOL has_assembly_dir
;
503 static const info_in_assembly manifest1_info
= {
505 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
509 static const info_in_assembly manifest1_child_info
= {
510 1, app_manifest_path
,
511 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
515 static const info_in_assembly manifest2_info
= {
517 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
521 static const info_in_assembly manifest3_info
= {
523 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
527 static const info_in_assembly manifest4_info
= {
529 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
533 static const info_in_assembly depmanifest1_info
= {
534 0x10, depmanifest_path
,
535 "testdep,processorArchitecture=\"" ARCH
"\","
536 "type=\"win32\",version=\"6.5.4.3\"",
540 static const info_in_assembly depmanifest2_info
= {
541 0x10, depmanifest_path
,
542 "testdep,processorArchitecture=\"" ARCH
"\","
543 "type=\"win32\",version=\"6.5.4.3\"",
547 static const info_in_assembly depmanifest3_info
= {
548 0x10, depmanifest_path
,
549 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
553 static const info_in_assembly manifest_comctrl_info
= {
554 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
557 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
559 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
564 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
565 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
566 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
569 b
= pQueryActCtxW(0, handle
, &id
,
570 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
571 sizeof(info_tmp
), &size
);
572 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
573 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
575 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
577 if (size
== 0xdeadbeef)
583 info
= HeapAlloc(GetProcessHeap(), 0, size
);
584 memset(info
, 0xfe, size
);
587 b
= pQueryActCtxW(0, handle
, &id
,
588 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
589 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
590 if (!exinfo
->manifest_path
)
591 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
592 if (!exinfo
->encoded_assembly_id
)
593 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
594 if (exinfo
->has_assembly_dir
)
595 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
596 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
598 if (0) /* FIXME: flags meaning unknown */
600 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
601 info
->ulFlags
, exinfo
->flags
);
603 if(exinfo
->encoded_assembly_id
) {
604 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
605 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
606 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
607 info
->ulEncodedAssemblyIdentityLength
, len
);
609 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
610 "info->ulEncodedAssemblyIdentityLength == 0\n");
612 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
613 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
614 if(exinfo
->manifest_path
) {
615 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
616 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
617 info
->ulManifestPathLength
, len
);
619 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
622 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
623 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
624 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
625 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
626 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
627 info
->ulMetadataSatelliteRosterIndex
);
628 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
629 info
->ulManifestVersionMajor
);
630 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
631 info
->ulManifestVersionMinor
);
632 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
633 info
->ulPolicyVersionMajor
);
634 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
635 info
->ulPolicyVersionMinor
);
636 if(exinfo
->has_assembly_dir
)
637 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
638 "info->ulAssemblyDirectoryNameLength == 0\n");
640 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
641 "info->ulAssemblyDirectoryNameLength != 0\n");
643 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
644 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
645 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
646 ok_(__FILE__
, line
)(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
647 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
648 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
650 if(exinfo
->manifest_path
) {
651 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
652 if(info
->lpAssemblyManifestPath
)
653 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
654 "unexpected info->lpAssemblyManifestPath\n");
656 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
659 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
660 if(info
->lpAssemblyPolicyPath
)
661 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
662 if(exinfo
->has_assembly_dir
)
663 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
665 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
666 strw(info
->lpAssemblyDirectoryName
));
667 HeapFree(GetProcessHeap(), 0, info
);
670 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
672 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
673 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
677 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
678 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
681 b
= pQueryActCtxW(0, handle
, &index
,
682 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
683 sizeof(info_tmp
), &size
);
684 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
685 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
686 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
688 if(size
== 0xdeadbeef)
694 info
= HeapAlloc(GetProcessHeap(), 0, size
);
695 memset(info
, 0xfe, size
);
697 b
= pQueryActCtxW(0, handle
, &index
,
698 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
699 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
700 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
702 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
703 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
704 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
705 info
->ulFilenameLength
, lstrlenW(filename
));
706 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
707 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
709 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
710 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
711 HeapFree(GetProcessHeap(), 0, info
);
714 static HANDLE
test_create(const char *file
)
718 WCHAR path
[MAX_PATH
];
720 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
721 memset(&actctx
, 0, sizeof(ACTCTXW
));
722 actctx
.cbSize
= sizeof(ACTCTXW
);
723 actctx
.lpSource
= path
;
725 handle
= pCreateActCtxW(&actctx
);
726 /* to be tested outside of this helper, including last error */
727 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
729 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
730 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%d\n", actctx
.dwFlags
);
731 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
732 ok(actctx
.wProcessorArchitecture
== 0,
733 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
734 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
735 ok(actctx
.lpAssemblyDirectory
== NULL
,
736 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
737 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
738 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
739 actctx
.lpApplicationName
);
740 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
745 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
749 WCHAR path
[MAX_PATH
];
751 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
752 memset(&actctx
, 0, sizeof(ACTCTXW
));
753 actctx
.cbSize
= sizeof(ACTCTXW
);
754 actctx
.lpSource
= path
;
756 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
757 handle
= pCreateActCtxW(&actctx
);
760 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
761 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
765 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
766 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
768 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
769 DeleteFileA("bad.manifest");
770 DeleteFileA("testdep.manifest");
773 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
777 WCHAR path
[MAX_PATH
];
779 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
780 memset(&actctx
, 0, sizeof(ACTCTXW
));
781 actctx
.cbSize
= sizeof(ACTCTXW
);
782 actctx
.lpSource
= path
;
784 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
785 handle
= pCreateActCtxW(&actctx
);
786 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
787 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
789 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
790 DeleteFileA("bad.manifest");
793 static void test_create_fail(void)
797 WCHAR path
[MAX_PATH
];
799 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
800 memset(&actctx
, 0, sizeof(ACTCTXW
));
801 actctx
.cbSize
= sizeof(ACTCTXW
);
802 actctx
.lpSource
= path
;
804 handle
= pCreateActCtxW(&actctx
);
805 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
806 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
808 trace("wrong_manifest1\n");
809 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
810 trace("wrong_manifest2\n");
811 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
812 trace("wrong_manifest3\n");
813 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
814 trace("wrong_manifest4\n");
815 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
816 trace("wrong_manifest5\n");
817 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
818 trace("wrong_manifest6\n");
819 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
820 trace("wrong_manifest7\n");
821 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
822 trace("wrong_manifest8\n");
823 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
824 trace("UTF-16 manifest1 without BOM\n");
825 test_create_wide_and_fail(manifest1
, FALSE
);
826 trace("manifest2\n");
827 test_create_and_fail(manifest2
, NULL
, 0 );
828 trace("manifest2+depmanifest1\n");
829 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
832 struct strsection_header
854 struct guidsection_header
874 struct wndclass_redirect_data
879 ULONG name_offset
; /* versioned name offset */
881 ULONG module_offset
;/* container name offset */
884 struct dllredirect_data
891 struct tlibredirect_data
905 struct progidredirect_data
912 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
914 ACTCTX_SECTION_KEYED_DATA data
;
917 memset(&data
, 0xfe, sizeof(data
));
918 data
.cbSize
= sizeof(data
);
920 ret
= pFindActCtxSectionStringW(0, NULL
,
921 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
923 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
926 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
927 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
928 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
929 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
933 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
934 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
935 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
936 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
937 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
938 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
941 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
942 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
943 data
.ulSectionGlobalDataLength
);
944 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
945 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
946 data
.ulSectionTotalLength
);
947 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
948 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
949 data
.ulAssemblyRosterIndex
, exid
);
951 memset(&data
, 0xfe, sizeof(data
));
952 data
.cbSize
= sizeof(data
);
954 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
955 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
957 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
960 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
961 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
962 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
963 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
964 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
965 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
966 data
.ulSectionGlobalDataLength
);
967 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
968 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
969 data
.ulSectionTotalLength
);
970 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
971 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
972 data
.ulAssemblyRosterIndex
, exid
);
974 pReleaseActCtx(handle
);
977 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
979 struct wndclass_redirect_data
*wnddata
;
980 struct strsection_header
*header
;
981 ACTCTX_SECTION_KEYED_DATA data
;
984 memset(&data
, 0xfe, sizeof(data
));
985 data
.cbSize
= sizeof(data
);
987 ret
= pFindActCtxSectionStringW(0, NULL
,
988 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
990 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
991 wine_dbgstr_w(clsname
));
994 header
= (struct strsection_header
*)data
.lpSectionBase
;
995 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
997 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
998 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
999 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1000 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1001 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1002 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1003 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1005 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1010 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1011 /* redirect class name (versioned or not) is stored just after header data */
1012 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1013 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1015 /* expected versioned name */
1016 lstrcpyW(buff
, verW
);
1017 lstrcatW(buff
, clsname
);
1018 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1019 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1020 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1021 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1023 /* data length is simply header length + string data length including nulls */
1024 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1025 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1027 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1029 WCHAR
*modulename
, *sectionptr
;
1031 /* just compare pointers */
1032 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1033 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1034 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1038 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1039 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1040 data
.ulSectionGlobalDataLength
);
1041 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1042 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1043 data
.ulSectionTotalLength
);
1044 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1045 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1046 data
.ulAssemblyRosterIndex
, exid
);
1048 memset(&data
, 0xfe, sizeof(data
));
1049 data
.cbSize
= sizeof(data
);
1051 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1052 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1054 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1055 wine_dbgstr_w(clsname
));
1058 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1059 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1060 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1061 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1062 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1063 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1064 data
.ulSectionGlobalDataLength
);
1065 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1066 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1067 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1068 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1069 data
.ulAssemblyRosterIndex
, exid
);
1071 pReleaseActCtx(handle
);
1074 static void test_find_string_fail(void)
1076 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1079 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1080 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1081 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1083 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1084 testlib2_dll
, &data
);
1085 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1086 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1088 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1090 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1091 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1093 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1095 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1096 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1099 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1100 testlib_dll
, &data
);
1101 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1102 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1105 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1106 testlib_dll
, &data
);
1107 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1108 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1112 static void test_basic_info(HANDLE handle
, int line
)
1114 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1118 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1119 ActivationContextBasicInformation
, &basic
,
1120 sizeof(basic
), &size
);
1122 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1123 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1124 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1125 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1127 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1128 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1129 ActivationContextBasicInformation
, &basic
,
1130 sizeof(basic
), &size
);
1133 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1134 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1135 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1136 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1137 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1141 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1142 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1143 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1144 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1148 enum comclass_threadingmodel
{
1149 ThreadingModel_Apartment
= 1,
1150 ThreadingModel_Free
= 2,
1151 ThreadingModel_No
= 3,
1152 ThreadingModel_Both
= 4,
1153 ThreadingModel_Neutral
= 5
1156 enum comclass_miscfields
{
1159 MiscStatusContent
= 4,
1160 MiscStatusThumbnail
= 8,
1161 MiscStatusDocPrint
= 16
1164 struct comclassredirect_data
{
1177 ULONG progid_offset
;
1179 ULONG clrdata_offset
;
1181 DWORD miscstatuscontent
;
1182 DWORD miscstatusthumbnail
;
1183 DWORD miscstatusicon
;
1184 DWORD miscstatusdocprint
;
1187 struct clrclass_data
{
1191 ULONG module_offset
;
1195 ULONG version_offset
;
1199 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1201 struct comclassredirect_data
*comclass
, *comclass2
;
1202 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1203 struct guidsection_header
*header
;
1206 memset(&data
, 0xfe, sizeof(data
));
1207 data
.cbSize
= sizeof(data
);
1209 ret
= pFindActCtxSectionGuid(0, NULL
,
1210 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1214 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1217 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1219 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1221 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1222 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1223 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1224 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1225 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1230 ok_(__FILE__
, line
)(comclass
->res
== 0, "got res as %d\n", comclass
->res
);
1231 ok_(__FILE__
, line
)(comclass
->res1
[0] == 0, "got res1[0] as %02x\n", comclass
->res1
[0]);
1232 ok_(__FILE__
, line
)(comclass
->res1
[1] == 0, "got res1[1] as %02x\n", comclass
->res1
[1]);
1233 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1234 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1235 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1237 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1238 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1242 len
= comclass
->size
+ comclass
->clrdata_len
;
1243 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1246 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1248 if (comclass
->progid_offset
)
1250 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1251 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1252 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1253 "got progid name length %d\n", comclass
->progid_len
);
1256 /* data length is simply header length + string data length including nulls */
1257 len
= comclass
->size
+ comclass
->clrdata_len
;
1258 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1259 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1261 /* keyed data structure doesn't include module name, it's available from section data */
1262 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1264 /* check misc fields are set */
1265 if (comclass
->miscmask
)
1267 if (comclass
->miscmask
& MiscStatus
)
1268 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1269 if (comclass
->miscmask
& MiscStatusIcon
)
1270 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1271 if (comclass
->miscmask
& MiscStatusContent
)
1272 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1273 if (comclass
->miscmask
& MiscStatusThumbnail
)
1274 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1275 if (comclass
->miscmask
& MiscStatusDocPrint
)
1276 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1279 /* part used for clrClass only */
1280 if (comclass
->clrdata_len
)
1282 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1283 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1284 struct clrclass_data
*clrclass
;
1287 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1288 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1289 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1290 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1291 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1292 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1294 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1295 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1296 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1297 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1299 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1300 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1302 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1303 in lower case, clsclass subsection - in upper case */
1304 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1305 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1307 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1308 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1310 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1311 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1315 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1316 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1317 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1318 data
.ulSectionGlobalDataLength
);
1319 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1320 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1321 data
.ulSectionTotalLength
);
1322 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1323 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1324 data
.ulAssemblyRosterIndex
, exid
);
1326 /* generated guid for this class works as key guid in search */
1327 memset(&data2
, 0xfe, sizeof(data2
));
1328 data2
.cbSize
= sizeof(data2
);
1329 ret
= pFindActCtxSectionGuid(0, NULL
,
1330 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1331 &comclass
->alias
, &data2
);
1332 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1334 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1335 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1336 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1345 struct ifacepsredirect_data
1357 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1358 const GUID
*ps32
, ULONG exid
, int line
)
1360 struct ifacepsredirect_data
*ifaceps
;
1361 ACTCTX_SECTION_KEYED_DATA data
;
1364 memset(&data
, 0xfe, sizeof(data
));
1365 data
.cbSize
= sizeof(data
);
1367 ret
= pFindActCtxSectionGuid(0, NULL
,
1368 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1370 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1372 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1374 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1375 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1376 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1377 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1378 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1382 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1385 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1388 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1390 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1391 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1392 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1394 /* data length is simply header length + string data length including nulls */
1395 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1396 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1398 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1399 always has non-zero value for it */
1400 if (ifaceps
->mask
& NumMethods
)
1401 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1402 if (ifaceps
->mask
& BaseIface
)
1403 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1406 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1407 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1408 data
.ulSectionGlobalDataLength
);
1409 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1410 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1411 data
.ulSectionTotalLength
);
1412 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1413 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1414 data
.ulAssemblyRosterIndex
, exid
);
1417 struct clrsurrogate_data
1422 ULONG version_offset
;
1428 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1429 ULONG exid
, int line
)
1431 struct clrsurrogate_data
*surrogate
;
1432 ACTCTX_SECTION_KEYED_DATA data
;
1435 memset(&data
, 0xfe, sizeof(data
));
1436 data
.cbSize
= sizeof(data
);
1438 ret
= pFindActCtxSectionGuid(0, NULL
,
1439 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1443 skip("surrogate sections are not supported\n");
1446 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1448 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1450 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1451 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1452 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1453 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1454 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1459 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1460 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1462 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1463 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1465 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1466 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1468 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1469 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1471 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1472 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1474 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1475 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1478 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1479 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1480 data
.ulSectionGlobalDataLength
);
1481 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1482 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1483 data
.ulSectionTotalLength
);
1484 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1485 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1486 data
.ulAssemblyRosterIndex
, exid
);
1489 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1491 struct progidredirect_data
*progiddata
;
1492 struct comclassredirect_data
*comclass
;
1493 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1494 struct strsection_header
*header
;
1497 memset(&data
, 0xfe, sizeof(data
));
1498 data
.cbSize
= sizeof(data
);
1500 ret
= pFindActCtxSectionStringA(0, NULL
,
1501 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1503 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1505 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1507 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1508 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1509 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1510 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1511 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1515 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1516 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1518 /* progid data points to generated alias guid */
1519 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1521 memset(&data2
, 0, sizeof(data2
));
1522 data2
.cbSize
= sizeof(data2
);
1523 ret
= pFindActCtxSectionGuid(0, NULL
,
1524 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1526 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1528 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1529 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1530 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1533 header
= (struct strsection_header
*)data
.lpSectionBase
;
1534 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1535 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1536 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1537 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1538 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1539 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1540 data
.ulAssemblyRosterIndex
, exid
);
1543 static void test_wndclass_section(void)
1545 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1546 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1547 struct wndclass_redirect_data
*classdata
;
1548 struct strsection_header
*section
;
1554 /* use two dependent manifests, each defines 2 window class redirects */
1555 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1556 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1557 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1559 handle
= test_create("main_wndcls.manifest");
1560 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1562 DeleteFileA("testdep1.manifest");
1563 DeleteFileA("testdep2.manifest");
1564 DeleteFileA("main_wndcls.manifest");
1566 ret
= pActivateActCtx(handle
, &cookie
);
1567 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1569 memset(&data
, 0, sizeof(data
));
1570 memset(&data2
, 0, sizeof(data2
));
1571 data
.cbSize
= sizeof(data
);
1572 data2
.cbSize
= sizeof(data2
);
1574 /* get data for two classes from different assemblies */
1575 ret
= pFindActCtxSectionStringW(0, NULL
,
1576 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1578 ok(ret
, "got %d\n", ret
);
1579 ret
= pFindActCtxSectionStringW(0, NULL
,
1580 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1581 wndClass3W
, &data2
);
1582 ok(ret
, "got %d\n", ret
);
1584 section
= (struct strsection_header
*)data
.lpSectionBase
;
1585 ok(section
->count
== 4, "got %d\n", section
->count
);
1586 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1588 /* For both string same section is returned, meaning it's one wndclass section per context */
1589 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1590 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1591 data2
.ulSectionTotalLength
);
1593 /* wndClass1 is versioned, wndClass3 is not */
1594 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1595 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1596 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1598 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1599 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1600 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1602 ret
= pDeactivateActCtx(0, cookie
);
1603 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1605 pReleaseActCtx(handle
);
1608 static void test_dllredirect_section(void)
1610 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1611 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1612 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1613 struct strsection_header
*section
;
1618 /* use two dependent manifests, 4 'files' total */
1619 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1620 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1621 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1623 handle
= test_create("main_wndcls.manifest");
1624 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1626 DeleteFileA("testdep1.manifest");
1627 DeleteFileA("testdep2.manifest");
1628 DeleteFileA("main_wndcls.manifest");
1630 ret
= pActivateActCtx(handle
, &cookie
);
1631 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1633 memset(&data
, 0, sizeof(data
));
1634 memset(&data2
, 0, sizeof(data2
));
1635 data
.cbSize
= sizeof(data
);
1636 data2
.cbSize
= sizeof(data2
);
1638 /* get data for two files from different assemblies */
1639 ret
= pFindActCtxSectionStringW(0, NULL
,
1640 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1642 ok(ret
, "got %d\n", ret
);
1643 ret
= pFindActCtxSectionStringW(0, NULL
,
1644 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1646 ok(ret
, "got %d\n", ret
);
1648 section
= (struct strsection_header
*)data
.lpSectionBase
;
1649 ok(section
->count
== 4, "got %d\n", section
->count
);
1650 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1652 /* For both string same section is returned, meaning it's one dll redirect section per context */
1653 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1654 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1655 data2
.ulSectionTotalLength
);
1657 ret
= pDeactivateActCtx(0, cookie
);
1658 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1660 pReleaseActCtx(handle
);
1663 static void test_typelib_section(void)
1665 static const WCHAR helpW
[] = {'h','e','l','p'};
1666 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1667 struct guidsection_header
*section
;
1668 struct tlibredirect_data
*tlib
;
1673 skip("test_typelib_section\n");
1676 /* use two dependent manifests, 4 'files' total */
1677 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1678 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1679 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1681 handle
= test_create("main_wndcls.manifest");
1682 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1684 DeleteFileA("testdep1.manifest");
1685 DeleteFileA("testdep2.manifest");
1686 DeleteFileA("main_wndcls.manifest");
1688 ret
= pActivateActCtx(handle
, &cookie
);
1689 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1691 memset(&data
, 0, sizeof(data
));
1692 memset(&data2
, 0, sizeof(data2
));
1693 data
.cbSize
= sizeof(data
);
1694 data2
.cbSize
= sizeof(data2
);
1696 /* get data for two typelibs from different assemblies */
1697 ret
= pFindActCtxSectionGuid(0, NULL
,
1698 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1699 &IID_TlibTest
, &data
);
1700 ok(ret
, "got %d\n", ret
);
1702 ret
= pFindActCtxSectionGuid(0, NULL
,
1703 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1704 &IID_TlibTest4
, &data2
);
1705 ok(ret
, "got %d\n", ret
);
1707 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1708 ok(section
->count
== 4, "got %d\n", section
->count
);
1709 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1711 /* For both GUIDs same section is returned */
1712 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1713 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1714 data2
.ulSectionTotalLength
);
1716 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1717 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1718 data
.ulSectionGlobalDataLength
);
1720 /* test some actual data */
1721 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1722 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1723 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1724 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1725 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1726 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1727 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1729 ret
= pDeactivateActCtx(0, cookie
);
1730 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1732 pReleaseActCtx(handle
);
1735 static void test_actctx(void)
1743 trace("default actctx\n");
1745 b
= pGetCurrentActCtx(&handle
);
1746 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1747 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1749 test_basic_info(handle
, __LINE__
);
1750 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1751 pReleaseActCtx(handle
);
1754 /* test for whitespace handling in Eq ::= S? '=' S? */
1755 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
1756 handle
= test_create("test1_1.manifest");
1757 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1758 DeleteFileA("test1_1.manifest");
1759 pReleaseActCtx(handle
);
1761 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1762 skip("Could not create manifest file\n");
1766 trace("manifest1\n");
1768 handle
= test_create("test1.manifest");
1769 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1770 DeleteFileA("test1.manifest");
1771 if(handle
!= INVALID_HANDLE_VALUE
) {
1772 test_basic_info(handle
, __LINE__
);
1773 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1774 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1776 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
1778 /* CloseHandle will generate an exception if a debugger is present */
1779 b
= CloseHandle(handle
);
1780 ok(!b
, "CloseHandle succeeded\n");
1781 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
1784 pReleaseActCtx(handle
);
1787 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
1788 skip("Could not create manifest file\n");
1792 trace("manifest2 depmanifest1\n");
1794 handle
= test_create("test2.manifest");
1795 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1796 DeleteFileA("test2.manifest");
1797 DeleteFileA("testdep.manifest");
1798 if(handle
!= INVALID_HANDLE_VALUE
) {
1799 test_basic_info(handle
, __LINE__
);
1800 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1801 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1802 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
1803 pReleaseActCtx(handle
);
1806 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
1807 skip("Could not create manifest file\n");
1811 trace("manifest2 depmanifest2\n");
1813 handle
= test_create("test2-2.manifest");
1814 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1815 DeleteFileA("test2-2.manifest");
1816 DeleteFileA("testdep.manifest");
1817 if(handle
!= INVALID_HANDLE_VALUE
) {
1818 test_basic_info(handle
, __LINE__
);
1819 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1820 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1821 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
1822 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1823 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1825 b
= pActivateActCtx(handle
, &cookie
);
1826 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1827 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1828 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1829 b
= pDeactivateActCtx(0, cookie
);
1830 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1832 pReleaseActCtx(handle
);
1835 trace("manifest2 depmanifest3\n");
1837 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
1838 skip("Could not create manifest file\n");
1842 handle
= test_create("test2-3.manifest");
1843 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1844 DeleteFileA("test2-3.manifest");
1845 DeleteFileA("testdep.manifest");
1846 if(handle
!= INVALID_HANDLE_VALUE
) {
1847 test_basic_info(handle
, __LINE__
);
1848 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1849 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1850 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
1851 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1852 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1854 b
= pActivateActCtx(handle
, &cookie
);
1855 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1856 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1857 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1858 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
1859 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
1860 b
= pDeactivateActCtx(0, cookie
);
1861 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1863 pReleaseActCtx(handle
);
1866 trace("manifest3\n");
1868 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1869 skip("Could not create manifest file\n");
1873 handle
= test_create("test3.manifest");
1874 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
1875 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1876 if (handle
== INVALID_HANDLE_VALUE
)
1877 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
1878 DeleteFileA("test3.manifest");
1879 if(handle
!= INVALID_HANDLE_VALUE
) {
1880 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
1881 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
1882 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
1883 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
1885 test_basic_info(handle
, __LINE__
);
1886 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1887 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
1888 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
1890 b
= pActivateActCtx(handle
, &cookie
);
1891 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1892 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1893 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1894 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
1895 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
1896 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
1897 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
1898 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
1899 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
1900 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
1901 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
1902 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
1903 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
1904 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
1905 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
1906 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
1907 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
1908 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
1909 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
1910 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
1911 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
1912 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1913 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
1914 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1915 test_find_string_fail();
1917 b
= pDeactivateActCtx(0, cookie
);
1918 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1919 pReleaseActCtx(handle
);
1922 trace("manifest4\n");
1924 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1925 skip("Could not create manifest file\n");
1929 handle
= test_create("test4.manifest");
1930 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1931 DeleteFileA("test4.manifest");
1932 DeleteFileA("testdep.manifest");
1933 if(handle
!= INVALID_HANDLE_VALUE
) {
1934 test_basic_info(handle
, __LINE__
);
1935 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1936 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
1937 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
1938 pReleaseActCtx(handle
);
1941 trace("manifest1 in subdir\n");
1943 CreateDirectoryW(work_dir_subdir
, NULL
);
1944 if (SetCurrentDirectoryW(work_dir_subdir
))
1946 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1947 skip("Could not create manifest file\n");
1950 handle
= test_create("..\\test1.manifest");
1951 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1952 DeleteFileA("..\\test1.manifest");
1953 if(handle
!= INVALID_HANDLE_VALUE
) {
1954 test_basic_info(handle
, __LINE__
);
1955 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1956 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1957 pReleaseActCtx(handle
);
1959 SetCurrentDirectoryW(work_dir
);
1962 skip("Couldn't change directory\n");
1963 RemoveDirectoryW(work_dir_subdir
);
1965 trace("UTF-16 manifest1, with BOM\n");
1966 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
1967 skip("Could not create manifest file\n");
1971 handle
= test_create("test1.manifest");
1972 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1973 DeleteFileA("test1.manifest");
1974 if (handle
!= INVALID_HANDLE_VALUE
) {
1975 test_basic_info(handle
, __LINE__
);
1976 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1977 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1978 pReleaseActCtx(handle
);
1981 trace("UTF-16 manifest1, reverse endian, with BOM\n");
1982 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
1983 skip("Could not create manifest file\n");
1987 handle
= test_create("test1.manifest");
1988 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1989 DeleteFileA("test1.manifest");
1990 if (handle
!= INVALID_HANDLE_VALUE
) {
1991 test_basic_info(handle
, __LINE__
);
1992 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1993 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1994 pReleaseActCtx(handle
);
1997 test_wndclass_section();
1998 test_dllredirect_section();
1999 test_typelib_section();
2002 static void test_app_manifest(void)
2007 trace("child process manifest1\n");
2009 b
= pGetCurrentActCtx(&handle
);
2010 ok(handle
== NULL
, "handle != NULL\n");
2011 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2013 test_basic_info(handle
, __LINE__
);
2014 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2015 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2016 pReleaseActCtx(handle
);
2020 static void run_child_process(void)
2022 char cmdline
[MAX_PATH
];
2023 char path
[MAX_PATH
];
2025 PROCESS_INFORMATION pi
;
2026 STARTUPINFOA si
= { 0 };
2031 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2032 strcat(path
, ".manifest");
2033 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2034 skip("Could not create manifest file\n");
2039 winetest_get_mainargs( &argv
);
2040 /* Vista+ seems to cache presence of .manifest files. Change last modified
2041 date to defeat the cache */
2042 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2043 NULL
, OPEN_EXISTING
, 0, NULL
);
2044 if (file
!= INVALID_HANDLE_VALUE
) {
2045 GetSystemTimeAsFileTime(&now
);
2046 SetFileTime(file
, NULL
, NULL
, &now
);
2049 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2050 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2051 ok(ret
, "Could not create process: %u\n", GetLastError());
2052 winetest_wait_child_process( pi
.hProcess
);
2053 CloseHandle(pi
.hThread
);
2054 CloseHandle(pi
.hProcess
);
2058 static void init_paths(void)
2063 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2064 static const WCHAR backslash
[] = {'\\',0};
2065 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2067 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2068 lstrcpyW(app_dir
, exe_path
);
2069 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2072 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2073 last
= work_dir
[lstrlenW(work_dir
) - 1];
2074 if (last
!= '\\' && last
!= '/')
2075 lstrcatW(work_dir
, backslash
);
2076 lstrcpyW(work_dir_subdir
, work_dir
);
2077 lstrcatW(work_dir_subdir
, subdir
);
2079 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2080 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2083 static void write_manifest(const char *filename
, const char *manifest
)
2087 CHAR path
[MAX_PATH
];
2089 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2090 strcat(path
, filename
);
2092 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2093 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2094 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2098 static void delete_manifest_file(const char *filename
)
2100 CHAR path
[MAX_PATH
];
2102 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2103 strcat(path
, filename
);
2107 static void test_CreateActCtx(void)
2109 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2113 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2114 strcat(path
, "main_wndcls.manifest");
2116 write_manifest("testdep1.manifest", manifest_wndcls1
);
2117 write_manifest("testdep2.manifest", manifest_wndcls2
);
2118 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2120 memset(&actctx
, 0, sizeof(ACTCTXA
));
2121 actctx
.cbSize
= sizeof(ACTCTXA
);
2122 actctx
.lpSource
= path
;
2124 /* create using lpSource without specified directory */
2125 handle
= pCreateActCtxA(&actctx
);
2126 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2127 pReleaseActCtx(handle
);
2129 /* with specified directory, that doesn't contain dependent assembly */
2130 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2132 memset(&actctx
, 0, sizeof(ACTCTXA
));
2133 actctx
.cbSize
= sizeof(ACTCTXA
);
2134 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2135 actctx
.lpAssemblyDirectory
= dir
;
2136 actctx
.lpSource
= path
;
2138 SetLastError(0xdeadbeef);
2139 handle
= pCreateActCtxA(&actctx
);
2141 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2142 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2144 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2146 delete_manifest_file("main_wndcls.manifest");
2147 delete_manifest_file("testdep1.manifest");
2148 delete_manifest_file("testdep2.manifest");
2150 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2151 memset(&actctx
, 0, sizeof(ACTCTXA
));
2152 actctx
.cbSize
= sizeof(ACTCTXA
);
2153 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2154 SetLastError(0xdeadbeef);
2155 handle
= pCreateActCtxA(&actctx
);
2156 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2158 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2159 "got error %d\n", GetLastError());
2161 /* create from HMODULE - resource doesn't exist, lpSource is set */
2162 memset(&actctx
, 0, sizeof(ACTCTXA
));
2163 actctx
.cbSize
= sizeof(ACTCTXA
);
2164 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2165 actctx
.lpSource
= "dummyfile.dll";
2166 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2167 actctx
.hModule
= GetModuleHandleA(NULL
);
2169 SetLastError(0xdeadbeef);
2170 handle
= pCreateActCtxA(&actctx
);
2171 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2172 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2175 static BOOL
init_funcs(void)
2177 HMODULE hKernel32
= GetModuleHandleA("kernel32.dll");
2179 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
2183 X(DeactivateActCtx
);
2184 X(FindActCtxSectionStringA
);
2185 X(FindActCtxSectionStringW
);
2186 X(GetCurrentActCtx
);
2187 X(IsDebuggerPresent
);
2190 X(FindActCtxSectionGuid
);
2201 argc
= winetest_get_mainargs(&argv
);
2205 win_skip("Needed functions are not available\n");
2210 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2211 test_app_manifest();
2216 test_CreateActCtx();
2217 run_child_process();