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
20 #define WIN32_NO_STATUS
21 #include "wine/test.h"
32 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
33 static HANDLE (WINAPI
*pCreateActCtxA
)(PCACTCTXA
);
34 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
35 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
36 static BOOL (WINAPI
*pFindActCtxSectionStringA
)(DWORD
,const GUID
*,ULONG
,LPCSTR
,PACTCTX_SECTION_KEYED_DATA
);
37 static BOOL (WINAPI
*pFindActCtxSectionStringW
)(DWORD
,const GUID
*,ULONG
,LPCWSTR
,PACTCTX_SECTION_KEYED_DATA
);
38 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
39 static BOOL (WINAPI
*pIsDebuggerPresent
)(void);
40 static BOOL (WINAPI
*pQueryActCtxW
)(DWORD
,HANDLE
,PVOID
,ULONG
,PVOID
,SIZE_T
,SIZE_T
*);
41 static VOID (WINAPI
*pReleaseActCtx
)(HANDLE
);
42 static BOOL (WINAPI
*pFindActCtxSectionGuid
)(DWORD
,const GUID
*,ULONG
,const GUID
*,PACTCTX_SECTION_KEYED_DATA
);
43 static BOOL (WINAPI
*pZombifyActCtx
)(HANDLE
);
45 static NTSTATUS(NTAPI
*pRtlFindActivationContextSectionString
)(DWORD
,const GUID
*,ULONG
,PUNICODE_STRING
,PACTCTX_SECTION_KEYED_DATA
);
46 static BOOLEAN (NTAPI
*pRtlCreateUnicodeStringFromAsciiz
)(PUNICODE_STRING
, PCSZ
);
47 static VOID (NTAPI
*pRtlFreeUnicodeString
)(PUNICODE_STRING
);
49 static const char* strw(LPCWSTR x
)
51 static char buffer
[1024];
54 if (!x
) return "(nil)";
55 else while ((*p
++ = *x
++));
61 #elif defined __x86_64__
65 #elif defined __aarch64__
71 static const char manifest1
[] =
72 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
73 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
76 static const char manifest1_1
[] =
77 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
78 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
81 static const char manifest2
[] =
82 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
83 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
87 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
89 "</dependentAssembly>"
93 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
94 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
95 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
96 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
97 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
98 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
99 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
100 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
101 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
102 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
103 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
104 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
105 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
107 static const char manifest3
[] =
108 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
109 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
110 " publicKeyToken=\"6595b6414666f1df\" />"
112 "<file name=\"testlib.dll\">"
113 "<windowClass>wndClass</windowClass>"
114 " <comClass description=\"Test com class\""
115 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
116 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
117 " threadingModel=\"Neutral\""
118 " progid=\"ProgId.ProgId\""
119 " miscStatus=\"cantlinkinside\""
120 " miscStatusIcon=\"recomposeonresize\""
121 " miscStatusContent=\"insideout\""
122 " miscStatusThumbnail=\"alignable\""
123 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
125 " <progid>ProgId.ProgId.1</progid>"
126 " <progid>ProgId.ProgId.2</progid>"
127 " <progid>ProgId.ProgId.3</progid>"
128 " <progid>ProgId.ProgId.4</progid>"
129 " <progid>ProgId.ProgId.5</progid>"
130 " <progid>ProgId.ProgId.6</progid>"
132 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
133 " <progid>ProgId.ProgId.7</progid>"
135 " <comInterfaceProxyStub "
137 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
138 " iid=\"{66666666-8888-7777-6666-555555555555}\""
139 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
140 " threadingModel=\"Free\""
142 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
145 " <comInterfaceExternalProxyStub "
146 " name=\"Iifaceps2\""
147 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
148 " iid=\"{76666666-8888-7777-6666-555555555555}\""
149 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
151 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
153 " <comInterfaceExternalProxyStub "
154 " name=\"Iifaceps3\""
155 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
156 " iid=\"{86666666-8888-7777-6666-555555555555}\""
158 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
161 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
162 " name=\"testsurrogate\""
163 " runtimeVersion=\"v2.0.50727\""
166 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
168 " progid=\"clrprogid\""
169 " description=\"test description\""
170 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
171 " runtimeVersion=\"1.2.3.4\""
172 " threadingModel=\"Neutral\""
174 " <progid>clrprogid.1</progid>"
175 " <progid>clrprogid.2</progid>"
176 " <progid>clrprogid.3</progid>"
177 " <progid>clrprogid.4</progid>"
178 " <progid>clrprogid.5</progid>"
179 " <progid>clrprogid.6</progid>"
183 static const char manifest_wndcls1
[] =
184 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
185 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
186 "<file name=\"testlib1.dll\">"
187 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
188 "<windowClass>wndClass2</windowClass>"
189 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
191 "<file name=\"testlib1_2.dll\" />"
194 static const char manifest_wndcls2
[] =
195 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
196 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
197 "<file name=\"testlib2.dll\">"
198 " <windowClass versioned=\"no\">wndClass3</windowClass>"
199 " <windowClass>wndClass4</windowClass>"
200 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
201 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
202 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
203 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
205 "<file name=\"testlib2_2.dll\" />"
208 static const char manifest_wndcls_main
[] =
209 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
210 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
212 " <dependentAssembly>"
213 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
214 " </dependentAssembly>"
217 " <dependentAssembly>"
218 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
219 " </dependentAssembly>"
223 static const char manifest4
[] =
224 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
225 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
226 "</assemblyIdentity>"
228 "<dependentAssembly>"
229 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
230 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
231 "</assemblyIdentity>"
232 "</dependentAssembly>"
236 static const char manifest5
[] =
237 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
238 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
239 "</assemblyIdentity>"
241 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
242 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
243 " </dependentAssembly>"
247 static const char testdep_manifest1
[] =
248 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
249 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
252 static const char testdep_manifest2
[] =
253 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
254 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
255 "<file name=\"testlib.dll\"></file>"
256 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
259 static const char testdep_manifest3
[] =
260 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
261 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
262 "<file name=\"testlib.dll\"/>"
263 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
264 "<windowClass>wndClass</windowClass>"
265 "<windowClass>wndClass2</windowClass>"
269 static const char wrong_manifest1
[] =
270 "<assembly manifestVersion=\"1.0\">"
271 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
274 static const char wrong_manifest2
[] =
275 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
276 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
279 static const char wrong_manifest3
[] =
280 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
281 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
284 static const char wrong_manifest4
[] =
285 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
286 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
290 static const char wrong_manifest5
[] =
291 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
292 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
296 static const char wrong_manifest6
[] =
297 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
298 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
301 static const char wrong_manifest7
[] =
302 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
303 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
304 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
307 static const char wrong_manifest8
[] =
308 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
309 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
313 static const char wrong_depmanifest1
[] =
314 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
315 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
318 static const WCHAR testlib_dll
[] =
319 {'t','e','s','t','l','i','b','.','d','l','l',0};
320 static const WCHAR testlib2_dll
[] =
321 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
322 static const WCHAR wndClassW
[] =
323 {'w','n','d','C','l','a','s','s',0};
324 static const WCHAR wndClass1W
[] =
325 {'w','n','d','C','l','a','s','s','1',0};
326 static const WCHAR wndClass2W
[] =
327 {'w','n','d','C','l','a','s','s','2',0};
328 static const WCHAR wndClass3W
[] =
329 {'w','n','d','C','l','a','s','s','3',0};
331 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
332 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
334 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
339 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
340 return lstrcmpW(strw
, buf
);
343 static DWORD
strlen_aw(const char *str
)
345 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
348 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
349 const char *depfile
, const char *depmanifest
)
353 WCHAR path
[MAX_PATH
];
355 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
356 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
358 if (manifest_len
== -1)
359 manifest_len
= strlen(manifest
);
361 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
362 FILE_ATTRIBUTE_NORMAL
, NULL
);
363 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
364 if(file
== INVALID_HANDLE_VALUE
)
366 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
371 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
372 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
373 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
374 FILE_ATTRIBUTE_NORMAL
, NULL
);
375 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
376 if(file
== INVALID_HANDLE_VALUE
)
378 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
384 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
386 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
388 int offset
= (fBOM
? 0 : 1);
390 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
391 wmanifest
[0] = 0xfeff;
395 for (i
= 0; i
< strlen(manifest
)+1; i
++)
396 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
398 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
399 HeapFree(GetProcessHeap(), 0, wmanifest
);
404 ULONG format_version
;
405 ULONG assembly_cnt_min
;
406 ULONG assembly_cnt_max
;
407 ULONG root_manifest_type
;
408 LPWSTR root_manifest_path
;
409 ULONG root_config_type
;
414 static const detailed_info_t detailed_info0
= {
415 0, 0, 0, 0, NULL
, 0, 0, NULL
418 static const detailed_info_t detailed_info1
= {
419 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
420 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
424 static const detailed_info_t detailed_info1_child
= {
425 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
426 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
430 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
431 static const detailed_info_t detailed_info2
= {
432 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
433 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
437 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
439 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
440 SIZE_T size
, exsize
, retsize
;
443 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
444 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
445 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
447 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
449 b
= pQueryActCtxW(0, handle
, NULL
,
450 ActivationContextDetailedInformation
, &detailed_info_tmp
,
451 sizeof(detailed_info_tmp
), &size
);
452 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
453 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
454 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
456 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
459 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
460 memset(detailed_info
, 0xfe, size
);
461 b
= pQueryActCtxW(0, handle
, NULL
,
462 ActivationContextDetailedInformation
, detailed_info
,
464 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
465 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
467 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
468 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
469 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
470 exinfo
->format_version
);
471 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
472 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
473 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
474 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
475 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
476 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
477 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
478 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
479 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
480 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
481 detailed_info
->ulRootManifestPathChars
,
482 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
483 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
484 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
485 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
486 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
487 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
488 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
489 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
490 exinfo
->app_dir_type
);
491 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
492 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
493 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
494 if(exinfo
->root_manifest_path
) {
495 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
496 if(detailed_info
->lpRootManifestPath
)
497 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
498 "unexpected detailed_info->lpRootManifestPath\n");
500 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
502 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
503 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
504 if(exinfo
->app_dir
) {
505 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
506 if(detailed_info
->lpAppDirPath
)
507 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
508 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
510 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
513 HeapFree(GetProcessHeap(), 0, detailed_info
);
518 /* ULONG manifest_path_type; FIXME */
519 LPCWSTR manifest_path
;
520 LPCSTR encoded_assembly_id
;
521 BOOL has_assembly_dir
;
524 static const info_in_assembly manifest1_info
= {
526 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
530 static const info_in_assembly manifest1_child_info
= {
531 1, app_manifest_path
,
532 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
536 static const info_in_assembly manifest2_info
= {
538 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
542 static const info_in_assembly manifest3_info
= {
544 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
548 static const info_in_assembly manifest4_info
= {
550 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
554 static const info_in_assembly depmanifest1_info
= {
555 0x10, depmanifest_path
,
556 "testdep,processorArchitecture=\"" ARCH
"\","
557 "type=\"win32\",version=\"6.5.4.3\"",
561 static const info_in_assembly depmanifest2_info
= {
562 0x10, depmanifest_path
,
563 "testdep,processorArchitecture=\"" ARCH
"\","
564 "type=\"win32\",version=\"6.5.4.3\"",
568 static const info_in_assembly depmanifest3_info
= {
569 0x10, depmanifest_path
,
570 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
574 static const info_in_assembly manifest_comctrl_info
= {
575 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
578 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
580 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
585 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
586 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
587 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
590 b
= pQueryActCtxW(0, handle
, &id
,
591 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
592 sizeof(info_tmp
), &size
);
593 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
594 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
596 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
598 if (size
== 0xdeadbeef)
604 info
= HeapAlloc(GetProcessHeap(), 0, size
);
605 memset(info
, 0xfe, size
);
608 b
= pQueryActCtxW(0, handle
, &id
,
609 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
610 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
611 if (!exinfo
->manifest_path
)
612 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
613 if (!exinfo
->encoded_assembly_id
)
614 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
615 if (exinfo
->has_assembly_dir
)
616 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
617 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
619 if (0) /* FIXME: flags meaning unknown */
621 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
622 info
->ulFlags
, exinfo
->flags
);
624 if(exinfo
->encoded_assembly_id
) {
625 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
626 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
627 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
628 info
->ulEncodedAssemblyIdentityLength
, len
);
630 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
631 "info->ulEncodedAssemblyIdentityLength == 0\n");
633 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
634 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
635 if(exinfo
->manifest_path
) {
636 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
637 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
638 info
->ulManifestPathLength
, len
);
640 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
643 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
644 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
645 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
646 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
647 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
648 info
->ulMetadataSatelliteRosterIndex
);
649 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
650 info
->ulManifestVersionMajor
);
651 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
652 info
->ulManifestVersionMinor
);
653 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
654 info
->ulPolicyVersionMajor
);
655 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
656 info
->ulPolicyVersionMinor
);
657 if(exinfo
->has_assembly_dir
)
658 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
659 "info->ulAssemblyDirectoryNameLength == 0\n");
661 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
662 "info->ulAssemblyDirectoryNameLength != 0\n");
664 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
665 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
666 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
667 ok_(__FILE__
, line
)(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
668 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
669 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
671 if(exinfo
->manifest_path
) {
672 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
673 if(info
->lpAssemblyManifestPath
)
674 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
675 "unexpected info->lpAssemblyManifestPath\n");
677 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
680 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
681 if(info
->lpAssemblyPolicyPath
)
682 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
683 if(exinfo
->has_assembly_dir
)
684 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
686 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
687 strw(info
->lpAssemblyDirectoryName
));
688 HeapFree(GetProcessHeap(), 0, info
);
691 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
693 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
694 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
698 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
699 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
702 b
= pQueryActCtxW(0, handle
, &index
,
703 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
704 sizeof(info_tmp
), &size
);
705 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
706 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
707 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
709 if(size
== 0xdeadbeef)
715 info
= HeapAlloc(GetProcessHeap(), 0, size
);
716 memset(info
, 0xfe, size
);
718 b
= pQueryActCtxW(0, handle
, &index
,
719 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
720 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
721 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
723 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
724 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
725 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
726 info
->ulFilenameLength
, lstrlenW(filename
));
727 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
728 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
730 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
731 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
732 HeapFree(GetProcessHeap(), 0, info
);
735 static HANDLE
test_create(const char *file
)
739 WCHAR path
[MAX_PATH
];
741 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
742 memset(&actctx
, 0, sizeof(ACTCTXW
));
743 actctx
.cbSize
= sizeof(ACTCTXW
);
744 actctx
.lpSource
= path
;
746 handle
= pCreateActCtxW(&actctx
);
747 /* to be tested outside of this helper, including last error */
748 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
750 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
751 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%d\n", actctx
.dwFlags
);
752 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
753 ok(actctx
.wProcessorArchitecture
== 0,
754 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
755 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
756 ok(actctx
.lpAssemblyDirectory
== NULL
,
757 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
758 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
759 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
760 actctx
.lpApplicationName
);
761 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
766 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
770 WCHAR path
[MAX_PATH
];
772 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
773 memset(&actctx
, 0, sizeof(ACTCTXW
));
774 actctx
.cbSize
= sizeof(ACTCTXW
);
775 actctx
.lpSource
= path
;
777 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
778 handle
= pCreateActCtxW(&actctx
);
781 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
782 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
784 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
785 DeleteFileA("bad.manifest");
786 DeleteFileA("testdep.manifest");
789 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
793 WCHAR path
[MAX_PATH
];
795 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
796 memset(&actctx
, 0, sizeof(ACTCTXW
));
797 actctx
.cbSize
= sizeof(ACTCTXW
);
798 actctx
.lpSource
= path
;
800 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
801 handle
= pCreateActCtxW(&actctx
);
802 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
803 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
805 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
806 DeleteFileA("bad.manifest");
809 static void test_create_fail(void)
813 WCHAR path
[MAX_PATH
];
815 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
816 memset(&actctx
, 0, sizeof(ACTCTXW
));
817 actctx
.cbSize
= sizeof(ACTCTXW
);
818 actctx
.lpSource
= path
;
820 handle
= pCreateActCtxW(&actctx
);
821 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
822 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
824 trace("wrong_manifest1\n");
825 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
826 trace("wrong_manifest2\n");
827 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
828 trace("wrong_manifest3\n");
829 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
830 trace("wrong_manifest4\n");
831 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
832 trace("wrong_manifest5\n");
833 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
834 trace("wrong_manifest6\n");
835 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
836 trace("wrong_manifest7\n");
837 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
838 trace("wrong_manifest8\n");
839 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
840 trace("UTF-16 manifest1 without BOM\n");
841 test_create_wide_and_fail(manifest1
, FALSE
);
842 trace("manifest2\n");
843 test_create_and_fail(manifest2
, NULL
, 0 );
844 trace("manifest2+depmanifest1\n");
845 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
848 struct strsection_header
870 struct guidsection_header
890 struct wndclass_redirect_data
895 ULONG name_offset
; /* versioned name offset */
897 ULONG module_offset
;/* container name offset */
900 struct dllredirect_data
907 struct tlibredirect_data
921 struct progidredirect_data
928 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
930 ACTCTX_SECTION_KEYED_DATA data
;
933 memset(&data
, 0xfe, sizeof(data
));
934 data
.cbSize
= sizeof(data
);
936 ret
= pFindActCtxSectionStringW(0, NULL
,
937 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
939 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
942 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
943 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
944 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
945 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
949 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
950 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
951 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
952 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
953 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
954 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
957 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
958 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
959 data
.ulSectionGlobalDataLength
);
960 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
961 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
962 data
.ulSectionTotalLength
);
963 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
964 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
965 data
.ulAssemblyRosterIndex
, exid
);
967 memset(&data
, 0xfe, sizeof(data
));
968 data
.cbSize
= sizeof(data
);
970 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
971 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
973 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
976 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
977 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
978 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
979 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
980 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
981 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
982 data
.ulSectionGlobalDataLength
);
983 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
984 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
985 data
.ulSectionTotalLength
);
986 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
987 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
988 data
.ulAssemblyRosterIndex
, exid
);
990 pReleaseActCtx(handle
);
993 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
995 struct wndclass_redirect_data
*wnddata
;
996 struct strsection_header
*header
;
997 ACTCTX_SECTION_KEYED_DATA data
;
1000 memset(&data
, 0xfe, sizeof(data
));
1001 data
.cbSize
= sizeof(data
);
1003 ret
= pFindActCtxSectionStringW(0, NULL
,
1004 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1006 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1007 wine_dbgstr_w(clsname
));
1010 header
= (struct strsection_header
*)data
.lpSectionBase
;
1011 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1013 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
1014 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
1015 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1016 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1017 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1018 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1019 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1021 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1026 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1027 /* redirect class name (versioned or not) is stored just after header data */
1028 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1029 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1031 /* expected versioned name */
1032 lstrcpyW(buff
, verW
);
1033 lstrcatW(buff
, clsname
);
1034 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1035 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1036 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1037 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1039 /* data length is simply header length + string data length including nulls */
1040 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1041 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1043 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1045 WCHAR
*modulename
, *sectionptr
;
1047 /* just compare pointers */
1048 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1049 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1050 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1054 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1055 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1056 data
.ulSectionGlobalDataLength
);
1057 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1058 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1059 data
.ulSectionTotalLength
);
1060 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1061 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1062 data
.ulAssemblyRosterIndex
, exid
);
1064 memset(&data
, 0xfe, sizeof(data
));
1065 data
.cbSize
= sizeof(data
);
1067 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1068 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1070 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1071 wine_dbgstr_w(clsname
));
1074 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1075 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1076 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1077 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1078 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1079 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1080 data
.ulSectionGlobalDataLength
);
1081 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1082 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1083 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1084 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1085 data
.ulAssemblyRosterIndex
, exid
);
1087 pReleaseActCtx(handle
);
1090 static void test_find_string_fail(void)
1092 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1095 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1096 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1097 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1099 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1100 testlib2_dll
, &data
);
1101 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1102 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1104 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1106 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1107 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1109 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1111 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1112 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1115 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1116 testlib_dll
, &data
);
1117 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1118 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1121 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1122 testlib_dll
, &data
);
1123 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1124 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1128 static void test_basic_info(HANDLE handle
, int line
)
1130 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1134 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1135 ActivationContextBasicInformation
, &basic
,
1136 sizeof(basic
), &size
);
1138 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1139 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1140 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1141 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1143 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1144 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1145 ActivationContextBasicInformation
, &basic
,
1146 sizeof(basic
), &size
);
1149 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1150 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1151 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1152 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1153 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1157 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1158 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1159 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1160 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1164 enum comclass_threadingmodel
{
1165 ThreadingModel_Apartment
= 1,
1166 ThreadingModel_Free
= 2,
1167 ThreadingModel_No
= 3,
1168 ThreadingModel_Both
= 4,
1169 ThreadingModel_Neutral
= 5
1172 enum comclass_miscfields
{
1175 MiscStatusContent
= 4,
1176 MiscStatusThumbnail
= 8,
1177 MiscStatusDocPrint
= 16
1180 struct comclassredirect_data
{
1193 ULONG progid_offset
;
1195 ULONG clrdata_offset
;
1197 DWORD miscstatuscontent
;
1198 DWORD miscstatusthumbnail
;
1199 DWORD miscstatusicon
;
1200 DWORD miscstatusdocprint
;
1203 struct clrclass_data
{
1207 ULONG module_offset
;
1211 ULONG version_offset
;
1215 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1217 struct comclassredirect_data
*comclass
, *comclass2
;
1218 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1219 struct guidsection_header
*header
;
1222 memset(&data
, 0xfe, sizeof(data
));
1223 data
.cbSize
= sizeof(data
);
1225 ret
= pFindActCtxSectionGuid(0, NULL
,
1226 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1230 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1233 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1235 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1237 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1238 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1239 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1240 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1241 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1246 ok_(__FILE__
, line
)(comclass
->res
== 0, "got res as %d\n", comclass
->res
);
1247 ok_(__FILE__
, line
)(comclass
->res1
[0] == 0, "got res1[0] as %02x\n", comclass
->res1
[0]);
1248 ok_(__FILE__
, line
)(comclass
->res1
[1] == 0, "got res1[1] as %02x\n", comclass
->res1
[1]);
1249 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1250 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1251 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1253 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1254 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1258 len
= comclass
->size
+ comclass
->clrdata_len
;
1259 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1262 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1264 if (comclass
->progid_offset
)
1266 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1267 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1268 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1269 "got progid name length %d\n", comclass
->progid_len
);
1272 /* data length is simply header length + string data length including nulls */
1273 len
= comclass
->size
+ comclass
->clrdata_len
;
1274 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1275 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1277 /* keyed data structure doesn't include module name, it's available from section data */
1278 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1280 /* check misc fields are set */
1281 if (comclass
->miscmask
)
1283 if (comclass
->miscmask
& MiscStatus
)
1284 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1285 if (comclass
->miscmask
& MiscStatusIcon
)
1286 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1287 if (comclass
->miscmask
& MiscStatusContent
)
1288 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1289 if (comclass
->miscmask
& MiscStatusThumbnail
)
1290 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1291 if (comclass
->miscmask
& MiscStatusDocPrint
)
1292 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1295 /* part used for clrClass only */
1296 if (comclass
->clrdata_len
)
1298 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1299 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1300 struct clrclass_data
*clrclass
;
1303 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1304 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1305 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1306 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1307 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1308 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1310 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1311 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1312 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1313 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1315 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1316 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1318 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1319 in lower case, clsclass subsection - in upper case */
1320 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1321 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1323 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1324 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1326 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1327 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1331 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1332 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1333 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1334 data
.ulSectionGlobalDataLength
);
1335 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1336 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1337 data
.ulSectionTotalLength
);
1338 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1339 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1340 data
.ulAssemblyRosterIndex
, exid
);
1342 /* generated guid for this class works as key guid in search */
1343 memset(&data2
, 0xfe, sizeof(data2
));
1344 data2
.cbSize
= sizeof(data2
);
1345 ret
= pFindActCtxSectionGuid(0, NULL
,
1346 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1347 &comclass
->alias
, &data2
);
1348 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1350 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1351 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1352 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1361 struct ifacepsredirect_data
1373 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1374 const GUID
*ps32
, ULONG exid
, int line
)
1376 struct ifacepsredirect_data
*ifaceps
;
1377 ACTCTX_SECTION_KEYED_DATA data
;
1380 memset(&data
, 0xfe, sizeof(data
));
1381 data
.cbSize
= sizeof(data
);
1383 ret
= pFindActCtxSectionGuid(0, NULL
,
1384 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1386 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1388 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1390 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1391 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1392 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1393 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1394 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1398 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1401 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1404 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1406 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1407 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1408 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1410 /* data length is simply header length + string data length including nulls */
1411 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1412 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1414 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1415 always has non-zero value for it */
1416 if (ifaceps
->mask
& NumMethods
)
1417 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1418 if (ifaceps
->mask
& BaseIface
)
1419 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1422 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1423 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1424 data
.ulSectionGlobalDataLength
);
1425 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1426 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1427 data
.ulSectionTotalLength
);
1428 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1429 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1430 data
.ulAssemblyRosterIndex
, exid
);
1433 struct clrsurrogate_data
1438 ULONG version_offset
;
1444 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1445 ULONG exid
, int line
)
1447 struct clrsurrogate_data
*surrogate
;
1448 ACTCTX_SECTION_KEYED_DATA data
;
1451 memset(&data
, 0xfe, sizeof(data
));
1452 data
.cbSize
= sizeof(data
);
1454 ret
= pFindActCtxSectionGuid(0, NULL
,
1455 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1459 skip("surrogate sections are not supported\n");
1462 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1464 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1466 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1467 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1468 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1469 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1470 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1475 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1476 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1478 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1479 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1481 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1482 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1484 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1485 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1487 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1488 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1490 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1491 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1494 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1495 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1496 data
.ulSectionGlobalDataLength
);
1497 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1498 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1499 data
.ulSectionTotalLength
);
1500 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1501 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1502 data
.ulAssemblyRosterIndex
, exid
);
1505 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1507 struct progidredirect_data
*progiddata
;
1508 struct comclassredirect_data
*comclass
;
1509 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1510 struct strsection_header
*header
;
1513 memset(&data
, 0xfe, sizeof(data
));
1514 data
.cbSize
= sizeof(data
);
1516 ret
= pFindActCtxSectionStringA(0, NULL
,
1517 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1519 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1521 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1523 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1524 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1525 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1526 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1527 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1531 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1532 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1534 /* progid data points to generated alias guid */
1535 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1537 memset(&data2
, 0, sizeof(data2
));
1538 data2
.cbSize
= sizeof(data2
);
1539 ret
= pFindActCtxSectionGuid(0, NULL
,
1540 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1542 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1544 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1545 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1546 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1549 header
= (struct strsection_header
*)data
.lpSectionBase
;
1550 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1551 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1552 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1553 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1554 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1555 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1556 data
.ulAssemblyRosterIndex
, exid
);
1559 static void test_wndclass_section(void)
1561 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1562 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1563 struct wndclass_redirect_data
*classdata
;
1564 struct strsection_header
*section
;
1570 /* use two dependent manifests, each defines 2 window class redirects */
1571 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1572 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1573 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1575 handle
= test_create("main_wndcls.manifest");
1576 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1578 DeleteFileA("testdep1.manifest");
1579 DeleteFileA("testdep2.manifest");
1580 DeleteFileA("main_wndcls.manifest");
1582 ret
= pActivateActCtx(handle
, &cookie
);
1583 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1585 memset(&data
, 0, sizeof(data
));
1586 memset(&data2
, 0, sizeof(data2
));
1587 data
.cbSize
= sizeof(data
);
1588 data2
.cbSize
= sizeof(data2
);
1590 /* get data for two classes from different assemblies */
1591 ret
= pFindActCtxSectionStringW(0, NULL
,
1592 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1594 ok(ret
, "got %d\n", ret
);
1595 ret
= pFindActCtxSectionStringW(0, NULL
,
1596 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1597 wndClass3W
, &data2
);
1598 ok(ret
, "got %d\n", ret
);
1600 section
= (struct strsection_header
*)data
.lpSectionBase
;
1601 ok(section
->count
== 4, "got %d\n", section
->count
);
1602 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1604 /* For both string same section is returned, meaning it's one wndclass section per context */
1605 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1606 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1607 data2
.ulSectionTotalLength
);
1609 /* wndClass1 is versioned, wndClass3 is not */
1610 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1611 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1612 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1614 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1615 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1616 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1618 ret
= pDeactivateActCtx(0, cookie
);
1619 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1621 pReleaseActCtx(handle
);
1624 static void test_dllredirect_section(void)
1626 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1627 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1628 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1629 struct strsection_header
*section
;
1634 /* use two dependent manifests, 4 'files' total */
1635 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1636 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1637 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1639 handle
= test_create("main_wndcls.manifest");
1640 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1642 DeleteFileA("testdep1.manifest");
1643 DeleteFileA("testdep2.manifest");
1644 DeleteFileA("main_wndcls.manifest");
1646 ret
= pActivateActCtx(handle
, &cookie
);
1647 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1649 memset(&data
, 0, sizeof(data
));
1650 memset(&data2
, 0, sizeof(data2
));
1651 data
.cbSize
= sizeof(data
);
1652 data2
.cbSize
= sizeof(data2
);
1654 /* get data for two files from different assemblies */
1655 ret
= pFindActCtxSectionStringW(0, NULL
,
1656 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1658 ok(ret
, "got %d\n", ret
);
1659 ret
= pFindActCtxSectionStringW(0, NULL
,
1660 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1662 ok(ret
, "got %d\n", ret
);
1664 section
= (struct strsection_header
*)data
.lpSectionBase
;
1665 ok(section
->count
== 4, "got %d\n", section
->count
);
1666 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1668 /* For both string same section is returned, meaning it's one dll redirect section per context */
1669 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1670 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1671 data2
.ulSectionTotalLength
);
1673 ret
= pDeactivateActCtx(0, cookie
);
1674 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1676 pReleaseActCtx(handle
);
1679 static void test_typelib_section(void)
1681 static const WCHAR helpW
[] = {'h','e','l','p'};
1682 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1683 struct guidsection_header
*section
;
1684 struct tlibredirect_data
*tlib
;
1689 /* use two dependent manifests, 4 'files' total */
1690 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1691 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1692 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1694 handle
= test_create("main_wndcls.manifest");
1695 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1697 DeleteFileA("testdep1.manifest");
1698 DeleteFileA("testdep2.manifest");
1699 DeleteFileA("main_wndcls.manifest");
1701 ret
= pActivateActCtx(handle
, &cookie
);
1702 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1704 memset(&data
, 0, sizeof(data
));
1705 memset(&data2
, 0, sizeof(data2
));
1706 data
.cbSize
= sizeof(data
);
1707 data2
.cbSize
= sizeof(data2
);
1709 /* get data for two typelibs from different assemblies */
1710 ret
= pFindActCtxSectionGuid(0, NULL
,
1711 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1712 &IID_TlibTest
, &data
);
1713 ok(ret
, "got %d\n", ret
);
1715 ret
= pFindActCtxSectionGuid(0, NULL
,
1716 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1717 &IID_TlibTest4
, &data2
);
1718 ok(ret
, "got %d\n", ret
);
1720 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1721 ok(section
->count
== 4, "got %d\n", section
->count
);
1722 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1724 /* For both GUIDs same section is returned */
1725 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1726 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1727 data2
.ulSectionTotalLength
);
1729 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1730 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1731 data
.ulSectionGlobalDataLength
);
1733 /* test some actual data */
1734 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1735 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1736 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1737 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1738 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1739 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1740 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1742 ret
= pDeactivateActCtx(0, cookie
);
1743 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1745 pReleaseActCtx(handle
);
1748 static void test_allowDelayedBinding(void)
1752 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
1753 skip("Could not create manifest file\n");
1757 handle
= test_create("test5.manifest");
1758 if (handle
== INVALID_HANDLE_VALUE
) {
1759 win_skip("allowDelayedBinding attribute is not supported.\n");
1763 DeleteFileA("test5.manifest");
1764 DeleteFileA("testdep.manifest");
1765 if (handle
!= INVALID_HANDLE_VALUE
) {
1766 test_basic_info(handle
, __LINE__
);
1767 pReleaseActCtx(handle
);
1771 static void test_actctx(void)
1779 trace("default actctx\n");
1781 b
= pGetCurrentActCtx(&handle
);
1782 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1783 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1785 test_basic_info(handle
, __LINE__
);
1786 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1787 pReleaseActCtx(handle
);
1790 /* test for whitespace handling in Eq ::= S? '=' S? */
1791 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
1792 handle
= test_create("test1_1.manifest");
1793 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1794 DeleteFileA("test1_1.manifest");
1795 pReleaseActCtx(handle
);
1797 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1798 skip("Could not create manifest file\n");
1802 trace("manifest1\n");
1804 handle
= test_create("test1.manifest");
1805 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1806 DeleteFileA("test1.manifest");
1807 if(handle
!= INVALID_HANDLE_VALUE
) {
1808 test_basic_info(handle
, __LINE__
);
1809 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1810 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1812 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
1814 /* CloseHandle will generate an exception if a debugger is present */
1815 b
= CloseHandle(handle
);
1816 ok(!b
, "CloseHandle succeeded\n");
1817 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
1820 pReleaseActCtx(handle
);
1823 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
1824 skip("Could not create manifest file\n");
1828 trace("manifest2 depmanifest1\n");
1830 handle
= test_create("test2.manifest");
1831 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1832 DeleteFileA("test2.manifest");
1833 DeleteFileA("testdep.manifest");
1834 if(handle
!= INVALID_HANDLE_VALUE
) {
1835 test_basic_info(handle
, __LINE__
);
1836 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1837 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1838 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
1839 pReleaseActCtx(handle
);
1842 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
1843 skip("Could not create manifest file\n");
1847 trace("manifest2 depmanifest2\n");
1849 handle
= test_create("test2-2.manifest");
1850 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1851 DeleteFileA("test2-2.manifest");
1852 DeleteFileA("testdep.manifest");
1853 if(handle
!= INVALID_HANDLE_VALUE
) {
1854 test_basic_info(handle
, __LINE__
);
1855 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1856 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1857 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
1858 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1859 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1861 b
= pActivateActCtx(handle
, &cookie
);
1862 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1863 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1864 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1865 b
= pDeactivateActCtx(0, cookie
);
1866 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1868 pReleaseActCtx(handle
);
1871 trace("manifest2 depmanifest3\n");
1873 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
1874 skip("Could not create manifest file\n");
1878 handle
= test_create("test2-3.manifest");
1879 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1880 DeleteFileA("test2-3.manifest");
1881 DeleteFileA("testdep.manifest");
1882 if(handle
!= INVALID_HANDLE_VALUE
) {
1883 test_basic_info(handle
, __LINE__
);
1884 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1885 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1886 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
1887 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1888 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1890 b
= pActivateActCtx(handle
, &cookie
);
1891 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1892 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1893 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1894 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
1895 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
1896 b
= pDeactivateActCtx(0, cookie
);
1897 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1899 pReleaseActCtx(handle
);
1902 trace("manifest3\n");
1904 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1905 skip("Could not create manifest file\n");
1909 handle
= test_create("test3.manifest");
1910 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
1911 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1912 if (handle
== INVALID_HANDLE_VALUE
)
1913 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
1914 DeleteFileA("test3.manifest");
1915 if(handle
!= INVALID_HANDLE_VALUE
) {
1916 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
1917 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
1918 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
1919 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
1921 test_basic_info(handle
, __LINE__
);
1922 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1923 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
1924 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
1926 b
= pActivateActCtx(handle
, &cookie
);
1927 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1928 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1929 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1930 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
1931 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
1932 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
1933 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
1934 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
1935 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
1936 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
1937 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
1938 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
1939 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
1940 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
1941 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
1942 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
1943 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
1944 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
1945 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
1946 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
1947 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
1948 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1949 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
1950 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1951 test_find_string_fail();
1953 b
= pDeactivateActCtx(0, cookie
);
1954 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1955 pReleaseActCtx(handle
);
1958 trace("manifest4\n");
1960 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1961 skip("Could not create manifest file\n");
1965 handle
= test_create("test4.manifest");
1966 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1967 DeleteFileA("test4.manifest");
1968 DeleteFileA("testdep.manifest");
1969 if(handle
!= INVALID_HANDLE_VALUE
) {
1970 test_basic_info(handle
, __LINE__
);
1971 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1972 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
1973 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
1974 pReleaseActCtx(handle
);
1977 trace("manifest1 in subdir\n");
1979 CreateDirectoryW(work_dir_subdir
, NULL
);
1980 if (SetCurrentDirectoryW(work_dir_subdir
))
1982 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1983 skip("Could not create manifest file\n");
1986 handle
= test_create("..\\test1.manifest");
1987 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1988 DeleteFileA("..\\test1.manifest");
1989 if(handle
!= INVALID_HANDLE_VALUE
) {
1990 test_basic_info(handle
, __LINE__
);
1991 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1992 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1993 pReleaseActCtx(handle
);
1995 SetCurrentDirectoryW(work_dir
);
1998 skip("Couldn't change directory\n");
1999 RemoveDirectoryW(work_dir_subdir
);
2001 trace("UTF-16 manifest1, with BOM\n");
2002 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
2003 skip("Could not create manifest file\n");
2007 handle
= test_create("test1.manifest");
2008 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2009 DeleteFileA("test1.manifest");
2010 if (handle
!= INVALID_HANDLE_VALUE
) {
2011 test_basic_info(handle
, __LINE__
);
2012 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2013 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2014 pReleaseActCtx(handle
);
2017 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2018 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
2019 skip("Could not create manifest file\n");
2023 handle
= test_create("test1.manifest");
2024 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2025 DeleteFileA("test1.manifest");
2026 if (handle
!= INVALID_HANDLE_VALUE
) {
2027 test_basic_info(handle
, __LINE__
);
2028 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2029 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2030 pReleaseActCtx(handle
);
2033 test_wndclass_section();
2034 test_dllredirect_section();
2035 test_typelib_section();
2036 test_allowDelayedBinding();
2039 static void test_app_manifest(void)
2044 trace("child process manifest1\n");
2046 b
= pGetCurrentActCtx(&handle
);
2047 ok(handle
== NULL
, "handle != NULL\n");
2048 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2050 test_basic_info(handle
, __LINE__
);
2051 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2052 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2053 pReleaseActCtx(handle
);
2057 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2060 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2062 handle
= test_create(filename
);
2063 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2064 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2066 DeleteFileA(filename
);
2070 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2072 UNICODE_STRING string_to_findW
;
2073 ACTCTX_SECTION_KEYED_DATA data
;
2077 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2079 memset(&data
, 0xfe, sizeof(data
));
2080 data
.cbSize
= sizeof(data
);
2083 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, &data
);
2084 err
= GetLastError();
2085 ok_(__FILE__
, line
)(ret
== should_find
,
2086 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find
, ret
);
2088 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2089 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2091 memset(&data
, 0xfe, sizeof(data
));
2092 data
.cbSize
= sizeof(data
);
2095 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2096 err
= GetLastError();
2097 ok_(__FILE__
, line
)(ret
== should_find
,
2098 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2100 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2101 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2104 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2105 err
= GetLastError();
2106 ok_(__FILE__
, line
)(!ret
,
2107 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2108 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2109 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2112 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2113 err
= GetLastError();
2114 ok_(__FILE__
, line
)(!ret
,
2115 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2116 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2117 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2119 pRtlFreeUnicodeString(&string_to_findW
);
2122 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2124 UNICODE_STRING string_to_findW
;
2125 ACTCTX_SECTION_KEYED_DATA data
;
2128 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2130 memset(&data
, 0xfe, sizeof(data
));
2131 data
.cbSize
= sizeof(data
);
2133 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2135 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2136 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2138 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2140 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2141 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2143 pRtlFreeUnicodeString(&string_to_findW
);
2146 static void test_findsectionstring(void)
2152 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2153 ret
= pActivateActCtx(handle
, &cookie
);
2154 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2156 /* first we show the parameter validation from kernel32 */
2157 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2158 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2159 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2160 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2161 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2162 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2163 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2165 /* then we show that ntdll plays by different rules */
2166 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2167 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2168 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2169 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2170 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2171 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2172 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2174 ret
= pDeactivateActCtx(0, cookie
);
2175 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2176 pReleaseActCtx(handle
);
2179 static void run_child_process(void)
2181 char cmdline
[MAX_PATH
];
2182 char path
[MAX_PATH
];
2184 PROCESS_INFORMATION pi
;
2185 STARTUPINFOA si
= { 0 };
2190 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2191 strcat(path
, ".manifest");
2192 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2193 skip("Could not create manifest file\n");
2198 winetest_get_mainargs( &argv
);
2199 /* Vista+ seems to cache presence of .manifest files. Change last modified
2200 date to defeat the cache */
2201 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2202 NULL
, OPEN_EXISTING
, 0, NULL
);
2203 if (file
!= INVALID_HANDLE_VALUE
) {
2204 GetSystemTimeAsFileTime(&now
);
2205 SetFileTime(file
, NULL
, NULL
, &now
);
2208 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2209 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2210 ok(ret
, "Could not create process: %u\n", GetLastError());
2211 winetest_wait_child_process( pi
.hProcess
);
2212 CloseHandle(pi
.hThread
);
2213 CloseHandle(pi
.hProcess
);
2217 static void init_paths(void)
2221 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2222 static const WCHAR backslash
[] = {'\\',0};
2223 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2225 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2226 lstrcpyW(app_dir
, exe_path
);
2227 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2230 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2231 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2232 if (*ptr
!= '\\' && *ptr
!= '/')
2233 lstrcatW(work_dir
, backslash
);
2234 lstrcpyW(work_dir_subdir
, work_dir
);
2235 lstrcatW(work_dir_subdir
, subdir
);
2237 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2238 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2241 static void write_manifest(const char *filename
, const char *manifest
)
2245 CHAR path
[MAX_PATH
];
2247 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2248 strcat(path
, filename
);
2250 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2251 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2252 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2256 static void delete_manifest_file(const char *filename
)
2258 CHAR path
[MAX_PATH
];
2260 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2261 strcat(path
, filename
);
2265 static void test_CreateActCtx(void)
2267 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2271 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2272 strcat(path
, "main_wndcls.manifest");
2274 write_manifest("testdep1.manifest", manifest_wndcls1
);
2275 write_manifest("testdep2.manifest", manifest_wndcls2
);
2276 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2278 memset(&actctx
, 0, sizeof(ACTCTXA
));
2279 actctx
.cbSize
= sizeof(ACTCTXA
);
2280 actctx
.lpSource
= path
;
2282 /* create using lpSource without specified directory */
2283 handle
= pCreateActCtxA(&actctx
);
2284 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2285 pReleaseActCtx(handle
);
2287 /* with specified directory, that doesn't contain dependent assembly */
2288 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2290 memset(&actctx
, 0, sizeof(ACTCTXA
));
2291 actctx
.cbSize
= sizeof(ACTCTXA
);
2292 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2293 actctx
.lpAssemblyDirectory
= dir
;
2294 actctx
.lpSource
= path
;
2296 SetLastError(0xdeadbeef);
2297 handle
= pCreateActCtxA(&actctx
);
2299 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2300 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2302 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2304 delete_manifest_file("main_wndcls.manifest");
2305 delete_manifest_file("testdep1.manifest");
2306 delete_manifest_file("testdep2.manifest");
2308 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2309 memset(&actctx
, 0, sizeof(ACTCTXA
));
2310 actctx
.cbSize
= sizeof(ACTCTXA
);
2311 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2312 SetLastError(0xdeadbeef);
2313 handle
= pCreateActCtxA(&actctx
);
2314 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2316 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2317 "got error %d\n", GetLastError());
2319 /* create from HMODULE - resource doesn't exist, lpSource is set */
2320 memset(&actctx
, 0, sizeof(ACTCTXA
));
2321 actctx
.cbSize
= sizeof(ACTCTXA
);
2322 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2323 actctx
.lpSource
= "dummyfile.dll";
2324 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2325 actctx
.hModule
= GetModuleHandleA(NULL
);
2327 SetLastError(0xdeadbeef);
2328 handle
= pCreateActCtxA(&actctx
);
2329 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2330 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2332 /* load manifest from lpAssemblyDirectory directory */
2333 write_manifest("testdir.manifest", manifest1
);
2334 GetTempPathA(sizeof(path
)/sizeof(path
[0]), path
);
2335 SetCurrentDirectoryA(path
);
2336 strcat(path
, "assembly_dir");
2338 strcat(path
, "\\testdir.manifest");
2340 memset(&actctx
, 0, sizeof(actctx
));
2341 actctx
.cbSize
= sizeof(actctx
);
2342 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2343 actctx
.lpSource
= "testdir.manifest";
2344 actctx
.lpAssemblyDirectory
= dir
;
2346 SetLastError(0xdeadbeef);
2347 handle
= pCreateActCtxA(&actctx
);
2348 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2349 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2350 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2351 "got error %d\n", GetLastError());
2353 CreateDirectoryA(dir
, NULL
);
2354 memset(&actctx
, 0, sizeof(actctx
));
2355 actctx
.cbSize
= sizeof(actctx
);
2356 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2357 actctx
.lpSource
= "testdir.manifest";
2358 actctx
.lpAssemblyDirectory
= dir
;
2360 SetLastError(0xdeadbeef);
2361 handle
= pCreateActCtxA(&actctx
);
2362 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2363 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %d\n", GetLastError());
2364 SetCurrentDirectoryW(work_dir
);
2366 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
2367 memset(&actctx
, 0, sizeof(actctx
));
2368 actctx
.cbSize
= sizeof(actctx
);
2369 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2370 actctx
.lpSource
= "testdir.manifest";
2371 actctx
.lpAssemblyDirectory
= dir
;
2373 handle
= pCreateActCtxA(&actctx
);
2374 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2375 pReleaseActCtx(handle
);
2377 memset(&actctx
, 0, sizeof(actctx
));
2378 actctx
.cbSize
= sizeof(actctx
);
2379 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2380 actctx
.lpSource
= path
;
2381 actctx
.lpAssemblyDirectory
= dir
;
2383 handle
= pCreateActCtxA(&actctx
);
2384 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2385 pReleaseActCtx(handle
);
2387 delete_manifest_file("testdir.manifest");
2388 delete_manifest_file("assembly_dir\\testdir.manifest");
2389 RemoveDirectoryA(dir
);
2392 static BOOL
init_funcs(void)
2394 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
2396 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2400 X(DeactivateActCtx
);
2401 X(FindActCtxSectionStringA
);
2402 X(FindActCtxSectionStringW
);
2403 X(GetCurrentActCtx
);
2404 X(IsDebuggerPresent
);
2407 X(FindActCtxSectionGuid
);
2410 hLibrary
= GetModuleHandleA("ntdll.dll");
2411 X(RtlFindActivationContextSectionString
);
2412 X(RtlCreateUnicodeStringFromAsciiz
);
2413 X(RtlFreeUnicodeString
);
2419 static void test_ZombifyActCtx(void)
2421 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
2423 HANDLE handle
, current
;
2426 SetLastError(0xdeadbeef);
2427 ret
= pZombifyActCtx(NULL
);
2429 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "got %d, error %d\n", ret
, GetLastError());
2431 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2433 ret
= pGetCurrentActCtx(¤t
);
2434 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2435 ok(current
== NULL
, "got %p\n", current
);
2437 ret
= pActivateActCtx(handle
, &cookie
);
2438 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2440 ret
= pGetCurrentActCtx(¤t
);
2441 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2442 ok(handle
== current
, "got %p, %p\n", current
, handle
);
2444 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2445 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2446 &basicinfo
, sizeof(basicinfo
), NULL
);
2447 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2448 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2449 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2451 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2452 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2453 &basicinfo
, sizeof(basicinfo
), NULL
);
2454 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2455 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2456 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2458 ret
= pZombifyActCtx(handle
);
2460 ok(ret
, "got %d\n", ret
);
2462 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2463 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2464 &basicinfo
, sizeof(basicinfo
), NULL
);
2465 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2466 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2467 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2469 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2470 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2471 &basicinfo
, sizeof(basicinfo
), NULL
);
2472 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2473 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2474 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2476 ret
= pGetCurrentActCtx(¤t
);
2477 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2478 ok(current
== handle
, "got %p\n", current
);
2481 ret
= pZombifyActCtx(handle
);
2483 ok(ret
, "got %d\n", ret
);
2485 ret
= pDeactivateActCtx(0, cookie
);
2486 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2487 pReleaseActCtx(handle
);
2495 argc
= winetest_get_mainargs(&argv
);
2499 win_skip("Needed functions are not available\n");
2504 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2505 test_app_manifest();
2510 test_CreateActCtx();
2511 test_findsectionstring();
2512 test_ZombifyActCtx();
2513 run_child_process();