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"
27 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
28 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
29 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
30 static BOOL (WINAPI
*pFindActCtxSectionStringW
)(DWORD
,const GUID
*,ULONG
,LPCWSTR
,PACTCTX_SECTION_KEYED_DATA
);
31 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
32 static BOOL (WINAPI
*pIsDebuggerPresent
)(void);
33 static BOOL (WINAPI
*pQueryActCtxW
)(DWORD
,HANDLE
,PVOID
,ULONG
,PVOID
,SIZE_T
,SIZE_T
*);
34 static VOID (WINAPI
*pReleaseActCtx
)(HANDLE
);
36 static const char* strw(LPCWSTR x
)
38 static char buffer
[1024];
41 if (!x
) return "(nil)";
42 else while ((*p
++ = *x
++));
48 #elif defined __x86_64__
54 static const char manifest1
[] =
55 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
56 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
59 static const char manifest2
[] =
60 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
61 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
65 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
67 "</dependentAssembly>"
71 static const char manifest3
[] =
72 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
73 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
74 " publicKeyToken=\"6595b6414666f1df\" />"
75 "<file name=\"testlib.dll\">"
76 "<windowClass>wndClass</windowClass>"
80 static const char manifest4
[] =
81 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
82 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
86 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
87 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
89 "</dependentAssembly>"
93 static const char testdep_manifest1
[] =
94 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
95 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
98 static const char testdep_manifest2
[] =
99 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
100 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
101 "<file name=\"testlib.dll\"></file>"
102 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
105 static const char testdep_manifest3
[] =
106 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
107 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
108 "<file name=\"testlib.dll\"/>"
109 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
110 "<windowClass>wndClass</windowClass>"
111 "<windowClass>wndClass2</windowClass>"
115 static const char wrong_manifest1
[] =
116 "<assembly manifestVersion=\"1.0\">"
117 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
120 static const char wrong_manifest2
[] =
121 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
122 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
125 static const char wrong_manifest3
[] =
126 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
127 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
130 static const char wrong_manifest4
[] =
131 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
132 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
136 static const char wrong_manifest5
[] =
137 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
138 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
142 static const char wrong_manifest6
[] =
143 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
144 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
147 static const char wrong_manifest7
[] =
148 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
149 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
150 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
153 static const char wrong_manifest8
[] =
154 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
155 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
159 static const char wrong_depmanifest1
[] =
160 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
161 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
164 static const WCHAR testlib_dll
[] =
165 {'t','e','s','t','l','i','b','.','d','l','l',0};
166 static const WCHAR testlib2_dll
[] =
167 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
168 static const WCHAR wndClassW
[] =
169 {'w','n','d','C','l','a','s','s',0};
170 static const WCHAR wndClass2W
[] =
171 {'w','n','d','C','l','a','s','s','2',0};
172 static const WCHAR acr_manifest
[] =
173 {'a','c','r','.','m','a','n','i','f','e','s','t',0};
175 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
176 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
178 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
183 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
184 return lstrcmpW(strw
, buf
);
187 static DWORD
strlen_aw(const char *str
)
189 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
192 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
193 const char *depfile
, const char *depmanifest
)
197 WCHAR path
[MAX_PATH
];
199 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
200 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
202 if (manifest_len
== -1)
203 manifest_len
= strlen(manifest
);
205 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
206 FILE_ATTRIBUTE_NORMAL
, NULL
);
207 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
208 if(file
== INVALID_HANDLE_VALUE
)
210 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
215 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
216 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
217 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
218 FILE_ATTRIBUTE_NORMAL
, NULL
);
219 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
220 if(file
== INVALID_HANDLE_VALUE
)
222 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
228 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
230 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
232 int offset
= (fBOM
? 0 : 1);
234 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
235 wmanifest
[0] = 0xfeff;
239 for (i
= 0; i
< strlen(manifest
)+1; i
++)
240 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
242 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
243 HeapFree(GetProcessHeap(), 0, wmanifest
);
248 ULONG format_version
;
249 ULONG assembly_cnt_min
;
250 ULONG assembly_cnt_max
;
251 ULONG root_manifest_type
;
252 LPWSTR root_manifest_path
;
253 ULONG root_config_type
;
258 static const detailed_info_t detailed_info0
= {
259 0, 0, 0, 0, NULL
, 0, 0, NULL
262 static const detailed_info_t detailed_info1
= {
263 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
264 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
268 static const detailed_info_t detailed_info1_child
= {
269 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
270 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
274 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
275 static const detailed_info_t detailed_info2
= {
276 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
277 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
281 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
283 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
284 SIZE_T size
, exsize
, retsize
;
287 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
288 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
289 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
291 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
293 b
= pQueryActCtxW(0, handle
, NULL
,
294 ActivationContextDetailedInformation
, &detailed_info_tmp
,
295 sizeof(detailed_info_tmp
), &size
);
296 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
297 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
298 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
300 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
303 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
304 memset(detailed_info
, 0xfe, size
);
305 b
= pQueryActCtxW(0, handle
, NULL
,
306 ActivationContextDetailedInformation
, detailed_info
,
308 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
309 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
311 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
312 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
313 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
314 exinfo
->format_version
);
315 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
316 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
317 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
318 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
319 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
320 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
321 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
322 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
323 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
324 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
325 detailed_info
->ulRootManifestPathChars
,
326 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
327 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
328 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
329 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
330 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
331 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
332 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
333 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
334 exinfo
->app_dir_type
);
335 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
336 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
337 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
338 if(exinfo
->root_manifest_path
) {
339 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
340 if(detailed_info
->lpRootManifestPath
)
341 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
342 "unexpected detailed_info->lpRootManifestPath\n");
344 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
346 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
347 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
348 if(exinfo
->app_dir
) {
349 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
350 if(detailed_info
->lpAppDirPath
)
351 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
352 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
354 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
357 HeapFree(GetProcessHeap(), 0, detailed_info
);
362 /* ULONG manifest_path_type; FIXME */
363 LPCWSTR manifest_path
;
364 LPCSTR encoded_assembly_id
;
365 BOOL has_assembly_dir
;
368 static const info_in_assembly manifest1_info
= {
370 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
374 static const info_in_assembly manifest1_child_info
= {
375 1, app_manifest_path
,
376 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
380 static const info_in_assembly manifest2_info
= {
382 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
386 static const info_in_assembly manifest3_info
= {
388 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
392 static const info_in_assembly manifest4_info
= {
394 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
398 static const info_in_assembly depmanifest1_info
= {
399 0x10, depmanifest_path
,
400 "testdep,processorArchitecture=\"" ARCH
"\","
401 "type=\"win32\",version=\"6.5.4.3\"",
405 static const info_in_assembly depmanifest2_info
= {
406 0x10, depmanifest_path
,
407 "testdep,processorArchitecture=\"" ARCH
"\","
408 "type=\"win32\",version=\"6.5.4.3\"",
412 static const info_in_assembly depmanifest3_info
= {
413 0x10, depmanifest_path
,
414 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
418 static const info_in_assembly manifest_comctrl_info
= {
419 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
422 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
424 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
429 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
430 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
431 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
434 b
= pQueryActCtxW(0, handle
, &id
,
435 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
436 sizeof(info_tmp
), &size
);
437 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
438 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
440 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
442 if (size
== 0xdeadbeef)
448 info
= HeapAlloc(GetProcessHeap(), 0, size
);
449 memset(info
, 0xfe, size
);
452 b
= pQueryActCtxW(0, handle
, &id
,
453 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
454 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
455 if (!exinfo
->manifest_path
)
456 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
457 if (!exinfo
->encoded_assembly_id
)
458 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
459 if (exinfo
->has_assembly_dir
)
460 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
461 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
463 if (0) /* FIXME: flags meaning unknown */
465 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
466 info
->ulFlags
, exinfo
->flags
);
468 if(exinfo
->encoded_assembly_id
) {
469 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
470 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
471 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
472 info
->ulEncodedAssemblyIdentityLength
, len
);
474 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
475 "info->ulEncodedAssemblyIdentityLength == 0\n");
477 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
478 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
479 if(exinfo
->manifest_path
) {
480 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
481 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
482 info
->ulManifestPathLength
, len
);
484 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
487 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
488 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
489 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
490 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
491 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
492 info
->ulMetadataSatelliteRosterIndex
);
493 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
494 info
->ulManifestVersionMajor
);
495 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
496 info
->ulManifestVersionMinor
);
497 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
498 info
->ulPolicyVersionMajor
);
499 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
500 info
->ulPolicyVersionMinor
);
501 if(exinfo
->has_assembly_dir
)
502 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
503 "info->ulAssemblyDirectoryNameLength == 0\n");
505 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
506 "info->ulAssemblyDirectoryNameLength != 0\n");
508 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
509 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
510 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
511 ok_(__FILE__
, line
)(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
512 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
513 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
515 if(exinfo
->manifest_path
) {
516 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
517 if(info
->lpAssemblyManifestPath
)
518 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
519 "unexpected info->lpAssemblyManifestPath\n");
521 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
524 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
525 if(info
->lpAssemblyPolicyPath
)
526 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
527 if(exinfo
->has_assembly_dir
)
528 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
530 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
531 strw(info
->lpAssemblyDirectoryName
));
532 HeapFree(GetProcessHeap(), 0, info
);
535 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
537 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
538 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
542 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
543 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
546 b
= pQueryActCtxW(0, handle
, &index
,
547 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
548 sizeof(info_tmp
), &size
);
549 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
550 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
551 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
553 if(size
== 0xdeadbeef)
559 info
= HeapAlloc(GetProcessHeap(), 0, size
);
560 memset(info
, 0xfe, size
);
562 b
= pQueryActCtxW(0, handle
, &index
,
563 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
564 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
565 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
567 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
568 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
569 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
570 info
->ulFilenameLength
, lstrlenW(filename
));
571 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
572 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
574 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
575 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
576 HeapFree(GetProcessHeap(), 0, info
);
579 static HANDLE
test_create(const char *file
, const char *manifest
)
583 WCHAR path
[MAX_PATH
];
585 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
586 memset(&actctx
, 0, sizeof(ACTCTXW
));
587 actctx
.cbSize
= sizeof(ACTCTXW
);
588 actctx
.lpSource
= path
;
590 handle
= pCreateActCtxW(&actctx
);
591 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
593 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
594 ok(actctx
.dwFlags
== 0, "actctx.=%d\n", actctx
.dwFlags
);
595 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
596 ok(actctx
.wProcessorArchitecture
== 0,
597 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
598 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
599 ok(actctx
.lpAssemblyDirectory
== NULL
,
600 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
601 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
602 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplocationName=%p\n",
603 actctx
.lpApplicationName
);
604 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
609 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
613 WCHAR path
[MAX_PATH
];
615 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
616 memset(&actctx
, 0, sizeof(ACTCTXW
));
617 actctx
.cbSize
= sizeof(ACTCTXW
);
618 actctx
.lpSource
= path
;
620 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
621 handle
= pCreateActCtxW(&actctx
);
624 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
625 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
629 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
630 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
632 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
633 DeleteFileA("bad.manifest");
634 DeleteFileA("testdep.manifest");
637 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
641 WCHAR path
[MAX_PATH
];
643 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
644 memset(&actctx
, 0, sizeof(ACTCTXW
));
645 actctx
.cbSize
= sizeof(ACTCTXW
);
646 actctx
.lpSource
= path
;
648 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
649 handle
= pCreateActCtxW(&actctx
);
650 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
651 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
653 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
654 DeleteFileA("bad.manifest");
657 static void test_create_fail(void)
661 WCHAR path
[MAX_PATH
];
663 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
664 memset(&actctx
, 0, sizeof(ACTCTXW
));
665 actctx
.cbSize
= sizeof(ACTCTXW
);
666 actctx
.lpSource
= path
;
668 handle
= pCreateActCtxW(&actctx
);
669 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
670 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
672 trace("wrong_manifest1\n");
673 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
674 trace("wrong_manifest2\n");
675 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
676 trace("wrong_manifest3\n");
677 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
678 trace("wrong_manifest4\n");
679 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
680 trace("wrong_manifest5\n");
681 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
682 trace("wrong_manifest6\n");
683 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
684 trace("wrong_manifest7\n");
685 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
686 trace("wrong_manifest8\n");
687 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
688 trace("UTF-16 manifest1 without BOM\n");
689 test_create_wide_and_fail(manifest1
, FALSE
);
690 trace("manifest2\n");
691 test_create_and_fail(manifest2
, NULL
, 0 );
692 trace("manifest2+depmanifest1\n");
693 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
696 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
698 ACTCTX_SECTION_KEYED_DATA data
;
702 memset(&data
, 0xfe, sizeof(data
));
703 data
.cbSize
= sizeof(data
);
705 ret
= pFindActCtxSectionStringW(0, NULL
,
706 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
708 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
711 skip("couldn't find %s\n",strw(libname
));
715 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
716 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
717 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
718 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
721 if(ret
&& p
) todo_wine
{
722 ok_(__FILE__
, line
)(p
[0] == 20 && p
[1] == 2 && p
[2] == 0 && p
[3] == 0 && p
[4] == 0,
723 "wrong data %u,%u,%u,%u,%u\n",p
[0], p
[1], p
[2], p
[3], p
[4]);
726 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
727 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
728 data
.ulSectionGlobalDataLength
);
729 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
730 /* ok_(__FILE__, line)(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n",
731 data.ulSectionTotalLength); */
732 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
733 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
734 data
.ulAssemblyRosterIndex
, exid
);
736 memset(&data
, 0xfe, sizeof(data
));
737 data
.cbSize
= sizeof(data
);
739 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
740 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
742 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
745 skip("couldn't find\n");
749 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
750 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
751 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
752 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
753 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
754 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
755 data
.ulSectionGlobalDataLength
);
756 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
757 /* ok_(__FILE__, line)(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n",
758 data.ulSectionTotalLength); */
759 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
760 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
761 data
.ulAssemblyRosterIndex
, exid
);
763 pReleaseActCtx(handle
);
766 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
768 ACTCTX_SECTION_KEYED_DATA data
;
771 memset(&data
, 0xfe, sizeof(data
));
772 data
.cbSize
= sizeof(data
);
774 ret
= pFindActCtxSectionStringW(0, NULL
,
775 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
777 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
780 skip("couldn't find\n");
784 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
785 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
786 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
787 /* ok_(__FILE__, line)(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); */
788 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
789 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
790 data
.ulSectionGlobalDataLength
);
791 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
792 /* ok_(__FILE__, line)(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n",
793 data.ulSectionTotalLength); FIXME */
794 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
795 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
796 data
.ulAssemblyRosterIndex
, exid
);
798 memset(&data
, 0xfe, sizeof(data
));
799 data
.cbSize
= sizeof(data
);
801 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
802 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
804 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
807 skip("couldn't find\n");
811 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
812 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
813 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
814 /* ok_(__FILE__, line)(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); FIXME */
815 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
816 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
817 data
.ulSectionGlobalDataLength
);
818 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
819 /* ok_(__FILE__, line)(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n",
820 data.ulSectionTotalLength); FIXME */
821 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
822 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
823 data
.ulAssemblyRosterIndex
, exid
);
825 pReleaseActCtx(handle
);
828 static void test_find_string_fail(void)
830 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
833 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
834 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
835 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
837 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
838 testlib2_dll
, &data
);
839 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
840 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
842 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
844 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
845 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
847 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
849 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
850 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
853 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
855 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
856 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
859 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
861 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
862 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
866 static void test_basic_info(HANDLE handle
, int line
)
868 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
872 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
873 ActivationContextBasicInformation
, &basic
,
874 sizeof(basic
), &size
);
876 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
877 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
878 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
879 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
881 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
882 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
883 ActivationContextBasicInformation
, &basic
,
884 sizeof(basic
), &size
);
887 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
888 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
889 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
890 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
891 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
895 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
896 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
897 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
898 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
902 static void test_actctx(void)
910 trace("default actctx\n");
912 b
= pGetCurrentActCtx(&handle
);
913 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
914 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
916 test_basic_info(handle
, __LINE__
);
917 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
918 pReleaseActCtx(handle
);
921 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
922 skip("Could not create manifest file\n");
926 trace("manifest1\n");
928 handle
= test_create("test1.manifest", manifest1
);
929 DeleteFileA("test1.manifest");
930 if(handle
!= INVALID_HANDLE_VALUE
) {
931 test_basic_info(handle
, __LINE__
);
932 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
933 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
935 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
937 /* CloseHandle will generate an exception if a debugger is present */
938 b
= CloseHandle(handle
);
939 ok(!b
, "CloseHandle succeeded\n");
940 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
943 pReleaseActCtx(handle
);
946 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
947 skip("Could not create manifest file\n");
951 trace("manifest2 depmanifest1\n");
953 handle
= test_create("test2.manifest", manifest2
);
954 DeleteFileA("test2.manifest");
955 DeleteFileA("testdep.manifest");
956 if(handle
!= INVALID_HANDLE_VALUE
) {
957 test_basic_info(handle
, __LINE__
);
958 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
959 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
960 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
961 pReleaseActCtx(handle
);
964 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
965 skip("Could not create manifest file\n");
969 trace("manifest2 depmanifest2\n");
971 handle
= test_create("test2-2.manifest", manifest2
);
972 DeleteFileA("test2-2.manifest");
973 DeleteFileA("testdep.manifest");
974 if(handle
!= INVALID_HANDLE_VALUE
) {
975 test_basic_info(handle
, __LINE__
);
976 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
977 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
978 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
979 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
980 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
982 b
= pActivateActCtx(handle
, &cookie
);
983 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
984 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
985 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
986 b
= pDeactivateActCtx(0, cookie
);
987 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
989 pReleaseActCtx(handle
);
992 trace("manifest2 depmanifest3\n");
994 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
995 skip("Could not create manifest file\n");
999 handle
= test_create("test2-3.manifest", manifest2
);
1000 DeleteFileA("test2-3.manifest");
1001 DeleteFileA("testdep.manifest");
1002 if(handle
!= INVALID_HANDLE_VALUE
) {
1003 test_basic_info(handle
, __LINE__
);
1004 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1005 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1006 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
1007 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1008 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1010 b
= pActivateActCtx(handle
, &cookie
);
1011 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1012 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1013 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1014 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
1015 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
1016 b
= pDeactivateActCtx(0, cookie
);
1017 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1019 pReleaseActCtx(handle
);
1022 trace("manifest3\n");
1024 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1025 skip("Could not create manifest file\n");
1029 handle
= test_create("test3.manifest", manifest3
);
1030 DeleteFileA("test3.manifest");
1031 if(handle
!= INVALID_HANDLE_VALUE
) {
1032 test_basic_info(handle
, __LINE__
);
1033 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1034 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
1035 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
1037 b
= pActivateActCtx(handle
, &cookie
);
1038 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1039 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1040 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1041 test_find_string_fail();
1042 b
= pDeactivateActCtx(0, cookie
);
1043 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1045 pReleaseActCtx(handle
);
1048 trace("manifest4\n");
1050 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1051 skip("Could not create manifest file\n");
1055 handle
= test_create("test4.manifest", manifest4
);
1056 DeleteFileA("test4.manifest");
1057 DeleteFileA("testdep.manifest");
1058 if(handle
!= INVALID_HANDLE_VALUE
) {
1059 test_basic_info(handle
, __LINE__
);
1060 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1061 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
1062 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
1063 pReleaseActCtx(handle
);
1066 trace("manifest1 in subdir\n");
1068 CreateDirectoryW(work_dir_subdir
, NULL
);
1069 if (SetCurrentDirectoryW(work_dir_subdir
))
1071 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1072 skip("Could not create manifest file\n");
1075 handle
= test_create("..\\test1.manifest", manifest1
);
1076 DeleteFileA("..\\test1.manifest");
1077 if(handle
!= INVALID_HANDLE_VALUE
) {
1078 test_basic_info(handle
, __LINE__
);
1079 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1080 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1081 pReleaseActCtx(handle
);
1083 SetCurrentDirectoryW(work_dir
);
1086 skip("Couldn't change directory\n");
1087 RemoveDirectoryW(work_dir_subdir
);
1089 trace("UTF-16 manifest1, with BOM\n");
1090 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
1091 skip("Could not create manifest file\n");
1095 handle
= test_create("test1.manifest", manifest1
);
1096 DeleteFileA("test1.manifest");
1097 if (handle
!= INVALID_HANDLE_VALUE
) {
1098 test_basic_info(handle
, __LINE__
);
1099 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1100 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1101 pReleaseActCtx(handle
);
1104 trace("UTF-16 manifest1, reverse endian, with BOM\n");
1105 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
1106 skip("Could not create manifest file\n");
1110 handle
= test_create("test1.manifest", manifest1
);
1111 DeleteFileA("test1.manifest");
1112 if (handle
!= INVALID_HANDLE_VALUE
) {
1113 test_basic_info(handle
, __LINE__
);
1114 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1115 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1116 pReleaseActCtx(handle
);
1121 static void test_app_manifest(void)
1126 trace("child process manifest1\n");
1128 b
= pGetCurrentActCtx(&handle
);
1129 ok(handle
== NULL
, "handle != NULL\n");
1130 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1132 test_basic_info(handle
, __LINE__
);
1133 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
1134 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
1135 pReleaseActCtx(handle
);
1139 static void run_child_process(void)
1141 char cmdline
[MAX_PATH
];
1142 char path
[MAX_PATH
];
1144 PROCESS_INFORMATION pi
;
1145 STARTUPINFO si
= { 0 };
1150 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
1151 strcat(path
, ".manifest");
1152 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
1153 skip("Could not create manifest file\n");
1158 winetest_get_mainargs( &argv
);
1159 /* Vista+ seems to cache presence of .manifest files. Change last modified
1160 date to defeat the cache */
1161 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1162 NULL
, OPEN_EXISTING
, 0, NULL
);
1163 if (file
!= INVALID_HANDLE_VALUE
) {
1164 GetSystemTimeAsFileTime(&now
);
1165 SetFileTime(file
, NULL
, NULL
, &now
);
1168 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
1169 ret
= CreateProcess(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
1170 ok(ret
, "Could not create process: %u\n", GetLastError());
1171 winetest_wait_child_process( pi
.hProcess
);
1172 CloseHandle(pi
.hThread
);
1173 CloseHandle(pi
.hProcess
);
1177 static void init_paths(void)
1182 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
1183 static const WCHAR backslash
[] = {'\\',0};
1184 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
1186 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
1187 lstrcpyW(app_dir
, exe_path
);
1188 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
1191 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
1192 last
= work_dir
[lstrlenW(work_dir
) - 1];
1193 if (last
!= '\\' && last
!= '/')
1194 lstrcatW(work_dir
, backslash
);
1195 lstrcpyW(work_dir_subdir
, work_dir
);
1196 lstrcatW(work_dir_subdir
, subdir
);
1198 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
1199 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
1202 static BOOL
init_funcs(void)
1204 HMODULE hKernel32
= GetModuleHandle("kernel32");
1206 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
1209 X(DeactivateActCtx
);
1210 X(FindActCtxSectionStringW
);
1211 X(GetCurrentActCtx
);
1212 X(IsDebuggerPresent
);
1225 argc
= winetest_get_mainargs(&argv
);
1229 win_skip("Needed functions are not available\n");
1234 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
1235 test_app_manifest();
1240 run_child_process();