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
);
44 static NTSTATUS(NTAPI
*pRtlFindActivationContextSectionString
)(DWORD
,const GUID
*,ULONG
,PUNICODE_STRING
,PACTCTX_SECTION_KEYED_DATA
);
45 static BOOLEAN (NTAPI
*pRtlCreateUnicodeStringFromAsciiz
)(PUNICODE_STRING
, PCSZ
);
46 static VOID (NTAPI
*pRtlFreeUnicodeString
)(PUNICODE_STRING
);
48 static const char* strw(LPCWSTR x
)
50 static char buffer
[1024];
53 if (!x
) return "(nil)";
54 else while ((*p
++ = *x
++));
60 #elif defined __x86_64__
64 #elif defined __aarch64__
70 static const char manifest1
[] =
71 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
72 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
75 static const char manifest1_1
[] =
76 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
77 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
80 static const char manifest2
[] =
81 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
82 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
86 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\">"
88 "</dependentAssembly>"
92 DEFINE_GUID(IID_CoTest
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
93 DEFINE_GUID(IID_CoTest2
, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
94 DEFINE_GUID(CLSID_clrclass
,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
95 DEFINE_GUID(IID_TlibTest
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
96 DEFINE_GUID(IID_TlibTest2
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
97 DEFINE_GUID(IID_TlibTest3
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
98 DEFINE_GUID(IID_TlibTest4
, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
99 DEFINE_GUID(IID_Iifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
100 DEFINE_GUID(IID_Ibifaceps
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
101 DEFINE_GUID(IID_Iifaceps2
, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
102 DEFINE_GUID(IID_Iifaceps3
, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
103 DEFINE_GUID(IID_Iiface
, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
104 DEFINE_GUID(IID_PS32
, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
106 static const char manifest3
[] =
107 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
108 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
109 " publicKeyToken=\"6595b6414666f1df\" />"
111 "<file name=\"testlib.dll\">"
112 "<windowClass>wndClass</windowClass>"
113 " <comClass description=\"Test com class\""
114 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
115 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
116 " threadingModel=\"Neutral\""
117 " progid=\"ProgId.ProgId\""
118 " miscStatus=\"cantlinkinside\""
119 " miscStatusIcon=\"recomposeonresize\""
120 " miscStatusContent=\"insideout\""
121 " miscStatusThumbnail=\"alignable\""
122 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
124 " <progid>ProgId.ProgId.1</progid>"
125 " <progid>ProgId.ProgId.2</progid>"
126 " <progid>ProgId.ProgId.3</progid>"
127 " <progid>ProgId.ProgId.4</progid>"
128 " <progid>ProgId.ProgId.5</progid>"
129 " <progid>ProgId.ProgId.6</progid>"
131 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
132 " <progid>ProgId.ProgId.7</progid>"
134 " <comInterfaceProxyStub "
136 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
137 " iid=\"{66666666-8888-7777-6666-555555555555}\""
138 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
139 " threadingModel=\"Free\""
141 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
144 " <comInterfaceExternalProxyStub "
145 " name=\"Iifaceps2\""
146 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
147 " iid=\"{76666666-8888-7777-6666-555555555555}\""
148 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
150 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
152 " <comInterfaceExternalProxyStub "
153 " name=\"Iifaceps3\""
154 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
155 " iid=\"{86666666-8888-7777-6666-555555555555}\""
157 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
160 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
161 " name=\"testsurrogate\""
162 " runtimeVersion=\"v2.0.50727\""
165 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
167 " progid=\"clrprogid\""
168 " description=\"test description\""
169 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
170 " runtimeVersion=\"1.2.3.4\""
171 " threadingModel=\"Neutral\""
173 " <progid>clrprogid.1</progid>"
174 " <progid>clrprogid.2</progid>"
175 " <progid>clrprogid.3</progid>"
176 " <progid>clrprogid.4</progid>"
177 " <progid>clrprogid.5</progid>"
178 " <progid>clrprogid.6</progid>"
182 static const char manifest_wndcls1
[] =
183 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
184 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
185 "<file name=\"testlib1.dll\">"
186 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
187 "<windowClass>wndClass2</windowClass>"
188 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
190 "<file name=\"testlib1_2.dll\" />"
193 static const char manifest_wndcls2
[] =
194 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
195 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH
"\" />"
196 "<file name=\"testlib2.dll\">"
197 " <windowClass versioned=\"no\">wndClass3</windowClass>"
198 " <windowClass>wndClass4</windowClass>"
199 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
200 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
201 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
202 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
204 "<file name=\"testlib2_2.dll\" />"
207 static const char manifest_wndcls_main
[] =
208 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
209 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
211 " <dependentAssembly>"
212 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
213 " </dependentAssembly>"
216 " <dependentAssembly>"
217 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH
"\" />"
218 " </dependentAssembly>"
222 static const char manifest4
[] =
223 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
224 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
225 "</assemblyIdentity>"
227 "<dependentAssembly>"
228 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
229 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH
"\" publicKeyToken=\"6595b64144ccf1df\">"
230 "</assemblyIdentity>"
231 "</dependentAssembly>"
235 static const char manifest5
[] =
236 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
237 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
238 "</assemblyIdentity>"
240 " <dependentAssembly dependencyType=\"preRequisite\" allowDelayedBinding=\"true\">"
241 " <assemblyIdentity name=\"Missing.Assembly\" version=\"1.0.0.0\" />"
242 " </dependentAssembly>"
246 static const char testdep_manifest1
[] =
247 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
248 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
251 static const char testdep_manifest2
[] =
252 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
253 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
254 "<file name=\"testlib.dll\"></file>"
255 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
258 static const char testdep_manifest3
[] =
259 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
260 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\"/>"
261 "<file name=\"testlib.dll\"/>"
262 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
263 "<windowClass>wndClass</windowClass>"
264 "<windowClass>wndClass2</windowClass>"
268 static const char wrong_manifest1
[] =
269 "<assembly manifestVersion=\"1.0\">"
270 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
273 static const char wrong_manifest2
[] =
274 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
275 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
278 static const char wrong_manifest3
[] =
279 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
280 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
283 static const char wrong_manifest4
[] =
284 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
285 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
289 static const char wrong_manifest5
[] =
290 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
291 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
295 static const char wrong_manifest6
[] =
296 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
297 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
300 static const char wrong_manifest7
[] =
301 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
302 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH
"\" />"
303 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
306 static const char wrong_manifest8
[] =
307 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
308 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
312 static const char wrong_depmanifest1
[] =
313 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
314 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH
"\" />"
317 static const WCHAR testlib_dll
[] =
318 {'t','e','s','t','l','i','b','.','d','l','l',0};
319 static const WCHAR testlib2_dll
[] =
320 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
321 static const WCHAR wndClassW
[] =
322 {'w','n','d','C','l','a','s','s',0};
323 static const WCHAR wndClass1W
[] =
324 {'w','n','d','C','l','a','s','s','1',0};
325 static const WCHAR wndClass2W
[] =
326 {'w','n','d','C','l','a','s','s','2',0};
327 static const WCHAR wndClass3W
[] =
328 {'w','n','d','C','l','a','s','s','3',0};
330 static WCHAR app_dir
[MAX_PATH
], exe_path
[MAX_PATH
], work_dir
[MAX_PATH
], work_dir_subdir
[MAX_PATH
];
331 static WCHAR app_manifest_path
[MAX_PATH
], manifest_path
[MAX_PATH
], depmanifest_path
[MAX_PATH
];
333 static int strcmp_aw(LPCWSTR strw
, const char *stra
)
338 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
339 return lstrcmpW(strw
, buf
);
342 static DWORD
strlen_aw(const char *str
)
344 return MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0) - 1;
347 static BOOL
create_manifest_file(const char *filename
, const char *manifest
, int manifest_len
,
348 const char *depfile
, const char *depmanifest
)
352 WCHAR path
[MAX_PATH
];
354 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
355 GetFullPathNameW(path
, sizeof(manifest_path
)/sizeof(WCHAR
), manifest_path
, NULL
);
357 if (manifest_len
== -1)
358 manifest_len
= strlen(manifest
);
360 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
361 FILE_ATTRIBUTE_NORMAL
, NULL
);
362 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
363 if(file
== INVALID_HANDLE_VALUE
)
365 WriteFile(file
, manifest
, manifest_len
, &size
, NULL
);
370 MultiByteToWideChar( CP_ACP
, 0, depfile
, -1, path
, MAX_PATH
);
371 GetFullPathNameW(path
, sizeof(depmanifest_path
)/sizeof(WCHAR
), depmanifest_path
, NULL
);
372 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
373 FILE_ATTRIBUTE_NORMAL
, NULL
);
374 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
375 if(file
== INVALID_HANDLE_VALUE
)
377 WriteFile(file
, depmanifest
, strlen(depmanifest
), &size
, NULL
);
383 static BOOL
create_wide_manifest(const char *filename
, const char *manifest
, BOOL fBOM
, BOOL fReverse
)
385 WCHAR
*wmanifest
= HeapAlloc(GetProcessHeap(), 0, (strlen(manifest
)+2) * sizeof(WCHAR
));
387 int offset
= (fBOM
? 0 : 1);
389 MultiByteToWideChar(CP_ACP
, 0, manifest
, -1, &wmanifest
[1], (strlen(manifest
)+1));
390 wmanifest
[0] = 0xfeff;
394 for (i
= 0; i
< strlen(manifest
)+1; i
++)
395 wmanifest
[i
] = (wmanifest
[i
] << 8) | ((wmanifest
[i
] >> 8) & 0xff);
397 ret
= create_manifest_file(filename
, (char *)&wmanifest
[offset
], (strlen(manifest
)+1-offset
) * sizeof(WCHAR
), NULL
, NULL
);
398 HeapFree(GetProcessHeap(), 0, wmanifest
);
403 ULONG format_version
;
404 ULONG assembly_cnt_min
;
405 ULONG assembly_cnt_max
;
406 ULONG root_manifest_type
;
407 LPWSTR root_manifest_path
;
408 ULONG root_config_type
;
413 static const detailed_info_t detailed_info0
= {
414 0, 0, 0, 0, NULL
, 0, 0, NULL
417 static const detailed_info_t detailed_info1
= {
418 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
419 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
423 static const detailed_info_t detailed_info1_child
= {
424 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, app_manifest_path
,
425 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
429 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
430 static const detailed_info_t detailed_info2
= {
431 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
, manifest_path
,
432 ACTIVATION_CONTEXT_PATH_TYPE_NONE
, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
436 static void test_detailed_info(HANDLE handle
, const detailed_info_t
*exinfo
, int line
)
438 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp
, *detailed_info
;
439 SIZE_T size
, exsize
, retsize
;
442 exsize
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)
443 + (exinfo
->root_manifest_path
? (lstrlenW(exinfo
->root_manifest_path
)+1)*sizeof(WCHAR
):0)
444 + (exinfo
->app_dir
? (lstrlenW(exinfo
->app_dir
)+1)*sizeof(WCHAR
) : 0);
446 if(exsize
!= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
)) {
448 b
= pQueryActCtxW(0, handle
, NULL
,
449 ActivationContextDetailedInformation
, &detailed_info_tmp
,
450 sizeof(detailed_info_tmp
), &size
);
451 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
452 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
453 ok_(__FILE__
, line
)(size
== exsize
, "size=%ld, expected %ld\n", size
, exsize
);
455 size
= sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION
);
458 detailed_info
= HeapAlloc(GetProcessHeap(), 0, size
);
459 memset(detailed_info
, 0xfe, size
);
460 b
= pQueryActCtxW(0, handle
, NULL
,
461 ActivationContextDetailedInformation
, detailed_info
,
463 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
464 ok_(__FILE__
, line
)(retsize
== exsize
, "size=%ld, expected %ld\n", retsize
, exsize
);
466 ok_(__FILE__
, line
)(detailed_info
->dwFlags
== 0, "detailed_info->dwFlags=%x\n", detailed_info
->dwFlags
);
467 ok_(__FILE__
, line
)(detailed_info
->ulFormatVersion
== exinfo
->format_version
,
468 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info
->ulFormatVersion
,
469 exinfo
->format_version
);
470 ok_(__FILE__
, line
)(exinfo
->assembly_cnt_min
<= detailed_info
->ulAssemblyCount
&&
471 detailed_info
->ulAssemblyCount
<= exinfo
->assembly_cnt_max
,
472 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info
->ulAssemblyCount
,
473 exinfo
->assembly_cnt_min
, exinfo
->assembly_cnt_max
);
474 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathType
== exinfo
->root_manifest_type
,
475 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
476 detailed_info
->ulRootManifestPathType
, exinfo
->root_manifest_type
);
477 ok_(__FILE__
, line
)(detailed_info
->ulRootManifestPathChars
==
478 (exinfo
->root_manifest_path
? lstrlenW(exinfo
->root_manifest_path
) : 0),
479 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
480 detailed_info
->ulRootManifestPathChars
,
481 exinfo
->root_manifest_path
?lstrlenW(exinfo
->root_manifest_path
) : 0);
482 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathType
== exinfo
->root_config_type
,
483 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
484 detailed_info
->ulRootConfigurationPathType
, exinfo
->root_config_type
);
485 ok_(__FILE__
, line
)(detailed_info
->ulRootConfigurationPathChars
== 0,
486 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info
->ulRootConfigurationPathChars
);
487 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathType
== exinfo
->app_dir_type
,
488 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info
->ulAppDirPathType
,
489 exinfo
->app_dir_type
);
490 ok_(__FILE__
, line
)(detailed_info
->ulAppDirPathChars
== (exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0),
491 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
492 detailed_info
->ulAppDirPathChars
, exinfo
->app_dir
? lstrlenW(exinfo
->app_dir
) : 0);
493 if(exinfo
->root_manifest_path
) {
494 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
!= NULL
, "detailed_info->lpRootManifestPath == NULL\n");
495 if(detailed_info
->lpRootManifestPath
)
496 ok_(__FILE__
, line
)(!lstrcmpiW(detailed_info
->lpRootManifestPath
, exinfo
->root_manifest_path
),
497 "unexpected detailed_info->lpRootManifestPath\n");
499 ok_(__FILE__
, line
)(detailed_info
->lpRootManifestPath
== NULL
, "detailed_info->lpRootManifestPath != NULL\n");
501 ok_(__FILE__
, line
)(detailed_info
->lpRootConfigurationPath
== NULL
,
502 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info
->lpRootConfigurationPath
);
503 if(exinfo
->app_dir
) {
504 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
!= NULL
, "detailed_info->lpAppDirPath == NULL\n");
505 if(detailed_info
->lpAppDirPath
)
506 ok_(__FILE__
, line
)(!lstrcmpiW(exinfo
->app_dir
, detailed_info
->lpAppDirPath
),
507 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info
->lpAppDirPath
));
509 ok_(__FILE__
, line
)(detailed_info
->lpAppDirPath
== NULL
, "detailed_info->lpAppDirPath != NULL\n");
512 HeapFree(GetProcessHeap(), 0, detailed_info
);
517 /* ULONG manifest_path_type; FIXME */
518 LPCWSTR manifest_path
;
519 LPCSTR encoded_assembly_id
;
520 BOOL has_assembly_dir
;
523 static const info_in_assembly manifest1_info
= {
525 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
529 static const info_in_assembly manifest1_child_info
= {
530 1, app_manifest_path
,
531 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
535 static const info_in_assembly manifest2_info
= {
537 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
541 static const info_in_assembly manifest3_info
= {
543 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
547 static const info_in_assembly manifest4_info
= {
549 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
553 static const info_in_assembly depmanifest1_info
= {
554 0x10, depmanifest_path
,
555 "testdep,processorArchitecture=\"" ARCH
"\","
556 "type=\"win32\",version=\"6.5.4.3\"",
560 static const info_in_assembly depmanifest2_info
= {
561 0x10, depmanifest_path
,
562 "testdep,processorArchitecture=\"" ARCH
"\","
563 "type=\"win32\",version=\"6.5.4.3\"",
567 static const info_in_assembly depmanifest3_info
= {
568 0x10, depmanifest_path
,
569 "testdep,processorArchitecture=\"" ARCH
"\",type=\"win32\",version=\"6.5.4.3\"",
573 static const info_in_assembly manifest_comctrl_info
= {
574 0, NULL
, NULL
, TRUE
/* These values may differ between Windows installations */
577 static void test_info_in_assembly(HANDLE handle
, DWORD id
, const info_in_assembly
*exinfo
, int line
)
579 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
*info
, info_tmp
;
584 exsize
= sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
);
585 if (exinfo
->manifest_path
) exsize
+= (lstrlenW(exinfo
->manifest_path
)+1) * sizeof(WCHAR
);
586 if (exinfo
->encoded_assembly_id
) exsize
+= (strlen_aw(exinfo
->encoded_assembly_id
) + 1) * sizeof(WCHAR
);
589 b
= pQueryActCtxW(0, handle
, &id
,
590 AssemblyDetailedInformationInActivationContext
, &info_tmp
,
591 sizeof(info_tmp
), &size
);
592 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
593 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
595 ok_(__FILE__
, line
)(size
>= exsize
, "size=%lu, expected %lu\n", size
, exsize
);
597 if (size
== 0xdeadbeef)
603 info
= HeapAlloc(GetProcessHeap(), 0, size
);
604 memset(info
, 0xfe, size
);
607 b
= pQueryActCtxW(0, handle
, &id
,
608 AssemblyDetailedInformationInActivationContext
, info
, size
, &size
);
609 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
610 if (!exinfo
->manifest_path
)
611 exsize
+= info
->ulManifestPathLength
+ sizeof(WCHAR
);
612 if (!exinfo
->encoded_assembly_id
)
613 exsize
+= info
->ulEncodedAssemblyIdentityLength
+ sizeof(WCHAR
);
614 if (exinfo
->has_assembly_dir
)
615 exsize
+= info
->ulAssemblyDirectoryNameLength
+ sizeof(WCHAR
);
616 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
618 if (0) /* FIXME: flags meaning unknown */
620 ok_(__FILE__
, line
)((info
->ulFlags
) == exinfo
->flags
, "info->ulFlags = %x, expected %x\n",
621 info
->ulFlags
, exinfo
->flags
);
623 if(exinfo
->encoded_assembly_id
) {
624 len
= strlen_aw(exinfo
->encoded_assembly_id
)*sizeof(WCHAR
);
625 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
== len
,
626 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
627 info
->ulEncodedAssemblyIdentityLength
, len
);
629 ok_(__FILE__
, line
)(info
->ulEncodedAssemblyIdentityLength
!= 0,
630 "info->ulEncodedAssemblyIdentityLength == 0\n");
632 ok_(__FILE__
, line
)(info
->ulManifestPathType
== ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE
,
633 "info->ulManifestPathType = %x\n", info
->ulManifestPathType
);
634 if(exinfo
->manifest_path
) {
635 len
= lstrlenW(exinfo
->manifest_path
)*sizeof(WCHAR
);
636 ok_(__FILE__
, line
)(info
->ulManifestPathLength
== len
, "info->ulManifestPathLength = %u, expected %u\n",
637 info
->ulManifestPathLength
, len
);
639 ok_(__FILE__
, line
)(info
->ulManifestPathLength
!= 0, "info->ulManifestPathLength == 0\n");
642 ok_(__FILE__
, line
)(info
->ulPolicyPathType
== ACTIVATION_CONTEXT_PATH_TYPE_NONE
,
643 "info->ulPolicyPathType = %x\n", info
->ulPolicyPathType
);
644 ok_(__FILE__
, line
)(info
->ulPolicyPathLength
== 0,
645 "info->ulPolicyPathLength = %u, expected 0\n", info
->ulPolicyPathLength
);
646 ok_(__FILE__
, line
)(info
->ulMetadataSatelliteRosterIndex
== 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
647 info
->ulMetadataSatelliteRosterIndex
);
648 ok_(__FILE__
, line
)(info
->ulManifestVersionMajor
== 1,"info->ulManifestVersionMajor = %x\n",
649 info
->ulManifestVersionMajor
);
650 ok_(__FILE__
, line
)(info
->ulManifestVersionMinor
== 0, "info->ulManifestVersionMinor = %x\n",
651 info
->ulManifestVersionMinor
);
652 ok_(__FILE__
, line
)(info
->ulPolicyVersionMajor
== 0, "info->ulPolicyVersionMajor = %x\n",
653 info
->ulPolicyVersionMajor
);
654 ok_(__FILE__
, line
)(info
->ulPolicyVersionMinor
== 0, "info->ulPolicyVersionMinor = %x\n",
655 info
->ulPolicyVersionMinor
);
656 if(exinfo
->has_assembly_dir
)
657 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
!= 0,
658 "info->ulAssemblyDirectoryNameLength == 0\n");
660 ok_(__FILE__
, line
)(info
->ulAssemblyDirectoryNameLength
== 0,
661 "info->ulAssemblyDirectoryNameLength != 0\n");
663 ok_(__FILE__
, line
)(info
->lpAssemblyEncodedAssemblyIdentity
!= NULL
,
664 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
665 if(info
->lpAssemblyEncodedAssemblyIdentity
&& exinfo
->encoded_assembly_id
) {
666 ok_(__FILE__
, line
)(!strcmp_aw(info
->lpAssemblyEncodedAssemblyIdentity
, exinfo
->encoded_assembly_id
),
667 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
668 strw(info
->lpAssemblyEncodedAssemblyIdentity
), exinfo
->encoded_assembly_id
);
670 if(exinfo
->manifest_path
) {
671 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
672 if(info
->lpAssemblyManifestPath
)
673 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpAssemblyManifestPath
, exinfo
->manifest_path
),
674 "unexpected info->lpAssemblyManifestPath\n");
676 ok_(__FILE__
, line
)(info
->lpAssemblyManifestPath
!= NULL
, "info->lpAssemblyManifestPath == NULL\n");
679 ok_(__FILE__
, line
)(info
->lpAssemblyPolicyPath
== NULL
, "info->lpAssemblyPolicyPath != NULL\n");
680 if(info
->lpAssemblyPolicyPath
)
681 ok_(__FILE__
, line
)(*(WORD
*)info
->lpAssemblyPolicyPath
== 0, "info->lpAssemblyPolicyPath is not empty\n");
682 if(exinfo
->has_assembly_dir
)
683 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
!= NULL
, "info->lpAssemblyDirectoryName == NULL\n");
685 ok_(__FILE__
, line
)(info
->lpAssemblyDirectoryName
== NULL
, "info->lpAssemblyDirectoryName = %s\n",
686 strw(info
->lpAssemblyDirectoryName
));
687 HeapFree(GetProcessHeap(), 0, info
);
690 static void test_file_info(HANDLE handle
, ULONG assid
, ULONG fileid
, LPCWSTR filename
, int line
)
692 ASSEMBLY_FILE_DETAILED_INFORMATION
*info
, info_tmp
;
693 ACTIVATION_CONTEXT_QUERY_INDEX index
= {assid
, fileid
};
697 exsize
= sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION
)
698 +(lstrlenW(filename
)+1)*sizeof(WCHAR
);
701 b
= pQueryActCtxW(0, handle
, &index
,
702 FileInformationInAssemblyOfAssemblyInActivationContext
, &info_tmp
,
703 sizeof(info_tmp
), &size
);
704 ok_(__FILE__
, line
)(!b
, "QueryActCtx succeeded\n");
705 ok_(__FILE__
, line
)(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %u\n", GetLastError());
706 ok_(__FILE__
, line
)(size
== exsize
, "size=%lu, expected %lu\n", size
, exsize
);
708 if(size
== 0xdeadbeef)
714 info
= HeapAlloc(GetProcessHeap(), 0, size
);
715 memset(info
, 0xfe, size
);
717 b
= pQueryActCtxW(0, handle
, &index
,
718 FileInformationInAssemblyOfAssemblyInActivationContext
, info
, size
, &size
);
719 ok_(__FILE__
, line
)(b
, "QueryActCtx failed: %u\n", GetLastError());
720 ok_(__FILE__
, line
)(!size
, "size=%lu, expected 0\n", size
);
722 ok_(__FILE__
, line
)(info
->ulFlags
== 2, "info->ulFlags=%x, expected 2\n", info
->ulFlags
);
723 ok_(__FILE__
, line
)(info
->ulFilenameLength
== lstrlenW(filename
)*sizeof(WCHAR
),
724 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
725 info
->ulFilenameLength
, lstrlenW(filename
));
726 ok_(__FILE__
, line
)(info
->ulPathLength
== 0, "info->ulPathLength=%u\n", info
->ulPathLength
);
727 ok_(__FILE__
, line
)(info
->lpFileName
!= NULL
, "info->lpFileName == NULL\n");
729 ok_(__FILE__
, line
)(!lstrcmpiW(info
->lpFileName
, filename
), "unexpected info->lpFileName\n");
730 ok_(__FILE__
, line
)(info
->lpFilePath
== NULL
, "info->lpFilePath != NULL\n");
731 HeapFree(GetProcessHeap(), 0, info
);
734 static HANDLE
test_create(const char *file
)
738 WCHAR path
[MAX_PATH
];
740 MultiByteToWideChar( CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
741 memset(&actctx
, 0, sizeof(ACTCTXW
));
742 actctx
.cbSize
= sizeof(ACTCTXW
);
743 actctx
.lpSource
= path
;
745 handle
= pCreateActCtxW(&actctx
);
746 /* to be tested outside of this helper, including last error */
747 if (handle
== INVALID_HANDLE_VALUE
) return handle
;
749 ok(actctx
.cbSize
== sizeof(actctx
), "actctx.cbSize=%d\n", actctx
.cbSize
);
750 ok(actctx
.dwFlags
== 0, "actctx.dwFlags=%d\n", actctx
.dwFlags
);
751 ok(actctx
.lpSource
== path
, "actctx.lpSource=%p\n", actctx
.lpSource
);
752 ok(actctx
.wProcessorArchitecture
== 0,
753 "actctx.wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
754 ok(actctx
.wLangId
== 0, "actctx.wLangId=%d\n", actctx
.wLangId
);
755 ok(actctx
.lpAssemblyDirectory
== NULL
,
756 "actctx.lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
757 ok(actctx
.lpResourceName
== NULL
, "actctx.lpResourceName=%p\n", actctx
.lpResourceName
);
758 ok(actctx
.lpApplicationName
== NULL
, "actctx.lpApplicationName=%p\n",
759 actctx
.lpApplicationName
);
760 ok(actctx
.hModule
== NULL
, "actctx.hModule=%p\n", actctx
.hModule
);
765 static void test_create_and_fail(const char *manifest
, const char *depmanifest
, int todo
)
769 WCHAR path
[MAX_PATH
];
771 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
772 memset(&actctx
, 0, sizeof(ACTCTXW
));
773 actctx
.cbSize
= sizeof(ACTCTXW
);
774 actctx
.lpSource
= path
;
776 create_manifest_file("bad.manifest", manifest
, -1, "testdep.manifest", depmanifest
);
777 handle
= pCreateActCtxW(&actctx
);
780 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
781 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
785 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
786 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
788 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
789 DeleteFileA("bad.manifest");
790 DeleteFileA("testdep.manifest");
793 static void test_create_wide_and_fail(const char *manifest
, BOOL fBOM
)
797 WCHAR path
[MAX_PATH
];
799 MultiByteToWideChar( CP_ACP
, 0, "bad.manifest", -1, path
, MAX_PATH
);
800 memset(&actctx
, 0, sizeof(ACTCTXW
));
801 actctx
.cbSize
= sizeof(ACTCTXW
);
802 actctx
.lpSource
= path
;
804 create_wide_manifest("bad.manifest", manifest
, fBOM
, FALSE
);
805 handle
= pCreateActCtxW(&actctx
);
806 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
807 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "GetLastError == %u\n", GetLastError());
809 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx( handle
);
810 DeleteFileA("bad.manifest");
813 static void test_create_fail(void)
817 WCHAR path
[MAX_PATH
];
819 MultiByteToWideChar( CP_ACP
, 0, "nonexistent.manifest", -1, path
, MAX_PATH
);
820 memset(&actctx
, 0, sizeof(ACTCTXW
));
821 actctx
.cbSize
= sizeof(ACTCTXW
);
822 actctx
.lpSource
= path
;
824 handle
= pCreateActCtxW(&actctx
);
825 ok(handle
== INVALID_HANDLE_VALUE
, "handle != INVALID_HANDLE_VALUE\n");
826 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError == %u\n", GetLastError());
828 trace("wrong_manifest1\n");
829 test_create_and_fail(wrong_manifest1
, NULL
, 0 );
830 trace("wrong_manifest2\n");
831 test_create_and_fail(wrong_manifest2
, NULL
, 0 );
832 trace("wrong_manifest3\n");
833 test_create_and_fail(wrong_manifest3
, NULL
, 1 );
834 trace("wrong_manifest4\n");
835 test_create_and_fail(wrong_manifest4
, NULL
, 1 );
836 trace("wrong_manifest5\n");
837 test_create_and_fail(wrong_manifest5
, NULL
, 0 );
838 trace("wrong_manifest6\n");
839 test_create_and_fail(wrong_manifest6
, NULL
, 0 );
840 trace("wrong_manifest7\n");
841 test_create_and_fail(wrong_manifest7
, NULL
, 1 );
842 trace("wrong_manifest8\n");
843 test_create_and_fail(wrong_manifest8
, NULL
, 0 );
844 trace("UTF-16 manifest1 without BOM\n");
845 test_create_wide_and_fail(manifest1
, FALSE
);
846 trace("manifest2\n");
847 test_create_and_fail(manifest2
, NULL
, 0 );
848 trace("manifest2+depmanifest1\n");
849 test_create_and_fail(manifest2
, wrong_depmanifest1
, 0 );
852 struct strsection_header
874 struct guidsection_header
894 struct wndclass_redirect_data
899 ULONG name_offset
; /* versioned name offset */
901 ULONG module_offset
;/* container name offset */
904 struct dllredirect_data
911 struct tlibredirect_data
925 struct progidredirect_data
932 static void test_find_dll_redirection(HANDLE handle
, LPCWSTR libname
, ULONG exid
, int line
)
934 ACTCTX_SECTION_KEYED_DATA data
;
937 memset(&data
, 0xfe, sizeof(data
));
938 data
.cbSize
= sizeof(data
);
940 ret
= pFindActCtxSectionStringW(0, NULL
,
941 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
943 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
946 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
947 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
948 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
949 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
953 struct dllredirect_data
*dlldata
= (struct dllredirect_data
*)data
.lpData
;
954 ok_(__FILE__
, line
)(dlldata
->size
== data
.ulLength
, "got wrong size %d\n", dlldata
->size
);
955 ok_(__FILE__
, line
)(dlldata
->unk
== 2, "got wrong field value %d\n", dlldata
->unk
);
956 ok_(__FILE__
, line
)(dlldata
->res
[0] == 0, "got wrong res[0] value %d\n", dlldata
->res
[0]);
957 ok_(__FILE__
, line
)(dlldata
->res
[1] == 0, "got wrong res[1] value %d\n", dlldata
->res
[1]);
958 ok_(__FILE__
, line
)(dlldata
->res
[2] == 0, "got wrong res[2] value %d\n", dlldata
->res
[2]);
961 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
962 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
963 data
.ulSectionGlobalDataLength
);
964 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
965 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
966 data
.ulSectionTotalLength
);
967 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
968 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
969 data
.ulAssemblyRosterIndex
, exid
);
971 memset(&data
, 0xfe, sizeof(data
));
972 data
.cbSize
= sizeof(data
);
974 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
975 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
977 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u\n", GetLastError());
980 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
981 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
982 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
983 ok_(__FILE__
, line
)(data
.ulLength
== 20, "data.ulLength=%u\n", data
.ulLength
);
984 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
985 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
986 data
.ulSectionGlobalDataLength
);
987 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
988 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
989 data
.ulSectionTotalLength
);
990 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
991 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
992 data
.ulAssemblyRosterIndex
, exid
);
994 pReleaseActCtx(handle
);
997 static void test_find_window_class(HANDLE handle
, LPCWSTR clsname
, ULONG exid
, int line
)
999 struct wndclass_redirect_data
*wnddata
;
1000 struct strsection_header
*header
;
1001 ACTCTX_SECTION_KEYED_DATA data
;
1004 memset(&data
, 0xfe, sizeof(data
));
1005 data
.cbSize
= sizeof(data
);
1007 ret
= pFindActCtxSectionStringW(0, NULL
,
1008 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1010 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1011 wine_dbgstr_w(clsname
));
1014 header
= (struct strsection_header
*)data
.lpSectionBase
;
1015 wnddata
= (struct wndclass_redirect_data
*)data
.lpData
;
1017 ok_(__FILE__
, line
)(header
->magic
== 0x64487353, "got wrong magic 0x%08x\n", header
->magic
);
1018 ok_(__FILE__
, line
)(header
->count
> 0, "got count %d\n", header
->count
);
1019 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1020 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1021 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1022 ok_(__FILE__
, line
)(wnddata
->size
== sizeof(*wnddata
), "got %d for header size\n", wnddata
->size
);
1023 if (data
.lpData
&& wnddata
->size
== sizeof(*wnddata
))
1025 static const WCHAR verW
[] = {'6','.','5','.','4','.','3','!',0};
1030 ok_(__FILE__
, line
)(wnddata
->res
== 0, "got reserved as %d\n", wnddata
->res
);
1031 /* redirect class name (versioned or not) is stored just after header data */
1032 ok_(__FILE__
, line
)(wnddata
->name_offset
== wnddata
->size
, "got name offset as %d\n", wnddata
->name_offset
);
1033 ok_(__FILE__
, line
)(wnddata
->module_len
> 0, "got module name length as %d\n", wnddata
->module_len
);
1035 /* expected versioned name */
1036 lstrcpyW(buff
, verW
);
1037 lstrcatW(buff
, clsname
);
1038 ptr
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->name_offset
);
1039 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, buff
), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(buff
));
1040 ok_(__FILE__
, line
)(lstrlenW(ptr
)*sizeof(WCHAR
) == wnddata
->name_len
,
1041 "got wrong class name length %d, expected %d\n", wnddata
->name_len
, lstrlenW(ptr
));
1043 /* data length is simply header length + string data length including nulls */
1044 len
= wnddata
->size
+ wnddata
->name_len
+ wnddata
->module_len
+ 2*sizeof(WCHAR
);
1045 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1047 if (data
.ulSectionTotalLength
> wnddata
->module_offset
)
1049 WCHAR
*modulename
, *sectionptr
;
1051 /* just compare pointers */
1052 modulename
= (WCHAR
*)((BYTE
*)wnddata
+ wnddata
->size
+ wnddata
->name_len
+ sizeof(WCHAR
));
1053 sectionptr
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ wnddata
->module_offset
);
1054 ok_(__FILE__
, line
)(modulename
== sectionptr
, "got wrong name offset %p, expected %p\n", sectionptr
, modulename
);
1058 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1059 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1060 data
.ulSectionGlobalDataLength
);
1061 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1062 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1063 data
.ulSectionTotalLength
);
1064 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1065 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1066 data
.ulAssemblyRosterIndex
, exid
);
1068 memset(&data
, 0xfe, sizeof(data
));
1069 data
.cbSize
= sizeof(data
);
1071 ret
= pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX
, NULL
,
1072 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1074 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1075 wine_dbgstr_w(clsname
));
1078 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1079 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1080 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1081 ok_(__FILE__
, line
)(data
.ulLength
> 0, "data.ulLength=%u\n", data
.ulLength
);
1082 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1083 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1084 data
.ulSectionGlobalDataLength
);
1085 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1086 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1087 ok_(__FILE__
, line
)(data
.hActCtx
== handle
, "data.hActCtx=%p\n", data
.hActCtx
);
1088 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1089 data
.ulAssemblyRosterIndex
, exid
);
1091 pReleaseActCtx(handle
);
1094 static void test_find_string_fail(void)
1096 ACTCTX_SECTION_KEYED_DATA data
= {sizeof(data
)};
1099 ret
= pFindActCtxSectionStringW(0, NULL
, 100, testlib_dll
, &data
);
1100 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1101 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1103 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1104 testlib2_dll
, &data
);
1105 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1106 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND
, "GetLastError()=%u\n", GetLastError());
1108 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1110 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1111 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1113 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1115 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1116 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1119 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1120 testlib_dll
, &data
);
1121 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1122 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1125 ret
= pFindActCtxSectionStringW(0, NULL
, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1126 testlib_dll
, &data
);
1127 ok(!ret
, "FindActCtxSectionStringW succeeded\n");
1128 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError()=%u\n", GetLastError());
1132 static void test_basic_info(HANDLE handle
, int line
)
1134 ACTIVATION_CONTEXT_BASIC_INFORMATION basic
;
1138 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1139 ActivationContextBasicInformation
, &basic
,
1140 sizeof(basic
), &size
);
1142 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1143 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1144 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1145 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1147 b
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
|
1148 QUERY_ACTCTX_FLAG_NO_ADDREF
, handle
, NULL
,
1149 ActivationContextBasicInformation
, &basic
,
1150 sizeof(basic
), &size
);
1153 ok_(__FILE__
, line
) (!b
,"ActivationContextBasicInformation succeeded\n");
1154 ok_(__FILE__
, line
) (size
== 0,"size mismatch\n");
1155 ok_(__FILE__
, line
) (GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong last error\n");
1156 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1157 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1161 ok_(__FILE__
, line
) (b
,"ActivationContextBasicInformation failed\n");
1162 ok_(__FILE__
, line
) (size
== sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION
),"size mismatch\n");
1163 ok_(__FILE__
, line
) (basic
.dwFlags
== 0, "unexpected flags %x\n",basic
.dwFlags
);
1164 ok_(__FILE__
, line
) (basic
.hActCtx
== handle
, "unexpected handle\n");
1168 enum comclass_threadingmodel
{
1169 ThreadingModel_Apartment
= 1,
1170 ThreadingModel_Free
= 2,
1171 ThreadingModel_No
= 3,
1172 ThreadingModel_Both
= 4,
1173 ThreadingModel_Neutral
= 5
1176 enum comclass_miscfields
{
1179 MiscStatusContent
= 4,
1180 MiscStatusThumbnail
= 8,
1181 MiscStatusDocPrint
= 16
1184 struct comclassredirect_data
{
1197 ULONG progid_offset
;
1199 ULONG clrdata_offset
;
1201 DWORD miscstatuscontent
;
1202 DWORD miscstatusthumbnail
;
1203 DWORD miscstatusicon
;
1204 DWORD miscstatusdocprint
;
1207 struct clrclass_data
{
1211 ULONG module_offset
;
1215 ULONG version_offset
;
1219 static void test_find_com_redirection(HANDLE handle
, const GUID
*clsid
, const GUID
*tlid
, const WCHAR
*progid
, ULONG exid
, int line
)
1221 struct comclassredirect_data
*comclass
, *comclass2
;
1222 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1223 struct guidsection_header
*header
;
1226 memset(&data
, 0xfe, sizeof(data
));
1227 data
.cbSize
= sizeof(data
);
1229 ret
= pFindActCtxSectionGuid(0, NULL
,
1230 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1234 skip("failed for guid %s\n", wine_dbgstr_guid(clsid
));
1237 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1239 comclass
= (struct comclassredirect_data
*)data
.lpData
;
1241 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1242 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1243 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1244 ok_(__FILE__
, line
)(comclass
->size
== sizeof(*comclass
), "got %d for header size\n", comclass
->size
);
1245 if (data
.lpData
&& comclass
->size
== sizeof(*comclass
))
1250 ok_(__FILE__
, line
)(comclass
->res
== 0, "got res as %d\n", comclass
->res
);
1251 ok_(__FILE__
, line
)(comclass
->res1
[0] == 0, "got res1[0] as %02x\n", comclass
->res1
[0]);
1252 ok_(__FILE__
, line
)(comclass
->res1
[1] == 0, "got res1[1] as %02x\n", comclass
->res1
[1]);
1253 ok_(__FILE__
, line
)(comclass
->model
== ThreadingModel_Neutral
, "got model %d\n", comclass
->model
);
1254 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass
->clsid
));
1255 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->clsid2
, clsid
), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass
->clsid2
));
1257 ok_(__FILE__
, line
)(IsEqualGUID(&comclass
->tlid
, tlid
), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass
->tlid
));
1258 ok_(__FILE__
, line
)(comclass
->name_len
> 0, "got modulename len %d\n", comclass
->name_len
);
1262 len
= comclass
->size
+ comclass
->clrdata_len
;
1263 ok_(__FILE__
, line
)(comclass
->progid_offset
== len
, "got progid offset %d, expected %d\n", comclass
->progid_offset
, len
);
1266 ok_(__FILE__
, line
)(comclass
->progid_offset
== 0, "got progid offset %d, expected 0\n", comclass
->progid_offset
);
1268 if (comclass
->progid_offset
)
1270 ptr
= (WCHAR
*)((BYTE
*)comclass
+ comclass
->progid_offset
);
1271 ok_(__FILE__
, line
)(!lstrcmpW(ptr
, progid
), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr
), wine_dbgstr_w(progid
));
1272 ok_(__FILE__
, line
)(lstrlenW(progid
)*sizeof(WCHAR
) == comclass
->progid_len
,
1273 "got progid name length %d\n", comclass
->progid_len
);
1276 /* data length is simply header length + string data length including nulls */
1277 len
= comclass
->size
+ comclass
->clrdata_len
;
1278 if (comclass
->progid_len
) len
+= comclass
->progid_len
+ sizeof(WCHAR
);
1279 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1281 /* keyed data structure doesn't include module name, it's available from section data */
1282 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> comclass
->name_offset
, "got wrong offset %d\n", comclass
->name_offset
);
1284 /* check misc fields are set */
1285 if (comclass
->miscmask
)
1287 if (comclass
->miscmask
& MiscStatus
)
1288 ok_(__FILE__
, line
)(comclass
->miscstatus
!= 0, "got miscstatus 0x%08x\n", comclass
->miscstatus
);
1289 if (comclass
->miscmask
& MiscStatusIcon
)
1290 ok_(__FILE__
, line
)(comclass
->miscstatusicon
!= 0, "got miscstatusicon 0x%08x\n", comclass
->miscstatusicon
);
1291 if (comclass
->miscmask
& MiscStatusContent
)
1292 ok_(__FILE__
, line
)(comclass
->miscstatuscontent
!= 0, "got miscstatuscontent 0x%08x\n", comclass
->miscstatuscontent
);
1293 if (comclass
->miscmask
& MiscStatusThumbnail
)
1294 ok_(__FILE__
, line
)(comclass
->miscstatusthumbnail
!= 0, "got miscstatusthumbnail 0x%08x\n", comclass
->miscstatusthumbnail
);
1295 if (comclass
->miscmask
& MiscStatusDocPrint
)
1296 ok_(__FILE__
, line
)(comclass
->miscstatusdocprint
!= 0, "got miscstatusdocprint 0x%08x\n", comclass
->miscstatusdocprint
);
1299 /* part used for clrClass only */
1300 if (comclass
->clrdata_len
)
1302 static const WCHAR mscoreeW
[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1303 static const WCHAR mscoree2W
[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1304 struct clrclass_data
*clrclass
;
1307 clrclass
= (struct clrclass_data
*)((BYTE
*)data
.lpData
+ comclass
->clrdata_offset
);
1308 ok_(__FILE__
, line
)(clrclass
->size
== sizeof(*clrclass
), "clrclass: got size %d\n", clrclass
->size
);
1309 ok_(__FILE__
, line
)(clrclass
->res
[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass
->res
[0]);
1310 ok_(__FILE__
, line
)(clrclass
->res
[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass
->res
[1]);
1311 ok_(__FILE__
, line
)(clrclass
->module_len
== lstrlenW(mscoreeW
)*sizeof(WCHAR
), "clrclass: got module len %d\n", clrclass
->module_len
);
1312 ok_(__FILE__
, line
)(clrclass
->module_offset
> 0, "clrclass: got module offset %d\n", clrclass
->module_offset
);
1314 ok_(__FILE__
, line
)(clrclass
->name_len
> 0, "clrclass: got name len %d\n", clrclass
->name_len
);
1315 ok_(__FILE__
, line
)(clrclass
->name_offset
== clrclass
->size
, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1316 ok_(__FILE__
, line
)(clrclass
->version_len
> 0, "clrclass: got version len %d\n", clrclass
->version_len
);
1317 ok_(__FILE__
, line
)(clrclass
->version_offset
> 0, "clrclass: got version offset %d\n", clrclass
->version_offset
);
1319 ok_(__FILE__
, line
)(clrclass
->res2
[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass
->res2
[0]);
1320 ok_(__FILE__
, line
)(clrclass
->res2
[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass
->res2
[1]);
1322 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1323 in lower case, clsclass subsection - in upper case */
1324 ok_(__FILE__
, line
)(comclass
->name_len
== lstrlenW(mscoree2W
)*sizeof(WCHAR
), "clrclass: got com name len %d\n", comclass
->name_len
);
1325 ok_(__FILE__
, line
)(comclass
->name_offset
> 0, "clrclass: got name offset %d\n", clrclass
->name_offset
);
1327 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ comclass
->name_offset
);
1328 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoreeW
), "clrclass: module name %s\n", wine_dbgstr_w(ptrW
));
1330 ptrW
= (WCHAR
*)((BYTE
*)data
.lpSectionBase
+ clrclass
->module_offset
);
1331 ok_(__FILE__
, line
)(!lstrcmpW(ptrW
, mscoree2W
), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW
));
1335 header
= (struct guidsection_header
*)data
.lpSectionBase
;
1336 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== ((BYTE
*)header
+ header
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1337 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1338 data
.ulSectionGlobalDataLength
);
1339 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1340 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1341 data
.ulSectionTotalLength
);
1342 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1343 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1344 data
.ulAssemblyRosterIndex
, exid
);
1346 /* generated guid for this class works as key guid in search */
1347 memset(&data2
, 0xfe, sizeof(data2
));
1348 data2
.cbSize
= sizeof(data2
);
1349 ret
= pFindActCtxSectionGuid(0, NULL
,
1350 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1351 &comclass
->alias
, &data2
);
1352 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1354 comclass2
= (struct comclassredirect_data
*)data2
.lpData
;
1355 ok_(__FILE__
, line
)(comclass
->size
== comclass2
->size
, "got wrong data length %d, expected %d\n", comclass2
->size
, comclass
->size
);
1356 ok_(__FILE__
, line
)(!memcmp(comclass
, comclass2
, comclass
->size
), "got wrong data\n");
1365 struct ifacepsredirect_data
1377 static void test_find_ifaceps_redirection(HANDLE handle
, const GUID
*iid
, const GUID
*tlbid
, const GUID
*base
,
1378 const GUID
*ps32
, ULONG exid
, int line
)
1380 struct ifacepsredirect_data
*ifaceps
;
1381 ACTCTX_SECTION_KEYED_DATA data
;
1384 memset(&data
, 0xfe, sizeof(data
));
1385 data
.cbSize
= sizeof(data
);
1387 ret
= pFindActCtxSectionGuid(0, NULL
,
1388 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION
,
1390 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1392 ifaceps
= (struct ifacepsredirect_data
*)data
.lpData
;
1394 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1395 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1396 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1397 ok_(__FILE__
, line
)(ifaceps
->size
== sizeof(*ifaceps
), "got %d for header size\n", ifaceps
->size
);
1398 if (data
.lpData
&& ifaceps
->size
== sizeof(*ifaceps
))
1402 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1405 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, ps32
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1408 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->iid
, iid
), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps
->iid
));
1410 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->tlbid
, tlbid
), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps
->tlbid
));
1411 ok_(__FILE__
, line
)(ifaceps
->name_len
> 0, "got modulename len %d\n", ifaceps
->name_len
);
1412 ok_(__FILE__
, line
)(ifaceps
->name_offset
== ifaceps
->size
, "got progid offset %d\n", ifaceps
->name_offset
);
1414 /* data length is simply header length + string data length including nulls */
1415 len
= ifaceps
->size
+ ifaceps
->name_len
+ sizeof(WCHAR
);
1416 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1418 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1419 always has non-zero value for it */
1420 if (ifaceps
->mask
& NumMethods
)
1421 ok_(__FILE__
, line
)(ifaceps
->nummethods
!= 0, "got nummethods %d\n", ifaceps
->nummethods
);
1422 if (ifaceps
->mask
& BaseIface
)
1423 ok_(__FILE__
, line
)(IsEqualGUID(&ifaceps
->base
, base
), "got base %s\n", wine_dbgstr_guid(&ifaceps
->base
));
1426 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1427 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1428 data
.ulSectionGlobalDataLength
);
1429 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1430 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1431 data
.ulSectionTotalLength
);
1432 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1433 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1434 data
.ulAssemblyRosterIndex
, exid
);
1437 struct clrsurrogate_data
1442 ULONG version_offset
;
1448 static void test_find_surrogate(HANDLE handle
, const GUID
*clsid
, const WCHAR
*name
, const WCHAR
*version
,
1449 ULONG exid
, int line
)
1451 struct clrsurrogate_data
*surrogate
;
1452 ACTCTX_SECTION_KEYED_DATA data
;
1455 memset(&data
, 0xfe, sizeof(data
));
1456 data
.cbSize
= sizeof(data
);
1458 ret
= pFindActCtxSectionGuid(0, NULL
,
1459 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES
,
1463 skip("surrogate sections are not supported\n");
1466 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1468 surrogate
= (struct clrsurrogate_data
*)data
.lpData
;
1470 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1471 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1472 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1473 ok_(__FILE__
, line
)(surrogate
->size
== sizeof(*surrogate
), "got %d for header size\n", surrogate
->size
);
1474 if (data
.lpData
&& surrogate
->size
== sizeof(*surrogate
))
1479 ok_(__FILE__
, line
)(surrogate
->res
== 0, "invalid res value %d\n", surrogate
->res
);
1480 ok_(__FILE__
, line
)(IsEqualGUID(&surrogate
->clsid
, clsid
), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate
->clsid
));
1482 ok_(__FILE__
, line
)(surrogate
->version_len
== lstrlenW(version
)*sizeof(WCHAR
), "got version len %d\n", surrogate
->version_len
);
1483 ok_(__FILE__
, line
)(surrogate
->version_offset
== surrogate
->size
, "got version offset %d\n", surrogate
->version_offset
);
1485 ok_(__FILE__
, line
)(surrogate
->name_len
== lstrlenW(name
)*sizeof(WCHAR
), "got name len %d\n", surrogate
->name_len
);
1486 ok_(__FILE__
, line
)(surrogate
->name_offset
> surrogate
->version_offset
, "got name offset %d\n", surrogate
->name_offset
);
1488 len
= surrogate
->size
+ surrogate
->name_len
+ surrogate
->version_len
+ 2*sizeof(WCHAR
);
1489 ok_(__FILE__
, line
)(data
.ulLength
== len
, "got wrong data length %d, expected %d\n", data
.ulLength
, len
);
1491 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->name_offset
);
1492 ok(!lstrcmpW(ptrW
, name
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1494 ptrW
= (WCHAR
*)((BYTE
*)surrogate
+ surrogate
->version_offset
);
1495 ok(!lstrcmpW(ptrW
, version
), "got wrong name %s\n", wine_dbgstr_w(ptrW
));
1498 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== NULL
, "data.lpSectionGlobalData != NULL\n");
1499 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== 0, "data.ulSectionGlobalDataLength=%u\n",
1500 data
.ulSectionGlobalDataLength
);
1501 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1502 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n",
1503 data
.ulSectionTotalLength
);
1504 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1505 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1506 data
.ulAssemblyRosterIndex
, exid
);
1509 static void test_find_progid_redirection(HANDLE handle
, const GUID
*clsid
, const char *progid
, ULONG exid
, int line
)
1511 struct progidredirect_data
*progiddata
;
1512 struct comclassredirect_data
*comclass
;
1513 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1514 struct strsection_header
*header
;
1517 memset(&data
, 0xfe, sizeof(data
));
1518 data
.cbSize
= sizeof(data
);
1520 ret
= pFindActCtxSectionStringA(0, NULL
,
1521 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION
,
1523 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1525 progiddata
= (struct progidredirect_data
*)data
.lpData
;
1527 ok_(__FILE__
, line
)(data
.cbSize
== sizeof(data
), "data.cbSize=%u\n", data
.cbSize
);
1528 ok_(__FILE__
, line
)(data
.ulDataFormatVersion
== 1, "data.ulDataFormatVersion=%u\n", data
.ulDataFormatVersion
);
1529 ok_(__FILE__
, line
)(data
.lpData
!= NULL
, "data.lpData == NULL\n");
1530 ok_(__FILE__
, line
)(progiddata
->size
== sizeof(*progiddata
), "got %d for header size\n", progiddata
->size
);
1531 if (data
.lpData
&& progiddata
->size
== sizeof(*progiddata
))
1535 ok_(__FILE__
, line
)(progiddata
->reserved
== 0, "got reserved as %d\n", progiddata
->reserved
);
1536 ok_(__FILE__
, line
)(progiddata
->clsid_offset
> 0, "got clsid_offset as %d\n", progiddata
->clsid_offset
);
1538 /* progid data points to generated alias guid */
1539 guid
= (GUID
*)((BYTE
*)data
.lpSectionBase
+ progiddata
->clsid_offset
);
1541 memset(&data2
, 0, sizeof(data2
));
1542 data2
.cbSize
= sizeof(data2
);
1543 ret
= pFindActCtxSectionGuid(0, NULL
,
1544 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION
,
1546 ok_(__FILE__
, line
)(ret
, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1548 comclass
= (struct comclassredirect_data
*)data2
.lpData
;
1549 ok_(__FILE__
, line
)(IsEqualGUID(guid
, &comclass
->alias
), "got wrong alias referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(guid
));
1550 ok_(__FILE__
, line
)(IsEqualGUID(clsid
, &comclass
->clsid
), "got wrong class referenced from progid %s, %s\n", progid
, wine_dbgstr_guid(clsid
));
1553 header
= (struct strsection_header
*)data
.lpSectionBase
;
1554 ok_(__FILE__
, line
)(data
.lpSectionGlobalData
== (BYTE
*)header
+ header
->global_offset
, "data.lpSectionGlobalData == NULL\n");
1555 ok_(__FILE__
, line
)(data
.ulSectionGlobalDataLength
== header
->global_len
, "data.ulSectionGlobalDataLength=%u\n", data
.ulSectionGlobalDataLength
);
1556 ok_(__FILE__
, line
)(data
.lpSectionBase
!= NULL
, "data.lpSectionBase == NULL\n");
1557 ok_(__FILE__
, line
)(data
.ulSectionTotalLength
> 0, "data.ulSectionTotalLength=%u\n", data
.ulSectionTotalLength
);
1558 ok_(__FILE__
, line
)(data
.hActCtx
== NULL
, "data.hActCtx=%p\n", data
.hActCtx
);
1559 ok_(__FILE__
, line
)(data
.ulAssemblyRosterIndex
== exid
, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1560 data
.ulAssemblyRosterIndex
, exid
);
1563 static void test_wndclass_section(void)
1565 static const WCHAR cls1W
[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1566 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1567 struct wndclass_redirect_data
*classdata
;
1568 struct strsection_header
*section
;
1574 /* use two dependent manifests, each defines 2 window class redirects */
1575 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1576 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1577 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1579 handle
= test_create("main_wndcls.manifest");
1580 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1582 DeleteFileA("testdep1.manifest");
1583 DeleteFileA("testdep2.manifest");
1584 DeleteFileA("main_wndcls.manifest");
1586 ret
= pActivateActCtx(handle
, &cookie
);
1587 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1589 memset(&data
, 0, sizeof(data
));
1590 memset(&data2
, 0, sizeof(data2
));
1591 data
.cbSize
= sizeof(data
);
1592 data2
.cbSize
= sizeof(data2
);
1594 /* get data for two classes from different assemblies */
1595 ret
= pFindActCtxSectionStringW(0, NULL
,
1596 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1598 ok(ret
, "got %d\n", ret
);
1599 ret
= pFindActCtxSectionStringW(0, NULL
,
1600 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
,
1601 wndClass3W
, &data2
);
1602 ok(ret
, "got %d\n", ret
);
1604 section
= (struct strsection_header
*)data
.lpSectionBase
;
1605 ok(section
->count
== 4, "got %d\n", section
->count
);
1606 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1608 /* For both string same section is returned, meaning it's one wndclass section per context */
1609 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1610 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1611 data2
.ulSectionTotalLength
);
1613 /* wndClass1 is versioned, wndClass3 is not */
1614 classdata
= (struct wndclass_redirect_data
*)data
.lpData
;
1615 ptrW
= (WCHAR
*)((BYTE
*)data
.lpData
+ classdata
->name_offset
);
1616 ok(!lstrcmpW(ptrW
, cls1W
), "got %s\n", wine_dbgstr_w(ptrW
));
1618 classdata
= (struct wndclass_redirect_data
*)data2
.lpData
;
1619 ptrW
= (WCHAR
*)((BYTE
*)data2
.lpData
+ classdata
->name_offset
);
1620 ok(!lstrcmpW(ptrW
, wndClass3W
), "got %s\n", wine_dbgstr_w(ptrW
));
1622 ret
= pDeactivateActCtx(0, cookie
);
1623 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1625 pReleaseActCtx(handle
);
1628 static void test_dllredirect_section(void)
1630 static const WCHAR testlib1W
[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1631 static const WCHAR testlib2W
[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1632 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1633 struct strsection_header
*section
;
1638 /* use two dependent manifests, 4 'files' total */
1639 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1640 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1641 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1643 handle
= test_create("main_wndcls.manifest");
1644 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1646 DeleteFileA("testdep1.manifest");
1647 DeleteFileA("testdep2.manifest");
1648 DeleteFileA("main_wndcls.manifest");
1650 ret
= pActivateActCtx(handle
, &cookie
);
1651 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1653 memset(&data
, 0, sizeof(data
));
1654 memset(&data2
, 0, sizeof(data2
));
1655 data
.cbSize
= sizeof(data
);
1656 data2
.cbSize
= sizeof(data2
);
1658 /* get data for two files from different assemblies */
1659 ret
= pFindActCtxSectionStringW(0, NULL
,
1660 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1662 ok(ret
, "got %d\n", ret
);
1663 ret
= pFindActCtxSectionStringW(0, NULL
,
1664 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
,
1666 ok(ret
, "got %d\n", ret
);
1668 section
= (struct strsection_header
*)data
.lpSectionBase
;
1669 ok(section
->count
== 4, "got %d\n", section
->count
);
1670 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1672 /* For both string same section is returned, meaning it's one dll redirect section per context */
1673 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1674 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1675 data2
.ulSectionTotalLength
);
1677 ret
= pDeactivateActCtx(0, cookie
);
1678 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1680 pReleaseActCtx(handle
);
1683 static void test_typelib_section(void)
1685 static const WCHAR helpW
[] = {'h','e','l','p'};
1686 ACTCTX_SECTION_KEYED_DATA data
, data2
;
1687 struct guidsection_header
*section
;
1688 struct tlibredirect_data
*tlib
;
1693 /* use two dependent manifests, 4 'files' total */
1694 create_manifest_file("testdep1.manifest", manifest_wndcls1
, -1, NULL
, NULL
);
1695 create_manifest_file("testdep2.manifest", manifest_wndcls2
, -1, NULL
, NULL
);
1696 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main
, -1, NULL
, NULL
);
1698 handle
= test_create("main_wndcls.manifest");
1699 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1701 DeleteFileA("testdep1.manifest");
1702 DeleteFileA("testdep2.manifest");
1703 DeleteFileA("main_wndcls.manifest");
1705 ret
= pActivateActCtx(handle
, &cookie
);
1706 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
1708 memset(&data
, 0, sizeof(data
));
1709 memset(&data2
, 0, sizeof(data2
));
1710 data
.cbSize
= sizeof(data
);
1711 data2
.cbSize
= sizeof(data2
);
1713 /* get data for two typelibs from different assemblies */
1714 ret
= pFindActCtxSectionGuid(0, NULL
,
1715 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1716 &IID_TlibTest
, &data
);
1717 ok(ret
, "got %d\n", ret
);
1719 ret
= pFindActCtxSectionGuid(0, NULL
,
1720 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION
,
1721 &IID_TlibTest4
, &data2
);
1722 ok(ret
, "got %d\n", ret
);
1724 section
= (struct guidsection_header
*)data
.lpSectionBase
;
1725 ok(section
->count
== 4, "got %d\n", section
->count
);
1726 ok(section
->size
== sizeof(*section
), "got %d\n", section
->size
);
1728 /* For both GUIDs same section is returned */
1729 ok(data
.lpSectionBase
== data2
.lpSectionBase
, "got %p, %p\n", data
.lpSectionBase
, data2
.lpSectionBase
);
1730 ok(data
.ulSectionTotalLength
== data2
.ulSectionTotalLength
, "got %u, %u\n", data
.ulSectionTotalLength
,
1731 data2
.ulSectionTotalLength
);
1733 ok(data
.lpSectionGlobalData
== ((BYTE
*)section
+ section
->names_offset
), "data.lpSectionGlobalData == NULL\n");
1734 ok(data
.ulSectionGlobalDataLength
== section
->names_len
, "data.ulSectionGlobalDataLength=%u\n",
1735 data
.ulSectionGlobalDataLength
);
1737 /* test some actual data */
1738 tlib
= (struct tlibredirect_data
*)data
.lpData
;
1739 ok(tlib
->size
== sizeof(*tlib
), "got %d\n", tlib
->size
);
1740 ok(tlib
->major_version
== 1, "got %d\n", tlib
->major_version
);
1741 ok(tlib
->minor_version
== 0, "got %d\n", tlib
->minor_version
);
1742 ok(tlib
->help_offset
> 0, "got %d\n", tlib
->help_offset
);
1743 ok(tlib
->help_len
== sizeof(helpW
), "got %d\n", tlib
->help_len
);
1744 ok(tlib
->flags
== (LIBFLAG_FHIDDEN
|LIBFLAG_FCONTROL
|LIBFLAG_FRESTRICTED
), "got %x\n", tlib
->flags
);
1746 ret
= pDeactivateActCtx(0, cookie
);
1747 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
1749 pReleaseActCtx(handle
);
1752 static void test_allowDelayedBinding(void)
1756 if (!create_manifest_file("test5.manifest", manifest5
, -1, NULL
, NULL
)) {
1757 skip("Could not create manifest file\n");
1761 handle
= test_create("test5.manifest");
1762 if (handle
== INVALID_HANDLE_VALUE
) {
1763 win_skip("allowDelayedBinding attribute is not supported.\n");
1767 DeleteFileA("test5.manifest");
1768 DeleteFileA("testdep.manifest");
1769 if (handle
!= INVALID_HANDLE_VALUE
) {
1770 test_basic_info(handle
, __LINE__
);
1771 pReleaseActCtx(handle
);
1775 static void test_actctx(void)
1783 trace("default actctx\n");
1785 b
= pGetCurrentActCtx(&handle
);
1786 ok(handle
== NULL
, "handle = %p, expected NULL\n", handle
);
1787 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
1789 test_basic_info(handle
, __LINE__
);
1790 test_detailed_info(handle
, &detailed_info0
, __LINE__
);
1791 pReleaseActCtx(handle
);
1794 /* test for whitespace handling in Eq ::= S? '=' S? */
1795 create_manifest_file("test1_1.manifest", manifest1_1
, -1, NULL
, NULL
);
1796 handle
= test_create("test1_1.manifest");
1797 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1798 DeleteFileA("test1_1.manifest");
1799 pReleaseActCtx(handle
);
1801 if(!create_manifest_file("test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1802 skip("Could not create manifest file\n");
1806 trace("manifest1\n");
1808 handle
= test_create("test1.manifest");
1809 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1810 DeleteFileA("test1.manifest");
1811 if(handle
!= INVALID_HANDLE_VALUE
) {
1812 test_basic_info(handle
, __LINE__
);
1813 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1814 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1816 if (pIsDebuggerPresent
&& !pIsDebuggerPresent())
1818 /* CloseHandle will generate an exception if a debugger is present */
1819 b
= CloseHandle(handle
);
1820 ok(!b
, "CloseHandle succeeded\n");
1821 ok(GetLastError() == ERROR_INVALID_HANDLE
, "GetLastError() == %u\n", GetLastError());
1824 pReleaseActCtx(handle
);
1827 if(!create_manifest_file("test2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest1
)) {
1828 skip("Could not create manifest file\n");
1832 trace("manifest2 depmanifest1\n");
1834 handle
= test_create("test2.manifest");
1835 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1836 DeleteFileA("test2.manifest");
1837 DeleteFileA("testdep.manifest");
1838 if(handle
!= INVALID_HANDLE_VALUE
) {
1839 test_basic_info(handle
, __LINE__
);
1840 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1841 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1842 test_info_in_assembly(handle
, 2, &depmanifest1_info
, __LINE__
);
1843 pReleaseActCtx(handle
);
1846 if(!create_manifest_file("test2-2.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest2
)) {
1847 skip("Could not create manifest file\n");
1851 trace("manifest2 depmanifest2\n");
1853 handle
= test_create("test2-2.manifest");
1854 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1855 DeleteFileA("test2-2.manifest");
1856 DeleteFileA("testdep.manifest");
1857 if(handle
!= INVALID_HANDLE_VALUE
) {
1858 test_basic_info(handle
, __LINE__
);
1859 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1860 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1861 test_info_in_assembly(handle
, 2, &depmanifest2_info
, __LINE__
);
1862 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1863 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1865 b
= pActivateActCtx(handle
, &cookie
);
1866 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1867 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1868 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1869 b
= pDeactivateActCtx(0, cookie
);
1870 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1872 pReleaseActCtx(handle
);
1875 trace("manifest2 depmanifest3\n");
1877 if(!create_manifest_file("test2-3.manifest", manifest2
, -1, "testdep.manifest", testdep_manifest3
)) {
1878 skip("Could not create manifest file\n");
1882 handle
= test_create("test2-3.manifest");
1883 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1884 DeleteFileA("test2-3.manifest");
1885 DeleteFileA("testdep.manifest");
1886 if(handle
!= INVALID_HANDLE_VALUE
) {
1887 test_basic_info(handle
, __LINE__
);
1888 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1889 test_info_in_assembly(handle
, 1, &manifest2_info
, __LINE__
);
1890 test_info_in_assembly(handle
, 2, &depmanifest3_info
, __LINE__
);
1891 test_file_info(handle
, 1, 0, testlib_dll
, __LINE__
);
1892 test_file_info(handle
, 1, 1, testlib2_dll
, __LINE__
);
1894 b
= pActivateActCtx(handle
, &cookie
);
1895 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1896 test_find_dll_redirection(handle
, testlib_dll
, 2, __LINE__
);
1897 test_find_dll_redirection(handle
, testlib2_dll
, 2, __LINE__
);
1898 test_find_window_class(handle
, wndClassW
, 2, __LINE__
);
1899 test_find_window_class(handle
, wndClass2W
, 2, __LINE__
);
1900 b
= pDeactivateActCtx(0, cookie
);
1901 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1903 pReleaseActCtx(handle
);
1906 trace("manifest3\n");
1908 if(!create_manifest_file("test3.manifest", manifest3
, -1, NULL
, NULL
)) {
1909 skip("Could not create manifest file\n");
1913 handle
= test_create("test3.manifest");
1914 ok(handle
!= INVALID_HANDLE_VALUE
|| broken(handle
== INVALID_HANDLE_VALUE
) /* XP pre-SP2, win2k3 w/o SP */,
1915 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1916 if (handle
== INVALID_HANDLE_VALUE
)
1917 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
1918 DeleteFileA("test3.manifest");
1919 if(handle
!= INVALID_HANDLE_VALUE
) {
1920 static const WCHAR nameW
[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
1921 static const WCHAR versionW
[] = {'v','2','.','0','.','5','0','7','2','7',0};
1922 static const WCHAR progidW
[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
1923 static const WCHAR clrprogidW
[] = {'c','l','r','p','r','o','g','i','d',0};
1925 test_basic_info(handle
, __LINE__
);
1926 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1927 test_info_in_assembly(handle
, 1, &manifest3_info
, __LINE__
);
1928 test_file_info(handle
, 0, 0, testlib_dll
, __LINE__
);
1930 b
= pActivateActCtx(handle
, &cookie
);
1931 ok(b
, "ActivateActCtx failed: %u\n", GetLastError());
1932 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1933 test_find_dll_redirection(handle
, testlib_dll
, 1, __LINE__
);
1934 test_find_com_redirection(handle
, &IID_CoTest
, &IID_TlibTest
, progidW
, 1, __LINE__
);
1935 test_find_com_redirection(handle
, &IID_CoTest2
, NULL
, NULL
, 1, __LINE__
);
1936 test_find_com_redirection(handle
, &CLSID_clrclass
, &IID_TlibTest
, clrprogidW
, 1, __LINE__
);
1937 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId", 1, __LINE__
);
1938 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.1", 1, __LINE__
);
1939 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.2", 1, __LINE__
);
1940 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.3", 1, __LINE__
);
1941 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.4", 1, __LINE__
);
1942 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.5", 1, __LINE__
);
1943 test_find_progid_redirection(handle
, &IID_CoTest
, "ProgId.ProgId.6", 1, __LINE__
);
1944 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid", 1, __LINE__
);
1945 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.1", 1, __LINE__
);
1946 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.2", 1, __LINE__
);
1947 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.3", 1, __LINE__
);
1948 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.4", 1, __LINE__
);
1949 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.5", 1, __LINE__
);
1950 test_find_progid_redirection(handle
, &CLSID_clrclass
, "clrprogid.6", 1, __LINE__
);
1951 test_find_surrogate(handle
, &IID_Iiface
, nameW
, versionW
, 1, __LINE__
);
1952 test_find_ifaceps_redirection(handle
, &IID_Iifaceps
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1953 test_find_ifaceps_redirection(handle
, &IID_Iifaceps2
, &IID_TlibTest4
, &IID_Ibifaceps
, &IID_PS32
, 1, __LINE__
);
1954 test_find_ifaceps_redirection(handle
, &IID_Iifaceps3
, &IID_TlibTest4
, &IID_Ibifaceps
, NULL
, 1, __LINE__
);
1955 test_find_string_fail();
1957 b
= pDeactivateActCtx(0, cookie
);
1958 ok(b
, "DeactivateActCtx failed: %u\n", GetLastError());
1959 pReleaseActCtx(handle
);
1962 trace("manifest4\n");
1964 if(!create_manifest_file("test4.manifest", manifest4
, -1, NULL
, NULL
)) {
1965 skip("Could not create manifest file\n");
1969 handle
= test_create("test4.manifest");
1970 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1971 DeleteFileA("test4.manifest");
1972 DeleteFileA("testdep.manifest");
1973 if(handle
!= INVALID_HANDLE_VALUE
) {
1974 test_basic_info(handle
, __LINE__
);
1975 test_detailed_info(handle
, &detailed_info2
, __LINE__
);
1976 test_info_in_assembly(handle
, 1, &manifest4_info
, __LINE__
);
1977 test_info_in_assembly(handle
, 2, &manifest_comctrl_info
, __LINE__
);
1978 pReleaseActCtx(handle
);
1981 trace("manifest1 in subdir\n");
1983 CreateDirectoryW(work_dir_subdir
, NULL
);
1984 if (SetCurrentDirectoryW(work_dir_subdir
))
1986 if(!create_manifest_file("..\\test1.manifest", manifest1
, -1, NULL
, NULL
)) {
1987 skip("Could not create manifest file\n");
1990 handle
= test_create("..\\test1.manifest");
1991 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1992 DeleteFileA("..\\test1.manifest");
1993 if(handle
!= INVALID_HANDLE_VALUE
) {
1994 test_basic_info(handle
, __LINE__
);
1995 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
1996 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
1997 pReleaseActCtx(handle
);
1999 SetCurrentDirectoryW(work_dir
);
2002 skip("Couldn't change directory\n");
2003 RemoveDirectoryW(work_dir_subdir
);
2005 trace("UTF-16 manifest1, with BOM\n");
2006 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, FALSE
)) {
2007 skip("Could not create manifest file\n");
2011 handle
= test_create("test1.manifest");
2012 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2013 DeleteFileA("test1.manifest");
2014 if (handle
!= INVALID_HANDLE_VALUE
) {
2015 test_basic_info(handle
, __LINE__
);
2016 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2017 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2018 pReleaseActCtx(handle
);
2021 trace("UTF-16 manifest1, reverse endian, with BOM\n");
2022 if(!create_wide_manifest("test1.manifest", manifest1
, TRUE
, TRUE
)) {
2023 skip("Could not create manifest file\n");
2027 handle
= test_create("test1.manifest");
2028 ok(handle
!= INVALID_HANDLE_VALUE
, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2029 DeleteFileA("test1.manifest");
2030 if (handle
!= INVALID_HANDLE_VALUE
) {
2031 test_basic_info(handle
, __LINE__
);
2032 test_detailed_info(handle
, &detailed_info1
, __LINE__
);
2033 test_info_in_assembly(handle
, 1, &manifest1_info
, __LINE__
);
2034 pReleaseActCtx(handle
);
2037 test_wndclass_section();
2038 test_dllredirect_section();
2039 test_typelib_section();
2040 test_allowDelayedBinding();
2043 static void test_app_manifest(void)
2048 trace("child process manifest1\n");
2050 b
= pGetCurrentActCtx(&handle
);
2051 ok(handle
== NULL
, "handle != NULL\n");
2052 ok(b
, "GetCurrentActCtx failed: %u\n", GetLastError());
2054 test_basic_info(handle
, __LINE__
);
2055 test_detailed_info(handle
, &detailed_info1_child
, __LINE__
);
2056 test_info_in_assembly(handle
, 1, &manifest1_child_info
, __LINE__
);
2057 pReleaseActCtx(handle
);
2061 static HANDLE
create_manifest(const char *filename
, const char *data
, int line
)
2064 create_manifest_file(filename
, data
, -1, NULL
, NULL
);
2066 handle
= test_create(filename
);
2067 ok_(__FILE__
, line
)(handle
!= INVALID_HANDLE_VALUE
,
2068 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
2070 DeleteFileA(filename
);
2074 static void kernel32_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2076 UNICODE_STRING string_to_findW
;
2077 ACTCTX_SECTION_KEYED_DATA data
;
2081 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2083 memset(&data
, 0xfe, sizeof(data
));
2084 data
.cbSize
= sizeof(data
);
2087 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, &data
);
2088 err
= GetLastError();
2089 ok_(__FILE__
, line
)(ret
== should_find
,
2090 "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find
, ret
);
2093 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2094 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2096 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2097 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2099 memset(&data
, 0xfe, sizeof(data
));
2100 data
.cbSize
= sizeof(data
);
2103 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, &data
);
2104 err
= GetLastError();
2105 ok_(__FILE__
, line
)(ret
== should_find
,
2106 "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find
, ret
);
2109 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2110 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2112 ok_(__FILE__
, line
)(err
== (should_find
? ERROR_SUCCESS
: ERROR_SXS_KEY_NOT_FOUND
),
2113 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2116 ret
= pFindActCtxSectionStringA(0, NULL
, section
, string_to_find
, NULL
);
2117 err
= GetLastError();
2118 ok_(__FILE__
, line
)(!ret
,
2119 "FindActCtxSectionStringA: expected failure, got %u\n", ret
);
2120 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2121 "FindActCtxSectionStringA: unexpected error %u\n", err
);
2124 ret
= pFindActCtxSectionStringW(0, NULL
, section
, string_to_findW
.Buffer
, NULL
);
2125 err
= GetLastError();
2126 ok_(__FILE__
, line
)(!ret
,
2127 "FindActCtxSectionStringW: expected failure, got %u\n", ret
);
2128 ok_(__FILE__
, line
)(err
== ERROR_INVALID_PARAMETER
,
2129 "FindActCtxSectionStringW: unexpected error %u\n", err
);
2131 pRtlFreeUnicodeString(&string_to_findW
);
2134 static void ntdll_find(ULONG section
, const char *string_to_find
, BOOL should_find
, BOOL todo
, int line
)
2136 UNICODE_STRING string_to_findW
;
2137 ACTCTX_SECTION_KEYED_DATA data
;
2140 pRtlCreateUnicodeStringFromAsciiz(&string_to_findW
, string_to_find
);
2142 memset(&data
, 0xfe, sizeof(data
));
2143 data
.cbSize
= sizeof(data
);
2145 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, &data
);
2148 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2149 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2151 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2152 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2154 ret
= pRtlFindActivationContextSectionString(0, NULL
, section
, &string_to_findW
, NULL
);
2157 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2158 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2160 ok_(__FILE__
, line
)(ret
== (should_find
? STATUS_SUCCESS
: STATUS_SXS_KEY_NOT_FOUND
),
2161 "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret
);
2163 pRtlFreeUnicodeString(&string_to_findW
);
2166 static void test_findsectionstring(void)
2172 handle
= create_manifest("test.manifest", testdep_manifest3
, __LINE__
);
2173 ret
= pActivateActCtx(handle
, &cookie
);
2174 ok(ret
, "ActivateActCtx failed: %u\n", GetLastError());
2176 /* first we show the parameter validation from kernel32 */
2177 kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2178 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2179 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2180 kernel32_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2181 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2182 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2183 kernel32_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2185 /* then we show that ntdll plays by different rules */
2186 ntdll_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION
, "testdep", FALSE
, TRUE
, __LINE__
);
2187 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib.dll", TRUE
, FALSE
, __LINE__
);
2188 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib2.dll", TRUE
, FALSE
, __LINE__
);
2189 ntdll_find(ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION
, "testlib3.dll", FALSE
, FALSE
, __LINE__
);
2190 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass", TRUE
, FALSE
, __LINE__
);
2191 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass2", TRUE
, FALSE
, __LINE__
);
2192 ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION
, "wndClass3", FALSE
, FALSE
, __LINE__
);
2194 ret
= pDeactivateActCtx(0, cookie
);
2195 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
2196 pReleaseActCtx(handle
);
2199 static void run_child_process(void)
2201 char cmdline
[MAX_PATH
];
2202 char path
[MAX_PATH
];
2204 PROCESS_INFORMATION pi
;
2205 STARTUPINFOA si
= { 0 };
2210 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
2211 strcat(path
, ".manifest");
2212 if(!create_manifest_file(path
, manifest1
, -1, NULL
, NULL
)) {
2213 skip("Could not create manifest file\n");
2218 winetest_get_mainargs( &argv
);
2219 /* Vista+ seems to cache presence of .manifest files. Change last modified
2220 date to defeat the cache */
2221 file
= CreateFileA(argv
[0], FILE_WRITE_ATTRIBUTES
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
2222 NULL
, OPEN_EXISTING
, 0, NULL
);
2223 if (file
!= INVALID_HANDLE_VALUE
) {
2224 GetSystemTimeAsFileTime(&now
);
2225 SetFileTime(file
, NULL
, NULL
, &now
);
2228 sprintf(cmdline
, "\"%s\" %s manifest1", argv
[0], argv
[1]);
2229 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
2230 ok(ret
, "Could not create process: %u\n", GetLastError());
2231 winetest_wait_child_process( pi
.hProcess
);
2232 CloseHandle(pi
.hThread
);
2233 CloseHandle(pi
.hProcess
);
2237 static void init_paths(void)
2241 static const WCHAR dot_manifest
[] = {'.','M','a','n','i','f','e','s','t',0};
2242 static const WCHAR backslash
[] = {'\\',0};
2243 static const WCHAR subdir
[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2245 GetModuleFileNameW(NULL
, exe_path
, sizeof(exe_path
)/sizeof(WCHAR
));
2246 lstrcpyW(app_dir
, exe_path
);
2247 for(ptr
=app_dir
+lstrlenW(app_dir
); *ptr
!= '\\' && *ptr
!= '/'; ptr
--);
2250 GetCurrentDirectoryW(MAX_PATH
, work_dir
);
2251 ptr
= work_dir
+ lstrlenW( work_dir
) - 1;
2252 if (*ptr
!= '\\' && *ptr
!= '/')
2253 lstrcatW(work_dir
, backslash
);
2254 lstrcpyW(work_dir_subdir
, work_dir
);
2255 lstrcatW(work_dir_subdir
, subdir
);
2257 GetModuleFileNameW(NULL
, app_manifest_path
, sizeof(app_manifest_path
)/sizeof(WCHAR
));
2258 lstrcpyW(app_manifest_path
+lstrlenW(app_manifest_path
), dot_manifest
);
2261 static void write_manifest(const char *filename
, const char *manifest
)
2265 CHAR path
[MAX_PATH
];
2267 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2268 strcat(path
, filename
);
2270 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
2271 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
2272 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
2276 static void delete_manifest_file(const char *filename
)
2278 CHAR path
[MAX_PATH
];
2280 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2281 strcat(path
, filename
);
2285 static void test_CreateActCtx(void)
2287 CHAR path
[MAX_PATH
], dir
[MAX_PATH
];
2291 GetTempPathA(sizeof(path
)/sizeof(CHAR
), path
);
2292 strcat(path
, "main_wndcls.manifest");
2294 write_manifest("testdep1.manifest", manifest_wndcls1
);
2295 write_manifest("testdep2.manifest", manifest_wndcls2
);
2296 write_manifest("main_wndcls.manifest", manifest_wndcls_main
);
2298 memset(&actctx
, 0, sizeof(ACTCTXA
));
2299 actctx
.cbSize
= sizeof(ACTCTXA
);
2300 actctx
.lpSource
= path
;
2302 /* create using lpSource without specified directory */
2303 handle
= pCreateActCtxA(&actctx
);
2304 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to generate context, error %u\n", GetLastError());
2305 pReleaseActCtx(handle
);
2307 /* with specified directory, that doesn't contain dependent assembly */
2308 GetWindowsDirectoryA(dir
, sizeof(dir
)/sizeof(CHAR
));
2310 memset(&actctx
, 0, sizeof(ACTCTXA
));
2311 actctx
.cbSize
= sizeof(ACTCTXA
);
2312 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2313 actctx
.lpAssemblyDirectory
= dir
;
2314 actctx
.lpSource
= path
;
2316 SetLastError(0xdeadbeef);
2317 handle
= pCreateActCtxA(&actctx
);
2319 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2320 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
, "got error %d\n", GetLastError());
2322 if (handle
!= INVALID_HANDLE_VALUE
) pReleaseActCtx(handle
);
2324 delete_manifest_file("main_wndcls.manifest");
2325 delete_manifest_file("testdep1.manifest");
2326 delete_manifest_file("testdep2.manifest");
2328 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2329 memset(&actctx
, 0, sizeof(ACTCTXA
));
2330 actctx
.cbSize
= sizeof(ACTCTXA
);
2331 actctx
.dwFlags
= ACTCTX_FLAG_HMODULE_VALID
;
2332 SetLastError(0xdeadbeef);
2333 handle
= pCreateActCtxA(&actctx
);
2334 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2336 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX
|| broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY
) /* XP, win2k3 */,
2337 "got error %d\n", GetLastError());
2339 /* create from HMODULE - resource doesn't exist, lpSource is set */
2340 memset(&actctx
, 0, sizeof(ACTCTXA
));
2341 actctx
.cbSize
= sizeof(ACTCTXA
);
2342 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
| ACTCTX_FLAG_HMODULE_VALID
;
2343 actctx
.lpSource
= "dummyfile.dll";
2344 actctx
.lpResourceName
= MAKEINTRESOURCEA(20);
2345 actctx
.hModule
= GetModuleHandleA(NULL
);
2347 SetLastError(0xdeadbeef);
2348 handle
= pCreateActCtxA(&actctx
);
2349 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2350 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND
, "got error %d\n", GetLastError());
2352 /* load manifest from lpAssemblyDirectory directory */
2353 write_manifest("testdir.manifest", manifest1
);
2354 GetTempPathA(sizeof(path
)/sizeof(path
[0]), path
);
2355 SetCurrentDirectoryA(path
);
2356 strcat(path
, "assembly_dir");
2358 strcat(path
, "\\testdir.manifest");
2360 memset(&actctx
, 0, sizeof(actctx
));
2361 actctx
.cbSize
= sizeof(actctx
);
2362 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2363 actctx
.lpSource
= "testdir.manifest";
2364 actctx
.lpAssemblyDirectory
= dir
;
2366 SetLastError(0xdeadbeef);
2367 handle
= pCreateActCtxA(&actctx
);
2368 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2369 ok(GetLastError()==ERROR_PATH_NOT_FOUND
||
2370 broken(GetLastError()==ERROR_FILE_NOT_FOUND
) /* WinXP */,
2371 "got error %d\n", GetLastError());
2373 CreateDirectoryA(dir
, NULL
);
2374 memset(&actctx
, 0, sizeof(actctx
));
2375 actctx
.cbSize
= sizeof(actctx
);
2376 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2377 actctx
.lpSource
= "testdir.manifest";
2378 actctx
.lpAssemblyDirectory
= dir
;
2380 SetLastError(0xdeadbeef);
2381 handle
= pCreateActCtxA(&actctx
);
2382 ok(handle
== INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2383 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %d\n", GetLastError());
2384 SetCurrentDirectoryW(work_dir
);
2386 write_manifest("assembly_dir\\testdir.manifest", manifest1
);
2387 memset(&actctx
, 0, sizeof(actctx
));
2388 actctx
.cbSize
= sizeof(actctx
);
2389 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2390 actctx
.lpSource
= "testdir.manifest";
2391 actctx
.lpAssemblyDirectory
= dir
;
2393 handle
= pCreateActCtxA(&actctx
);
2394 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2395 pReleaseActCtx(handle
);
2397 memset(&actctx
, 0, sizeof(actctx
));
2398 actctx
.cbSize
= sizeof(actctx
);
2399 actctx
.dwFlags
= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID
;
2400 actctx
.lpSource
= path
;
2401 actctx
.lpAssemblyDirectory
= dir
;
2403 handle
= pCreateActCtxA(&actctx
);
2404 ok(handle
!= INVALID_HANDLE_VALUE
, "got handle %p\n", handle
);
2405 pReleaseActCtx(handle
);
2407 delete_manifest_file("testdir.manifest");
2408 delete_manifest_file("assembly_dir\\testdir.manifest");
2409 RemoveDirectoryA(dir
);
2412 static BOOL
init_funcs(void)
2414 HMODULE hLibrary
= GetModuleHandleA("kernel32.dll");
2416 #define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
2420 X(DeactivateActCtx
);
2421 X(FindActCtxSectionStringA
);
2422 X(FindActCtxSectionStringW
);
2423 X(GetCurrentActCtx
);
2424 X(IsDebuggerPresent
);
2427 X(FindActCtxSectionGuid
);
2429 hLibrary
= GetModuleHandleA("ntdll.dll");
2430 X(RtlFindActivationContextSectionString
);
2431 X(RtlCreateUnicodeStringFromAsciiz
);
2432 X(RtlFreeUnicodeString
);
2443 argc
= winetest_get_mainargs(&argv
);
2447 win_skip("Needed functions are not available\n");
2452 if(argc
> 2 && !strcmp(argv
[2], "manifest1")) {
2453 test_app_manifest();
2458 test_CreateActCtx();
2459 test_findsectionstring();
2460 run_child_process();