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());
786 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
787 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
789 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
790 DeleteFileA("bad.manifest");
791 DeleteFileA("testdep.manifest");
794 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
798 WCHAR path
[MAX_PATH
];
800 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
801 memset(&actctx
, 0, sizeof(ACTCTXW
));
802 actctx
.cbSize
= sizeof(ACTCTXW
);
803 actctx
.lpSource
= path
;
805 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
806 handle
= pCreateActCtxW(&actctx
);
807 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
808 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
810 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
811 DeleteFileA("bad.manifest");
814 static void test_create_fail(void)
818 WCHAR path
[MAX_PATH
];
820 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
821 memset(&actctx
, 0, sizeof(ACTCTXW
));
822 actctx
.cbSize
= sizeof(ACTCTXW
);
823 actctx
.lpSource
= path
;
825 handle
= pCreateActCtxW(&actctx
);
826 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
827 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
829 trace("wrong_manifest1\n");
830 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
831 trace("wrong_manifest2\n");
832 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
833 trace("wrong_manifest3\n");
834 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
835 trace("wrong_manifest4\n");
836 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
837 trace("wrong_manifest5\n");
838 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
839 trace("wrong_manifest6\n");
840 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
841 trace("wrong_manifest7\n");
842 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
843 trace("wrong_manifest8\n");
844 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
845 trace("UTF-16 manifest1 without BOM\n");
846 test_create_wide_and_fail(manifest1
, FALSE
);
847 trace("manifest2\n");
848 test_create_and_fail(manifest2
, NULL
, 0 );
849 trace("manifest2+depmanifest1\n");
850 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
853 struct strsection_header
875 struct guidsection_header
895 struct wndclass_redirect_data
900 ULONG name_offset
; /* versioned name offset */
902 ULONG module_offset
;/* container name offset */
905 struct dllredirect_data
912 struct tlibredirect_data
926 struct progidredirect_data
933 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
935 ACTCTX_SECTION_KEYED_DATA data
;
938 memset(&data
, 0xfe, sizeof(data
));
939 data
.cbSize
= sizeof(data
);
941 ret
= pFindActCtxSectionStringW(0, NULL
,
942 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
944 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
947 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
948 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
949 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
950 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
954 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
955 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
956 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
957 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
958 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
959 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
962 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
963 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
964 data
.ulSectionGlobalDataLength
);
965 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
966 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
967 data
.ulSectionTotalLength
);
968 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
969 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
970 data
.ulAssemblyRosterIndex
, exid
);
972 memset(&data
, 0xfe, sizeof(data
));
973 data
.cbSize
= sizeof(data
);
975 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
976 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
978 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
981 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
982 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
983 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
984 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
985 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
986 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
987 data
.ulSectionGlobalDataLength
);
988 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
989 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
990 data
.ulSectionTotalLength
);
991 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
992 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
993 data
.ulAssemblyRosterIndex
, exid
);
995 pReleaseActCtx(handle
);
998 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
1000 struct wndclass_redirect_data
*wnddata
;
1001 struct strsection_header
*header
;
1002 ACTCTX_SECTION_KEYED_DATA data
;
1005 memset(&data
, 0xfe, sizeof(data
));
1006 data
.cbSize
= sizeof(data
);
1008 ret
= pFindActCtxSectionStringW(0, NULL
,
1009 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1011 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1012 wine_dbgstr_w(clsname
));
1015 header
= (struct strsection_header
*)data
.lpSectionBase
;
1016 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1018 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
1019 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
1020 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1021 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1022 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1023 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1024 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1026 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1031 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1032 /* redirect class name (versioned or not) is stored just after header data */
1033 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1034 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1036 /* expected versioned name */
1037 lstrcpyW(buff
, verW
);
1038 lstrcatW(buff
, clsname
);
1039 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1040 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1041 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1042 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1044 /* data length is simply header length + string data length including nulls */
1045 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1046 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1048 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1050 WCHAR
*modulename
, *sectionptr
;
1052 /* just compare pointers */
1053 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1054 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1055 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1059 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1060 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1061 data
.ulSectionGlobalDataLength
);
1062 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1063 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1064 data
.ulSectionTotalLength
);
1065 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1066 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1067 data
.ulAssemblyRosterIndex
, exid
);
1069 memset(&data
, 0xfe, sizeof(data
));
1070 data
.cbSize
= sizeof(data
);
1072 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1073 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1075 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1076 wine_dbgstr_w(clsname
));
1079 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1080 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1081 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1082 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1083 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1084 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1085 data
.ulSectionGlobalDataLength
);
1086 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1087 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1088 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1089 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1090 data
.ulAssemblyRosterIndex
, exid
);
1092 pReleaseActCtx(handle
);
1095 static void test_find_string_fail(void)
1097 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1100 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1101 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1102 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1104 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1105 testlib2_dll
, &data
);
1106 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1107 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "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());
1114 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1116 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1117 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1120 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1121 testlib_dll
, &data
);
1122 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1123 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1126 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1127 testlib_dll
, &data
);
1128 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1129 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1133 static void test_basic_info(HANDLE handle
, int line
)
1135 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1139 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1140 ActivationContextBasicInformation
, &basic
,
1141 sizeof(basic
), &size
);
1143 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1144 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1145 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1146 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1148 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1149 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1150 ActivationContextBasicInformation
, &basic
,
1151 sizeof(basic
), &size
);
1154 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1155 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1156 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1157 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1158 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1162 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1163 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1164 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1165 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1169 enum comclass_threadingmodel
{
1170 ThreadingModel_Apartment
= 1,
1171 ThreadingModel_Free
= 2,
1172 ThreadingModel_No
= 3,
1173 ThreadingModel_Both
= 4,
1174 ThreadingModel_Neutral
= 5
1177 enum comclass_miscfields
{
1180 MiscStatusContent
= 4,
1181 MiscStatusThumbnail
= 8,
1182 MiscStatusDocPrint
= 16
1185 struct comclassredirect_data
{
1198 ULONG progid_offset
;
1200 ULONG clrdata_offset
;
1202 DWORD miscstatuscontent
;
1203 DWORD miscstatusthumbnail
;
1204 DWORD miscstatusicon
;
1205 DWORD miscstatusdocprint
;
1208 struct clrclass_data
{
1212 ULONG module_offset
;
1216 ULONG version_offset
;
1220 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1222 struct comclassredirect_data
*comclass
, *comclass2
;
1223 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1224 struct guidsection_header
*header
;
1227 memset(&data
, 0xfe, sizeof(data
));
1228 data
.cbSize
= sizeof(data
);
1230 ret
= pFindActCtxSectionGuid(0, NULL
,
1231 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1235 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1238 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1240 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1242 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1243 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1244 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1245 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1246 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1251 ok_(__FILE__
, line
)(comclass
->res
== 0, "got res as %d\n", comclass
->res
);
1252 ok_(__FILE__
, line
)(comclass
->res1
[0] == 0, "got res1[0] as %02x\n", comclass
->res1
[0]);
1253 ok_(__FILE__
, line
)(comclass
->res1
[1] == 0, "got res1[1] as %02x\n", comclass
->res1
[1]);
1254 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1255 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1256 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1258 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1259 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1263 len
= comclass
->size
+ comclass
->clrdata_len
;
1264 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1267 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1269 if (comclass
->progid_offset
)
1271 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1272 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1273 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1274 "got progid name length %d\n", comclass
->progid_len
);
1277 /* data length is simply header length + string data length including nulls */
1278 len
= comclass
->size
+ comclass
->clrdata_len
;
1279 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1280 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1282 /* keyed data structure doesn't include module name, it's available from section data */
1283 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1285 /* check misc fields are set */
1286 if (comclass
->miscmask
)
1288 if (comclass
->miscmask
& MiscStatus
)
1289 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1290 if (comclass
->miscmask
& MiscStatusIcon
)
1291 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1292 if (comclass
->miscmask
& MiscStatusContent
)
1293 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1294 if (comclass
->miscmask
& MiscStatusThumbnail
)
1295 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1296 if (comclass
->miscmask
& MiscStatusDocPrint
)
1297 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1300 /* part used for clrClass only */
1301 if (comclass
->clrdata_len
)
1303 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1304 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1305 struct clrclass_data
*clrclass
;
1308 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1309 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1310 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1311 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1312 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1313 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1315 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1316 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1317 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1318 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1320 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1321 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1323 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1324 in lower case, clsclass subsection - in upper case */
1325 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1326 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1328 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1329 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1331 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1332 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1336 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1337 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1338 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1339 data
.ulSectionGlobalDataLength
);
1340 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1341 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1342 data
.ulSectionTotalLength
);
1343 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1344 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1345 data
.ulAssemblyRosterIndex
, exid
);
1347 /* generated guid for this class works as key guid in search */
1348 memset(&data2
, 0xfe, sizeof(data2
));
1349 data2
.cbSize
= sizeof(data2
);
1350 ret
= pFindActCtxSectionGuid(0, NULL
,
1351 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1352 &comclass
->alias
, &data2
);
1353 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1355 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1356 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1357 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1366 struct ifacepsredirect_data
1378 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1379 const GUID
*ps32
, ULONG exid
, int line
)
1381 struct ifacepsredirect_data
*ifaceps
;
1382 ACTCTX_SECTION_KEYED_DATA data
;
1385 memset(&data
, 0xfe, sizeof(data
));
1386 data
.cbSize
= sizeof(data
);
1388 ret
= pFindActCtxSectionGuid(0, NULL
,
1389 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1391 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1393 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1395 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1396 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1397 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1398 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1399 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1403 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1406 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1409 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1411 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1412 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1413 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1415 /* data length is simply header length + string data length including nulls */
1416 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1417 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1419 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1420 always has non-zero value for it */
1421 if (ifaceps
->mask
& NumMethods
)
1422 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1423 if (ifaceps
->mask
& BaseIface
)
1424 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1427 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1428 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1429 data
.ulSectionGlobalDataLength
);
1430 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1431 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1432 data
.ulSectionTotalLength
);
1433 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1434 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1435 data
.ulAssemblyRosterIndex
, exid
);
1438 struct clrsurrogate_data
1443 ULONG version_offset
;
1449 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1450 ULONG exid
, int line
)
1452 struct clrsurrogate_data
*surrogate
;
1453 ACTCTX_SECTION_KEYED_DATA data
;
1456 memset(&data
, 0xfe, sizeof(data
));
1457 data
.cbSize
= sizeof(data
);
1459 ret
= pFindActCtxSectionGuid(0, NULL
,
1460 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1464 skip("surrogate sections are not supported\n");
1467 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1469 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1471 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1472 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1473 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1474 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1475 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1480 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1481 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1483 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1484 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1486 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1487 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1489 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1490 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1492 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1493 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1495 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1496 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1499 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1500 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1501 data
.ulSectionGlobalDataLength
);
1502 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1503 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1504 data
.ulSectionTotalLength
);
1505 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1506 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1507 data
.ulAssemblyRosterIndex
, exid
);
1510 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1512 struct progidredirect_data
*progiddata
;
1513 struct comclassredirect_data
*comclass
;
1514 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1515 struct strsection_header
*header
;
1518 memset(&data
, 0xfe, sizeof(data
));
1519 data
.cbSize
= sizeof(data
);
1521 ret
= pFindActCtxSectionStringA(0, NULL
,
1522 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1524 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1526 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1528 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1529 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1530 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1531 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1532 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1536 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1537 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1539 /* progid data points to generated alias guid */
1540 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1542 memset(&data2
, 0, sizeof(data2
));
1543 data2
.cbSize
= sizeof(data2
);
1544 ret
= pFindActCtxSectionGuid(0, NULL
,
1545 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1547 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1549 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1550 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1551 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1554 header
= (struct strsection_header
*)data
.lpSectionBase
;
1555 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1556 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1557 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1558 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1559 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1560 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1561 data
.ulAssemblyRosterIndex
, exid
);
1564 static void test_wndclass_section(void)
1566 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1567 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1568 struct wndclass_redirect_data
*classdata
;
1569 struct strsection_header
*section
;
1575 /* use two dependent manifests, each defines 2 window class redirects */
1576 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1577 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1578 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1580 handle
= test_create("main_wndcls.manifest");
1581 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1583 DeleteFileA("testdep1.manifest");
1584 DeleteFileA("testdep2.manifest");
1585 DeleteFileA("main_wndcls.manifest");
1587 ret
= pActivateActCtx(handle
, &cookie
);
1588 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1590 memset(&data
, 0, sizeof(data
));
1591 memset(&data2
, 0, sizeof(data2
));
1592 data
.cbSize
= sizeof(data
);
1593 data2
.cbSize
= sizeof(data2
);
1595 /* get data for two classes from different assemblies */
1596 ret
= pFindActCtxSectionStringW(0, NULL
,
1597 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1599 ok(ret
, "got %d\n", ret
);
1600 ret
= pFindActCtxSectionStringW(0, NULL
,
1601 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1602 wndClass3W
, &data2
);
1603 ok(ret
, "got %d\n", ret
);
1605 section
= (struct strsection_header
*)data
.lpSectionBase
;
1606 ok(section
->count
== 4, "got %d\n", section
->count
);
1607 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1609 /* For both string same section is returned, meaning it's one wndclass section per context */
1610 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1611 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1612 data2
.ulSectionTotalLength
);
1614 /* wndClass1 is versioned, wndClass3 is not */
1615 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1616 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1617 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1619 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1620 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1621 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1623 ret
= pDeactivateActCtx(0, cookie
);
1624 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1626 pReleaseActCtx(handle
);
1629 static void test_dllredirect_section(void)
1631 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1632 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1633 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1634 struct strsection_header
*section
;
1639 /* use two dependent manifests, 4 'files' total */
1640 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1641 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1642 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1644 handle
= test_create("main_wndcls.manifest");
1645 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1647 DeleteFileA("testdep1.manifest");
1648 DeleteFileA("testdep2.manifest");
1649 DeleteFileA("main_wndcls.manifest");
1651 ret
= pActivateActCtx(handle
, &cookie
);
1652 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1654 memset(&data
, 0, sizeof(data
));
1655 memset(&data2
, 0, sizeof(data2
));
1656 data
.cbSize
= sizeof(data
);
1657 data2
.cbSize
= sizeof(data2
);
1659 /* get data for two files from different assemblies */
1660 ret
= pFindActCtxSectionStringW(0, NULL
,
1661 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1663 ok(ret
, "got %d\n", ret
);
1664 ret
= pFindActCtxSectionStringW(0, NULL
,
1665 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1667 ok(ret
, "got %d\n", ret
);
1669 section
= (struct strsection_header
*)data
.lpSectionBase
;
1670 ok(section
->count
== 4, "got %d\n", section
->count
);
1671 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1673 /* For both string same section is returned, meaning it's one dll redirect section per context */
1674 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1675 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1676 data2
.ulSectionTotalLength
);
1678 ret
= pDeactivateActCtx(0, cookie
);
1679 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1681 pReleaseActCtx(handle
);
1684 static void test_typelib_section(void)
1686 static const WCHAR helpW
[] = {'h','e','l','p'};
1687 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1688 struct guidsection_header
*section
;
1689 struct tlibredirect_data
*tlib
;
1694 /* use two dependent manifests, 4 'files' total */
1695 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1696 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1697 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1699 handle
= test_create("main_wndcls.manifest");
1700 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1702 DeleteFileA("testdep1.manifest");
1703 DeleteFileA("testdep2.manifest");
1704 DeleteFileA("main_wndcls.manifest");
1706 ret
= pActivateActCtx(handle
, &cookie
);
1707 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1709 memset(&data
, 0, sizeof(data
));
1710 memset(&data2
, 0, sizeof(data2
));
1711 data
.cbSize
= sizeof(data
);
1712 data2
.cbSize
= sizeof(data2
);
1714 /* get data for two typelibs from different assemblies */
1715 ret
= pFindActCtxSectionGuid(0, NULL
,
1716 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1717 &IID_TlibTest
, &data
);
1718 ok(ret
, "got %d\n", ret
);
1720 ret
= pFindActCtxSectionGuid(0, NULL
,
1721 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1722 &IID_TlibTest4
, &data2
);
1723 ok(ret
, "got %d\n", ret
);
1725 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1726 ok(section
->count
== 4, "got %d\n", section
->count
);
1727 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1729 /* For both GUIDs same section is returned */
1730 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1731 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1732 data2
.ulSectionTotalLength
);
1734 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1735 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1736 data
.ulSectionGlobalDataLength
);
1738 /* test some actual data */
1739 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1740 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1741 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1742 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1743 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1744 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1745 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1747 ret
= pDeactivateActCtx(0, cookie
);
1748 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1750 pReleaseActCtx(handle
);
1753 static void test_allowDelayedBinding(void)
1757 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
1758 skip("Could not create manifest file\n");
1762 handle
= test_create("test5.manifest");
1763 if (handle
== INVALID_HANDLE_VALUE
) {
1764 win_skip("allowDelayedBinding attribute is not supported.\n");
1768 DeleteFileA("test5.manifest");
1769 DeleteFileA("testdep.manifest");
1770 if (handle
!= INVALID_HANDLE_VALUE
) {
1771 test_basic_info(handle
, __LINE__
);
1772 pReleaseActCtx(handle
);
1776 static void test_actctx(void)
1784 trace("default actctx\n");
1786 b
= pGetCurrentActCtx(&handle
);
1787 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1788 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1790 test_basic_info(handle
, __LINE__
);
1791 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1792 pReleaseActCtx(handle
);
1795 /* test for whitespace handling in Eq ::= S? '=' S? */
1796 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
1797 handle
= test_create("test1_1.manifest");
1798 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1799 DeleteFileA("test1_1.manifest");
1800 pReleaseActCtx(handle
);
1802 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1803 skip("Could not create manifest file\n");
1807 trace("manifest1\n");
1809 handle
= test_create("test1.manifest");
1810 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1811 DeleteFileA("test1.manifest");
1812 if(handle
!= INVALID_HANDLE_VALUE
) {
1813 test_basic_info(handle
, __LINE__
);
1814 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1815 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1817 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
1819 /* CloseHandle will generate an exception if a debugger is present */
1820 b
= CloseHandle(handle
);
1821 ok(!b
, "CloseHandle succeeded\n");
1822 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
1825 pReleaseActCtx(handle
);
1828 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
1829 skip("Could not create manifest file\n");
1833 trace("manifest2 depmanifest1\n");
1835 handle
= test_create("test2.manifest");
1836 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1837 DeleteFileA("test2.manifest");
1838 DeleteFileA("testdep.manifest");
1839 if(handle
!= INVALID_HANDLE_VALUE
) {
1840 test_basic_info(handle
, __LINE__
);
1841 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1842 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1843 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
1844 pReleaseActCtx(handle
);
1847 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
1848 skip("Could not create manifest file\n");
1852 trace("manifest2 depmanifest2\n");
1854 handle
= test_create("test2-2.manifest");
1855 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1856 DeleteFileA("test2-2.manifest");
1857 DeleteFileA("testdep.manifest");
1858 if(handle
!= INVALID_HANDLE_VALUE
) {
1859 test_basic_info(handle
, __LINE__
);
1860 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1861 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1862 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
1863 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1864 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1866 b
= pActivateActCtx(handle
, &cookie
);
1867 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1868 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1869 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1870 b
= pDeactivateActCtx(0, cookie
);
1871 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1873 pReleaseActCtx(handle
);
1876 trace("manifest2 depmanifest3\n");
1878 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
1879 skip("Could not create manifest file\n");
1883 handle
= test_create("test2-3.manifest");
1884 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1885 DeleteFileA("test2-3.manifest");
1886 DeleteFileA("testdep.manifest");
1887 if(handle
!= INVALID_HANDLE_VALUE
) {
1888 test_basic_info(handle
, __LINE__
);
1889 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1890 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1891 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
1892 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1893 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1895 b
= pActivateActCtx(handle
, &cookie
);
1896 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1897 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1898 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1899 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
1900 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
1901 b
= pDeactivateActCtx(0, cookie
);
1902 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1904 pReleaseActCtx(handle
);
1907 trace("manifest3\n");
1909 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1910 skip("Could not create manifest file\n");
1914 handle
= test_create("test3.manifest");
1915 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
1916 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1917 if (handle
== INVALID_HANDLE_VALUE
)
1918 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
1919 DeleteFileA("test3.manifest");
1920 if(handle
!= INVALID_HANDLE_VALUE
) {
1921 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
1922 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
1923 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
1924 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
1926 test_basic_info(handle
, __LINE__
);
1927 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1928 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
1929 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
1931 b
= pActivateActCtx(handle
, &cookie
);
1932 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1933 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1934 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1935 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
1936 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
1937 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
1938 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
1939 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
1940 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
1941 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
1942 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
1943 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
1944 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
1945 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
1946 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
1947 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
1948 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
1949 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
1950 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
1951 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
1952 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
1953 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1954 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
1955 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1956 test_find_string_fail();
1958 b
= pDeactivateActCtx(0, cookie
);
1959 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1960 pReleaseActCtx(handle
);
1963 trace("manifest4\n");
1965 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1966 skip("Could not create manifest file\n");
1970 handle
= test_create("test4.manifest");
1971 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1972 DeleteFileA("test4.manifest");
1973 DeleteFileA("testdep.manifest");
1974 if(handle
!= INVALID_HANDLE_VALUE
) {
1975 test_basic_info(handle
, __LINE__
);
1976 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1977 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
1978 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
1979 pReleaseActCtx(handle
);
1982 trace("manifest1 in subdir\n");
1984 CreateDirectoryW(work_dir_subdir
, NULL
);
1985 if (SetCurrentDirectoryW(work_dir_subdir
))
1987 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1988 skip("Could not create manifest file\n");
1991 handle
= test_create("..\\test1.manifest");
1992 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1993 DeleteFileA("..\\test1.manifest");
1994 if(handle
!= INVALID_HANDLE_VALUE
) {
1995 test_basic_info(handle
, __LINE__
);
1996 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1997 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1998 pReleaseActCtx(handle
);
2000 SetCurrentDirectoryW(work_dir
);
2003 skip("Couldn't change directory\n");
2004 RemoveDirectoryW(work_dir_subdir
);
2006 trace("UTF-16 manifest1, with BOM\n");
2007 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
2008 skip("Could not create manifest file\n");
2012 handle
= test_create("test1.manifest");
2013 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2014 DeleteFileA("test1.manifest");
2015 if (handle
!= INVALID_HANDLE_VALUE
) {
2016 test_basic_info(handle
, __LINE__
);
2017 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2018 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2019 pReleaseActCtx(handle
);
2022 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2023 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
2024 skip("Could not create manifest file\n");
2028 handle
= test_create("test1.manifest");
2029 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2030 DeleteFileA("test1.manifest");
2031 if (handle
!= INVALID_HANDLE_VALUE
) {
2032 test_basic_info(handle
, __LINE__
);
2033 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2034 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2035 pReleaseActCtx(handle
);
2038 test_wndclass_section();
2039 test_dllredirect_section();
2040 test_typelib_section();
2041 test_allowDelayedBinding();
2044 static void test_app_manifest(void)
2049 trace("child process manifest1\n");
2051 b
= pGetCurrentActCtx(&handle
);
2052 ok(handle
== NULL
, "handle != NULL\n");
2053 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2055 test_basic_info(handle
, __LINE__
);
2056 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2057 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2058 pReleaseActCtx(handle
);
2062 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2065 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2067 handle
= test_create(filename
);
2068 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2069 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2071 DeleteFileA(filename
);
2075 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2077 UNICODE_STRING string_to_findW
;
2078 ACTCTX_SECTION_KEYED_DATA data
;
2082 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2084 memset(&data
, 0xfe, sizeof(data
));
2085 data
.cbSize
= sizeof(data
);
2088 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, &data
);
2089 err
= GetLastError();
2090 ok_(__FILE__
, line
)(ret
== should_find
,
2091 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find
, ret
);
2094 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2095 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2097 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2098 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2100 memset(&data
, 0xfe, sizeof(data
));
2101 data
.cbSize
= sizeof(data
);
2104 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2105 err
= GetLastError();
2106 ok_(__FILE__
, line
)(ret
== should_find
,
2107 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2110 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2111 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2113 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2114 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2117 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2118 err
= GetLastError();
2119 ok_(__FILE__
, line
)(!ret
,
2120 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2121 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2122 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2125 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2126 err
= GetLastError();
2127 ok_(__FILE__
, line
)(!ret
,
2128 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2129 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2130 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2132 pRtlFreeUnicodeString(&string_to_findW
);
2135 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2137 UNICODE_STRING string_to_findW
;
2138 ACTCTX_SECTION_KEYED_DATA data
;
2141 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2143 memset(&data
, 0xfe, sizeof(data
));
2144 data
.cbSize
= sizeof(data
);
2146 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2149 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2150 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2152 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2153 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2155 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2158 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2159 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2161 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2162 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2164 pRtlFreeUnicodeString(&string_to_findW
);
2167 static void test_findsectionstring(void)
2173 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2174 ret
= pActivateActCtx(handle
, &cookie
);
2175 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2177 /* first we show the parameter validation from kernel32 */
2178 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2179 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2180 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2181 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2182 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2183 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2184 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2186 /* then we show that ntdll plays by different rules */
2187 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2188 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2189 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2190 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2191 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2192 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2193 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2195 ret
= pDeactivateActCtx(0, cookie
);
2196 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2197 pReleaseActCtx(handle
);
2200 static void run_child_process(void)
2202 char cmdline
[MAX_PATH
];
2203 char path
[MAX_PATH
];
2205 PROCESS_INFORMATION pi
;
2206 STARTUPINFOA si
= { 0 };
2211 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2212 strcat(path
, ".manifest");
2213 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2214 skip("Could not create manifest file\n");
2219 winetest_get_mainargs( &argv
);
2220 /* Vista+ seems to cache presence of .manifest files. Change last modified
2221 date to defeat the cache */
2222 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2223 NULL
, OPEN_EXISTING
, 0, NULL
);
2224 if (file
!= INVALID_HANDLE_VALUE
) {
2225 GetSystemTimeAsFileTime(&now
);
2226 SetFileTime(file
, NULL
, NULL
, &now
);
2229 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2230 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2231 ok(ret
, "Could not create process: %u\n", GetLastError());
2232 winetest_wait_child_process( pi
.hProcess
);
2233 CloseHandle(pi
.hThread
);
2234 CloseHandle(pi
.hProcess
);
2238 static void init_paths(void)
2242 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2243 static const WCHAR backslash
[] = {'\\',0};
2244 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2246 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2247 lstrcpyW(app_dir
, exe_path
);
2248 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2251 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2252 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2253 if (*ptr
!= '\\' && *ptr
!= '/')
2254 lstrcatW(work_dir
, backslash
);
2255 lstrcpyW(work_dir_subdir
, work_dir
);
2256 lstrcatW(work_dir_subdir
, subdir
);
2258 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2259 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2262 static void write_manifest(const char *filename
, const char *manifest
)
2266 CHAR path
[MAX_PATH
];
2268 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2269 strcat(path
, filename
);
2271 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2272 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2273 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2277 static void delete_manifest_file(const char *filename
)
2279 CHAR path
[MAX_PATH
];
2281 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2282 strcat(path
, filename
);
2286 static void test_CreateActCtx(void)
2288 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2292 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2293 strcat(path
, "main_wndcls.manifest");
2295 write_manifest("testdep1.manifest", manifest_wndcls1
);
2296 write_manifest("testdep2.manifest", manifest_wndcls2
);
2297 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2299 memset(&actctx
, 0, sizeof(ACTCTXA
));
2300 actctx
.cbSize
= sizeof(ACTCTXA
);
2301 actctx
.lpSource
= path
;
2303 /* create using lpSource without specified directory */
2304 handle
= pCreateActCtxA(&actctx
);
2305 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2306 pReleaseActCtx(handle
);
2308 /* with specified directory, that doesn't contain dependent assembly */
2309 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2311 memset(&actctx
, 0, sizeof(ACTCTXA
));
2312 actctx
.cbSize
= sizeof(ACTCTXA
);
2313 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2314 actctx
.lpAssemblyDirectory
= dir
;
2315 actctx
.lpSource
= path
;
2317 SetLastError(0xdeadbeef);
2318 handle
= pCreateActCtxA(&actctx
);
2320 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2321 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2323 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2325 delete_manifest_file("main_wndcls.manifest");
2326 delete_manifest_file("testdep1.manifest");
2327 delete_manifest_file("testdep2.manifest");
2329 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2330 memset(&actctx
, 0, sizeof(ACTCTXA
));
2331 actctx
.cbSize
= sizeof(ACTCTXA
);
2332 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2333 SetLastError(0xdeadbeef);
2334 handle
= pCreateActCtxA(&actctx
);
2335 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2337 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2338 "got error %d\n", GetLastError());
2340 /* create from HMODULE - resource doesn't exist, lpSource is set */
2341 memset(&actctx
, 0, sizeof(ACTCTXA
));
2342 actctx
.cbSize
= sizeof(ACTCTXA
);
2343 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2344 actctx
.lpSource
= "dummyfile.dll";
2345 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2346 actctx
.hModule
= GetModuleHandleA(NULL
);
2348 SetLastError(0xdeadbeef);
2349 handle
= pCreateActCtxA(&actctx
);
2350 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2351 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2353 /* load manifest from lpAssemblyDirectory directory */
2354 write_manifest("testdir.manifest", manifest1
);
2355 GetTempPathA(sizeof(path
)/sizeof(path
[0]), path
);
2356 SetCurrentDirectoryA(path
);
2357 strcat(path
, "assembly_dir");
2359 strcat(path
, "\\testdir.manifest");
2361 memset(&actctx
, 0, sizeof(actctx
));
2362 actctx
.cbSize
= sizeof(actctx
);
2363 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2364 actctx
.lpSource
= "testdir.manifest";
2365 actctx
.lpAssemblyDirectory
= dir
;
2367 SetLastError(0xdeadbeef);
2368 handle
= pCreateActCtxA(&actctx
);
2369 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2370 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2371 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2372 "got error %d\n", GetLastError());
2374 CreateDirectoryA(dir
, NULL
);
2375 memset(&actctx
, 0, sizeof(actctx
));
2376 actctx
.cbSize
= sizeof(actctx
);
2377 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2378 actctx
.lpSource
= "testdir.manifest";
2379 actctx
.lpAssemblyDirectory
= dir
;
2381 SetLastError(0xdeadbeef);
2382 handle
= pCreateActCtxA(&actctx
);
2383 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2384 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %d\n", GetLastError());
2385 SetCurrentDirectoryW(work_dir
);
2387 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
2388 memset(&actctx
, 0, sizeof(actctx
));
2389 actctx
.cbSize
= sizeof(actctx
);
2390 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2391 actctx
.lpSource
= "testdir.manifest";
2392 actctx
.lpAssemblyDirectory
= dir
;
2394 handle
= pCreateActCtxA(&actctx
);
2395 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2396 pReleaseActCtx(handle
);
2398 memset(&actctx
, 0, sizeof(actctx
));
2399 actctx
.cbSize
= sizeof(actctx
);
2400 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2401 actctx
.lpSource
= path
;
2402 actctx
.lpAssemblyDirectory
= dir
;
2404 handle
= pCreateActCtxA(&actctx
);
2405 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2406 pReleaseActCtx(handle
);
2408 delete_manifest_file("testdir.manifest");
2409 delete_manifest_file("assembly_dir\\testdir.manifest");
2410 RemoveDirectoryA(dir
);
2413 static BOOL
init_funcs(void)
2415 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
2417 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2421 X(DeactivateActCtx
);
2422 X(FindActCtxSectionStringA
);
2423 X(FindActCtxSectionStringW
);
2424 X(GetCurrentActCtx
);
2425 X(IsDebuggerPresent
);
2428 X(FindActCtxSectionGuid
);
2431 hLibrary
= GetModuleHandleA("ntdll.dll");
2432 X(RtlFindActivationContextSectionString
);
2433 X(RtlCreateUnicodeStringFromAsciiz
);
2434 X(RtlFreeUnicodeString
);
2440 static void test_ZombifyActCtx(void)
2442 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
2444 HANDLE handle
, current
;
2447 SetLastError(0xdeadbeef);
2448 ret
= pZombifyActCtx(NULL
);
2450 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "got %d, error %d\n", ret
, GetLastError());
2452 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2454 ret
= pGetCurrentActCtx(¤t
);
2455 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2456 ok(current
== NULL
, "got %p\n", current
);
2458 ret
= pActivateActCtx(handle
, &cookie
);
2459 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2461 ret
= pGetCurrentActCtx(¤t
);
2462 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2463 ok(handle
== current
, "got %p, %p\n", current
, handle
);
2465 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2466 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2467 &basicinfo
, sizeof(basicinfo
), NULL
);
2468 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2469 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2470 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2472 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2473 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2474 &basicinfo
, sizeof(basicinfo
), NULL
);
2475 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2476 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2477 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2479 ret
= pZombifyActCtx(handle
);
2481 ok(ret
, "got %d\n", ret
);
2483 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2484 ret
= pQueryActCtxW(0, handle
, 0, ActivationContextBasicInformation
,
2485 &basicinfo
, sizeof(basicinfo
), NULL
);
2486 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2487 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2488 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2490 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
2491 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, NULL
, 0, ActivationContextBasicInformation
,
2492 &basicinfo
, sizeof(basicinfo
), NULL
);
2493 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2494 ok(basicinfo
.hActCtx
== handle
, "got %p\n", basicinfo
.hActCtx
);
2495 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
2497 ret
= pGetCurrentActCtx(¤t
);
2498 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
2499 ok(current
== handle
, "got %p\n", current
);
2502 ret
= pZombifyActCtx(handle
);
2504 ok(ret
, "got %d\n", ret
);
2506 ret
= pDeactivateActCtx(0, cookie
);
2507 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2508 pReleaseActCtx(handle
);
2516 argc
= winetest_get_mainargs(&argv
);
2520 win_skip("Needed functions are not available\n");
2525 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2526 test_app_manifest();
2531 test_CreateActCtx();
2532 test_findsectionstring();
2533 test_ZombifyActCtx();
2534 run_child_process();