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
*pQueryActCtxW
)(DWORD
,HANDLE
,PVOID
,ULONG
,PVOID
,SIZE_T
,SIZE_T
*);
33 static VOID (WINAPI
*pReleaseActCtx
)(HANDLE
);
35 static const char* strw(LPCWSTR x
)
37 static char buffer
[1024];
40 if (!x
) return "(nil)";
41 else while ((*p
++ = *x
++));
45 static const char manifest1
[] =
46 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
47 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
50 static const char manifest2
[] =
51 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
52 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
56 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\">"
58 "</dependentAssembly>"
62 static const char manifest3
[] =
63 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
64 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
65 " publicKeyToken=\"6595b6414666f1df\" />"
66 "<file name=\"testlib.dll\">"
67 "<windowClass>wndClass</windowClass>"
71 static const char manifest4
[] =
72 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
73 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
77 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
78 "version=\"6.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"6595b64144ccf1df\">"
80 "</dependentAssembly>"
84 static const char testdep_manifest1
[] =
85 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
86 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\"/>"
89 static const char testdep_manifest2
[] =
90 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
91 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\" />"
92 "<file name=\"testlib.dll\"></file>"
93 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
96 static const char testdep_manifest3
[] =
97 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
98 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\"/>"
99 "<file name=\"testlib.dll\"/>"
100 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
101 "<windowClass>wndClass</windowClass>"
102 "<windowClass>wndClass2</windowClass>"
106 static const char wrong_manifest1
[] =
107 "<assembly manifestVersion=\"1.0\">"
108 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
111 static const char wrong_manifest2
[] =
112 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
113 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
116 static const char wrong_manifest3
[] =
117 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
118 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
121 static const char wrong_manifest4
[] =
122 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
123 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
127 static const char wrong_manifest5
[] =
128 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
129 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
133 static const char wrong_manifest6
[] =
134 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
135 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
138 static const char wrong_manifest7
[] =
139 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
140 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\" />"
141 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
144 static const char wrong_manifest8
[] =
145 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
146 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
150 static const char wrong_depmanifest1
[] =
151 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
152 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"x86\" />"
155 static const WCHAR testlib_dll
[] =
156 {'t','e','s','t','l','i','b','.','d','l','l',0};
157 static const WCHAR testlib2_dll
[] =
158 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
159 static const WCHAR wndClassW
[] =
160 {'w','n','d','C','l','a','s','s',0};
161 static const WCHAR wndClass2W
[] =
162 {'w','n','d','C','l','a','s','s','2',0};
163 static const WCHAR acr_manifest
[] =
164 {'a','c','r','.','m','a','n','i','f','e','s','t',0};
166 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
167 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
169 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
174 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
175 return lstrcmpW(strw
, buf
);
178 static DWORD
strlen_aw(const char *str
)
180 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
183 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
184 const char *depfile
, const char *depmanifest
)
188 WCHAR path
[MAX_PATH
];
190 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
191 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
193 if (manifest_len
== -1)
194 manifest_len
= strlen(manifest
);
196 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
197 FILE_ATTRIBUTE_NORMAL
, NULL
);
198 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
199 if(file
== INVALID_HANDLE_VALUE
)
201 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
206 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
207 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
208 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
209 FILE_ATTRIBUTE_NORMAL
, NULL
);
210 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
211 if(file
== INVALID_HANDLE_VALUE
)
213 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
219 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
221 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
223 int offset
= (fBOM
? 0 : 1);
225 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1) * sizeof(WCHAR
));
226 wmanifest
[0] = 0xfeff;
230 for (i
= 0; i
< strlen(manifest
)+1; i
++)
231 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
233 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
234 HeapFree(GetProcessHeap(), 0, wmanifest
);
239 ULONG format_version
;
241 ULONG root_manifest_type
;
242 LPWSTR root_manifest_path
;
243 ULONG root_config_type
;
248 static const detailed_info_t detailed_info0
= {
249 0, 0, 0, NULL
, 0, 0, NULL
252 static const detailed_info_t detailed_info1
= {
253 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
254 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
258 static const detailed_info_t detailed_info1_child
= {
259 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
260 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
264 static const detailed_info_t detailed_info2
= {
265 1, 2, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
266 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
270 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
)
272 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
273 SIZE_T size
, exsize
, retsize
;
276 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
277 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
278 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
280 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
282 b
= pQueryActCtxW(0, handle
, NULL
,
283 ActivationContextDetailedInformation
, &detailed_info_tmp
,
284 sizeof(detailed_info_tmp
), &size
);
285 ok(!b
, "QueryActCtx succeeded\n");
286 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
287 ok(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
289 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
292 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
293 memset(detailed_info
, 0xfe, size
);
294 b
= pQueryActCtxW(0, handle
, NULL
,
295 ActivationContextDetailedInformation
, detailed_info
,
297 ok(b
, "QueryActCtx failed: %u\n", GetLastError());
298 ok(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
300 ok(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
301 ok(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
302 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
303 exinfo
->format_version
);
304 ok(detailed_info
->ulAssemblyCount
== exinfo
->assembly_cnt
,
305 "detailed_info->ulAssemblyCount=%u, expected %u\n", detailed_info
->ulAssemblyCount
,
306 exinfo
->assembly_cnt
);
307 ok(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
308 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
309 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
310 ok(detailed_info
->ulRootManifestPathChars
==
311 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
312 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
313 detailed_info
->ulRootManifestPathChars
,
314 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
315 ok(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
316 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
317 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
318 ok(detailed_info
->ulRootConfigurationPathChars
== 0,
319 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
320 ok(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
321 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
322 exinfo
->app_dir_type
);
323 ok(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
324 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
325 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
326 if(exinfo
->root_manifest_path
) {
327 ok(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
328 if(detailed_info
->lpRootManifestPath
)
329 ok(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
330 "unexpected detailed_info->lpRootManifestPath\n");
332 ok(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
334 ok(detailed_info
->lpRootConfigurationPath
== NULL
,
335 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
336 if(exinfo
->app_dir
) {
337 ok(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
338 if(detailed_info
->lpAppDirPath
)
339 ok(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
340 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
342 ok(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
345 HeapFree(GetProcessHeap(), 0, detailed_info
);
350 /* ULONG manifest_path_type; FIXME */
351 LPCWSTR manifest_path
;
352 LPCSTR encoded_assembly_id
;
353 BOOL has_assembly_dir
;
356 static const info_in_assembly manifest1_info
= {
358 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
362 static const info_in_assembly manifest1_child_info
= {
363 1, app_manifest_path
,
364 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
368 static const info_in_assembly manifest2_info
= {
370 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
374 static const info_in_assembly manifest3_info
= {
376 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
380 static const info_in_assembly manifest4_info
= {
382 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
386 static const info_in_assembly depmanifest1_info
= {
387 0x10, depmanifest_path
,
388 "testdep,processorArchitecture=\"x86\","
389 "type=\"win32\",version=\"6.5.4.3\"",
393 static const info_in_assembly depmanifest2_info
= {
394 0x10, depmanifest_path
,
395 "testdep,processorArchitecture=\"x86\","
396 "type=\"win32\",version=\"6.5.4.3\"",
400 static const info_in_assembly depmanifest3_info
= {
401 0x10, depmanifest_path
,
402 "testdep,processorArchitecture=\"x86\",type=\"win32\",version=\"6.5.4.3\"",
406 static const info_in_assembly manifest_comctrl_info
= {
407 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
410 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
)
412 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
417 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
418 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
419 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
422 b
= pQueryActCtxW(0, handle
, &id
,
423 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
424 sizeof(info_tmp
), &size
);
425 ok(!b
, "QueryActCtx succeeded\n");
426 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
428 ok(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
430 if (size
== 0xdeadbeef)
436 info
= HeapAlloc(GetProcessHeap(), 0, size
);
437 memset(info
, 0xfe, size
);
440 b
= pQueryActCtxW(0, handle
, &id
,
441 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
442 ok(b
, "QueryActCtx failed: %u\n", GetLastError());
443 if (!exinfo
->manifest_path
)
444 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
445 if (!exinfo
->encoded_assembly_id
)
446 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
447 if (exinfo
->has_assembly_dir
)
448 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
449 ok(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
451 if (0) /* FIXME: flags meaning unknown */
453 ok((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
454 info
->ulFlags
, exinfo
->flags
);
456 if(exinfo
->encoded_assembly_id
) {
457 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
458 ok(info
->ulEncodedAssemblyIdentityLength
== len
,
459 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
460 info
->ulEncodedAssemblyIdentityLength
, len
);
462 ok(info
->ulEncodedAssemblyIdentityLength
!= 0,
463 "info->ulEncodedAssemblyIdentityLength == 0\n");
465 ok(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
466 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
467 if(exinfo
->manifest_path
) {
468 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
469 ok(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
470 info
->ulManifestPathLength
, len
);
472 ok(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
475 ok(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
476 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
477 ok(info
->ulPolicyPathLength
== 0,
478 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
479 ok(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
480 info
->ulMetadataSatelliteRosterIndex
);
481 ok(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
482 info
->ulManifestVersionMajor
);
483 ok(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
484 info
->ulManifestVersionMinor
);
485 ok(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
486 info
->ulPolicyVersionMajor
);
487 ok(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
488 info
->ulPolicyVersionMinor
);
489 if(exinfo
->has_assembly_dir
)
490 ok(info
->ulAssemblyDirectoryNameLength
!= 0,
491 "info->ulAssemblyDirectoryNameLength == 0\n");
493 ok(info
->ulAssemblyDirectoryNameLength
== 0,
494 "info->ulAssemblyDirectoryNameLength != 0\n");
496 ok(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
497 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
498 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
499 ok(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
500 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
501 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
503 if(exinfo
->manifest_path
) {
504 ok(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
505 if(info
->lpAssemblyManifestPath
)
506 ok(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
507 "unexpected info->lpAssemblyManifestPath\n");
509 ok(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
512 ok(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
513 if(info
->lpAssemblyPolicyPath
)
514 ok(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
515 if(exinfo
->has_assembly_dir
)
516 ok(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
518 ok(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
519 strw(info
->lpAssemblyDirectoryName
));
522 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
)
524 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
525 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
529 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
530 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
533 b
= pQueryActCtxW(0, handle
, &index
,
534 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
535 sizeof(info_tmp
), &size
);
536 ok(!b
, "QueryActCtx succeeded\n");
537 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
538 ok(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
540 if(size
== 0xdeadbeef)
546 info
= HeapAlloc(GetProcessHeap(), 0, size
);
547 memset(info
, 0xfe, size
);
549 b
= pQueryActCtxW(0, handle
, &index
,
550 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
551 ok(b
, "QueryActCtx failed: %u\n", GetLastError());
552 ok(!size
, "size=%lu, expected 0\n", size
);
554 ok(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
555 ok(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
556 "info->ulFilenameLength=%u, expected %u\n",
557 info
->ulFilenameLength
, lstrlenW(filename
)*sizeof(WCHAR
));
558 ok(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
559 ok(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
561 ok(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
562 ok(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
565 static HANDLE
test_create(const char *file
, const char *manifest
)
569 WCHAR path
[MAX_PATH
];
571 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
572 memset(&actctx
, 0, sizeof(ACTCTXW
));
573 actctx
.cbSize
= sizeof(ACTCTXW
);
574 actctx
.lpSource
= path
;
576 handle
= pCreateActCtxW(&actctx
);
577 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
579 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
580 ok(actctx
.dwFlags
== 0, "actctx.=%d\n", actctx
.dwFlags
);
581 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
582 ok(actctx
.wProcessorArchitecture
== 0,
583 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
584 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
585 ok(actctx
.lpAssemblyDirectory
== NULL
,
586 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
587 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
588 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplocationName=%p\n",
589 actctx
.lpApplicationName
);
590 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
595 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
599 WCHAR path
[MAX_PATH
];
601 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
602 memset(&actctx
, 0, sizeof(ACTCTXW
));
603 actctx
.cbSize
= sizeof(ACTCTXW
);
604 actctx
.lpSource
= path
;
606 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
607 handle
= pCreateActCtxW(&actctx
);
610 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
611 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
615 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
616 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
618 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
619 DeleteFileA("bad.manifest");
620 DeleteFileA("testdep.manifest");
623 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
627 WCHAR path
[MAX_PATH
];
629 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
630 memset(&actctx
, 0, sizeof(ACTCTXW
));
631 actctx
.cbSize
= sizeof(ACTCTXW
);
632 actctx
.lpSource
= path
;
634 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
635 handle
= pCreateActCtxW(&actctx
);
636 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
637 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
639 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
640 DeleteFileA("bad.manifest");
643 static void test_create_fail(void)
647 WCHAR path
[MAX_PATH
];
649 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
650 memset(&actctx
, 0, sizeof(ACTCTXW
));
651 actctx
.cbSize
= sizeof(ACTCTXW
);
652 actctx
.lpSource
= path
;
654 handle
= pCreateActCtxW(&actctx
);
655 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
656 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
658 trace("wrong_manifest1\n");
659 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
660 trace("wrong_manifest2\n");
661 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
662 trace("wrong_manifest3\n");
663 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
664 trace("wrong_manifest4\n");
665 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
666 trace("wrong_manifest5\n");
667 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
668 trace("wrong_manifest6\n");
669 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
670 trace("wrong_manifest7\n");
671 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
672 trace("wrong_manifest8\n");
673 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
674 trace("UTF-16 manifest1 without BOM\n");
675 test_create_wide_and_fail(manifest1
, FALSE
);
676 trace("manifest2\n");
677 test_create_and_fail(manifest2
, NULL
, 0 );
678 trace("manifest2+depmanifest1\n");
679 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
682 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
)
684 ACTCTX_SECTION_KEYED_DATA data
;
688 memset(&data
, 0xfe, sizeof(data
));
689 data
.cbSize
= sizeof(data
);
691 ret
= pFindActCtxSectionStringW(0, NULL
,
692 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
694 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
697 skip("couldn't find %s\n",strw(libname
));
701 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
702 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
703 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
704 ok(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
707 if(ret
&& p
) todo_wine
{
708 ok(p
[0] == 20 && p
[1] == 2 && p
[2] == 0 && p
[3] == 0 && p
[4] == 0,
709 "wrong data %u,%u,%u,%u,%u\n",p
[0], p
[1], p
[2], p
[3], p
[4]);
712 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
713 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
714 data
.ulSectionGlobalDataLength
);
715 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
716 /* ok(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n",
717 data.ulSectionTotalLength); */
718 ok(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
719 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
720 data
.ulAssemblyRosterIndex
, exid
);
722 memset(&data
, 0xfe, sizeof(data
));
723 data
.cbSize
= sizeof(data
);
725 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
726 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
728 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
731 skip("couldn't find\n");
735 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
736 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
737 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
738 ok(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
739 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
740 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
741 data
.ulSectionGlobalDataLength
);
742 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
743 /* ok(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n",
744 data.ulSectionTotalLength); */
745 ok(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
746 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
747 data
.ulAssemblyRosterIndex
, exid
);
749 pReleaseActCtx(handle
);
752 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
)
754 ACTCTX_SECTION_KEYED_DATA data
;
757 memset(&data
, 0xfe, sizeof(data
));
758 data
.cbSize
= sizeof(data
);
760 ret
= pFindActCtxSectionStringW(0, NULL
,
761 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
763 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
766 skip("couldn't find\n");
770 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
771 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
772 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
773 /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); */
774 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
775 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
776 data
.ulSectionGlobalDataLength
);
777 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
778 /* ok(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n",
779 data.ulSectionTotalLength); FIXME */
780 ok(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
781 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
782 data
.ulAssemblyRosterIndex
, exid
);
784 memset(&data
, 0xfe, sizeof(data
));
785 data
.cbSize
= sizeof(data
);
787 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
788 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
790 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
793 skip("couldn't find\n");
797 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
798 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
799 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
800 /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); FIXME */
801 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
802 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
803 data
.ulSectionGlobalDataLength
);
804 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
805 /* ok(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n",
806 data.ulSectionTotalLength); FIXME */
807 ok(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
808 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
809 data
.ulAssemblyRosterIndex
, exid
);
811 pReleaseActCtx(handle
);
814 static void test_find_string_fail(void)
816 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
819 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
820 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
821 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
823 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
824 testlib2_dll
, &data
);
825 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
826 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
828 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
830 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
831 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
833 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
835 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
836 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
839 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
841 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
842 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
845 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
847 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
848 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
851 static void test_actctx(void)
859 trace("default actctx\n");
861 b
= pGetCurrentActCtx(&handle
);
862 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
863 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
865 test_detailed_info(handle
, &detailed_info0
);
866 pReleaseActCtx(handle
);
869 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
870 skip("Could not create manifest file\n");
874 trace("manifest1\n");
876 handle
= test_create("test1.manifest", manifest1
);
877 DeleteFileA("test1.manifest");
878 if(handle
!= INVALID_HANDLE_VALUE
) {
879 test_detailed_info(handle
, &detailed_info1
);
880 test_info_in_assembly(handle
, 1, &manifest1_info
);
882 if (!IsDebuggerPresent()) /* CloseHandle will generate an exception if a debugger is present */
884 b
= CloseHandle(handle
);
885 ok(!b
, "CloseHandle succeeded\n");
886 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
889 pReleaseActCtx(handle
);
892 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
893 skip("Could not create manifest file\n");
897 trace("manifest2 depmanifest1\n");
899 handle
= test_create("test2.manifest", manifest2
);
900 DeleteFileA("test2.manifest");
901 DeleteFileA("testdep.manifest");
902 if(handle
!= INVALID_HANDLE_VALUE
) {
903 test_detailed_info(handle
, &detailed_info2
);
904 test_info_in_assembly(handle
, 1, &manifest2_info
);
905 test_info_in_assembly(handle
, 2, &depmanifest1_info
);
906 pReleaseActCtx(handle
);
909 if(!create_manifest_file("test3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
910 skip("Could not create manifest file\n");
914 trace("manifest2 depmanifest2\n");
916 handle
= test_create("test3.manifest", manifest2
);
917 DeleteFileA("test3.manifest");
918 DeleteFileA("testdep.manifest");
919 if(handle
!= INVALID_HANDLE_VALUE
) {
920 test_detailed_info(handle
, &detailed_info2
);
921 test_info_in_assembly(handle
, 1, &manifest2_info
);
922 test_info_in_assembly(handle
, 2, &depmanifest2_info
);
923 test_file_info(handle
, 1, 0, testlib_dll
);
924 test_file_info(handle
, 1, 1, testlib2_dll
);
926 b
= pActivateActCtx(handle
, &cookie
);
927 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
928 test_find_dll_redirection(handle
, testlib_dll
, 2);
929 test_find_dll_redirection(handle
, testlib2_dll
, 2);
930 b
= pDeactivateActCtx(0, cookie
);
931 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
933 pReleaseActCtx(handle
);
936 trace("manifest2 depmanifest3\n");
938 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
939 skip("Could not create manifest file\n");
943 handle
= test_create("test2-3.manifest", manifest2
);
944 DeleteFileA("test2-3.manifest");
945 DeleteFileA("testdep.manifest");
946 if(handle
!= INVALID_HANDLE_VALUE
) {
947 test_detailed_info(handle
, &detailed_info2
);
948 test_info_in_assembly(handle
, 1, &manifest2_info
);
949 test_info_in_assembly(handle
, 2, &depmanifest3_info
);
950 test_file_info(handle
, 1, 0, testlib_dll
);
951 test_file_info(handle
, 1, 1, testlib2_dll
);
953 b
= pActivateActCtx(handle
, &cookie
);
954 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
955 test_find_dll_redirection(handle
, testlib_dll
, 2);
956 test_find_dll_redirection(handle
, testlib2_dll
, 2);
957 test_find_window_class(handle
, wndClassW
, 2);
958 test_find_window_class(handle
, wndClass2W
, 2);
959 b
= pDeactivateActCtx(0, cookie
);
960 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
962 pReleaseActCtx(handle
);
965 trace("manifest3\n");
967 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
968 skip("Could not create manifest file\n");
972 handle
= test_create("test3.manifest", manifest3
);
973 DeleteFileA("test3.manifest");
974 if(handle
!= INVALID_HANDLE_VALUE
) {
975 test_detailed_info(handle
, &detailed_info1
);
976 test_info_in_assembly(handle
, 1, &manifest3_info
);
977 test_file_info(handle
, 0, 0, testlib_dll
);
979 b
= pActivateActCtx(handle
, &cookie
);
980 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
981 test_find_dll_redirection(handle
, testlib_dll
, 1);
982 test_find_dll_redirection(handle
, testlib_dll
, 1);
983 test_find_string_fail();
984 b
= pDeactivateActCtx(0, cookie
);
985 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
987 pReleaseActCtx(handle
);
990 trace("manifest4\n");
992 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
993 skip("Could not create manifest file\n");
997 handle
= test_create("test4.manifest", manifest4
);
998 DeleteFileA("test4.manifest");
999 DeleteFileA("testdep.manifest");
1000 if(handle
!= INVALID_HANDLE_VALUE
) {
1001 test_detailed_info(handle
, &detailed_info2
);
1002 test_info_in_assembly(handle
, 1, &manifest4_info
);
1003 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
);
1004 pReleaseActCtx(handle
);
1007 trace("manifest1 in subdir\n");
1009 CreateDirectoryW(work_dir_subdir
, NULL
);
1010 if (SetCurrentDirectoryW(work_dir_subdir
))
1012 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1013 skip("Could not create manifest file\n");
1016 handle
= test_create("..\\test1.manifest", manifest1
);
1017 DeleteFileA("..\\test1.manifest");
1018 if(handle
!= INVALID_HANDLE_VALUE
) {
1019 test_detailed_info(handle
, &detailed_info1
);
1020 test_info_in_assembly(handle
, 1, &manifest1_info
);
1021 pReleaseActCtx(handle
);
1023 SetCurrentDirectoryW(work_dir
);
1026 skip("Couldn't change directory\n");
1027 RemoveDirectoryW(work_dir_subdir
);
1029 trace("UTF-16 manifest1, with BOM\n");
1030 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
1031 skip("Could not create manifest file\n");
1035 handle
= test_create("test1.manifest", manifest1
);
1036 DeleteFileA("test1.manifest");
1037 if (handle
!= INVALID_HANDLE_VALUE
) {
1038 test_detailed_info(handle
, &detailed_info1
);
1039 test_info_in_assembly(handle
, 1, &manifest1_info
);
1040 pReleaseActCtx(handle
);
1043 trace("UTF-16 manifest1, reverse endian, with BOM\n");
1044 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
1045 skip("Could not create manifest file\n");
1049 handle
= test_create("test1.manifest", manifest1
);
1050 DeleteFileA("test1.manifest");
1051 if (handle
!= INVALID_HANDLE_VALUE
) {
1052 test_detailed_info(handle
, &detailed_info1
);
1053 test_info_in_assembly(handle
, 1, &manifest1_info
);
1054 pReleaseActCtx(handle
);
1059 static void test_app_manifest(void)
1064 trace("child process manifest1\n");
1066 b
= pGetCurrentActCtx(&handle
);
1067 ok(handle
== NULL
, "handle != NULL\n");
1068 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1070 test_detailed_info(handle
, &detailed_info1_child
);
1071 test_info_in_assembly(handle
, 1, &manifest1_child_info
);
1072 pReleaseActCtx(handle
);
1076 static void run_child_process(void)
1078 char cmdline
[MAX_PATH
];
1079 char path
[MAX_PATH
];
1081 PROCESS_INFORMATION pi
;
1082 STARTUPINFO si
= { 0 };
1084 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
1085 strcat(path
, ".manifest");
1086 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
1087 skip("Could not create manifest file\n");
1092 winetest_get_mainargs( &argv
);
1093 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
1094 ok(CreateProcess(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
,
1095 &si
, &pi
) != 0, "Could not create process: %u\n", GetLastError());
1096 CloseHandle(pi
.hThread
);
1098 WaitForSingleObject(pi
.hProcess
, INFINITE
);
1099 CloseHandle(pi
.hProcess
);
1103 static void init_paths(void)
1108 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
1109 static const WCHAR backslash
[] = {'\\',0};
1110 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
1112 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
1113 lstrcpyW(app_dir
, exe_path
);
1114 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
1117 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
1118 last
= work_dir
[lstrlenW(work_dir
) - 1];
1119 if (last
!= '\\' && last
!= '/')
1120 lstrcatW(work_dir
, backslash
);
1121 lstrcpyW(work_dir_subdir
, work_dir
);
1122 lstrcatW(work_dir_subdir
, subdir
);
1124 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
1125 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
1128 static BOOL
init_funcs(void)
1130 HMODULE hKernel32
= GetModuleHandle("kernel32");
1132 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
1135 X(DeactivateActCtx
);
1136 X(FindActCtxSectionStringW
);
1137 X(GetCurrentActCtx
);
1150 argc
= winetest_get_mainargs(&argv
);
1154 skip("Needed functions are not available\n");
1159 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
1160 test_app_manifest();
1165 run_child_process();