[FASTFAT]
[reactos.git] / rostests / winetests / kernel32 / actctx.c
1 /*
2 * Copyright 2007 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include <wine/test.h>
20 #include <winbase.h>
21 #include <windef.h>
22 #include <winnt.h>
23 #include <winternl.h>
24 #include <winnls.h>
25 #include <stdio.h>
26
27 #include <oaidl.h>
28 #include <initguid.h>
29
30 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
31 static HANDLE (WINAPI *pCreateActCtxA)(PCACTCTXA);
32 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
33 static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
34 static BOOL (WINAPI *pFindActCtxSectionStringA)(DWORD,const GUID *,ULONG,LPCSTR,PACTCTX_SECTION_KEYED_DATA);
35 static BOOL (WINAPI *pFindActCtxSectionStringW)(DWORD,const GUID *,ULONG,LPCWSTR,PACTCTX_SECTION_KEYED_DATA);
36 static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *);
37 static BOOL (WINAPI *pIsDebuggerPresent)(void);
38 static BOOL (WINAPI *pQueryActCtxW)(DWORD,HANDLE,PVOID,ULONG,PVOID,SIZE_T,SIZE_T*);
39 static VOID (WINAPI *pReleaseActCtx)(HANDLE);
40 static BOOL (WINAPI *pFindActCtxSectionGuid)(DWORD,const GUID*,ULONG,const GUID*,PACTCTX_SECTION_KEYED_DATA);
41
42 static const char* strw(LPCWSTR x)
43 {
44 static char buffer[1024];
45 char* p = buffer;
46
47 if (!x) return "(nil)";
48 else while ((*p++ = *x++));
49 return buffer;
50 }
51
52 #ifdef __i386__
53 #define ARCH "x86"
54 #elif defined __x86_64__
55 #define ARCH "amd64"
56 #else
57 #define ARCH "none"
58 #endif
59
60 static const char manifest1[] =
61 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
62 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
63 "</assembly>";
64
65 static const char manifest1_1[] =
66 "<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
67 "<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
68 "</assembly>";
69
70 static const char manifest2[] =
71 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
72 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
73 "</assemblyIdentity>"
74 "<dependency>"
75 "<dependentAssembly>"
76 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\">"
77 "</assemblyIdentity>"
78 "</dependentAssembly>"
79 "</dependency>"
80 "</assembly>";
81
82 DEFINE_GUID(IID_CoTest, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
83 DEFINE_GUID(IID_CoTest2, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
84 DEFINE_GUID(CLSID_clrclass,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
85 DEFINE_GUID(IID_TlibTest, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
86 DEFINE_GUID(IID_TlibTest2, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
87 DEFINE_GUID(IID_TlibTest3, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
88 DEFINE_GUID(IID_TlibTest4, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
89 DEFINE_GUID(IID_Iifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
90 DEFINE_GUID(IID_Ibifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
91 DEFINE_GUID(IID_Iifaceps2, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
92 DEFINE_GUID(IID_Iifaceps3, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
93 DEFINE_GUID(IID_Iiface, 0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
94 DEFINE_GUID(IID_PS32, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
95
96 static const char manifest3[] =
97 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
98 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
99 " publicKeyToken=\"6595b6414666f1df\" />"
100 "<file name=\"testlib.dll\">"
101 "<windowClass>wndClass</windowClass>"
102 " <comClass description=\"Test com class\""
103 " clsid=\"{12345678-1234-5678-1234-111122223333}\""
104 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
105 " threadingModel=\"Neutral\""
106 " progid=\"ProgId.ProgId\""
107 " miscStatus=\"cantlinkinside\""
108 " miscStatusIcon=\"recomposeonresize\""
109 " miscStatusContent=\"insideout\""
110 " miscStatusThumbnail=\"alignable\""
111 " miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
112 " >"
113 " <progid>ProgId.ProgId.1</progid>"
114 " <progid>ProgId.ProgId.2</progid>"
115 " <progid>ProgId.ProgId.3</progid>"
116 " <progid>ProgId.ProgId.4</progid>"
117 " <progid>ProgId.ProgId.5</progid>"
118 " <progid>ProgId.ProgId.6</progid>"
119 " </comClass>"
120 " <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
121 " <progid>ProgId.ProgId.7</progid>"
122 " </comClass>"
123 " <comInterfaceProxyStub "
124 " name=\"Iifaceps\""
125 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
126 " iid=\"{66666666-8888-7777-6666-555555555555}\""
127 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
128 " threadingModel=\"Free\""
129 " numMethods=\"10\""
130 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
131 " />"
132 "</file>"
133 " <comInterfaceExternalProxyStub "
134 " name=\"Iifaceps2\""
135 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
136 " iid=\"{76666666-8888-7777-6666-555555555555}\""
137 " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
138 " numMethods=\"10\""
139 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
140 " />"
141 " <comInterfaceExternalProxyStub "
142 " name=\"Iifaceps3\""
143 " tlbid=\"{99999999-8888-7777-6666-555555555558}\""
144 " iid=\"{86666666-8888-7777-6666-555555555555}\""
145 " numMethods=\"10\""
146 " baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
147 " />"
148 " <clrSurrogate "
149 " clsid=\"{96666666-8888-7777-6666-555555555555}\""
150 " name=\"testsurrogate\""
151 " runtimeVersion=\"v2.0.50727\""
152 " />"
153 " <clrClass "
154 " clsid=\"{22345678-1234-5678-1234-111122223333}\""
155 " name=\"clrclass\""
156 " progid=\"clrprogid\""
157 " description=\"test description\""
158 " tlbid=\"{99999999-8888-7777-6666-555555555555}\""
159 " runtimeVersion=\"1.2.3.4\""
160 " threadingModel=\"Neutral\""
161 " >"
162 " <progid>clrprogid.1</progid>"
163 " <progid>clrprogid.2</progid>"
164 " <progid>clrprogid.3</progid>"
165 " <progid>clrprogid.4</progid>"
166 " <progid>clrprogid.5</progid>"
167 " <progid>clrprogid.6</progid>"
168 " </clrClass>"
169 "</assembly>";
170
171 static const char manifest_wndcls1[] =
172 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
173 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
174 "<file name=\"testlib1.dll\">"
175 "<windowClass versioned=\"yes\">wndClass1</windowClass>"
176 "<windowClass>wndClass2</windowClass>"
177 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555558}\" version=\"1.0\" helpdir=\"\" />"
178 "</file>"
179 "<file name=\"testlib1_2.dll\" />"
180 "</assembly>";
181
182 static const char manifest_wndcls2[] =
183 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
184 "<assemblyIdentity version=\"4.3.2.1\" name=\"testdep2\" type=\"win32\" processorArchitecture=\"" ARCH "\" />"
185 "<file name=\"testlib2.dll\">"
186 " <windowClass versioned=\"no\">wndClass3</windowClass>"
187 " <windowClass>wndClass4</windowClass>"
188 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
189 " flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
190 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
191 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
192 "</file>"
193 "<file name=\"testlib2_2.dll\" />"
194 "</assembly>";
195
196 static const char manifest_wndcls_main[] =
197 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
198 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
199 "<dependency>"
200 " <dependentAssembly>"
201 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
202 " </dependentAssembly>"
203 "</dependency>"
204 "<dependency>"
205 " <dependentAssembly>"
206 " <assemblyIdentity type=\"win32\" name=\"testdep2\" version=\"4.3.2.1\" processorArchitecture=\"" ARCH "\" />"
207 " </dependentAssembly>"
208 "</dependency>"
209 "</assembly>";
210
211 static const char manifest4[] =
212 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
213 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
214 "</assemblyIdentity>"
215 "<dependency>"
216 "<dependentAssembly>"
217 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
218 "version=\"6.0.1.0\" processorArchitecture=\"" ARCH "\" publicKeyToken=\"6595b64144ccf1df\">"
219 "</assemblyIdentity>"
220 "</dependentAssembly>"
221 "</dependency>"
222 "</assembly>";
223
224 static const char testdep_manifest1[] =
225 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
226 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>"
227 "</assembly>";
228
229 static const char testdep_manifest2[] =
230 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
231 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />"
232 "<file name=\"testlib.dll\"></file>"
233 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
234 "</assembly>";
235
236 static const char testdep_manifest3[] =
237 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
238 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>"
239 "<file name=\"testlib.dll\"/>"
240 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
241 "<windowClass>wndClass</windowClass>"
242 "<windowClass>wndClass2</windowClass>"
243 "</file>"
244 "</assembly>";
245
246 static const char wrong_manifest1[] =
247 "<assembly manifestVersion=\"1.0\">"
248 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
249 "</assembly>";
250
251 static const char wrong_manifest2[] =
252 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
253 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
254 "</assembly>";
255
256 static const char wrong_manifest3[] =
257 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
258 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
259 "</assembly>";
260
261 static const char wrong_manifest4[] =
262 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
263 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
264 "<test></test>"
265 "</assembly>";
266
267 static const char wrong_manifest5[] =
268 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
269 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
270 "</assembly>"
271 "<test></test>";
272
273 static const char wrong_manifest6[] =
274 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
275 "<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
276 "</assembly>";
277
278 static const char wrong_manifest7[] =
279 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
280 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />"
281 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
282 "</assembly>";
283
284 static const char wrong_manifest8[] =
285 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
286 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
287 "<file></file>"
288 "</assembly>";
289
290 static const char wrong_depmanifest1[] =
291 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
292 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH "\" />"
293 "</assembly>";
294
295 static const WCHAR testlib_dll[] =
296 {'t','e','s','t','l','i','b','.','d','l','l',0};
297 static const WCHAR testlib2_dll[] =
298 {'t','e','s','t','l','i','b','2','.','d','l','l',0};
299 static const WCHAR wndClassW[] =
300 {'w','n','d','C','l','a','s','s',0};
301 static const WCHAR wndClass1W[] =
302 {'w','n','d','C','l','a','s','s','1',0};
303 static const WCHAR wndClass2W[] =
304 {'w','n','d','C','l','a','s','s','2',0};
305 static const WCHAR wndClass3W[] =
306 {'w','n','d','C','l','a','s','s','3',0};
307 static const WCHAR acr_manifest[] =
308 {'a','c','r','.','m','a','n','i','f','e','s','t',0};
309
310 static WCHAR app_dir[MAX_PATH], exe_path[MAX_PATH], work_dir[MAX_PATH], work_dir_subdir[MAX_PATH];
311 static WCHAR app_manifest_path[MAX_PATH], manifest_path[MAX_PATH], depmanifest_path[MAX_PATH];
312
313 static int strcmp_aw(LPCWSTR strw, const char *stra)
314 {
315 WCHAR buf[1024];
316
317 if (!stra) return 1;
318 MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
319 return lstrcmpW(strw, buf);
320 }
321
322 static DWORD strlen_aw(const char *str)
323 {
324 return MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0) - 1;
325 }
326
327 static BOOL create_manifest_file(const char *filename, const char *manifest, int manifest_len,
328 const char *depfile, const char *depmanifest)
329 {
330 DWORD size;
331 HANDLE file;
332 WCHAR path[MAX_PATH];
333
334 MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
335 GetFullPathNameW(path, sizeof(manifest_path)/sizeof(WCHAR), manifest_path, NULL);
336
337 if (manifest_len == -1)
338 manifest_len = strlen(manifest);
339
340 file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
341 FILE_ATTRIBUTE_NORMAL, NULL);
342 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
343 if(file == INVALID_HANDLE_VALUE)
344 return FALSE;
345 WriteFile(file, manifest, manifest_len, &size, NULL);
346 CloseHandle(file);
347
348 if (depmanifest)
349 {
350 MultiByteToWideChar( CP_ACP, 0, depfile, -1, path, MAX_PATH );
351 GetFullPathNameW(path, sizeof(depmanifest_path)/sizeof(WCHAR), depmanifest_path, NULL);
352 file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
353 FILE_ATTRIBUTE_NORMAL, NULL);
354 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
355 if(file == INVALID_HANDLE_VALUE)
356 return FALSE;
357 WriteFile(file, depmanifest, strlen(depmanifest), &size, NULL);
358 CloseHandle(file);
359 }
360 return TRUE;
361 }
362
363 static BOOL create_wide_manifest(const char *filename, const char *manifest, BOOL fBOM, BOOL fReverse)
364 {
365 WCHAR *wmanifest = HeapAlloc(GetProcessHeap(), 0, (strlen(manifest)+2) * sizeof(WCHAR));
366 BOOL ret;
367 int offset = (fBOM ? 0 : 1);
368
369 MultiByteToWideChar(CP_ACP, 0, manifest, -1, &wmanifest[1], (strlen(manifest)+1));
370 wmanifest[0] = 0xfeff;
371 if (fReverse)
372 {
373 size_t i;
374 for (i = 0; i < strlen(manifest)+1; i++)
375 wmanifest[i] = (wmanifest[i] << 8) | ((wmanifest[i] >> 8) & 0xff);
376 }
377 ret = create_manifest_file(filename, (char *)&wmanifest[offset], (strlen(manifest)+1-offset) * sizeof(WCHAR), NULL, NULL);
378 HeapFree(GetProcessHeap(), 0, wmanifest);
379 return ret;
380 }
381
382 typedef struct {
383 ULONG format_version;
384 ULONG assembly_cnt_min;
385 ULONG assembly_cnt_max;
386 ULONG root_manifest_type;
387 LPWSTR root_manifest_path;
388 ULONG root_config_type;
389 ULONG app_dir_type;
390 LPCWSTR app_dir;
391 } detailed_info_t;
392
393 static const detailed_info_t detailed_info0 = {
394 0, 0, 0, 0, NULL, 0, 0, NULL
395 };
396
397 static const detailed_info_t detailed_info1 = {
398 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
399 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
400 work_dir,
401 };
402
403 static const detailed_info_t detailed_info1_child = {
404 1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, app_manifest_path,
405 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
406 app_dir,
407 };
408
409 /* On Vista+, there's an extra assembly for Microsoft.Windows.Common-Controls.Resources */
410 static const detailed_info_t detailed_info2 = {
411 1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
412 ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
413 work_dir,
414 };
415
416 static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int line)
417 {
418 ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp, *detailed_info;
419 SIZE_T size, exsize, retsize;
420 BOOL b;
421
422 exsize = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)
423 + (exinfo->root_manifest_path ? (lstrlenW(exinfo->root_manifest_path)+1)*sizeof(WCHAR):0)
424 + (exinfo->app_dir ? (lstrlenW(exinfo->app_dir)+1)*sizeof(WCHAR) : 0);
425
426 if(exsize != sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)) {
427 size = 0xdeadbeef;
428 b = pQueryActCtxW(0, handle, NULL,
429 ActivationContextDetailedInformation, &detailed_info_tmp,
430 sizeof(detailed_info_tmp), &size);
431 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
432 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
433 ok_(__FILE__, line)(size == exsize, "size=%ld, expected %ld\n", size, exsize);
434 }else {
435 size = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION);
436 }
437
438 detailed_info = HeapAlloc(GetProcessHeap(), 0, size);
439 memset(detailed_info, 0xfe, size);
440 b = pQueryActCtxW(0, handle, NULL,
441 ActivationContextDetailedInformation, detailed_info,
442 size, &retsize);
443 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
444 ok_(__FILE__, line)(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize);
445
446 ok_(__FILE__, line)(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags);
447 ok_(__FILE__, line)(detailed_info->ulFormatVersion == exinfo->format_version,
448 "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info->ulFormatVersion,
449 exinfo->format_version);
450 ok_(__FILE__, line)(exinfo->assembly_cnt_min <= detailed_info->ulAssemblyCount &&
451 detailed_info->ulAssemblyCount <= exinfo->assembly_cnt_max,
452 "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info->ulAssemblyCount,
453 exinfo->assembly_cnt_min, exinfo->assembly_cnt_max);
454 ok_(__FILE__, line)(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type,
455 "detailed_info->ulRootManifestPathType=%u, expected %u\n",
456 detailed_info->ulRootManifestPathType, exinfo->root_manifest_type);
457 ok_(__FILE__, line)(detailed_info->ulRootManifestPathChars ==
458 (exinfo->root_manifest_path ? lstrlenW(exinfo->root_manifest_path) : 0),
459 "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
460 detailed_info->ulRootManifestPathChars,
461 exinfo->root_manifest_path ?lstrlenW(exinfo->root_manifest_path) : 0);
462 ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type,
463 "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
464 detailed_info->ulRootConfigurationPathType, exinfo->root_config_type);
465 ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathChars == 0,
466 "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info->ulRootConfigurationPathChars);
467 ok_(__FILE__, line)(detailed_info->ulAppDirPathType == exinfo->app_dir_type,
468 "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info->ulAppDirPathType,
469 exinfo->app_dir_type);
470 ok_(__FILE__, line)(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0),
471 "detailed_info->ulAppDirPathChars=%u, expected %u\n",
472 detailed_info->ulAppDirPathChars, exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0);
473 if(exinfo->root_manifest_path) {
474 ok_(__FILE__, line)(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n");
475 if(detailed_info->lpRootManifestPath)
476 ok_(__FILE__, line)(!lstrcmpiW(detailed_info->lpRootManifestPath, exinfo->root_manifest_path),
477 "unexpected detailed_info->lpRootManifestPath\n");
478 }else {
479 ok_(__FILE__, line)(detailed_info->lpRootManifestPath == NULL, "detailed_info->lpRootManifestPath != NULL\n");
480 }
481 ok_(__FILE__, line)(detailed_info->lpRootConfigurationPath == NULL,
482 "detailed_info->lpRootConfigurationPath=%p\n", detailed_info->lpRootConfigurationPath);
483 if(exinfo->app_dir) {
484 ok_(__FILE__, line)(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n");
485 if(detailed_info->lpAppDirPath)
486 ok_(__FILE__, line)(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath),
487 "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info->lpAppDirPath));
488 }else {
489 ok_(__FILE__, line)(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n");
490 }
491
492 HeapFree(GetProcessHeap(), 0, detailed_info);
493 }
494
495 typedef struct {
496 ULONG flags;
497 /* ULONG manifest_path_type; FIXME */
498 LPCWSTR manifest_path;
499 LPCSTR encoded_assembly_id;
500 BOOL has_assembly_dir;
501 } info_in_assembly;
502
503 static const info_in_assembly manifest1_info = {
504 1, manifest_path,
505 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
506 FALSE
507 };
508
509 static const info_in_assembly manifest1_child_info = {
510 1, app_manifest_path,
511 "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
512 FALSE
513 };
514
515 static const info_in_assembly manifest2_info = {
516 1, manifest_path,
517 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
518 FALSE
519 };
520
521 static const info_in_assembly manifest3_info = {
522 1, manifest_path,
523 "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
524 FALSE
525 };
526
527 static const info_in_assembly manifest4_info = {
528 1, manifest_path,
529 "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
530 FALSE
531 };
532
533 static const info_in_assembly depmanifest1_info = {
534 0x10, depmanifest_path,
535 "testdep,processorArchitecture=\"" ARCH "\","
536 "type=\"win32\",version=\"6.5.4.3\"",
537 TRUE
538 };
539
540 static const info_in_assembly depmanifest2_info = {
541 0x10, depmanifest_path,
542 "testdep,processorArchitecture=\"" ARCH "\","
543 "type=\"win32\",version=\"6.5.4.3\"",
544 TRUE
545 };
546
547 static const info_in_assembly depmanifest3_info = {
548 0x10, depmanifest_path,
549 "testdep,processorArchitecture=\"" ARCH "\",type=\"win32\",version=\"6.5.4.3\"",
550 TRUE
551 };
552
553 static const info_in_assembly manifest_comctrl_info = {
554 0, NULL, NULL, TRUE /* These values may differ between Windows installations */
555 };
556
557 static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembly *exinfo, int line)
558 {
559 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info, info_tmp;
560 SIZE_T size, exsize;
561 ULONG len;
562 BOOL b;
563
564 exsize = sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION);
565 if (exinfo->manifest_path) exsize += (lstrlenW(exinfo->manifest_path)+1) * sizeof(WCHAR);
566 if (exinfo->encoded_assembly_id) exsize += (strlen_aw(exinfo->encoded_assembly_id) + 1) * sizeof(WCHAR);
567
568 size = 0xdeadbeef;
569 b = pQueryActCtxW(0, handle, &id,
570 AssemblyDetailedInformationInActivationContext, &info_tmp,
571 sizeof(info_tmp), &size);
572 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
573 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
574
575 ok_(__FILE__, line)(size >= exsize, "size=%lu, expected %lu\n", size, exsize);
576
577 if (size == 0xdeadbeef)
578 {
579 skip("bad size\n");
580 return;
581 }
582
583 info = HeapAlloc(GetProcessHeap(), 0, size);
584 memset(info, 0xfe, size);
585
586 size = 0xdeadbeef;
587 b = pQueryActCtxW(0, handle, &id,
588 AssemblyDetailedInformationInActivationContext, info, size, &size);
589 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
590 if (!exinfo->manifest_path)
591 exsize += info->ulManifestPathLength + sizeof(WCHAR);
592 if (!exinfo->encoded_assembly_id)
593 exsize += info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
594 if (exinfo->has_assembly_dir)
595 exsize += info->ulAssemblyDirectoryNameLength + sizeof(WCHAR);
596 ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize);
597
598 if (0) /* FIXME: flags meaning unknown */
599 {
600 ok_(__FILE__, line)((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n",
601 info->ulFlags, exinfo->flags);
602 }
603 if(exinfo->encoded_assembly_id) {
604 len = strlen_aw(exinfo->encoded_assembly_id)*sizeof(WCHAR);
605 ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength == len,
606 "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
607 info->ulEncodedAssemblyIdentityLength, len);
608 } else {
609 ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength != 0,
610 "info->ulEncodedAssemblyIdentityLength == 0\n");
611 }
612 ok_(__FILE__, line)(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
613 "info->ulManifestPathType = %x\n", info->ulManifestPathType);
614 if(exinfo->manifest_path) {
615 len = lstrlenW(exinfo->manifest_path)*sizeof(WCHAR);
616 ok_(__FILE__, line)(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n",
617 info->ulManifestPathLength, len);
618 } else {
619 ok_(__FILE__, line)(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n");
620 }
621
622 ok_(__FILE__, line)(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE,
623 "info->ulPolicyPathType = %x\n", info->ulPolicyPathType);
624 ok_(__FILE__, line)(info->ulPolicyPathLength == 0,
625 "info->ulPolicyPathLength = %u, expected 0\n", info->ulPolicyPathLength);
626 ok_(__FILE__, line)(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
627 info->ulMetadataSatelliteRosterIndex);
628 ok_(__FILE__, line)(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n",
629 info->ulManifestVersionMajor);
630 ok_(__FILE__, line)(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n",
631 info->ulManifestVersionMinor);
632 ok_(__FILE__, line)(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n",
633 info->ulPolicyVersionMajor);
634 ok_(__FILE__, line)(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n",
635 info->ulPolicyVersionMinor);
636 if(exinfo->has_assembly_dir)
637 ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength != 0,
638 "info->ulAssemblyDirectoryNameLength == 0\n");
639 else
640 ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength == 0,
641 "info->ulAssemblyDirectoryNameLength != 0\n");
642
643 ok_(__FILE__, line)(info->lpAssemblyEncodedAssemblyIdentity != NULL,
644 "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
645 if(info->lpAssemblyEncodedAssemblyIdentity && exinfo->encoded_assembly_id) {
646 ok_(__FILE__, line)(!strcmp_aw(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id),
647 "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
648 strw(info->lpAssemblyEncodedAssemblyIdentity), exinfo->encoded_assembly_id);
649 }
650 if(exinfo->manifest_path) {
651 ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
652 if(info->lpAssemblyManifestPath)
653 ok_(__FILE__, line)(!lstrcmpiW(info->lpAssemblyManifestPath, exinfo->manifest_path),
654 "unexpected info->lpAssemblyManifestPath\n");
655 }else {
656 ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
657 }
658
659 ok_(__FILE__, line)(info->lpAssemblyPolicyPath == NULL, "info->lpAssemblyPolicyPath != NULL\n");
660 if(info->lpAssemblyPolicyPath)
661 ok_(__FILE__, line)(*(WORD*)info->lpAssemblyPolicyPath == 0, "info->lpAssemblyPolicyPath is not empty\n");
662 if(exinfo->has_assembly_dir)
663 ok_(__FILE__, line)(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n");
664 else
665 ok_(__FILE__, line)(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n",
666 strw(info->lpAssemblyDirectoryName));
667 HeapFree(GetProcessHeap(), 0, info);
668 }
669
670 static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR filename, int line)
671 {
672 ASSEMBLY_FILE_DETAILED_INFORMATION *info, info_tmp;
673 ACTIVATION_CONTEXT_QUERY_INDEX index = {assid, fileid};
674 SIZE_T size, exsize;
675 BOOL b;
676
677 exsize = sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION)
678 +(lstrlenW(filename)+1)*sizeof(WCHAR);
679
680 size = 0xdeadbeef;
681 b = pQueryActCtxW(0, handle, &index,
682 FileInformationInAssemblyOfAssemblyInActivationContext, &info_tmp,
683 sizeof(info_tmp), &size);
684 ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
685 ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
686 ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize);
687
688 if(size == 0xdeadbeef)
689 {
690 skip("bad size\n");
691 return;
692 }
693
694 info = HeapAlloc(GetProcessHeap(), 0, size);
695 memset(info, 0xfe, size);
696
697 b = pQueryActCtxW(0, handle, &index,
698 FileInformationInAssemblyOfAssemblyInActivationContext, info, size, &size);
699 ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
700 ok_(__FILE__, line)(!size, "size=%lu, expected 0\n", size);
701
702 ok_(__FILE__, line)(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags);
703 ok_(__FILE__, line)(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR),
704 "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
705 info->ulFilenameLength, lstrlenW(filename));
706 ok_(__FILE__, line)(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength);
707 ok_(__FILE__, line)(info->lpFileName != NULL, "info->lpFileName == NULL\n");
708 if(info->lpFileName)
709 ok_(__FILE__, line)(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n");
710 ok_(__FILE__, line)(info->lpFilePath == NULL, "info->lpFilePath != NULL\n");
711 HeapFree(GetProcessHeap(), 0, info);
712 }
713
714 static HANDLE test_create(const char *file)
715 {
716 ACTCTXW actctx;
717 HANDLE handle;
718 WCHAR path[MAX_PATH];
719
720 MultiByteToWideChar( CP_ACP, 0, file, -1, path, MAX_PATH );
721 memset(&actctx, 0, sizeof(ACTCTXW));
722 actctx.cbSize = sizeof(ACTCTXW);
723 actctx.lpSource = path;
724
725 handle = pCreateActCtxW(&actctx);
726 /* to be tested outside of this helper, including last error */
727 if (handle == INVALID_HANDLE_VALUE) return handle;
728
729 ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
730 ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
731 ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
732 ok(actctx.wProcessorArchitecture == 0,
733 "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
734 ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId);
735 ok(actctx.lpAssemblyDirectory == NULL,
736 "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
737 ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName);
738 ok(actctx.lpApplicationName == NULL, "actctx.lpApplicationName=%p\n",
739 actctx.lpApplicationName);
740 ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule);
741
742 return handle;
743 }
744
745 static void test_create_and_fail(const char *manifest, const char *depmanifest, int todo)
746 {
747 ACTCTXW actctx;
748 HANDLE handle;
749 WCHAR path[MAX_PATH];
750
751 MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH );
752 memset(&actctx, 0, sizeof(ACTCTXW));
753 actctx.cbSize = sizeof(ACTCTXW);
754 actctx.lpSource = path;
755
756 create_manifest_file("bad.manifest", manifest, -1, "testdep.manifest", depmanifest);
757 handle = pCreateActCtxW(&actctx);
758 if (todo) todo_wine
759 {
760 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
761 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
762 }
763 else
764 {
765 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
766 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
767 }
768 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle );
769 DeleteFileA("bad.manifest");
770 DeleteFileA("testdep.manifest");
771 }
772
773 static void test_create_wide_and_fail(const char *manifest, BOOL fBOM)
774 {
775 ACTCTXW actctx;
776 HANDLE handle;
777 WCHAR path[MAX_PATH];
778
779 MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH );
780 memset(&actctx, 0, sizeof(ACTCTXW));
781 actctx.cbSize = sizeof(ACTCTXW);
782 actctx.lpSource = path;
783
784 create_wide_manifest("bad.manifest", manifest, fBOM, FALSE);
785 handle = pCreateActCtxW(&actctx);
786 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
787 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
788
789 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle );
790 DeleteFileA("bad.manifest");
791 }
792
793 static void test_create_fail(void)
794 {
795 ACTCTXW actctx;
796 HANDLE handle;
797 WCHAR path[MAX_PATH];
798
799 MultiByteToWideChar( CP_ACP, 0, "nonexistent.manifest", -1, path, MAX_PATH );
800 memset(&actctx, 0, sizeof(ACTCTXW));
801 actctx.cbSize = sizeof(ACTCTXW);
802 actctx.lpSource = path;
803
804 handle = pCreateActCtxW(&actctx);
805 ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
806 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError == %u\n", GetLastError());
807
808 trace("wrong_manifest1\n");
809 test_create_and_fail(wrong_manifest1, NULL, 0 );
810 trace("wrong_manifest2\n");
811 test_create_and_fail(wrong_manifest2, NULL, 0 );
812 trace("wrong_manifest3\n");
813 test_create_and_fail(wrong_manifest3, NULL, 1 );
814 trace("wrong_manifest4\n");
815 test_create_and_fail(wrong_manifest4, NULL, 1 );
816 trace("wrong_manifest5\n");
817 test_create_and_fail(wrong_manifest5, NULL, 0 );
818 trace("wrong_manifest6\n");
819 test_create_and_fail(wrong_manifest6, NULL, 0 );
820 trace("wrong_manifest7\n");
821 test_create_and_fail(wrong_manifest7, NULL, 1 );
822 trace("wrong_manifest8\n");
823 test_create_and_fail(wrong_manifest8, NULL, 0 );
824 trace("UTF-16 manifest1 without BOM\n");
825 test_create_wide_and_fail(manifest1, FALSE );
826 trace("manifest2\n");
827 test_create_and_fail(manifest2, NULL, 0 );
828 trace("manifest2+depmanifest1\n");
829 test_create_and_fail(manifest2, wrong_depmanifest1, 0 );
830 }
831
832 struct strsection_header
833 {
834 DWORD magic;
835 ULONG size;
836 DWORD unk1[3];
837 ULONG count;
838 ULONG index_offset;
839 DWORD unk2[2];
840 ULONG global_offset;
841 ULONG global_len;
842 };
843
844 struct string_index
845 {
846 ULONG hash;
847 ULONG name_offset;
848 ULONG name_len;
849 ULONG data_offset;
850 ULONG data_len;
851 ULONG rosterindex;
852 };
853
854 struct guidsection_header
855 {
856 DWORD magic;
857 ULONG size;
858 DWORD unk[3];
859 ULONG count;
860 ULONG index_offset;
861 DWORD unk2;
862 ULONG names_offset;
863 ULONG names_len;
864 };
865
866 struct guid_index
867 {
868 GUID guid;
869 ULONG data_offset;
870 ULONG data_len;
871 ULONG rosterindex;
872 };
873
874 struct wndclass_redirect_data
875 {
876 ULONG size;
877 DWORD res;
878 ULONG name_len;
879 ULONG name_offset; /* versioned name offset */
880 ULONG module_len;
881 ULONG module_offset;/* container name offset */
882 };
883
884 struct dllredirect_data
885 {
886 ULONG size;
887 ULONG unk;
888 DWORD res[3];
889 };
890
891 struct tlibredirect_data
892 {
893 ULONG size;
894 DWORD res;
895 ULONG name_len;
896 ULONG name_offset;
897 LANGID langid;
898 WORD flags;
899 ULONG help_len;
900 ULONG help_offset;
901 WORD major_version;
902 WORD minor_version;
903 };
904
905 struct progidredirect_data
906 {
907 ULONG size;
908 DWORD reserved;
909 ULONG clsid_offset;
910 };
911
912 static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid, int line)
913 {
914 ACTCTX_SECTION_KEYED_DATA data;
915 BOOL ret;
916
917 memset(&data, 0xfe, sizeof(data));
918 data.cbSize = sizeof(data);
919
920 ret = pFindActCtxSectionStringW(0, NULL,
921 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
922 libname, &data);
923 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
924 if (!ret) return;
925
926 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
927 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
928 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
929 ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
930
931 if (data.lpData)
932 {
933 struct dllredirect_data *dlldata = (struct dllredirect_data*)data.lpData;
934 ok_(__FILE__, line)(dlldata->size == data.ulLength, "got wrong size %d\n", dlldata->size);
935 ok_(__FILE__, line)(dlldata->unk == 2, "got wrong field value %d\n", dlldata->unk);
936 ok_(__FILE__, line)(dlldata->res[0] == 0, "got wrong res[0] value %d\n", dlldata->res[0]);
937 ok_(__FILE__, line)(dlldata->res[1] == 0, "got wrong res[1] value %d\n", dlldata->res[1]);
938 ok_(__FILE__, line)(dlldata->res[2] == 0, "got wrong res[2] value %d\n", dlldata->res[2]);
939 }
940
941 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
942 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
943 data.ulSectionGlobalDataLength);
944 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
945 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
946 data.ulSectionTotalLength);
947 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
948 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
949 data.ulAssemblyRosterIndex, exid);
950
951 memset(&data, 0xfe, sizeof(data));
952 data.cbSize = sizeof(data);
953
954 ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
955 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
956 libname, &data);
957 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
958 if (!ret) return;
959
960 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
961 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
962 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
963 ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
964 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
965 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
966 data.ulSectionGlobalDataLength);
967 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
968 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
969 data.ulSectionTotalLength);
970 ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
971 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
972 data.ulAssemblyRosterIndex, exid);
973
974 pReleaseActCtx(handle);
975 }
976
977 static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, int line)
978 {
979 struct wndclass_redirect_data *wnddata;
980 struct strsection_header *header;
981 ACTCTX_SECTION_KEYED_DATA data;
982 BOOL ret;
983
984 memset(&data, 0xfe, sizeof(data));
985 data.cbSize = sizeof(data);
986
987 ret = pFindActCtxSectionStringW(0, NULL,
988 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
989 clsname, &data);
990 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
991 wine_dbgstr_w(clsname));
992 if (!ret) return;
993
994 header = (struct strsection_header*)data.lpSectionBase;
995 wnddata = (struct wndclass_redirect_data*)data.lpData;
996
997 ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08x\n", header->magic);
998 ok_(__FILE__, line)(header->count > 0, "got count %d\n", header->count);
999 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1000 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1001 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1002 ok_(__FILE__, line)(wnddata->size == sizeof(*wnddata), "got %d for header size\n", wnddata->size);
1003 if (data.lpData && wnddata->size == sizeof(*wnddata))
1004 {
1005 static const WCHAR verW[] = {'6','.','5','.','4','.','3','!',0};
1006 WCHAR buff[50];
1007 WCHAR *ptr;
1008 ULONG len;
1009
1010 ok_(__FILE__, line)(wnddata->res == 0, "got reserved as %d\n", wnddata->res);
1011 /* redirect class name (versioned or not) is stored just after header data */
1012 ok_(__FILE__, line)(wnddata->name_offset == wnddata->size, "got name offset as %d\n", wnddata->name_offset);
1013 ok_(__FILE__, line)(wnddata->module_len > 0, "got module name length as %d\n", wnddata->module_len);
1014
1015 /* expected versioned name */
1016 lstrcpyW(buff, verW);
1017 lstrcatW(buff, clsname);
1018 ptr = (WCHAR*)((BYTE*)wnddata + wnddata->name_offset);
1019 ok_(__FILE__, line)(!lstrcmpW(ptr, buff), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(buff));
1020 ok_(__FILE__, line)(lstrlenW(ptr)*sizeof(WCHAR) == wnddata->name_len,
1021 "got wrong class name length %d, expected %d\n", wnddata->name_len, lstrlenW(ptr));
1022
1023 /* data length is simply header length + string data length including nulls */
1024 len = wnddata->size + wnddata->name_len + wnddata->module_len + 2*sizeof(WCHAR);
1025 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1026
1027 if (data.ulSectionTotalLength > wnddata->module_offset)
1028 {
1029 WCHAR *modulename, *sectionptr;
1030
1031 /* just compare pointers */
1032 modulename = (WCHAR*)((BYTE*)wnddata + wnddata->size + wnddata->name_len + sizeof(WCHAR));
1033 sectionptr = (WCHAR*)((BYTE*)data.lpSectionBase + wnddata->module_offset);
1034 ok_(__FILE__, line)(modulename == sectionptr, "got wrong name offset %p, expected %p\n", sectionptr, modulename);
1035 }
1036 }
1037
1038 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1039 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1040 data.ulSectionGlobalDataLength);
1041 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1042 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1043 data.ulSectionTotalLength);
1044 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1045 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1046 data.ulAssemblyRosterIndex, exid);
1047
1048 memset(&data, 0xfe, sizeof(data));
1049 data.cbSize = sizeof(data);
1050
1051 ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
1052 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1053 clsname, &data);
1054 ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
1055 wine_dbgstr_w(clsname));
1056 if (!ret) return;
1057
1058 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1059 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1060 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1061 ok_(__FILE__, line)(data.ulLength > 0, "data.ulLength=%u\n", data.ulLength);
1062 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1063 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1064 data.ulSectionGlobalDataLength);
1065 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1066 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
1067 ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
1068 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1069 data.ulAssemblyRosterIndex, exid);
1070
1071 pReleaseActCtx(handle);
1072 }
1073
1074 static void test_find_string_fail(void)
1075 {
1076 ACTCTX_SECTION_KEYED_DATA data = {sizeof(data)};
1077 BOOL ret;
1078
1079 ret = pFindActCtxSectionStringW(0, NULL, 100, testlib_dll, &data);
1080 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1081 ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1082
1083 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1084 testlib2_dll, &data);
1085 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1086 ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1087
1088 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1089 testlib_dll, NULL);
1090 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1091 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1092
1093 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1094 NULL, &data);
1095 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1096 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1097
1098 data.cbSize = 0;
1099 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1100 testlib_dll, &data);
1101 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1102 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1103
1104 data.cbSize = 35;
1105 ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1106 testlib_dll, &data);
1107 ok(!ret, "FindActCtxSectionStringW succeeded\n");
1108 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
1109 }
1110
1111
1112 static void test_basic_info(HANDLE handle, int line)
1113 {
1114 ACTIVATION_CONTEXT_BASIC_INFORMATION basic;
1115 SIZE_T size;
1116 BOOL b;
1117
1118 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
1119 ActivationContextBasicInformation, &basic,
1120 sizeof(basic), &size);
1121
1122 ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n");
1123 ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n");
1124 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
1125 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
1126
1127 b = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX |
1128 QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
1129 ActivationContextBasicInformation, &basic,
1130 sizeof(basic), &size);
1131 if (handle)
1132 {
1133 ok_(__FILE__, line) (!b,"ActivationContextBasicInformation succeeded\n");
1134 ok_(__FILE__, line) (size == 0,"size mismatch\n");
1135 ok_(__FILE__, line) (GetLastError() == ERROR_INVALID_PARAMETER, "Wrong last error\n");
1136 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
1137 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
1138 }
1139 else
1140 {
1141 ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n");
1142 ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n");
1143 ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
1144 ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
1145 }
1146 }
1147
1148 enum comclass_threadingmodel {
1149 ThreadingModel_Apartment = 1,
1150 ThreadingModel_Free = 2,
1151 ThreadingModel_No = 3,
1152 ThreadingModel_Both = 4,
1153 ThreadingModel_Neutral = 5
1154 };
1155
1156 enum comclass_miscfields {
1157 MiscStatus = 1,
1158 MiscStatusIcon = 2,
1159 MiscStatusContent = 4,
1160 MiscStatusThumbnail = 8,
1161 MiscStatusDocPrint = 16
1162 };
1163
1164 struct comclassredirect_data {
1165 ULONG size;
1166 BYTE res;
1167 BYTE miscmask;
1168 BYTE res1[2];
1169 DWORD model;
1170 GUID clsid;
1171 GUID alias;
1172 GUID clsid2;
1173 GUID tlid;
1174 ULONG name_len;
1175 ULONG name_offset;
1176 ULONG progid_len;
1177 ULONG progid_offset;
1178 ULONG clrdata_len;
1179 ULONG clrdata_offset;
1180 DWORD miscstatus;
1181 DWORD miscstatuscontent;
1182 DWORD miscstatusthumbnail;
1183 DWORD miscstatusicon;
1184 DWORD miscstatusdocprint;
1185 };
1186
1187 struct clrclass_data {
1188 ULONG size;
1189 DWORD res[2];
1190 ULONG module_len;
1191 ULONG module_offset;
1192 ULONG name_len;
1193 ULONG name_offset;
1194 ULONG version_len;
1195 ULONG version_offset;
1196 DWORD res2[2];
1197 };
1198
1199 static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GUID *tlid, const WCHAR *progid, ULONG exid, int line)
1200 {
1201 struct comclassredirect_data *comclass, *comclass2;
1202 ACTCTX_SECTION_KEYED_DATA data, data2;
1203 struct guidsection_header *header;
1204 BOOL ret;
1205
1206 memset(&data, 0xfe, sizeof(data));
1207 data.cbSize = sizeof(data);
1208
1209 ret = pFindActCtxSectionGuid(0, NULL,
1210 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1211 clsid, &data);
1212 if (!ret)
1213 {
1214 skip("failed for guid %s\n", wine_dbgstr_guid(clsid));
1215 return;
1216 }
1217 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1218
1219 comclass = (struct comclassredirect_data*)data.lpData;
1220
1221 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1222 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1223 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1224 ok_(__FILE__, line)(comclass->size == sizeof(*comclass), "got %d for header size\n", comclass->size);
1225 if (data.lpData && comclass->size == sizeof(*comclass))
1226 {
1227 WCHAR *ptr;
1228 ULONG len;
1229
1230 ok_(__FILE__, line)(comclass->res == 0, "got res as %d\n", comclass->res);
1231 ok_(__FILE__, line)(comclass->res1[0] == 0, "got res1[0] as %02x\n", comclass->res1[0]);
1232 ok_(__FILE__, line)(comclass->res1[1] == 0, "got res1[1] as %02x\n", comclass->res1[1]);
1233 ok_(__FILE__, line)(comclass->model == ThreadingModel_Neutral, "got model %d\n", comclass->model);
1234 ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass->clsid));
1235 ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid2, clsid), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass->clsid2));
1236 if (tlid)
1237 ok_(__FILE__, line)(IsEqualGUID(&comclass->tlid, tlid), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass->tlid));
1238 ok_(__FILE__, line)(comclass->name_len > 0, "got modulename len %d\n", comclass->name_len);
1239
1240 if (progid)
1241 {
1242 len = comclass->size + comclass->clrdata_len;
1243 ok_(__FILE__, line)(comclass->progid_offset == len, "got progid offset %d, expected %d\n", comclass->progid_offset, len);
1244 }
1245 else
1246 ok_(__FILE__, line)(comclass->progid_offset == 0, "got progid offset %d, expected 0\n", comclass->progid_offset);
1247
1248 if (comclass->progid_offset)
1249 {
1250 ptr = (WCHAR*)((BYTE*)comclass + comclass->progid_offset);
1251 ok_(__FILE__, line)(!lstrcmpW(ptr, progid), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(progid));
1252 ok_(__FILE__, line)(lstrlenW(progid)*sizeof(WCHAR) == comclass->progid_len,
1253 "got progid name length %d\n", comclass->progid_len);
1254 }
1255
1256 /* data length is simply header length + string data length including nulls */
1257 len = comclass->size + comclass->clrdata_len;
1258 if (comclass->progid_len) len += comclass->progid_len + sizeof(WCHAR);
1259 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1260
1261 /* keyed data structure doesn't include module name, it's available from section data */
1262 ok_(__FILE__, line)(data.ulSectionTotalLength > comclass->name_offset, "got wrong offset %d\n", comclass->name_offset);
1263
1264 /* check misc fields are set */
1265 if (comclass->miscmask)
1266 {
1267 if (comclass->miscmask & MiscStatus)
1268 ok_(__FILE__, line)(comclass->miscstatus != 0, "got miscstatus 0x%08x\n", comclass->miscstatus);
1269 if (comclass->miscmask & MiscStatusIcon)
1270 ok_(__FILE__, line)(comclass->miscstatusicon != 0, "got miscstatusicon 0x%08x\n", comclass->miscstatusicon);
1271 if (comclass->miscmask & MiscStatusContent)
1272 ok_(__FILE__, line)(comclass->miscstatuscontent != 0, "got miscstatuscontent 0x%08x\n", comclass->miscstatuscontent);
1273 if (comclass->miscmask & MiscStatusThumbnail)
1274 ok_(__FILE__, line)(comclass->miscstatusthumbnail != 0, "got miscstatusthumbnail 0x%08x\n", comclass->miscstatusthumbnail);
1275 if (comclass->miscmask & MiscStatusDocPrint)
1276 ok_(__FILE__, line)(comclass->miscstatusdocprint != 0, "got miscstatusdocprint 0x%08x\n", comclass->miscstatusdocprint);
1277 }
1278
1279 /* part used for clrClass only */
1280 if (comclass->clrdata_len)
1281 {
1282 static const WCHAR mscoreeW[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
1283 static const WCHAR mscoree2W[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
1284 struct clrclass_data *clrclass;
1285 WCHAR *ptrW;
1286
1287 clrclass = (struct clrclass_data*)((BYTE*)data.lpData + comclass->clrdata_offset);
1288 ok_(__FILE__, line)(clrclass->size == sizeof(*clrclass), "clrclass: got size %d\n", clrclass->size);
1289 ok_(__FILE__, line)(clrclass->res[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass->res[0]);
1290 ok_(__FILE__, line)(clrclass->res[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass->res[1]);
1291 ok_(__FILE__, line)(clrclass->module_len == lstrlenW(mscoreeW)*sizeof(WCHAR), "clrclass: got module len %d\n", clrclass->module_len);
1292 ok_(__FILE__, line)(clrclass->module_offset > 0, "clrclass: got module offset %d\n", clrclass->module_offset);
1293
1294 ok_(__FILE__, line)(clrclass->name_len > 0, "clrclass: got name len %d\n", clrclass->name_len);
1295 ok_(__FILE__, line)(clrclass->name_offset == clrclass->size, "clrclass: got name offset %d\n", clrclass->name_offset);
1296 ok_(__FILE__, line)(clrclass->version_len > 0, "clrclass: got version len %d\n", clrclass->version_len);
1297 ok_(__FILE__, line)(clrclass->version_offset > 0, "clrclass: got version offset %d\n", clrclass->version_offset);
1298
1299 ok_(__FILE__, line)(clrclass->res2[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass->res2[0]);
1300 ok_(__FILE__, line)(clrclass->res2[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass->res2[1]);
1301
1302 /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
1303 in lower case, clsclass subsection - in upper case */
1304 ok_(__FILE__, line)(comclass->name_len == lstrlenW(mscoree2W)*sizeof(WCHAR), "clrclass: got com name len %d\n", comclass->name_len);
1305 ok_(__FILE__, line)(comclass->name_offset > 0, "clrclass: got name offset %d\n", clrclass->name_offset);
1306
1307 ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + comclass->name_offset);
1308 ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoreeW), "clrclass: module name %s\n", wine_dbgstr_w(ptrW));
1309
1310 ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + clrclass->module_offset);
1311 ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoree2W), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW));
1312 }
1313 }
1314
1315 header = (struct guidsection_header*)data.lpSectionBase;
1316 ok_(__FILE__, line)(data.lpSectionGlobalData == ((BYTE*)header + header->names_offset), "data.lpSectionGlobalData == NULL\n");
1317 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%u\n",
1318 data.ulSectionGlobalDataLength);
1319 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1320 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1321 data.ulSectionTotalLength);
1322 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1323 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1324 data.ulAssemblyRosterIndex, exid);
1325
1326 /* generated guid for this class works as key guid in search */
1327 memset(&data2, 0xfe, sizeof(data2));
1328 data2.cbSize = sizeof(data2);
1329 ret = pFindActCtxSectionGuid(0, NULL,
1330 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1331 &comclass->alias, &data2);
1332 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1333
1334 comclass2 = (struct comclassredirect_data*)data2.lpData;
1335 ok_(__FILE__, line)(comclass->size == comclass2->size, "got wrong data length %d, expected %d\n", comclass2->size, comclass->size);
1336 ok_(__FILE__, line)(!memcmp(comclass, comclass2, comclass->size), "got wrong data\n");
1337 }
1338
1339 enum ifaceps_mask
1340 {
1341 NumMethods = 1,
1342 BaseIface = 2
1343 };
1344
1345 struct ifacepsredirect_data
1346 {
1347 ULONG size;
1348 DWORD mask;
1349 GUID iid;
1350 ULONG nummethods;
1351 GUID tlbid;
1352 GUID base;
1353 ULONG name_len;
1354 ULONG name_offset;
1355 };
1356
1357 static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const GUID *tlbid, const GUID *base,
1358 const GUID *ps32, ULONG exid, int line)
1359 {
1360 struct ifacepsredirect_data *ifaceps;
1361 ACTCTX_SECTION_KEYED_DATA data;
1362 BOOL ret;
1363
1364 memset(&data, 0xfe, sizeof(data));
1365 data.cbSize = sizeof(data);
1366
1367 ret = pFindActCtxSectionGuid(0, NULL,
1368 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION,
1369 iid, &data);
1370 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1371
1372 ifaceps = (struct ifacepsredirect_data*)data.lpData;
1373
1374 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1375 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1376 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1377 ok_(__FILE__, line)(ifaceps->size == sizeof(*ifaceps), "got %d for header size\n", ifaceps->size);
1378 if (data.lpData && ifaceps->size == sizeof(*ifaceps))
1379 {
1380 ULONG len;
1381
1382 /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
1383 if (ps32)
1384 {
1385 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, ps32), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
1386 }
1387 else
1388 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, iid), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
1389
1390 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->tlbid, tlbid), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps->tlbid));
1391 ok_(__FILE__, line)(ifaceps->name_len > 0, "got modulename len %d\n", ifaceps->name_len);
1392 ok_(__FILE__, line)(ifaceps->name_offset == ifaceps->size, "got progid offset %d\n", ifaceps->name_offset);
1393
1394 /* data length is simply header length + string data length including nulls */
1395 len = ifaceps->size + ifaceps->name_len + sizeof(WCHAR);
1396 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1397
1398 /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
1399 always has non-zero value for it */
1400 if (ifaceps->mask & NumMethods)
1401 ok_(__FILE__, line)(ifaceps->nummethods != 0, "got nummethods %d\n", ifaceps->nummethods);
1402 if (ifaceps->mask & BaseIface)
1403 ok_(__FILE__, line)(IsEqualGUID(&ifaceps->base, base), "got base %s\n", wine_dbgstr_guid(&ifaceps->base));
1404 }
1405
1406 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1407 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1408 data.ulSectionGlobalDataLength);
1409 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1410 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1411 data.ulSectionTotalLength);
1412 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1413 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1414 data.ulAssemblyRosterIndex, exid);
1415 }
1416
1417 struct clrsurrogate_data
1418 {
1419 ULONG size;
1420 DWORD res;
1421 GUID clsid;
1422 ULONG version_offset;
1423 ULONG version_len;
1424 ULONG name_offset;
1425 ULONG name_len;
1426 };
1427
1428 static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *name, const WCHAR *version,
1429 ULONG exid, int line)
1430 {
1431 struct clrsurrogate_data *surrogate;
1432 ACTCTX_SECTION_KEYED_DATA data;
1433 BOOL ret;
1434
1435 memset(&data, 0xfe, sizeof(data));
1436 data.cbSize = sizeof(data);
1437
1438 ret = pFindActCtxSectionGuid(0, NULL,
1439 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES,
1440 clsid, &data);
1441 if (!ret)
1442 {
1443 skip("surrogate sections are not supported\n");
1444 return;
1445 }
1446 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1447
1448 surrogate = (struct clrsurrogate_data*)data.lpData;
1449
1450 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1451 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1452 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1453 ok_(__FILE__, line)(surrogate->size == sizeof(*surrogate), "got %d for header size\n", surrogate->size);
1454 if (data.lpData && surrogate->size == sizeof(*surrogate))
1455 {
1456 WCHAR *ptrW;
1457 ULONG len;
1458
1459 ok_(__FILE__, line)(surrogate->res == 0, "invalid res value %d\n", surrogate->res);
1460 ok_(__FILE__, line)(IsEqualGUID(&surrogate->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate->clsid));
1461
1462 ok_(__FILE__, line)(surrogate->version_len == lstrlenW(version)*sizeof(WCHAR), "got version len %d\n", surrogate->version_len);
1463 ok_(__FILE__, line)(surrogate->version_offset == surrogate->size, "got version offset %d\n", surrogate->version_offset);
1464
1465 ok_(__FILE__, line)(surrogate->name_len == lstrlenW(name)*sizeof(WCHAR), "got name len %d\n", surrogate->name_len);
1466 ok_(__FILE__, line)(surrogate->name_offset > surrogate->version_offset, "got name offset %d\n", surrogate->name_offset);
1467
1468 len = surrogate->size + surrogate->name_len + surrogate->version_len + 2*sizeof(WCHAR);
1469 ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
1470
1471 ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->name_offset);
1472 ok(!lstrcmpW(ptrW, name), "got wrong name %s\n", wine_dbgstr_w(ptrW));
1473
1474 ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->version_offset);
1475 ok(!lstrcmpW(ptrW, version), "got wrong name %s\n", wine_dbgstr_w(ptrW));
1476 }
1477
1478 ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
1479 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
1480 data.ulSectionGlobalDataLength);
1481 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1482 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
1483 data.ulSectionTotalLength);
1484 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1485 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1486 data.ulAssemblyRosterIndex, exid);
1487 }
1488
1489 static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const char *progid, ULONG exid, int line)
1490 {
1491 struct progidredirect_data *progiddata;
1492 struct comclassredirect_data *comclass;
1493 ACTCTX_SECTION_KEYED_DATA data, data2;
1494 struct strsection_header *header;
1495 BOOL ret;
1496
1497 memset(&data, 0xfe, sizeof(data));
1498 data.cbSize = sizeof(data);
1499
1500 ret = pFindActCtxSectionStringA(0, NULL,
1501 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION,
1502 progid, &data);
1503 ok_(__FILE__, line)(ret, "FindActCtxSectionStringA failed: %u\n", GetLastError());
1504
1505 progiddata = (struct progidredirect_data*)data.lpData;
1506
1507 ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
1508 ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
1509 ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
1510 ok_(__FILE__, line)(progiddata->size == sizeof(*progiddata), "got %d for header size\n", progiddata->size);
1511 if (data.lpData && progiddata->size == sizeof(*progiddata))
1512 {
1513 GUID *guid;
1514
1515 ok_(__FILE__, line)(progiddata->reserved == 0, "got reserved as %d\n", progiddata->reserved);
1516 ok_(__FILE__, line)(progiddata->clsid_offset > 0, "got clsid_offset as %d\n", progiddata->clsid_offset);
1517
1518 /* progid data points to generated alias guid */
1519 guid = (GUID*)((BYTE*)data.lpSectionBase + progiddata->clsid_offset);
1520
1521 memset(&data2, 0, sizeof(data2));
1522 data2.cbSize = sizeof(data2);
1523 ret = pFindActCtxSectionGuid(0, NULL,
1524 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1525 guid, &data2);
1526 ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
1527
1528 comclass = (struct comclassredirect_data*)data2.lpData;
1529 ok_(__FILE__, line)(IsEqualGUID(guid, &comclass->alias), "got wrong alias referenced from progid %s, %s\n", progid, wine_dbgstr_guid(guid));
1530 ok_(__FILE__, line)(IsEqualGUID(clsid, &comclass->clsid), "got wrong class referenced from progid %s, %s\n", progid, wine_dbgstr_guid(clsid));
1531 }
1532
1533 header = (struct strsection_header*)data.lpSectionBase;
1534 ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE*)header + header->global_offset, "data.lpSectionGlobalData == NULL\n");
1535 ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength);
1536 ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
1537 ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
1538 ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
1539 ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
1540 data.ulAssemblyRosterIndex, exid);
1541 }
1542
1543 static void test_wndclass_section(void)
1544 {
1545 static const WCHAR cls1W[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
1546 ACTCTX_SECTION_KEYED_DATA data, data2;
1547 struct wndclass_redirect_data *classdata;
1548 struct strsection_header *section;
1549 ULONG_PTR cookie;
1550 HANDLE handle;
1551 WCHAR *ptrW;
1552 BOOL ret;
1553
1554 /* use two dependent manifests, each defines 2 window class redirects */
1555 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
1556 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
1557 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
1558
1559 handle = test_create("main_wndcls.manifest");
1560 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1561
1562 DeleteFileA("testdep1.manifest");
1563 DeleteFileA("testdep2.manifest");
1564 DeleteFileA("main_wndcls.manifest");
1565
1566 ret = pActivateActCtx(handle, &cookie);
1567 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
1568
1569 memset(&data, 0, sizeof(data));
1570 memset(&data2, 0, sizeof(data2));
1571 data.cbSize = sizeof(data);
1572 data2.cbSize = sizeof(data2);
1573
1574 /* get data for two classes from different assemblies */
1575 ret = pFindActCtxSectionStringW(0, NULL,
1576 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1577 wndClass1W, &data);
1578 ok(ret, "got %d\n", ret);
1579 ret = pFindActCtxSectionStringW(0, NULL,
1580 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
1581 wndClass3W, &data2);
1582 ok(ret, "got %d\n", ret);
1583
1584 section = (struct strsection_header*)data.lpSectionBase;
1585 ok(section->count == 4, "got %d\n", section->count);
1586 ok(section->size == sizeof(*section), "got %d\n", section->size);
1587
1588 /* For both string same section is returned, meaning it's one wndclass section per context */
1589 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
1590 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
1591 data2.ulSectionTotalLength);
1592
1593 /* wndClass1 is versioned, wndClass3 is not */
1594 classdata = (struct wndclass_redirect_data*)data.lpData;
1595 ptrW = (WCHAR*)((BYTE*)data.lpData + classdata->name_offset);
1596 ok(!lstrcmpW(ptrW, cls1W), "got %s\n", wine_dbgstr_w(ptrW));
1597
1598 classdata = (struct wndclass_redirect_data*)data2.lpData;
1599 ptrW = (WCHAR*)((BYTE*)data2.lpData + classdata->name_offset);
1600 ok(!lstrcmpW(ptrW, wndClass3W), "got %s\n", wine_dbgstr_w(ptrW));
1601
1602 ret = pDeactivateActCtx(0, cookie);
1603 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
1604
1605 pReleaseActCtx(handle);
1606 }
1607
1608 static void test_dllredirect_section(void)
1609 {
1610 static const WCHAR testlib1W[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
1611 static const WCHAR testlib2W[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
1612 ACTCTX_SECTION_KEYED_DATA data, data2;
1613 struct strsection_header *section;
1614 ULONG_PTR cookie;
1615 HANDLE handle;
1616 BOOL ret;
1617
1618 /* use two dependent manifests, 4 'files' total */
1619 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
1620 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
1621 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
1622
1623 handle = test_create("main_wndcls.manifest");
1624 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1625
1626 DeleteFileA("testdep1.manifest");
1627 DeleteFileA("testdep2.manifest");
1628 DeleteFileA("main_wndcls.manifest");
1629
1630 ret = pActivateActCtx(handle, &cookie);
1631 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
1632
1633 memset(&data, 0, sizeof(data));
1634 memset(&data2, 0, sizeof(data2));
1635 data.cbSize = sizeof(data);
1636 data2.cbSize = sizeof(data2);
1637
1638 /* get data for two files from different assemblies */
1639 ret = pFindActCtxSectionStringW(0, NULL,
1640 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1641 testlib1W, &data);
1642 ok(ret, "got %d\n", ret);
1643 ret = pFindActCtxSectionStringW(0, NULL,
1644 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
1645 testlib2W, &data2);
1646 ok(ret, "got %d\n", ret);
1647
1648 section = (struct strsection_header*)data.lpSectionBase;
1649 ok(section->count == 4, "got %d\n", section->count);
1650 ok(section->size == sizeof(*section), "got %d\n", section->size);
1651
1652 /* For both string same section is returned, meaning it's one dll redirect section per context */
1653 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
1654 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
1655 data2.ulSectionTotalLength);
1656
1657 ret = pDeactivateActCtx(0, cookie);
1658 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
1659
1660 pReleaseActCtx(handle);
1661 }
1662
1663 static void test_typelib_section(void)
1664 {
1665 static const WCHAR helpW[] = {'h','e','l','p'};
1666 ACTCTX_SECTION_KEYED_DATA data, data2;
1667 struct guidsection_header *section;
1668 struct tlibredirect_data *tlib;
1669 ULONG_PTR cookie;
1670 HANDLE handle;
1671 BOOL ret;
1672
1673 /* use two dependent manifests, 4 'files' total */
1674 create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
1675 create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
1676 create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
1677
1678 handle = test_create("main_wndcls.manifest");
1679 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1680
1681 DeleteFileA("testdep1.manifest");
1682 DeleteFileA("testdep2.manifest");
1683 DeleteFileA("main_wndcls.manifest");
1684
1685 ret = pActivateActCtx(handle, &cookie);
1686 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
1687
1688 memset(&data, 0, sizeof(data));
1689 memset(&data2, 0, sizeof(data2));
1690 data.cbSize = sizeof(data);
1691 data2.cbSize = sizeof(data2);
1692
1693 /* get data for two typelibs from different assemblies */
1694 ret = pFindActCtxSectionGuid(0, NULL,
1695 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION,
1696 &IID_TlibTest, &data);
1697 ok(ret, "got %d\n", ret);
1698
1699 ret = pFindActCtxSectionGuid(0, NULL,
1700 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION,
1701 &IID_TlibTest4, &data2);
1702 ok(ret, "got %d\n", ret);
1703
1704 section = (struct guidsection_header*)data.lpSectionBase;
1705 ok(section->count == 4, "got %d\n", section->count);
1706 ok(section->size == sizeof(*section), "got %d\n", section->size);
1707
1708 /* For both GUIDs same section is returned */
1709 ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
1710 ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
1711 data2.ulSectionTotalLength);
1712
1713 ok(data.lpSectionGlobalData == ((BYTE*)section + section->names_offset), "data.lpSectionGlobalData == NULL\n");
1714 ok(data.ulSectionGlobalDataLength == section->names_len, "data.ulSectionGlobalDataLength=%u\n",
1715 data.ulSectionGlobalDataLength);
1716
1717 /* test some actual data */
1718 tlib = (struct tlibredirect_data*)data.lpData;
1719 ok(tlib->size == sizeof(*tlib), "got %d\n", tlib->size);
1720 ok(tlib->major_version == 1, "got %d\n", tlib->major_version);
1721 ok(tlib->minor_version == 0, "got %d\n", tlib->minor_version);
1722 ok(tlib->help_offset > 0, "got %d\n", tlib->help_offset);
1723 ok(tlib->help_len == sizeof(helpW), "got %d\n", tlib->help_len);
1724 ok(tlib->flags == (LIBFLAG_FHIDDEN|LIBFLAG_FCONTROL|LIBFLAG_FRESTRICTED), "got %x\n", tlib->flags);
1725
1726 ret = pDeactivateActCtx(0, cookie);
1727 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
1728
1729 pReleaseActCtx(handle);
1730 }
1731
1732 static void test_actctx(void)
1733 {
1734 ULONG_PTR cookie;
1735 HANDLE handle;
1736 BOOL b;
1737
1738 test_create_fail();
1739
1740 trace("default actctx\n");
1741
1742 b = pGetCurrentActCtx(&handle);
1743 ok(handle == NULL, "handle = %p, expected NULL\n", handle);
1744 ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
1745 if(b) {
1746 test_basic_info(handle, __LINE__);
1747 test_detailed_info(handle, &detailed_info0, __LINE__);
1748 pReleaseActCtx(handle);
1749 }
1750
1751 /* test for whitespace handling in Eq ::= S? '=' S? */
1752 create_manifest_file("test1_1.manifest", manifest1_1, -1, NULL, NULL);
1753 handle = test_create("test1_1.manifest");
1754 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1755 DeleteFileA("test1_1.manifest");
1756 pReleaseActCtx(handle);
1757
1758 if(!create_manifest_file("test1.manifest", manifest1, -1, NULL, NULL)) {
1759 skip("Could not create manifest file\n");
1760 return;
1761 }
1762
1763 trace("manifest1\n");
1764
1765 handle = test_create("test1.manifest");
1766 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1767 DeleteFileA("test1.manifest");
1768 if(handle != INVALID_HANDLE_VALUE) {
1769 test_basic_info(handle, __LINE__);
1770 test_detailed_info(handle, &detailed_info1, __LINE__);
1771 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__);
1772
1773 if (pIsDebuggerPresent && !pIsDebuggerPresent())
1774 {
1775 /* CloseHandle will generate an exception if a debugger is present */
1776 b = CloseHandle(handle);
1777 ok(!b, "CloseHandle succeeded\n");
1778 ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() == %u\n", GetLastError());
1779 }
1780
1781 pReleaseActCtx(handle);
1782 }
1783
1784 if(!create_manifest_file("test2.manifest", manifest2, -1, "testdep.manifest", testdep_manifest1)) {
1785 skip("Could not create manifest file\n");
1786 return;
1787 }
1788
1789 trace("manifest2 depmanifest1\n");
1790
1791 handle = test_create("test2.manifest");
1792 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1793 DeleteFileA("test2.manifest");
1794 DeleteFileA("testdep.manifest");
1795 if(handle != INVALID_HANDLE_VALUE) {
1796 test_basic_info(handle, __LINE__);
1797 test_detailed_info(handle, &detailed_info2, __LINE__);
1798 test_info_in_assembly(handle, 1, &manifest2_info, __LINE__);
1799 test_info_in_assembly(handle, 2, &depmanifest1_info, __LINE__);
1800 pReleaseActCtx(handle);
1801 }
1802
1803 if(!create_manifest_file("test2-2.manifest", manifest2, -1, "testdep.manifest", testdep_manifest2)) {
1804 skip("Could not create manifest file\n");
1805 return;
1806 }
1807
1808 trace("manifest2 depmanifest2\n");
1809
1810 handle = test_create("test2-2.manifest");
1811 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1812 DeleteFileA("test2-2.manifest");
1813 DeleteFileA("testdep.manifest");
1814 if(handle != INVALID_HANDLE_VALUE) {
1815 test_basic_info(handle, __LINE__);
1816 test_detailed_info(handle, &detailed_info2, __LINE__);
1817 test_info_in_assembly(handle, 1, &manifest2_info, __LINE__);
1818 test_info_in_assembly(handle, 2, &depmanifest2_info, __LINE__);
1819 test_file_info(handle, 1, 0, testlib_dll, __LINE__);
1820 test_file_info(handle, 1, 1, testlib2_dll, __LINE__);
1821
1822 b = pActivateActCtx(handle, &cookie);
1823 ok(b, "ActivateActCtx failed: %u\n", GetLastError());
1824 test_find_dll_redirection(handle, testlib_dll, 2, __LINE__);
1825 test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__);
1826 b = pDeactivateActCtx(0, cookie);
1827 ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
1828
1829 pReleaseActCtx(handle);
1830 }
1831
1832 trace("manifest2 depmanifest3\n");
1833
1834 if(!create_manifest_file("test2-3.manifest", manifest2, -1, "testdep.manifest", testdep_manifest3)) {
1835 skip("Could not create manifest file\n");
1836 return;
1837 }
1838
1839 handle = test_create("test2-3.manifest");
1840 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1841 DeleteFileA("test2-3.manifest");
1842 DeleteFileA("testdep.manifest");
1843 if(handle != INVALID_HANDLE_VALUE) {
1844 test_basic_info(handle, __LINE__);
1845 test_detailed_info(handle, &detailed_info2, __LINE__);
1846 test_info_in_assembly(handle, 1, &manifest2_info, __LINE__);
1847 test_info_in_assembly(handle, 2, &depmanifest3_info, __LINE__);
1848 test_file_info(handle, 1, 0, testlib_dll, __LINE__);
1849 test_file_info(handle, 1, 1, testlib2_dll, __LINE__);
1850
1851 b = pActivateActCtx(handle, &cookie);
1852 ok(b, "ActivateActCtx failed: %u\n", GetLastError());
1853 test_find_dll_redirection(handle, testlib_dll, 2, __LINE__);
1854 test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__);
1855 test_find_window_class(handle, wndClassW, 2, __LINE__);
1856 test_find_window_class(handle, wndClass2W, 2, __LINE__);
1857 b = pDeactivateActCtx(0, cookie);
1858 ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
1859
1860 pReleaseActCtx(handle);
1861 }
1862
1863 trace("manifest3\n");
1864
1865 if(!create_manifest_file("test3.manifest", manifest3, -1, NULL, NULL)) {
1866 skip("Could not create manifest file\n");
1867 return;
1868 }
1869
1870 handle = test_create("test3.manifest");
1871 ok(handle != INVALID_HANDLE_VALUE || broken(handle == INVALID_HANDLE_VALUE) /* XP pre-SP2, win2k3 w/o SP */,
1872 "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1873 if (handle == INVALID_HANDLE_VALUE)
1874 win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
1875 DeleteFileA("test3.manifest");
1876 if(handle != INVALID_HANDLE_VALUE) {
1877 static const WCHAR nameW[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
1878 static const WCHAR versionW[] = {'v','2','.','0','.','5','0','7','2','7',0};
1879 static const WCHAR progidW[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
1880 static const WCHAR clrprogidW[] = {'c','l','r','p','r','o','g','i','d',0};
1881
1882 test_basic_info(handle, __LINE__);
1883 test_detailed_info(handle, &detailed_info1, __LINE__);
1884 test_info_in_assembly(handle, 1, &manifest3_info, __LINE__);
1885 test_file_info(handle, 0, 0, testlib_dll, __LINE__);
1886
1887 b = pActivateActCtx(handle, &cookie);
1888 ok(b, "ActivateActCtx failed: %u\n", GetLastError());
1889 test_find_dll_redirection(handle, testlib_dll, 1, __LINE__);
1890 test_find_dll_redirection(handle, testlib_dll, 1, __LINE__);
1891 test_find_com_redirection(handle, &IID_CoTest, &IID_TlibTest, progidW, 1, __LINE__);
1892 test_find_com_redirection(handle, &IID_CoTest2, NULL, NULL, 1, __LINE__);
1893 test_find_com_redirection(handle, &CLSID_clrclass, &IID_TlibTest, clrprogidW, 1, __LINE__);
1894 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId", 1, __LINE__);
1895 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.1", 1, __LINE__);
1896 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.2", 1, __LINE__);
1897 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.3", 1, __LINE__);
1898 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.4", 1, __LINE__);
1899 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.5", 1, __LINE__);
1900 test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.6", 1, __LINE__);
1901 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid", 1, __LINE__);
1902 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.1", 1, __LINE__);
1903 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.2", 1, __LINE__);
1904 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.3", 1, __LINE__);
1905 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.4", 1, __LINE__);
1906 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.5", 1, __LINE__);
1907 test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.6", 1, __LINE__);
1908 test_find_surrogate(handle, &IID_Iiface, nameW, versionW, 1, __LINE__);
1909 test_find_ifaceps_redirection(handle, &IID_Iifaceps, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__);
1910 test_find_ifaceps_redirection(handle, &IID_Iifaceps2, &IID_TlibTest4, &IID_Ibifaceps, &IID_PS32, 1, __LINE__);
1911 test_find_ifaceps_redirection(handle, &IID_Iifaceps3, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__);
1912 test_find_string_fail();
1913
1914 b = pDeactivateActCtx(0, cookie);
1915 ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
1916 pReleaseActCtx(handle);
1917 }
1918
1919 trace("manifest4\n");
1920
1921 if(!create_manifest_file("test4.manifest", manifest4, -1, NULL, NULL)) {
1922 skip("Could not create manifest file\n");
1923 return;
1924 }
1925
1926 handle = test_create("test4.manifest");
1927 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1928 DeleteFileA("test4.manifest");
1929 DeleteFileA("testdep.manifest");
1930 if(handle != INVALID_HANDLE_VALUE) {
1931 test_basic_info(handle, __LINE__);
1932 test_detailed_info(handle, &detailed_info2, __LINE__);
1933 test_info_in_assembly(handle, 1, &manifest4_info, __LINE__);
1934 test_info_in_assembly(handle, 2, &manifest_comctrl_info, __LINE__);
1935 pReleaseActCtx(handle);
1936 }
1937
1938 trace("manifest1 in subdir\n");
1939
1940 CreateDirectoryW(work_dir_subdir, NULL);
1941 if (SetCurrentDirectoryW(work_dir_subdir))
1942 {
1943 if(!create_manifest_file("..\\test1.manifest", manifest1, -1, NULL, NULL)) {
1944 skip("Could not create manifest file\n");
1945 return;
1946 }
1947 handle = test_create("..\\test1.manifest");
1948 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1949 DeleteFileA("..\\test1.manifest");
1950 if(handle != INVALID_HANDLE_VALUE) {
1951 test_basic_info(handle, __LINE__);
1952 test_detailed_info(handle, &detailed_info1, __LINE__);
1953 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__);
1954 pReleaseActCtx(handle);
1955 }
1956 SetCurrentDirectoryW(work_dir);
1957 }
1958 else
1959 skip("Couldn't change directory\n");
1960 RemoveDirectoryW(work_dir_subdir);
1961
1962 trace("UTF-16 manifest1, with BOM\n");
1963 if(!create_wide_manifest("test1.manifest", manifest1, TRUE, FALSE)) {
1964 skip("Could not create manifest file\n");
1965 return;
1966 }
1967
1968 handle = test_create("test1.manifest");
1969 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1970 DeleteFileA("test1.manifest");
1971 if (handle != INVALID_HANDLE_VALUE) {
1972 test_basic_info(handle, __LINE__);
1973 test_detailed_info(handle, &detailed_info1, __LINE__);
1974 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__);
1975 pReleaseActCtx(handle);
1976 }
1977
1978 trace("UTF-16 manifest1, reverse endian, with BOM\n");
1979 if(!create_wide_manifest("test1.manifest", manifest1, TRUE, TRUE)) {
1980 skip("Could not create manifest file\n");
1981 return;
1982 }
1983
1984 handle = test_create("test1.manifest");
1985 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
1986 DeleteFileA("test1.manifest");
1987 if (handle != INVALID_HANDLE_VALUE) {
1988 test_basic_info(handle, __LINE__);
1989 test_detailed_info(handle, &detailed_info1, __LINE__);
1990 test_info_in_assembly(handle, 1, &manifest1_info, __LINE__);
1991 pReleaseActCtx(handle);
1992 }
1993
1994 test_wndclass_section();
1995 test_dllredirect_section();
1996 test_typelib_section();
1997 }
1998
1999 static void test_app_manifest(void)
2000 {
2001 HANDLE handle;
2002 BOOL b;
2003
2004 trace("child process manifest1\n");
2005
2006 b = pGetCurrentActCtx(&handle);
2007 ok(handle == NULL, "handle != NULL\n");
2008 ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
2009 if(b) {
2010 test_basic_info(handle, __LINE__);
2011 test_detailed_info(handle, &detailed_info1_child, __LINE__);
2012 test_info_in_assembly(handle, 1, &manifest1_child_info, __LINE__);
2013 pReleaseActCtx(handle);
2014 }
2015 }
2016
2017 static void run_child_process(void)
2018 {
2019 char cmdline[MAX_PATH];
2020 char path[MAX_PATH];
2021 char **argv;
2022 PROCESS_INFORMATION pi;
2023 STARTUPINFOA si = { 0 };
2024 HANDLE file;
2025 FILETIME now;
2026 BOOL ret;
2027
2028 GetModuleFileNameA(NULL, path, MAX_PATH);
2029 strcat(path, ".manifest");
2030 if(!create_manifest_file(path, manifest1, -1, NULL, NULL)) {
2031 skip("Could not create manifest file\n");
2032 return;
2033 }
2034
2035 si.cb = sizeof(si);
2036 winetest_get_mainargs( &argv );
2037 /* Vista+ seems to cache presence of .manifest files. Change last modified
2038 date to defeat the cache */
2039 file = CreateFileA(argv[0], FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE,
2040 NULL, OPEN_EXISTING, 0, NULL);
2041 if (file != INVALID_HANDLE_VALUE) {
2042 GetSystemTimeAsFileTime(&now);
2043 SetFileTime(file, NULL, NULL, &now);
2044 CloseHandle(file);
2045 }
2046 sprintf(cmdline, "\"%s\" %s manifest1", argv[0], argv[1]);
2047 ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
2048 ok(ret, "Could not create process: %u\n", GetLastError());
2049 winetest_wait_child_process( pi.hProcess );
2050 CloseHandle(pi.hThread);
2051 CloseHandle(pi.hProcess);
2052 DeleteFileA(path);
2053 }
2054
2055 static void init_paths(void)
2056 {
2057 LPWSTR ptr;
2058 WCHAR last;
2059
2060 static const WCHAR dot_manifest[] = {'.','M','a','n','i','f','e','s','t',0};
2061 static const WCHAR backslash[] = {'\\',0};
2062 static const WCHAR subdir[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
2063
2064 GetModuleFileNameW(NULL, exe_path, sizeof(exe_path)/sizeof(WCHAR));
2065 lstrcpyW(app_dir, exe_path);
2066 for(ptr=app_dir+lstrlenW(app_dir); *ptr != '\\' && *ptr != '/'; ptr--);
2067 ptr[1] = 0;
2068
2069 GetCurrentDirectoryW(MAX_PATH, work_dir);
2070 last = work_dir[lstrlenW(work_dir) - 1];
2071 if (last != '\\' && last != '/')
2072 lstrcatW(work_dir, backslash);
2073 lstrcpyW(work_dir_subdir, work_dir);
2074 lstrcatW(work_dir_subdir, subdir);
2075
2076 GetModuleFileNameW(NULL, app_manifest_path, sizeof(app_manifest_path)/sizeof(WCHAR));
2077 lstrcpyW(app_manifest_path+lstrlenW(app_manifest_path), dot_manifest);
2078 }
2079
2080 static void write_manifest(const char *filename, const char *manifest)
2081 {
2082 HANDLE file;
2083 DWORD size;
2084 CHAR path[MAX_PATH];
2085
2086 GetTempPathA(sizeof(path)/sizeof(CHAR), path);
2087 strcat(path, filename);
2088
2089 file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2090 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
2091 WriteFile(file, manifest, strlen(manifest), &size, NULL);
2092 CloseHandle(file);
2093 }
2094
2095 static void delete_manifest_file(const char *filename)
2096 {
2097 CHAR path[MAX_PATH];
2098
2099 GetTempPathA(sizeof(path)/sizeof(CHAR), path);
2100 strcat(path, filename);
2101 DeleteFileA(path);
2102 }
2103
2104 static void test_CreateActCtx(void)
2105 {
2106 CHAR path[MAX_PATH], dir[MAX_PATH];
2107 ACTCTXA actctx;
2108 HANDLE handle;
2109
2110 GetTempPathA(sizeof(path)/sizeof(CHAR), path);
2111 strcat(path, "main_wndcls.manifest");
2112
2113 write_manifest("testdep1.manifest", manifest_wndcls1);
2114 write_manifest("testdep2.manifest", manifest_wndcls2);
2115 write_manifest("main_wndcls.manifest", manifest_wndcls_main);
2116
2117 memset(&actctx, 0, sizeof(ACTCTXA));
2118 actctx.cbSize = sizeof(ACTCTXA);
2119 actctx.lpSource = path;
2120
2121 /* create using lpSource without specified directory */
2122 handle = pCreateActCtxA(&actctx);
2123 ok(handle != INVALID_HANDLE_VALUE, "failed to generate context, error %u\n", GetLastError());
2124 pReleaseActCtx(handle);
2125
2126 /* with specified directory, that doesn't contain dependent assembly */
2127 GetWindowsDirectoryA(dir, sizeof(dir)/sizeof(CHAR));
2128
2129 memset(&actctx, 0, sizeof(ACTCTXA));
2130 actctx.cbSize = sizeof(ACTCTXA);
2131 actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
2132 actctx.lpAssemblyDirectory = dir;
2133 actctx.lpSource = path;
2134
2135 SetLastError(0xdeadbeef);
2136 handle = pCreateActCtxA(&actctx);
2137 todo_wine {
2138 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2139 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "got error %d\n", GetLastError());
2140 }
2141 if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx(handle);
2142
2143 delete_manifest_file("main_wndcls.manifest");
2144 delete_manifest_file("testdep1.manifest");
2145 delete_manifest_file("testdep2.manifest");
2146
2147 /* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
2148 memset(&actctx, 0, sizeof(ACTCTXA));
2149 actctx.cbSize = sizeof(ACTCTXA);
2150 actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID;
2151 SetLastError(0xdeadbeef);
2152 handle = pCreateActCtxA(&actctx);
2153 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2154 todo_wine
2155 ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY) /* XP, win2k3 */,
2156 "got error %d\n", GetLastError());
2157
2158 /* create from HMODULE - resource doesn't exist, lpSource is set */
2159 memset(&actctx, 0, sizeof(ACTCTXA));
2160 actctx.cbSize = sizeof(ACTCTXA);
2161 actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
2162 actctx.lpSource = "dummyfile.dll";
2163 actctx.lpResourceName = MAKEINTRESOURCEA(20);
2164 actctx.hModule = GetModuleHandleA(NULL);
2165
2166 SetLastError(0xdeadbeef);
2167 handle = pCreateActCtxA(&actctx);
2168 ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
2169 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "got error %d\n", GetLastError());
2170 }
2171
2172 static BOOL init_funcs(void)
2173 {
2174 HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
2175
2176 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
2177 X(ActivateActCtx);
2178 X(CreateActCtxA);
2179 X(CreateActCtxW);
2180 X(DeactivateActCtx);
2181 X(FindActCtxSectionStringA);
2182 X(FindActCtxSectionStringW);
2183 X(GetCurrentActCtx);
2184 X(IsDebuggerPresent);
2185 X(QueryActCtxW);
2186 X(ReleaseActCtx);
2187 X(FindActCtxSectionGuid);
2188 #undef X
2189
2190 return TRUE;
2191 }
2192
2193 START_TEST(actctx)
2194 {
2195 int argc;
2196 char **argv;
2197
2198 argc = winetest_get_mainargs(&argv);
2199
2200 if (!init_funcs())
2201 {
2202 win_skip("Needed functions are not available\n");
2203 return;
2204 }
2205 init_paths();
2206
2207 if(argc > 2 && !strcmp(argv[2], "manifest1")) {
2208 test_app_manifest();
2209 return;
2210 }
2211
2212 test_actctx();
2213 test_CreateActCtx();
2214 run_child_process();
2215 }