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
++));
52 static const char *debugstr_guid(REFIID riid
)
56 sprintf(buf
, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
57 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
58 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
59 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
66 #elif defined __x86_64__
72 static const char manifest1
[] =
73 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
74 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
77 static const char manifest2
[] =
78 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
79 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
83 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
85 "</dependentAssembly>"
89 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
90 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
91 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
92 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
93 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
94 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
95 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
96 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
97 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
98 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
99 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
100 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
101 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
103 static const char manifest3
[] =
104 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
105 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
106 " publicKeyToken=\"6595b6414666f1df\" />"
107 "<file name=\"testlib.dll\">"
108 "<windowClass>wndClass</windowClass>"
109 " <comClass description=\"Test com class\""
110 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
111 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
112 " threadingModel=\"Neutral\""
113 " progid=\"ProgId.ProgId\""
114 " miscStatus=\"cantlinkinside\""
115 " miscStatusIcon=\"recomposeonresize\""
116 " miscStatusContent=\"insideout\""
117 " miscStatusThumbnail=\"alignable\""
118 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
120 " <progid>ProgId.ProgId.1</progid>"
121 " <progid>ProgId.ProgId.2</progid>"
122 " <progid>ProgId.ProgId.3</progid>"
123 " <progid>ProgId.ProgId.4</progid>"
124 " <progid>ProgId.ProgId.5</progid>"
125 " <progid>ProgId.ProgId.6</progid>"
127 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
128 " <progid>ProgId.ProgId.7</progid>"
130 " <comInterfaceProxyStub "
132 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
133 " iid=\"{66666666-8888-7777-6666-555555555555}\""
134 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
135 " threadingModel=\"Free\""
137 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
140 " <comInterfaceExternalProxyStub "
141 " name=\"Iifaceps2\""
142 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
143 " iid=\"{76666666-8888-7777-6666-555555555555}\""
144 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
146 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
148 " <comInterfaceExternalProxyStub "
149 " name=\"Iifaceps3\""
150 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
151 " iid=\"{86666666-8888-7777-6666-555555555555}\""
153 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
156 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
157 " name=\"testsurrogate\""
158 " runtimeVersion=\"v2.0.50727\""
161 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
163 " progid=\"clrprogid\""
164 " description=\"test description\""
165 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
166 " runtimeVersion=\"1.2.3.4\""
167 " threadingModel=\"Neutral\""
169 " <progid>clrprogid.1</progid>"
170 " <progid>clrprogid.2</progid>"
171 " <progid>clrprogid.3</progid>"
172 " <progid>clrprogid.4</progid>"
173 " <progid>clrprogid.5</progid>"
174 " <progid>clrprogid.6</progid>"
178 static const char manifest_wndcls1
[] =
179 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
180 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
181 "<file name=\"testlib1.dll\">"
182 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
183 "<windowClass>wndClass2</windowClass>"
184 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
186 "<file name=\"testlib1_2.dll\" />"
189 static const char manifest_wndcls2
[] =
190 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
191 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
192 "<file name=\"testlib2.dll\">"
193 " <windowClass versioned=\"no\">wndClass3</windowClass>"
194 " <windowClass>wndClass4</windowClass>"
195 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
196 " flags=\"HIDDEN,CONTROL,RESTRICTED\" />"
197 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
198 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
200 "<file name=\"testlib2_2.dll\" />"
203 static const char manifest_wndcls_main
[] =
204 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
205 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
207 " <dependentAssembly>"
208 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
209 " </dependentAssembly>"
212 " <dependentAssembly>"
213 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
214 " </dependentAssembly>"
218 static const char manifest4
[] =
219 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
220 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
221 "</assemblyIdentity>"
223 "<dependentAssembly>"
224 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
225 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
226 "</assemblyIdentity>"
227 "</dependentAssembly>"
231 static const char testdep_manifest1
[] =
232 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
233 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
236 static const char testdep_manifest2
[] =
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\"></file>"
240 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
243 static const char testdep_manifest3
[] =
244 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
245 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
246 "<file name=\"testlib.dll\"/>"
247 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
248 "<windowClass>wndClass</windowClass>"
249 "<windowClass>wndClass2</windowClass>"
253 static const char wrong_manifest1
[] =
254 "<assembly manifestVersion=\"1.0\">"
255 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
258 static const char wrong_manifest2
[] =
259 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
260 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
263 static const char wrong_manifest3
[] =
264 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
265 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
268 static const char wrong_manifest4
[] =
269 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
270 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
274 static const char wrong_manifest5
[] =
275 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
276 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
280 static const char wrong_manifest6
[] =
281 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
282 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
285 static const char wrong_manifest7
[] =
286 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
287 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
288 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
291 static const char wrong_manifest8
[] =
292 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
293 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
297 static const char wrong_depmanifest1
[] =
298 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
299 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
302 static const WCHAR testlib_dll
[] =
303 {'t','e','s','t','l','i','b','.','d','l','l',0};
304 static const WCHAR testlib2_dll
[] =
305 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
306 static const WCHAR wndClassW
[] =
307 {'w','n','d','C','l','a','s','s',0};
308 static const WCHAR wndClass1W
[] =
309 {'w','n','d','C','l','a','s','s','1',0};
310 static const WCHAR wndClass2W
[] =
311 {'w','n','d','C','l','a','s','s','2',0};
312 static const WCHAR wndClass3W
[] =
313 {'w','n','d','C','l','a','s','s','3',0};
314 static const WCHAR acr_manifest
[] =
315 {'a','c','r','.','m','a','n','i','f','e','s','t',0};
317 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
318 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
320 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
325 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
326 return lstrcmpW(strw
, buf
);
329 static DWORD
strlen_aw(const char *str
)
331 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
334 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
335 const char *depfile
, const char *depmanifest
)
339 WCHAR path
[MAX_PATH
];
341 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
342 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
344 if (manifest_len
== -1)
345 manifest_len
= strlen(manifest
);
347 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
348 FILE_ATTRIBUTE_NORMAL
, NULL
);
349 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
350 if(file
== INVALID_HANDLE_VALUE
)
352 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
357 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
358 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
359 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
360 FILE_ATTRIBUTE_NORMAL
, NULL
);
361 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
362 if(file
== INVALID_HANDLE_VALUE
)
364 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
370 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
372 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
374 int offset
= (fBOM
? 0 : 1);
376 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
377 wmanifest
[0] = 0xfeff;
381 for (i
= 0; i
< strlen(manifest
)+1; i
++)
382 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
384 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
385 HeapFree(GetProcessHeap(), 0, wmanifest
);
390 ULONG format_version
;
391 ULONG assembly_cnt_min
;
392 ULONG assembly_cnt_max
;
393 ULONG root_manifest_type
;
394 LPWSTR root_manifest_path
;
395 ULONG root_config_type
;
400 static const detailed_info_t detailed_info0
= {
401 0, 0, 0, 0, NULL
, 0, 0, NULL
404 static const detailed_info_t detailed_info1
= {
405 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
406 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
410 static const detailed_info_t detailed_info1_child
= {
411 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
412 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
416 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
417 static const detailed_info_t detailed_info2
= {
418 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
419 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
423 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
425 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
426 SIZE_T size
, exsize
, retsize
;
429 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
430 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
431 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
433 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
435 b
= pQueryActCtxW(0, handle
, NULL
,
436 ActivationContextDetailedInformation
, &detailed_info_tmp
,
437 sizeof(detailed_info_tmp
), &size
);
438 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
439 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
440 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
442 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
445 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
446 memset(detailed_info
, 0xfe, size
);
447 b
= pQueryActCtxW(0, handle
, NULL
,
448 ActivationContextDetailedInformation
, detailed_info
,
450 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
451 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
453 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
454 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
455 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
456 exinfo
->format_version
);
457 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
458 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
459 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
460 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
461 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
462 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
463 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
464 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
465 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
466 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
467 detailed_info
->ulRootManifestPathChars
,
468 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
469 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
470 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
471 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
472 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
473 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
474 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
475 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
476 exinfo
->app_dir_type
);
477 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
478 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
479 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
480 if(exinfo
->root_manifest_path
) {
481 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
482 if(detailed_info
->lpRootManifestPath
)
483 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
484 "unexpected detailed_info->lpRootManifestPath\n");
486 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
488 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
489 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
490 if(exinfo
->app_dir
) {
491 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
492 if(detailed_info
->lpAppDirPath
)
493 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
494 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
496 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
499 HeapFree(GetProcessHeap(), 0, detailed_info
);
504 /* ULONG manifest_path_type; FIXME */
505 LPCWSTR manifest_path
;
506 LPCSTR encoded_assembly_id
;
507 BOOL has_assembly_dir
;
510 static const info_in_assembly manifest1_info
= {
512 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
516 static const info_in_assembly manifest1_child_info
= {
517 1, app_manifest_path
,
518 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
522 static const info_in_assembly manifest2_info
= {
524 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
528 static const info_in_assembly manifest3_info
= {
530 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
534 static const info_in_assembly manifest4_info
= {
536 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
540 static const info_in_assembly depmanifest1_info
= {
541 0x10, depmanifest_path
,
542 "testdep,processorArchitecture=\"" ARCH
"\","
543 "type=\"win32\",version=\"6.5.4.3\"",
547 static const info_in_assembly depmanifest2_info
= {
548 0x10, depmanifest_path
,
549 "testdep,processorArchitecture=\"" ARCH
"\","
550 "type=\"win32\",version=\"6.5.4.3\"",
554 static const info_in_assembly depmanifest3_info
= {
555 0x10, depmanifest_path
,
556 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
560 static const info_in_assembly manifest_comctrl_info
= {
561 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
564 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
566 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
571 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
572 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
573 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
576 b
= pQueryActCtxW(0, handle
, &id
,
577 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
578 sizeof(info_tmp
), &size
);
579 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
580 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
582 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
584 if (size
== 0xdeadbeef)
590 info
= HeapAlloc(GetProcessHeap(), 0, size
);
591 memset(info
, 0xfe, size
);
594 b
= pQueryActCtxW(0, handle
, &id
,
595 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
596 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
597 if (!exinfo
->manifest_path
)
598 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
599 if (!exinfo
->encoded_assembly_id
)
600 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
601 if (exinfo
->has_assembly_dir
)
602 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
603 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
605 if (0) /* FIXME: flags meaning unknown */
607 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
608 info
->ulFlags
, exinfo
->flags
);
610 if(exinfo
->encoded_assembly_id
) {
611 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
612 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
613 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
614 info
->ulEncodedAssemblyIdentityLength
, len
);
616 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
617 "info->ulEncodedAssemblyIdentityLength == 0\n");
619 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
620 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
621 if(exinfo
->manifest_path
) {
622 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
623 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
624 info
->ulManifestPathLength
, len
);
626 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
629 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
630 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
631 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
632 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
633 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
634 info
->ulMetadataSatelliteRosterIndex
);
635 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
636 info
->ulManifestVersionMajor
);
637 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
638 info
->ulManifestVersionMinor
);
639 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
640 info
->ulPolicyVersionMajor
);
641 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
642 info
->ulPolicyVersionMinor
);
643 if(exinfo
->has_assembly_dir
)
644 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
645 "info->ulAssemblyDirectoryNameLength == 0\n");
647 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
648 "info->ulAssemblyDirectoryNameLength != 0\n");
650 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
651 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
652 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
653 ok_(__FILE__
, line
)(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
654 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
655 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
657 if(exinfo
->manifest_path
) {
658 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
659 if(info
->lpAssemblyManifestPath
)
660 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
661 "unexpected info->lpAssemblyManifestPath\n");
663 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
666 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
667 if(info
->lpAssemblyPolicyPath
)
668 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
669 if(exinfo
->has_assembly_dir
)
670 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
672 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
673 strw(info
->lpAssemblyDirectoryName
));
674 HeapFree(GetProcessHeap(), 0, info
);
677 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
679 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
680 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
684 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
685 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
688 b
= pQueryActCtxW(0, handle
, &index
,
689 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
690 sizeof(info_tmp
), &size
);
691 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
692 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
693 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
695 if(size
== 0xdeadbeef)
701 info
= HeapAlloc(GetProcessHeap(), 0, size
);
702 memset(info
, 0xfe, size
);
704 b
= pQueryActCtxW(0, handle
, &index
,
705 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
706 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
707 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
709 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
710 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
711 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
712 info
->ulFilenameLength
, lstrlenW(filename
));
713 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
714 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
716 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
717 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
718 HeapFree(GetProcessHeap(), 0, info
);
721 static HANDLE
test_create(const char *file
)
725 WCHAR path
[MAX_PATH
];
727 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
728 memset(&actctx
, 0, sizeof(ACTCTXW
));
729 actctx
.cbSize
= sizeof(ACTCTXW
);
730 actctx
.lpSource
= path
;
732 handle
= pCreateActCtxW(&actctx
);
733 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
735 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
736 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%d\n", actctx
.dwFlags
);
737 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
738 ok(actctx
.wProcessorArchitecture
== 0,
739 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
740 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
741 ok(actctx
.lpAssemblyDirectory
== NULL
,
742 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
743 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
744 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
745 actctx
.lpApplicationName
);
746 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
751 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
755 WCHAR path
[MAX_PATH
];
757 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
758 memset(&actctx
, 0, sizeof(ACTCTXW
));
759 actctx
.cbSize
= sizeof(ACTCTXW
);
760 actctx
.lpSource
= path
;
762 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
763 handle
= pCreateActCtxW(&actctx
);
766 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
767 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
771 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
772 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
774 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
775 DeleteFileA("bad.manifest");
776 DeleteFileA("testdep.manifest");
779 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
783 WCHAR path
[MAX_PATH
];
785 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
786 memset(&actctx
, 0, sizeof(ACTCTXW
));
787 actctx
.cbSize
= sizeof(ACTCTXW
);
788 actctx
.lpSource
= path
;
790 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
791 handle
= pCreateActCtxW(&actctx
);
792 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
793 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
795 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
796 DeleteFileA("bad.manifest");
799 static void test_create_fail(void)
803 WCHAR path
[MAX_PATH
];
805 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
806 memset(&actctx
, 0, sizeof(ACTCTXW
));
807 actctx
.cbSize
= sizeof(ACTCTXW
);
808 actctx
.lpSource
= path
;
810 handle
= pCreateActCtxW(&actctx
);
811 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
812 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
814 trace("wrong_manifest1\n");
815 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
816 trace("wrong_manifest2\n");
817 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
818 trace("wrong_manifest3\n");
819 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
820 trace("wrong_manifest4\n");
821 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
822 trace("wrong_manifest5\n");
823 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
824 trace("wrong_manifest6\n");
825 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
826 trace("wrong_manifest7\n");
827 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
828 trace("wrong_manifest8\n");
829 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
830 trace("UTF-16 manifest1 without BOM\n");
831 test_create_wide_and_fail(manifest1
, FALSE
);
832 trace("manifest2\n");
833 test_create_and_fail(manifest2
, NULL
, 0 );
834 trace("manifest2+depmanifest1\n");
835 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
838 struct strsection_header
860 struct guidsection_header
880 struct wndclass_redirect_data
885 ULONG name_offset
; /* versioned name offset */
887 ULONG module_offset
;/* container name offset */
890 struct dllredirect_data
897 struct tlibredirect_data
911 struct progidredirect_data
918 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
920 ACTCTX_SECTION_KEYED_DATA data
;
923 memset(&data
, 0xfe, sizeof(data
));
924 data
.cbSize
= sizeof(data
);
926 ret
= pFindActCtxSectionStringW(0, NULL
,
927 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
929 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
932 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
933 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
934 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
935 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
939 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
940 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
941 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
942 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
943 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
944 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
947 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
948 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
949 data
.ulSectionGlobalDataLength
);
950 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
951 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
952 data
.ulSectionTotalLength
);
953 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
954 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
955 data
.ulAssemblyRosterIndex
, exid
);
957 memset(&data
, 0xfe, sizeof(data
));
958 data
.cbSize
= sizeof(data
);
960 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
961 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
963 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
966 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
967 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
968 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
969 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
970 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
971 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
972 data
.ulSectionGlobalDataLength
);
973 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
974 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
975 data
.ulSectionTotalLength
);
976 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
977 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
978 data
.ulAssemblyRosterIndex
, exid
);
980 pReleaseActCtx(handle
);
983 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
985 struct wndclass_redirect_data
*wnddata
;
986 struct strsection_header
*header
;
987 ACTCTX_SECTION_KEYED_DATA data
;
990 memset(&data
, 0xfe, sizeof(data
));
991 data
.cbSize
= sizeof(data
);
993 ret
= pFindActCtxSectionStringW(0, NULL
,
994 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
996 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
997 wine_dbgstr_w(clsname
));
1000 header
= (struct strsection_header
*)data
.lpSectionBase
;
1001 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1003 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
1004 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
1005 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1006 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1007 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1008 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1009 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1011 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1016 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1017 /* redirect class name (versioned or not) is stored just after header data */
1018 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1019 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1021 /* expected versioned name */
1022 lstrcpyW(buff
, verW
);
1023 lstrcatW(buff
, clsname
);
1024 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1025 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1026 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1027 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1029 /* data length is simply header length + string data length including nulls */
1030 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1031 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1033 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1035 WCHAR
*modulename
, *sectionptr
;
1037 /* just compare pointers */
1038 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1039 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1040 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1044 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1045 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1046 data
.ulSectionGlobalDataLength
);
1047 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1048 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1049 data
.ulSectionTotalLength
);
1050 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1051 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1052 data
.ulAssemblyRosterIndex
, exid
);
1054 memset(&data
, 0xfe, sizeof(data
));
1055 data
.cbSize
= sizeof(data
);
1057 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1058 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1060 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1061 wine_dbgstr_w(clsname
));
1064 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1065 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1066 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1067 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1068 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1069 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1070 data
.ulSectionGlobalDataLength
);
1071 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1072 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1073 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1074 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1075 data
.ulAssemblyRosterIndex
, exid
);
1077 pReleaseActCtx(handle
);
1080 static void test_find_string_fail(void)
1082 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1085 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1086 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1087 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1089 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1090 testlib2_dll
, &data
);
1091 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1092 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1094 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1096 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1097 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1099 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
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());
1111 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1112 testlib_dll
, &data
);
1113 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1114 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1118 static void test_basic_info(HANDLE handle
, int line
)
1120 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1124 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1125 ActivationContextBasicInformation
, &basic
,
1126 sizeof(basic
), &size
);
1128 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1129 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1130 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1131 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1133 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1134 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1135 ActivationContextBasicInformation
, &basic
,
1136 sizeof(basic
), &size
);
1139 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1140 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1141 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1142 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1143 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1147 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1148 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1149 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1150 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1154 enum comclass_threadingmodel
{
1155 ThreadingModel_Apartment
= 1,
1156 ThreadingModel_Free
= 2,
1157 ThreadingModel_No
= 3,
1158 ThreadingModel_Both
= 4,
1159 ThreadingModel_Neutral
= 5
1162 enum comclass_miscfields
{
1165 MiscStatusContent
= 4,
1166 MiscStatusThumbnail
= 8,
1167 MiscStatusDocPrint
= 16
1170 struct comclassredirect_data
{
1183 ULONG progid_offset
;
1185 ULONG clrdata_offset
;
1187 DWORD miscstatuscontent
;
1188 DWORD miscstatusthumbnail
;
1189 DWORD miscstatusicon
;
1190 DWORD miscstatusdocprint
;
1193 struct clrclass_data
{
1197 ULONG module_offset
;
1201 ULONG version_offset
;
1205 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1207 struct comclassredirect_data
*comclass
, *comclass2
;
1208 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1209 struct guidsection_header
*header
;
1212 memset(&data
, 0xfe, sizeof(data
));
1213 data
.cbSize
= sizeof(data
);
1215 ret
= pFindActCtxSectionGuid(0, NULL
,
1216 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1220 skip("failed for guid %s\n", debugstr_guid(clsid
));
1223 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1225 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1227 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1228 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1229 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1230 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1231 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1236 ok_(__FILE__
, line
)(comclass
->res
== 0, "got res as %d\n", comclass
->res
);
1237 ok_(__FILE__
, line
)(comclass
->res1
[0] == 0, "got res1[0] as %02x\n", comclass
->res1
[0]);
1238 ok_(__FILE__
, line
)(comclass
->res1
[1] == 0, "got res1[1] as %02x\n", comclass
->res1
[1]);
1239 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1240 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", debugstr_guid(&comclass
->clsid
));
1241 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", debugstr_guid(&comclass
->clsid2
));
1243 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", debugstr_guid(&comclass
->tlid
));
1244 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1248 len
= comclass
->size
+ comclass
->clrdata_len
;
1249 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1252 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1254 if (comclass
->progid_offset
)
1256 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1257 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1258 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1259 "got progid name length %d\n", comclass
->progid_len
);
1262 /* data length is simply header length + string data length including nulls */
1263 len
= comclass
->size
+ comclass
->clrdata_len
;
1264 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1265 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1267 /* keyed data structure doesn't include module name, it's available from section data */
1268 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1270 /* check misc fields are set */
1271 if (comclass
->miscmask
)
1273 if (comclass
->miscmask
& MiscStatus
)
1274 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1275 if (comclass
->miscmask
& MiscStatusIcon
)
1276 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1277 if (comclass
->miscmask
& MiscStatusContent
)
1278 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1279 if (comclass
->miscmask
& MiscStatusThumbnail
)
1280 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1281 if (comclass
->miscmask
& MiscStatusDocPrint
)
1282 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1285 /* part used for clrClass only */
1286 if (comclass
->clrdata_len
)
1288 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1289 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1290 struct clrclass_data
*clrclass
;
1293 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1294 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1295 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1296 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1297 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1298 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1300 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1301 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1302 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1303 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1305 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1306 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1308 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1309 in lower case, clsclass subsection - in upper case */
1310 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1311 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1313 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1314 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1316 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1317 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1321 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1322 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1323 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1324 data
.ulSectionGlobalDataLength
);
1325 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1326 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1327 data
.ulSectionTotalLength
);
1328 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1329 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1330 data
.ulAssemblyRosterIndex
, exid
);
1332 /* generated guid for this class works as key guid in search */
1333 memset(&data2
, 0xfe, sizeof(data2
));
1334 data2
.cbSize
= sizeof(data2
);
1335 ret
= pFindActCtxSectionGuid(0, NULL
,
1336 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1337 &comclass
->alias
, &data2
);
1338 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1340 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1341 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1342 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1351 struct ifacepsredirect_data
1363 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1364 const GUID
*ps32
, ULONG exid
, int line
)
1366 struct ifacepsredirect_data
*ifaceps
;
1367 ACTCTX_SECTION_KEYED_DATA data
;
1370 memset(&data
, 0xfe, sizeof(data
));
1371 data
.cbSize
= sizeof(data
);
1373 ret
= pFindActCtxSectionGuid(0, NULL
,
1374 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1376 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1378 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1380 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1381 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1382 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1383 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1384 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1388 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1391 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", debugstr_guid(&ifaceps
->iid
));
1394 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", debugstr_guid(&ifaceps
->iid
));
1396 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", debugstr_guid(&ifaceps
->tlbid
));
1397 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1398 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1400 /* data length is simply header length + string data length including nulls */
1401 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1402 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1404 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1405 always has non-zero value for it */
1406 if (ifaceps
->mask
& NumMethods
)
1407 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1408 if (ifaceps
->mask
& BaseIface
)
1409 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", debugstr_guid(&ifaceps
->base
));
1412 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1413 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1414 data
.ulSectionGlobalDataLength
);
1415 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1416 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1417 data
.ulSectionTotalLength
);
1418 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1419 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1420 data
.ulAssemblyRosterIndex
, exid
);
1423 struct clrsurrogate_data
1428 ULONG version_offset
;
1434 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1435 ULONG exid
, int line
)
1437 struct clrsurrogate_data
*surrogate
;
1438 ACTCTX_SECTION_KEYED_DATA data
;
1441 memset(&data
, 0xfe, sizeof(data
));
1442 data
.cbSize
= sizeof(data
);
1444 ret
= pFindActCtxSectionGuid(0, NULL
,
1445 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1449 skip("surrogate sections are not supported\n");
1452 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1454 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1456 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1457 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1458 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1459 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1460 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1465 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1466 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", debugstr_guid(&surrogate
->clsid
));
1468 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1469 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1471 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1472 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1474 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1475 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1477 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1478 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1480 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1481 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1484 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1485 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1486 data
.ulSectionGlobalDataLength
);
1487 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1488 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1489 data
.ulSectionTotalLength
);
1490 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1491 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1492 data
.ulAssemblyRosterIndex
, exid
);
1495 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1497 struct progidredirect_data
*progiddata
;
1498 struct comclassredirect_data
*comclass
;
1499 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1500 struct strsection_header
*header
;
1503 memset(&data
, 0xfe, sizeof(data
));
1504 data
.cbSize
= sizeof(data
);
1506 ret
= pFindActCtxSectionStringA(0, NULL
,
1507 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1509 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1511 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1513 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1514 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1515 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1516 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1517 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1521 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1522 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1524 /* progid data points to generated alias guid */
1525 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1527 memset(&data2
, 0, sizeof(data2
));
1528 data2
.cbSize
= sizeof(data2
);
1529 ret
= pFindActCtxSectionGuid(0, NULL
,
1530 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1532 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1534 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1535 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, debugstr_guid(guid
));
1536 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, debugstr_guid(clsid
));
1539 header
= (struct strsection_header
*)data
.lpSectionBase
;
1540 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1541 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1542 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1543 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1544 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1545 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1546 data
.ulAssemblyRosterIndex
, exid
);
1549 static void test_wndclass_section(void)
1551 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1552 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1553 struct wndclass_redirect_data
*classdata
;
1554 struct strsection_header
*section
;
1560 /* use two dependent manifests, each defines 2 window class redirects */
1561 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1562 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1563 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1565 handle
= test_create("main_wndcls.manifest");
1566 DeleteFileA("testdep1.manifest");
1567 DeleteFileA("testdep2.manifest");
1568 DeleteFileA("main_wndcls.manifest");
1570 ret
= pActivateActCtx(handle
, &cookie
);
1571 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1573 memset(&data
, 0, sizeof(data
));
1574 memset(&data2
, 0, sizeof(data2
));
1575 data
.cbSize
= sizeof(data
);
1576 data2
.cbSize
= sizeof(data2
);
1578 /* get data for two classes from different assemblies */
1579 ret
= pFindActCtxSectionStringW(0, NULL
,
1580 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1582 ok(ret
, "got %d\n", ret
);
1583 ret
= pFindActCtxSectionStringW(0, NULL
,
1584 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1585 wndClass3W
, &data2
);
1586 ok(ret
, "got %d\n", ret
);
1588 section
= (struct strsection_header
*)data
.lpSectionBase
;
1589 ok(section
->count
== 4, "got %d\n", section
->count
);
1590 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1592 /* For both string same section is returned, meaning it's one wndclass section per context */
1593 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1594 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1595 data2
.ulSectionTotalLength
);
1597 /* wndClass1 is versioned, wndClass3 is not */
1598 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1599 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1600 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1602 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1603 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1604 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1606 ret
= pDeactivateActCtx(0, cookie
);
1607 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1609 pReleaseActCtx(handle
);
1612 static void test_dllredirect_section(void)
1614 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1615 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1616 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1617 struct strsection_header
*section
;
1622 /* use two dependent manifests, 4 'files' total */
1623 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1624 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1625 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1627 handle
= test_create("main_wndcls.manifest");
1628 DeleteFileA("testdep1.manifest");
1629 DeleteFileA("testdep2.manifest");
1630 DeleteFileA("main_wndcls.manifest");
1632 ret
= pActivateActCtx(handle
, &cookie
);
1633 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1635 memset(&data
, 0, sizeof(data
));
1636 memset(&data2
, 0, sizeof(data2
));
1637 data
.cbSize
= sizeof(data
);
1638 data2
.cbSize
= sizeof(data2
);
1640 /* get data for two files from different assemblies */
1641 ret
= pFindActCtxSectionStringW(0, NULL
,
1642 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1644 ok(ret
, "got %d\n", ret
);
1645 ret
= pFindActCtxSectionStringW(0, NULL
,
1646 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1648 ok(ret
, "got %d\n", ret
);
1650 section
= (struct strsection_header
*)data
.lpSectionBase
;
1651 ok(section
->count
== 4, "got %d\n", section
->count
);
1652 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1654 /* For both string same section is returned, meaning it's one dll redirect section per context */
1655 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1656 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1657 data2
.ulSectionTotalLength
);
1659 ret
= pDeactivateActCtx(0, cookie
);
1660 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1662 pReleaseActCtx(handle
);
1665 static void test_typelib_section(void)
1667 static const WCHAR helpW
[] = {'h','e','l','p'};
1668 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1669 struct guidsection_header
*section
;
1670 struct tlibredirect_data
*tlib
;
1675 /* use two dependent manifests, 4 'files' total */
1676 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1677 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1678 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1680 handle
= test_create("main_wndcls.manifest");
1681 DeleteFileA("testdep1.manifest");
1682 DeleteFileA("testdep2.manifest");
1683 DeleteFileA("main_wndcls.manifest");
1685 ret
= pActivateActCtx(handle
, &cookie
);
1686 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1688 memset(&data
, 0, sizeof(data
));
1689 memset(&data2
, 0, sizeof(data2
));
1690 data
.cbSize
= sizeof(data
);
1691 data2
.cbSize
= sizeof(data2
);
1693 /* get data for two typelibs from different assemblies */
1694 ret
= pFindActCtxSectionGuid(0, NULL
,
1695 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1696 &IID_TlibTest
, &data
);
1697 ok(ret
, "got %d\n", ret
);
1699 ret
= pFindActCtxSectionGuid(0, NULL
,
1700 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1701 &IID_TlibTest4
, &data2
);
1702 ok(ret
, "got %d\n", ret
);
1704 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1705 ok(section
->count
== 4, "got %d\n", section
->count
);
1706 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1708 /* For both GUIDs same section is returned */
1709 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1710 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1711 data2
.ulSectionTotalLength
);
1713 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1714 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1715 data
.ulSectionGlobalDataLength
);
1717 /* test some actual data */
1718 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1719 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1720 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1721 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1722 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1723 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1724 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1726 ret
= pDeactivateActCtx(0, cookie
);
1727 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1729 pReleaseActCtx(handle
);
1732 static void test_actctx(void)
1740 trace("default actctx\n");
1742 b
= pGetCurrentActCtx(&handle
);
1743 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1744 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1746 test_basic_info(handle
, __LINE__
);
1747 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1748 pReleaseActCtx(handle
);
1751 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1752 skip("Could not create manifest file\n");
1756 trace("manifest1\n");
1758 handle
= test_create("test1.manifest");
1759 DeleteFileA("test1.manifest");
1760 if(handle
!= INVALID_HANDLE_VALUE
) {
1761 test_basic_info(handle
, __LINE__
);
1762 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1763 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1765 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
1767 /* CloseHandle will generate an exception if a debugger is present */
1768 b
= CloseHandle(handle
);
1769 ok(!b
, "CloseHandle succeeded\n");
1770 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
1773 pReleaseActCtx(handle
);
1776 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
1777 skip("Could not create manifest file\n");
1781 trace("manifest2 depmanifest1\n");
1783 handle
= test_create("test2.manifest");
1784 DeleteFileA("test2.manifest");
1785 DeleteFileA("testdep.manifest");
1786 if(handle
!= INVALID_HANDLE_VALUE
) {
1787 test_basic_info(handle
, __LINE__
);
1788 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1789 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1790 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
1791 pReleaseActCtx(handle
);
1794 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
1795 skip("Could not create manifest file\n");
1799 trace("manifest2 depmanifest2\n");
1801 handle
= test_create("test2-2.manifest");
1802 DeleteFileA("test2-2.manifest");
1803 DeleteFileA("testdep.manifest");
1804 if(handle
!= INVALID_HANDLE_VALUE
) {
1805 test_basic_info(handle
, __LINE__
);
1806 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1807 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1808 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
1809 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1810 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1812 b
= pActivateActCtx(handle
, &cookie
);
1813 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1814 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1815 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1816 b
= pDeactivateActCtx(0, cookie
);
1817 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1819 pReleaseActCtx(handle
);
1822 trace("manifest2 depmanifest3\n");
1824 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
1825 skip("Could not create manifest file\n");
1829 handle
= test_create("test2-3.manifest");
1830 DeleteFileA("test2-3.manifest");
1831 DeleteFileA("testdep.manifest");
1832 if(handle
!= INVALID_HANDLE_VALUE
) {
1833 test_basic_info(handle
, __LINE__
);
1834 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1835 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1836 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
1837 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1838 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1840 b
= pActivateActCtx(handle
, &cookie
);
1841 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1842 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1843 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1844 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
1845 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
1846 b
= pDeactivateActCtx(0, cookie
);
1847 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1849 pReleaseActCtx(handle
);
1852 trace("manifest3\n");
1854 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1855 skip("Could not create manifest file\n");
1859 handle
= test_create("test3.manifest");
1860 DeleteFileA("test3.manifest");
1861 if(handle
!= INVALID_HANDLE_VALUE
) {
1862 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
1863 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
1864 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
1865 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
1867 test_basic_info(handle
, __LINE__
);
1868 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1869 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
1870 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
1872 b
= pActivateActCtx(handle
, &cookie
);
1873 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1874 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1875 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1876 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
1877 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
1878 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
1879 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
1880 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
1881 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
1882 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
1883 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
1884 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
1885 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
1886 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
1887 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
1888 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
1889 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
1890 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
1891 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
1892 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
1893 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
1894 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1895 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
1896 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1897 test_find_string_fail();
1899 b
= pDeactivateActCtx(0, cookie
);
1900 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1901 pReleaseActCtx(handle
);
1904 trace("manifest4\n");
1906 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1907 skip("Could not create manifest file\n");
1911 handle
= test_create("test4.manifest");
1912 DeleteFileA("test4.manifest");
1913 DeleteFileA("testdep.manifest");
1914 if(handle
!= INVALID_HANDLE_VALUE
) {
1915 test_basic_info(handle
, __LINE__
);
1916 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1917 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
1918 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
1919 pReleaseActCtx(handle
);
1922 trace("manifest1 in subdir\n");
1924 CreateDirectoryW(work_dir_subdir
, NULL
);
1925 if (SetCurrentDirectoryW(work_dir_subdir
))
1927 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1928 skip("Could not create manifest file\n");
1931 handle
= test_create("..\\test1.manifest");
1932 DeleteFileA("..\\test1.manifest");
1933 if(handle
!= INVALID_HANDLE_VALUE
) {
1934 test_basic_info(handle
, __LINE__
);
1935 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1936 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1937 pReleaseActCtx(handle
);
1939 SetCurrentDirectoryW(work_dir
);
1942 skip("Couldn't change directory\n");
1943 RemoveDirectoryW(work_dir_subdir
);
1945 trace("UTF-16 manifest1, with BOM\n");
1946 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
1947 skip("Could not create manifest file\n");
1951 handle
= test_create("test1.manifest");
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
);
1960 trace("UTF-16 manifest1, reverse endian, with BOM\n");
1961 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
1962 skip("Could not create manifest file\n");
1966 handle
= test_create("test1.manifest");
1967 DeleteFileA("test1.manifest");
1968 if (handle
!= INVALID_HANDLE_VALUE
) {
1969 test_basic_info(handle
, __LINE__
);
1970 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1971 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1972 pReleaseActCtx(handle
);
1975 test_wndclass_section();
1976 test_dllredirect_section();
1977 test_typelib_section();
1980 static void test_app_manifest(void)
1985 trace("child process manifest1\n");
1987 b
= pGetCurrentActCtx(&handle
);
1988 ok(handle
== NULL
, "handle != NULL\n");
1989 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1991 test_basic_info(handle
, __LINE__
);
1992 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
1993 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
1994 pReleaseActCtx(handle
);
1998 static void run_child_process(void)
2000 char cmdline
[MAX_PATH
];
2001 char path
[MAX_PATH
];
2003 PROCESS_INFORMATION pi
;
2004 STARTUPINFOA si
= { 0 };
2009 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2010 strcat(path
, ".manifest");
2011 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2012 skip("Could not create manifest file\n");
2017 winetest_get_mainargs( &argv
);
2018 /* Vista+ seems to cache presence of .manifest files. Change last modified
2019 date to defeat the cache */
2020 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2021 NULL
, OPEN_EXISTING
, 0, NULL
);
2022 if (file
!= INVALID_HANDLE_VALUE
) {
2023 GetSystemTimeAsFileTime(&now
);
2024 SetFileTime(file
, NULL
, NULL
, &now
);
2027 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2028 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2029 ok(ret
, "Could not create process: %u\n", GetLastError());
2030 winetest_wait_child_process( pi
.hProcess
);
2031 CloseHandle(pi
.hThread
);
2032 CloseHandle(pi
.hProcess
);
2036 static void init_paths(void)
2041 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2042 static const WCHAR backslash
[] = {'\\',0};
2043 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2045 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2046 lstrcpyW(app_dir
, exe_path
);
2047 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2050 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2051 last
= work_dir
[lstrlenW(work_dir
) - 1];
2052 if (last
!= '\\' && last
!= '/')
2053 lstrcatW(work_dir
, backslash
);
2054 lstrcpyW(work_dir_subdir
, work_dir
);
2055 lstrcatW(work_dir_subdir
, subdir
);
2057 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2058 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2061 static void write_manifest(const char *filename
, const char *manifest
)
2065 CHAR path
[MAX_PATH
];
2067 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2068 strcat(path
, filename
);
2070 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2071 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2072 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2076 static void delete_manifest_file(const char *filename
)
2078 CHAR path
[MAX_PATH
];
2080 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2081 strcat(path
, filename
);
2085 static void test_CreateActCtx(void)
2087 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2091 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2092 strcat(path
, "main_wndcls.manifest");
2094 write_manifest("testdep1.manifest", manifest_wndcls1
);
2095 write_manifest("testdep2.manifest", manifest_wndcls2
);
2096 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2098 memset(&actctx
, 0, sizeof(ACTCTXA
));
2099 actctx
.cbSize
= sizeof(ACTCTXA
);
2100 actctx
.lpSource
= path
;
2102 /* create using lpSource without specified directory */
2103 handle
= pCreateActCtxA(&actctx
);
2104 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2105 pReleaseActCtx(handle
);
2107 /* with specified directory, that doesn't contain dependent assembly */
2108 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2110 memset(&actctx
, 0, sizeof(ACTCTXA
));
2111 actctx
.cbSize
= sizeof(ACTCTXA
);
2112 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2113 actctx
.lpAssemblyDirectory
= dir
;
2114 actctx
.lpSource
= path
;
2116 handle
= pCreateActCtxA(&actctx
);
2118 ok(handle
== INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
,
2119 "got handle %p, supposed to fail\n", handle
);
2120 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2122 delete_manifest_file("main.manifest");
2123 delete_manifest_file("testdep1.manifest");
2126 static BOOL
init_funcs(void)
2128 HMODULE hKernel32
= GetModuleHandleA("kernel32.dll");
2130 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
2134 X(DeactivateActCtx
);
2135 X(FindActCtxSectionStringA
);
2136 X(FindActCtxSectionStringW
);
2137 X(GetCurrentActCtx
);
2138 X(IsDebuggerPresent
);
2141 X(FindActCtxSectionGuid
);
2152 argc
= winetest_get_mainargs(&argv
);
2156 win_skip("Needed functions are not available\n");
2161 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2162 test_app_manifest();
2167 test_CreateActCtx();
2168 run_child_process();