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
;
250 ULONG root_manifest_type
;
251 LPWSTR root_manifest_path
;
252 ULONG root_config_type
;
257 static const detailed_info_t detailed_info0
= {
258 0, 0, 0, NULL
, 0, 0, NULL
261 static const detailed_info_t detailed_info1
= {
262 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
263 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
267 static const detailed_info_t detailed_info1_child
= {
268 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
269 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
273 static const detailed_info_t detailed_info2
= {
274 1, 2, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
275 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
279 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
)
281 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
282 SIZE_T size
, exsize
, retsize
;
285 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
286 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
287 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
289 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
291 b
= pQueryActCtxW(0, handle
, NULL
,
292 ActivationContextDetailedInformation
, &detailed_info_tmp
,
293 sizeof(detailed_info_tmp
), &size
);
294 ok(!b
, "QueryActCtx succeeded\n");
295 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
296 ok(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
298 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
301 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
302 memset(detailed_info
, 0xfe, size
);
303 b
= pQueryActCtxW(0, handle
, NULL
,
304 ActivationContextDetailedInformation
, detailed_info
,
306 ok(b
, "QueryActCtx failed: %u\n", GetLastError());
307 ok(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
309 ok(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
310 ok(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
311 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
312 exinfo
->format_version
);
313 ok(detailed_info
->ulAssemblyCount
== exinfo
->assembly_cnt
,
314 "detailed_info->ulAssemblyCount=%u, expected %u\n", detailed_info
->ulAssemblyCount
,
315 exinfo
->assembly_cnt
);
316 ok(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
317 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
318 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
319 ok(detailed_info
->ulRootManifestPathChars
==
320 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
321 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
322 detailed_info
->ulRootManifestPathChars
,
323 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
324 ok(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
325 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
326 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
327 ok(detailed_info
->ulRootConfigurationPathChars
== 0,
328 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
329 ok(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
330 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
331 exinfo
->app_dir_type
);
332 ok(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
333 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
334 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
335 if(exinfo
->root_manifest_path
) {
336 ok(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
337 if(detailed_info
->lpRootManifestPath
)
338 ok(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
339 "unexpected detailed_info->lpRootManifestPath\n");
341 ok(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
343 ok(detailed_info
->lpRootConfigurationPath
== NULL
,
344 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
345 if(exinfo
->app_dir
) {
346 ok(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
347 if(detailed_info
->lpAppDirPath
)
348 ok(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
349 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
351 ok(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
354 HeapFree(GetProcessHeap(), 0, detailed_info
);
359 /* ULONG manifest_path_type; FIXME */
360 LPCWSTR manifest_path
;
361 LPCSTR encoded_assembly_id
;
362 BOOL has_assembly_dir
;
365 static const info_in_assembly manifest1_info
= {
367 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
371 static const info_in_assembly manifest1_child_info
= {
372 1, app_manifest_path
,
373 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
377 static const info_in_assembly manifest2_info
= {
379 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
383 static const info_in_assembly manifest3_info
= {
385 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
389 static const info_in_assembly manifest4_info
= {
391 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
395 static const info_in_assembly depmanifest1_info
= {
396 0x10, depmanifest_path
,
397 "testdep,processorArchitecture=\"" ARCH
"\","
398 "type=\"win32\",version=\"6.5.4.3\"",
402 static const info_in_assembly depmanifest2_info
= {
403 0x10, depmanifest_path
,
404 "testdep,processorArchitecture=\"" ARCH
"\","
405 "type=\"win32\",version=\"6.5.4.3\"",
409 static const info_in_assembly depmanifest3_info
= {
410 0x10, depmanifest_path
,
411 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
415 static const info_in_assembly manifest_comctrl_info
= {
416 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
419 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
)
421 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
426 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
427 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
428 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
431 b
= pQueryActCtxW(0, handle
, &id
,
432 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
433 sizeof(info_tmp
), &size
);
434 ok(!b
, "QueryActCtx succeeded\n");
435 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
437 ok(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
439 if (size
== 0xdeadbeef)
445 info
= HeapAlloc(GetProcessHeap(), 0, size
);
446 memset(info
, 0xfe, size
);
449 b
= pQueryActCtxW(0, handle
, &id
,
450 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
451 ok(b
, "QueryActCtx failed: %u\n", GetLastError());
452 if (!exinfo
->manifest_path
)
453 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
454 if (!exinfo
->encoded_assembly_id
)
455 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
456 if (exinfo
->has_assembly_dir
)
457 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
458 ok(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
460 if (0) /* FIXME: flags meaning unknown */
462 ok((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
463 info
->ulFlags
, exinfo
->flags
);
465 if(exinfo
->encoded_assembly_id
) {
466 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
467 ok(info
->ulEncodedAssemblyIdentityLength
== len
,
468 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
469 info
->ulEncodedAssemblyIdentityLength
, len
);
471 ok(info
->ulEncodedAssemblyIdentityLength
!= 0,
472 "info->ulEncodedAssemblyIdentityLength == 0\n");
474 ok(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
475 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
476 if(exinfo
->manifest_path
) {
477 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
478 ok(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
479 info
->ulManifestPathLength
, len
);
481 ok(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
484 ok(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
485 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
486 ok(info
->ulPolicyPathLength
== 0,
487 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
488 ok(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
489 info
->ulMetadataSatelliteRosterIndex
);
490 ok(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
491 info
->ulManifestVersionMajor
);
492 ok(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
493 info
->ulManifestVersionMinor
);
494 ok(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
495 info
->ulPolicyVersionMajor
);
496 ok(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
497 info
->ulPolicyVersionMinor
);
498 if(exinfo
->has_assembly_dir
)
499 ok(info
->ulAssemblyDirectoryNameLength
!= 0,
500 "info->ulAssemblyDirectoryNameLength == 0\n");
502 ok(info
->ulAssemblyDirectoryNameLength
== 0,
503 "info->ulAssemblyDirectoryNameLength != 0\n");
505 ok(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
506 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
507 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
508 ok(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
509 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
510 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
512 if(exinfo
->manifest_path
) {
513 ok(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
514 if(info
->lpAssemblyManifestPath
)
515 ok(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
516 "unexpected info->lpAssemblyManifestPath\n");
518 ok(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
521 ok(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
522 if(info
->lpAssemblyPolicyPath
)
523 ok(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
524 if(exinfo
->has_assembly_dir
)
525 ok(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
527 ok(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
528 strw(info
->lpAssemblyDirectoryName
));
529 HeapFree(GetProcessHeap(), 0, info
);
532 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
)
534 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
535 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
539 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
540 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
543 b
= pQueryActCtxW(0, handle
, &index
,
544 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
545 sizeof(info_tmp
), &size
);
546 ok(!b
, "QueryActCtx succeeded\n");
547 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
548 ok(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
550 if(size
== 0xdeadbeef)
556 info
= HeapAlloc(GetProcessHeap(), 0, size
);
557 memset(info
, 0xfe, size
);
559 b
= pQueryActCtxW(0, handle
, &index
,
560 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
561 ok(b
, "QueryActCtx failed: %u\n", GetLastError());
562 ok(!size
, "size=%lu, expected 0\n", size
);
564 ok(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
565 ok(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
566 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
567 info
->ulFilenameLength
, lstrlenW(filename
));
568 ok(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
569 ok(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
571 ok(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
572 ok(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
573 HeapFree(GetProcessHeap(), 0, info
);
576 static HANDLE
test_create(const char *file
, const char *manifest
)
580 WCHAR path
[MAX_PATH
];
582 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
583 memset(&actctx
, 0, sizeof(ACTCTXW
));
584 actctx
.cbSize
= sizeof(ACTCTXW
);
585 actctx
.lpSource
= path
;
587 handle
= pCreateActCtxW(&actctx
);
588 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
590 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
591 ok(actctx
.dwFlags
== 0, "actctx.=%d\n", actctx
.dwFlags
);
592 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
593 ok(actctx
.wProcessorArchitecture
== 0,
594 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
595 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
596 ok(actctx
.lpAssemblyDirectory
== NULL
,
597 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
598 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
599 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplocationName=%p\n",
600 actctx
.lpApplicationName
);
601 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
606 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
610 WCHAR path
[MAX_PATH
];
612 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
613 memset(&actctx
, 0, sizeof(ACTCTXW
));
614 actctx
.cbSize
= sizeof(ACTCTXW
);
615 actctx
.lpSource
= path
;
617 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
618 handle
= pCreateActCtxW(&actctx
);
621 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
622 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
626 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
627 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
629 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
630 DeleteFileA("bad.manifest");
631 DeleteFileA("testdep.manifest");
634 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
638 WCHAR path
[MAX_PATH
];
640 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
641 memset(&actctx
, 0, sizeof(ACTCTXW
));
642 actctx
.cbSize
= sizeof(ACTCTXW
);
643 actctx
.lpSource
= path
;
645 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
646 handle
= pCreateActCtxW(&actctx
);
647 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
648 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
650 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
651 DeleteFileA("bad.manifest");
654 static void test_create_fail(void)
658 WCHAR path
[MAX_PATH
];
660 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
661 memset(&actctx
, 0, sizeof(ACTCTXW
));
662 actctx
.cbSize
= sizeof(ACTCTXW
);
663 actctx
.lpSource
= path
;
665 handle
= pCreateActCtxW(&actctx
);
666 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
667 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
669 trace("wrong_manifest1\n");
670 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
671 trace("wrong_manifest2\n");
672 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
673 trace("wrong_manifest3\n");
674 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
675 trace("wrong_manifest4\n");
676 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
677 trace("wrong_manifest5\n");
678 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
679 trace("wrong_manifest6\n");
680 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
681 trace("wrong_manifest7\n");
682 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
683 trace("wrong_manifest8\n");
684 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
685 trace("UTF-16 manifest1 without BOM\n");
686 test_create_wide_and_fail(manifest1
, FALSE
);
687 trace("manifest2\n");
688 test_create_and_fail(manifest2
, NULL
, 0 );
689 trace("manifest2+depmanifest1\n");
690 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
693 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
)
695 ACTCTX_SECTION_KEYED_DATA data
;
699 memset(&data
, 0xfe, sizeof(data
));
700 data
.cbSize
= sizeof(data
);
702 ret
= pFindActCtxSectionStringW(0, NULL
,
703 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
705 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
708 skip("couldn't find %s\n",strw(libname
));
712 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
713 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
714 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
715 ok(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
718 if(ret
&& p
) todo_wine
{
719 ok(p
[0] == 20 && p
[1] == 2 && p
[2] == 0 && p
[3] == 0 && p
[4] == 0,
720 "wrong data %u,%u,%u,%u,%u\n",p
[0], p
[1], p
[2], p
[3], p
[4]);
723 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
724 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
725 data
.ulSectionGlobalDataLength
);
726 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
727 /* ok(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n",
728 data.ulSectionTotalLength); */
729 ok(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
730 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
731 data
.ulAssemblyRosterIndex
, exid
);
733 memset(&data
, 0xfe, sizeof(data
));
734 data
.cbSize
= sizeof(data
);
736 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
737 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
739 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
742 skip("couldn't find\n");
746 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
747 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
748 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
749 ok(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
750 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
751 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
752 data
.ulSectionGlobalDataLength
);
753 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
754 /* ok(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n",
755 data.ulSectionTotalLength); */
756 ok(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
757 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
758 data
.ulAssemblyRosterIndex
, exid
);
760 pReleaseActCtx(handle
);
763 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
)
765 ACTCTX_SECTION_KEYED_DATA data
;
768 memset(&data
, 0xfe, sizeof(data
));
769 data
.cbSize
= sizeof(data
);
771 ret
= pFindActCtxSectionStringW(0, NULL
,
772 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
774 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
777 skip("couldn't find\n");
781 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
782 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
783 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
784 /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); */
785 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
786 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
787 data
.ulSectionGlobalDataLength
);
788 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
789 /* ok(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n",
790 data.ulSectionTotalLength); FIXME */
791 ok(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
792 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
793 data
.ulAssemblyRosterIndex
, exid
);
795 memset(&data
, 0xfe, sizeof(data
));
796 data
.cbSize
= sizeof(data
);
798 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
799 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
801 ok(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
804 skip("couldn't find\n");
808 ok(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
809 ok(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
810 ok(data
.lpData
!= NULL
, "data.lpData == NULL\n");
811 /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); FIXME */
812 ok(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
813 ok(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
814 data
.ulSectionGlobalDataLength
);
815 ok(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
816 /* ok(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n",
817 data.ulSectionTotalLength); FIXME */
818 ok(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
819 ok(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
820 data
.ulAssemblyRosterIndex
, exid
);
822 pReleaseActCtx(handle
);
825 static void test_find_string_fail(void)
827 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
830 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
831 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
832 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
834 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
835 testlib2_dll
, &data
);
836 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
837 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "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());
844 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
846 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
847 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
850 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
852 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
853 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
856 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
858 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
859 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
863 static void test_basic_info(HANDLE handle
)
865 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
869 b
= pQueryActCtxW(0, handle
, NULL
,
870 ActivationContextBasicInformation
, &basic
,
871 sizeof(basic
), &size
);
873 ok (b
,"ActivationContextBasicInformation failed\n");
874 ok (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
875 ok (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
876 ok (basic
.hActCtx
== handle
, "unexpected handle\n");
878 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, handle
, NULL
,
879 ActivationContextBasicInformation
, &basic
,
880 sizeof(basic
), &size
);
883 ok (!b
,"ActivationContextBasicInformation succeeded\n");
884 ok (size
== 0,"size mismatch\n");
885 ok (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
886 ok (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
887 ok (basic
.hActCtx
== handle
, "unexpected handle\n");
891 ok (b
,"ActivationContextBasicInformation failed\n");
892 ok (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
893 ok (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
894 ok (basic
.hActCtx
== handle
, "unexpected handle\n");
898 static void test_actctx(void)
906 trace("default actctx\n");
908 b
= pGetCurrentActCtx(&handle
);
909 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
910 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
912 test_basic_info(handle
);
913 test_detailed_info(handle
, &detailed_info0
);
914 pReleaseActCtx(handle
);
917 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
918 skip("Could not create manifest file\n");
922 trace("manifest1\n");
924 handle
= test_create("test1.manifest", manifest1
);
925 DeleteFileA("test1.manifest");
926 if(handle
!= INVALID_HANDLE_VALUE
) {
927 test_basic_info(handle
);
928 test_detailed_info(handle
, &detailed_info1
);
929 test_info_in_assembly(handle
, 1, &manifest1_info
);
931 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
933 /* CloseHandle will generate an exception if a debugger is present */
934 b
= CloseHandle(handle
);
935 ok(!b
, "CloseHandle succeeded\n");
936 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
939 pReleaseActCtx(handle
);
942 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
943 skip("Could not create manifest file\n");
947 trace("manifest2 depmanifest1\n");
949 handle
= test_create("test2.manifest", manifest2
);
950 DeleteFileA("test2.manifest");
951 DeleteFileA("testdep.manifest");
952 if(handle
!= INVALID_HANDLE_VALUE
) {
953 test_basic_info(handle
);
954 test_detailed_info(handle
, &detailed_info2
);
955 test_info_in_assembly(handle
, 1, &manifest2_info
);
956 test_info_in_assembly(handle
, 2, &depmanifest1_info
);
957 pReleaseActCtx(handle
);
960 if(!create_manifest_file("test3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
961 skip("Could not create manifest file\n");
965 trace("manifest2 depmanifest2\n");
967 handle
= test_create("test3.manifest", manifest2
);
968 DeleteFileA("test3.manifest");
969 DeleteFileA("testdep.manifest");
970 if(handle
!= INVALID_HANDLE_VALUE
) {
971 test_basic_info(handle
);
972 test_detailed_info(handle
, &detailed_info2
);
973 test_info_in_assembly(handle
, 1, &manifest2_info
);
974 test_info_in_assembly(handle
, 2, &depmanifest2_info
);
975 test_file_info(handle
, 1, 0, testlib_dll
);
976 test_file_info(handle
, 1, 1, testlib2_dll
);
978 b
= pActivateActCtx(handle
, &cookie
);
979 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
980 test_find_dll_redirection(handle
, testlib_dll
, 2);
981 test_find_dll_redirection(handle
, testlib2_dll
, 2);
982 b
= pDeactivateActCtx(0, cookie
);
983 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
985 pReleaseActCtx(handle
);
988 trace("manifest2 depmanifest3\n");
990 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
991 skip("Could not create manifest file\n");
995 handle
= test_create("test2-3.manifest", manifest2
);
996 DeleteFileA("test2-3.manifest");
997 DeleteFileA("testdep.manifest");
998 if(handle
!= INVALID_HANDLE_VALUE
) {
999 test_basic_info(handle
);
1000 test_detailed_info(handle
, &detailed_info2
);
1001 test_info_in_assembly(handle
, 1, &manifest2_info
);
1002 test_info_in_assembly(handle
, 2, &depmanifest3_info
);
1003 test_file_info(handle
, 1, 0, testlib_dll
);
1004 test_file_info(handle
, 1, 1, testlib2_dll
);
1006 b
= pActivateActCtx(handle
, &cookie
);
1007 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1008 test_find_dll_redirection(handle
, testlib_dll
, 2);
1009 test_find_dll_redirection(handle
, testlib2_dll
, 2);
1010 test_find_window_class(handle
, wndClassW
, 2);
1011 test_find_window_class(handle
, wndClass2W
, 2);
1012 b
= pDeactivateActCtx(0, cookie
);
1013 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1015 pReleaseActCtx(handle
);
1018 trace("manifest3\n");
1020 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1021 skip("Could not create manifest file\n");
1025 handle
= test_create("test3.manifest", manifest3
);
1026 DeleteFileA("test3.manifest");
1027 if(handle
!= INVALID_HANDLE_VALUE
) {
1028 test_basic_info(handle
);
1029 test_detailed_info(handle
, &detailed_info1
);
1030 test_info_in_assembly(handle
, 1, &manifest3_info
);
1031 test_file_info(handle
, 0, 0, testlib_dll
);
1033 b
= pActivateActCtx(handle
, &cookie
);
1034 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1035 test_find_dll_redirection(handle
, testlib_dll
, 1);
1036 test_find_dll_redirection(handle
, testlib_dll
, 1);
1037 test_find_string_fail();
1038 b
= pDeactivateActCtx(0, cookie
);
1039 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1041 pReleaseActCtx(handle
);
1044 trace("manifest4\n");
1046 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1047 skip("Could not create manifest file\n");
1051 handle
= test_create("test4.manifest", manifest4
);
1052 DeleteFileA("test4.manifest");
1053 DeleteFileA("testdep.manifest");
1054 if(handle
!= INVALID_HANDLE_VALUE
) {
1055 test_basic_info(handle
);
1056 test_detailed_info(handle
, &detailed_info2
);
1057 test_info_in_assembly(handle
, 1, &manifest4_info
);
1058 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
);
1059 pReleaseActCtx(handle
);
1062 trace("manifest1 in subdir\n");
1064 CreateDirectoryW(work_dir_subdir
, NULL
);
1065 if (SetCurrentDirectoryW(work_dir_subdir
))
1067 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1068 skip("Could not create manifest file\n");
1071 handle
= test_create("..\\test1.manifest", manifest1
);
1072 DeleteFileA("..\\test1.manifest");
1073 if(handle
!= INVALID_HANDLE_VALUE
) {
1074 test_basic_info(handle
);
1075 test_detailed_info(handle
, &detailed_info1
);
1076 test_info_in_assembly(handle
, 1, &manifest1_info
);
1077 pReleaseActCtx(handle
);
1079 SetCurrentDirectoryW(work_dir
);
1082 skip("Couldn't change directory\n");
1083 RemoveDirectoryW(work_dir_subdir
);
1085 trace("UTF-16 manifest1, with BOM\n");
1086 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
1087 skip("Could not create manifest file\n");
1091 handle
= test_create("test1.manifest", manifest1
);
1092 DeleteFileA("test1.manifest");
1093 if (handle
!= INVALID_HANDLE_VALUE
) {
1094 test_basic_info(handle
);
1095 test_detailed_info(handle
, &detailed_info1
);
1096 test_info_in_assembly(handle
, 1, &manifest1_info
);
1097 pReleaseActCtx(handle
);
1100 trace("UTF-16 manifest1, reverse endian, with BOM\n");
1101 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
1102 skip("Could not create manifest file\n");
1106 handle
= test_create("test1.manifest", manifest1
);
1107 DeleteFileA("test1.manifest");
1108 if (handle
!= INVALID_HANDLE_VALUE
) {
1109 test_basic_info(handle
);
1110 test_detailed_info(handle
, &detailed_info1
);
1111 test_info_in_assembly(handle
, 1, &manifest1_info
);
1112 pReleaseActCtx(handle
);
1117 static void test_app_manifest(void)
1122 trace("child process manifest1\n");
1124 b
= pGetCurrentActCtx(&handle
);
1125 ok(handle
== NULL
, "handle != NULL\n");
1126 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1128 test_basic_info(handle
);
1129 test_detailed_info(handle
, &detailed_info1_child
);
1130 test_info_in_assembly(handle
, 1, &manifest1_child_info
);
1131 pReleaseActCtx(handle
);
1135 static void run_child_process(void)
1137 char cmdline
[MAX_PATH
];
1138 char path
[MAX_PATH
];
1140 PROCESS_INFORMATION pi
;
1141 STARTUPINFO si
= { 0 };
1143 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
1144 strcat(path
, ".manifest");
1145 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
1146 skip("Could not create manifest file\n");
1151 winetest_get_mainargs( &argv
);
1152 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
1153 ok(CreateProcess(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
,
1154 &si
, &pi
) != 0, "Could not create process: %u\n", GetLastError());
1155 winetest_wait_child_process( pi
.hProcess
);
1156 CloseHandle(pi
.hThread
);
1157 CloseHandle(pi
.hProcess
);
1161 static void init_paths(void)
1166 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
1167 static const WCHAR backslash
[] = {'\\',0};
1168 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
1170 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
1171 lstrcpyW(app_dir
, exe_path
);
1172 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
1175 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
1176 last
= work_dir
[lstrlenW(work_dir
) - 1];
1177 if (last
!= '\\' && last
!= '/')
1178 lstrcatW(work_dir
, backslash
);
1179 lstrcpyW(work_dir_subdir
, work_dir
);
1180 lstrcatW(work_dir_subdir
, subdir
);
1182 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
1183 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
1186 static BOOL
init_funcs(void)
1188 HMODULE hKernel32
= GetModuleHandle("kernel32");
1190 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
1193 X(DeactivateActCtx
);
1194 X(FindActCtxSectionStringW
);
1195 X(GetCurrentActCtx
);
1196 X(IsDebuggerPresent
);
1209 argc
= winetest_get_mainargs(&argv
);
1213 win_skip("Needed functions are not available\n");
1218 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
1219 test_app_manifest();
1224 run_child_process();