~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/kernel32/tests/actctx.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  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 static BOOL   (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
 28 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
 29 static BOOL   (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
 30 static BOOL   (WINAPI *pFindActCtxSectionStringW)(DWORD,const GUID *,ULONG,LPCWSTR,PACTCTX_SECTION_KEYED_DATA);
 31 static BOOL   (WINAPI *pGetCurrentActCtx)(HANDLE *);
 32 static BOOL   (WINAPI *pIsDebuggerPresent)(void);
 33 static BOOL   (WINAPI *pQueryActCtxW)(DWORD,HANDLE,PVOID,ULONG,PVOID,SIZE_T,SIZE_T*);
 34 static VOID   (WINAPI *pReleaseActCtx)(HANDLE);
 35 
 36 static const char* strw(LPCWSTR x)
 37 {
 38     static char buffer[1024];
 39     char*       p = buffer;
 40 
 41     if (!x) return "(nil)";
 42     else while ((*p++ = *x++));
 43     return buffer;
 44 }
 45 
 46 static const char manifest1[] =
 47 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 48 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
 49 "</assembly>";
 50 
 51 static const char manifest2[] =
 52 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 53 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
 54 "</assemblyIdentity>"
 55 "<dependency>"
 56 "<dependentAssembly>"
 57 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\">"
 58 "</assemblyIdentity>"
 59 "</dependentAssembly>"
 60 "</dependency>"
 61 "</assembly>";
 62 
 63 static const char manifest3[] =
 64 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 65 "<assemblyIdentity version=\"1.2.3.4\"  name=\"Wine.Test\" type=\"win32\""
 66 " publicKeyToken=\"6595b6414666f1df\" />"
 67 "<file name=\"testlib.dll\">"
 68 "<windowClass>wndClass</windowClass>"
 69 "</file>"
 70 "</assembly>";
 71 
 72 static const char manifest4[] =
 73 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 74 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
 75 "</assemblyIdentity>"
 76 "<dependency>"
 77 "<dependentAssembly>"
 78 "<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
 79     "version=\"6.0.1.0\" processorArchitecture=\"x86\" publicKeyToken=\"6595b64144ccf1df\">"
 80 "</assemblyIdentity>"
 81 "</dependentAssembly>"
 82 "</dependency>"
 83 "</assembly>";
 84 
 85 static const char testdep_manifest1[] =
 86 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 87 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\"/>"
 88 "</assembly>";
 89 
 90 static const char testdep_manifest2[] =
 91 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 92 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\" />"
 93 "<file name=\"testlib.dll\"></file>"
 94 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
 95 "</assembly>";
 96 
 97 static const char testdep_manifest3[] =
 98 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
 99 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\"/>"
100 "<file name=\"testlib.dll\"/>"
101 "<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
102 "<windowClass>wndClass</windowClass>"
103 "<windowClass>wndClass2</windowClass>"
104 "</file>"
105 "</assembly>";
106 
107 static const char wrong_manifest1[] =
108 "<assembly manifestVersion=\"1.0\">"
109 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
110 "</assembly>";
111 
112 static const char wrong_manifest2[] =
113 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\">"
114 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
115 "</assembly>";
116 
117 static const char wrong_manifest3[] =
118 "<assembly test=\"test\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
119 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
120 "</assembly>";
121 
122 static const char wrong_manifest4[] =
123 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
124 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
125 "<test></test>"
126 "</assembly>";
127 
128 static const char wrong_manifest5[] =
129 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
130 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
131 "</assembly>"
132 "<test></test>";
133 
134 static const char wrong_manifest6[] =
135 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v5\" manifestVersion=\"1.0\">"
136 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
137 "</assembly>";
138 
139 static const char wrong_manifest7[] =
140 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
141 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\" />"
142 "<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
143 "</assembly>";
144 
145 static const char wrong_manifest8[] =
146 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
147 "<assemblyIdentity version=\"1.2.3.4\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
148 "<file></file>"
149 "</assembly>";
150 
151 static const char wrong_depmanifest1[] =
152 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
153 "<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"x86\" />"
154 "</assembly>";
155 
156 static const WCHAR testlib_dll[] =
157     {'t','e','s','t','l','i','b','.','d','l','l',0};
158 static const WCHAR testlib2_dll[] =
159     {'t','e','s','t','l','i','b','2','.','d','l','l',0};
160 static const WCHAR wndClassW[] =
161     {'w','n','d','C','l','a','s','s',0};
162 static const WCHAR wndClass2W[] =
163     {'w','n','d','C','l','a','s','s','2',0};
164 static const WCHAR acr_manifest[] =
165     {'a','c','r','.','m','a','n','i','f','e','s','t',0};
166 
167 static WCHAR app_dir[MAX_PATH], exe_path[MAX_PATH], work_dir[MAX_PATH], work_dir_subdir[MAX_PATH];
168 static WCHAR app_manifest_path[MAX_PATH], manifest_path[MAX_PATH], depmanifest_path[MAX_PATH];
169 
170 static int strcmp_aw(LPCWSTR strw, const char *stra)
171 {
172     WCHAR buf[1024];
173 
174     if (!stra) return 1;
175     MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
176     return lstrcmpW(strw, buf);
177 }
178 
179 static DWORD strlen_aw(const char *str)
180 {
181     return MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0) - 1;
182 }
183 
184 static BOOL create_manifest_file(const char *filename, const char *manifest, int manifest_len,
185                                  const char *depfile, const char *depmanifest)
186 {
187     DWORD size;
188     HANDLE file;
189     WCHAR path[MAX_PATH];
190 
191     MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
192     GetFullPathNameW(path, sizeof(manifest_path)/sizeof(WCHAR), manifest_path, NULL);
193 
194     if (manifest_len == -1)
195         manifest_len = strlen(manifest);
196 
197     file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
198                        FILE_ATTRIBUTE_NORMAL, NULL);
199     ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
200     if(file == INVALID_HANDLE_VALUE)
201         return FALSE;
202     WriteFile(file, manifest, manifest_len, &size, NULL);
203     CloseHandle(file);
204 
205     if (depmanifest)
206     {
207         MultiByteToWideChar( CP_ACP, 0, depfile, -1, path, MAX_PATH );
208         GetFullPathNameW(path, sizeof(depmanifest_path)/sizeof(WCHAR), depmanifest_path, NULL);
209         file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
210                            FILE_ATTRIBUTE_NORMAL, NULL);
211         ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
212         if(file == INVALID_HANDLE_VALUE)
213             return FALSE;
214         WriteFile(file, depmanifest, strlen(depmanifest), &size, NULL);
215         CloseHandle(file);
216     }
217     return TRUE;
218 }
219 
220 static BOOL create_wide_manifest(const char *filename, const char *manifest, BOOL fBOM, BOOL fReverse)
221 {
222     WCHAR *wmanifest = HeapAlloc(GetProcessHeap(), 0, (strlen(manifest)+2) * sizeof(WCHAR));
223     BOOL ret;
224     int offset = (fBOM ? 0 : 1);
225 
226     MultiByteToWideChar(CP_ACP, 0, manifest, -1, &wmanifest[1], (strlen(manifest)+1));
227     wmanifest[0] = 0xfeff;
228     if (fReverse)
229     {
230         size_t i;
231         for (i = 0; i < strlen(manifest)+1; i++)
232             wmanifest[i] = (wmanifest[i] << 8) | ((wmanifest[i] >> 8) & 0xff);
233     }
234     ret = create_manifest_file(filename, (char *)&wmanifest[offset], (strlen(manifest)+1-offset) * sizeof(WCHAR), NULL, NULL);
235     HeapFree(GetProcessHeap(), 0, wmanifest);
236     return ret;
237 }
238 
239 typedef struct {
240     ULONG format_version;
241     ULONG assembly_cnt;
242     ULONG root_manifest_type;
243     LPWSTR root_manifest_path;
244     ULONG root_config_type;
245     ULONG app_dir_type;
246     LPCWSTR app_dir;
247 } detailed_info_t;
248 
249 static const detailed_info_t detailed_info0 = {
250     0, 0, 0, NULL, 0, 0, NULL
251 };
252 
253 static const detailed_info_t detailed_info1 = {
254     1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
255     ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
256     work_dir,
257 };
258 
259 static const detailed_info_t detailed_info1_child = {
260     1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, app_manifest_path,
261     ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
262     app_dir,
263 };
264 
265 static const detailed_info_t detailed_info2 = {
266     1, 2, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
267     ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
268     work_dir,
269 };
270 
271 static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo)
272 {
273     ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp, *detailed_info;
274     SIZE_T size, exsize, retsize;
275     BOOL b;
276 
277     exsize = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)
278         + (exinfo->root_manifest_path ? (lstrlenW(exinfo->root_manifest_path)+1)*sizeof(WCHAR):0)
279         + (exinfo->app_dir ? (lstrlenW(exinfo->app_dir)+1)*sizeof(WCHAR) : 0);
280 
281     if(exsize != sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION)) {
282         size = 0xdeadbeef;
283         b = pQueryActCtxW(0, handle, NULL,
284                           ActivationContextDetailedInformation, &detailed_info_tmp,
285                           sizeof(detailed_info_tmp), &size);
286         ok(!b, "QueryActCtx succeeded\n");
287         ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
288         ok(size == exsize, "size=%ld, expected %ld\n", size, exsize);
289     }else {
290         size = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION);
291     }
292 
293     detailed_info = HeapAlloc(GetProcessHeap(), 0, size);
294     memset(detailed_info, 0xfe, size);
295     b = pQueryActCtxW(0, handle, NULL,
296                       ActivationContextDetailedInformation, detailed_info,
297                       size, &retsize);
298     ok(b, "QueryActCtx failed: %u\n", GetLastError());
299     ok(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize);
300 
301     ok(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags);
302     ok(detailed_info->ulFormatVersion == exinfo->format_version,
303        "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info->ulFormatVersion,
304        exinfo->format_version);
305     ok(detailed_info->ulAssemblyCount == exinfo->assembly_cnt,
306        "detailed_info->ulAssemblyCount=%u, expected %u\n", detailed_info->ulAssemblyCount,
307        exinfo->assembly_cnt);
308     ok(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type,
309        "detailed_info->ulRootManifestPathType=%u, expected %u\n",
310        detailed_info->ulRootManifestPathType, exinfo->root_manifest_type);
311     ok(detailed_info->ulRootManifestPathChars ==
312        (exinfo->root_manifest_path ? lstrlenW(exinfo->root_manifest_path) : 0),
313        "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
314        detailed_info->ulRootManifestPathChars,
315        exinfo->root_manifest_path ?lstrlenW(exinfo->root_manifest_path) : 0);
316     ok(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type,
317        "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
318        detailed_info->ulRootConfigurationPathType, exinfo->root_config_type);
319     ok(detailed_info->ulRootConfigurationPathChars == 0,
320        "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info->ulRootConfigurationPathChars);
321     ok(detailed_info->ulAppDirPathType == exinfo->app_dir_type,
322        "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info->ulAppDirPathType,
323        exinfo->app_dir_type);
324     ok(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0),
325        "detailed_info->ulAppDirPathChars=%u, expected %u\n",
326        detailed_info->ulAppDirPathChars, exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0);
327     if(exinfo->root_manifest_path) {
328         ok(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n");
329         if(detailed_info->lpRootManifestPath)
330             ok(!lstrcmpiW(detailed_info->lpRootManifestPath, exinfo->root_manifest_path),
331                "unexpected detailed_info->lpRootManifestPath\n");
332     }else {
333         ok(detailed_info->lpRootManifestPath == NULL, "detailed_info->lpRootManifestPath != NULL\n");
334     }
335     ok(detailed_info->lpRootConfigurationPath == NULL,
336        "detailed_info->lpRootConfigurationPath=%p\n", detailed_info->lpRootConfigurationPath);
337     if(exinfo->app_dir) {
338         ok(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n");
339         if(detailed_info->lpAppDirPath)
340             ok(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath),
341                "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info->lpAppDirPath));
342     }else {
343         ok(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n");
344     }
345 
346     HeapFree(GetProcessHeap(), 0, detailed_info);
347 }
348 
349 typedef struct {
350     ULONG flags;
351 /*    ULONG manifest_path_type; FIXME */
352     LPCWSTR manifest_path;
353     LPCSTR encoded_assembly_id;
354     BOOL has_assembly_dir;
355 } info_in_assembly;
356 
357 static const info_in_assembly manifest1_info = {
358     1, manifest_path,
359     "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
360     FALSE
361 };
362 
363 static const info_in_assembly manifest1_child_info = {
364     1, app_manifest_path,
365     "Wine.Test,type=\"win32\",version=\"1.0.0.0\"",
366     FALSE
367 };
368 
369 static const info_in_assembly manifest2_info = {
370     1, manifest_path,
371     "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
372     FALSE
373 };
374 
375 static const info_in_assembly manifest3_info = {
376     1, manifest_path,
377     "Wine.Test,publicKeyToken=\"6595b6414666f1df\",type=\"win32\",version=\"1.2.3.4\"",
378     FALSE
379 };
380 
381 static const info_in_assembly manifest4_info = {
382     1, manifest_path,
383     "Wine.Test,type=\"win32\",version=\"1.2.3.4\"",
384     FALSE
385 };
386 
387 static const info_in_assembly depmanifest1_info = {
388     0x10, depmanifest_path,
389     "testdep,processorArchitecture=\"x86\","
390     "type=\"win32\",version=\"6.5.4.3\"",
391     TRUE
392 };
393 
394 static const info_in_assembly depmanifest2_info = {
395     0x10, depmanifest_path,
396     "testdep,processorArchitecture=\"x86\","
397     "type=\"win32\",version=\"6.5.4.3\"",
398     TRUE
399 };
400 
401 static const info_in_assembly depmanifest3_info = {
402     0x10, depmanifest_path,
403     "testdep,processorArchitecture=\"x86\",type=\"win32\",version=\"6.5.4.3\"",
404     TRUE
405 };
406 
407 static const info_in_assembly manifest_comctrl_info = {
408     0, NULL, NULL, TRUE /* These values may differ between Windows installations */
409 };
410 
411 static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembly *exinfo)
412 {
413     ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info, info_tmp;
414     SIZE_T size, exsize;
415     ULONG len;
416     BOOL b;
417 
418     exsize = sizeof(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION);
419     if (exinfo->manifest_path) exsize += (lstrlenW(exinfo->manifest_path)+1) * sizeof(WCHAR);
420     if (exinfo->encoded_assembly_id) exsize += (strlen_aw(exinfo->encoded_assembly_id) + 1) * sizeof(WCHAR);
421 
422     size = 0xdeadbeef;
423     b = pQueryActCtxW(0, handle, &id,
424                       AssemblyDetailedInformationInActivationContext, &info_tmp,
425                       sizeof(info_tmp), &size);
426     ok(!b, "QueryActCtx succeeded\n");
427     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
428 
429     ok(size >= exsize, "size=%lu, expected %lu\n", size, exsize);
430 
431     if (size == 0xdeadbeef)
432     {
433         skip("bad size\n");
434         return;
435     }
436 
437     info = HeapAlloc(GetProcessHeap(), 0, size);
438     memset(info, 0xfe, size);
439 
440     size = 0xdeadbeef;
441     b = pQueryActCtxW(0, handle, &id,
442                       AssemblyDetailedInformationInActivationContext, info, size, &size);
443     ok(b, "QueryActCtx failed: %u\n", GetLastError());
444     if (!exinfo->manifest_path)
445         exsize += info->ulManifestPathLength + sizeof(WCHAR);
446     if (!exinfo->encoded_assembly_id)
447         exsize += info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
448     if (exinfo->has_assembly_dir)
449         exsize += info->ulAssemblyDirectoryNameLength + sizeof(WCHAR);
450     ok(size == exsize, "size=%lu, expected %lu\n", size, exsize);
451 
452     if (0)  /* FIXME: flags meaning unknown */
453     {
454         ok((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n",
455            info->ulFlags, exinfo->flags);
456     }
457     if(exinfo->encoded_assembly_id) {
458         len = strlen_aw(exinfo->encoded_assembly_id)*sizeof(WCHAR);
459         ok(info->ulEncodedAssemblyIdentityLength == len,
460            "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
461            info->ulEncodedAssemblyIdentityLength, len);
462     } else {
463         ok(info->ulEncodedAssemblyIdentityLength != 0,
464            "info->ulEncodedAssemblyIdentityLength == 0\n");
465     }
466     ok(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
467        "info->ulManifestPathType = %x\n", info->ulManifestPathType);
468     if(exinfo->manifest_path) {
469         len = lstrlenW(exinfo->manifest_path)*sizeof(WCHAR);
470         ok(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n",
471            info->ulManifestPathLength, len);
472     } else {
473         ok(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n");
474     }
475 
476     ok(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE,
477        "info->ulPolicyPathType = %x\n", info->ulPolicyPathType);
478     ok(info->ulPolicyPathLength == 0,
479        "info->ulPolicyPathLength = %u, expected 0\n", info->ulPolicyPathLength);
480     ok(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
481        info->ulMetadataSatelliteRosterIndex);
482     ok(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n",
483        info->ulManifestVersionMajor);
484     ok(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n",
485        info->ulManifestVersionMinor);
486     ok(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n",
487        info->ulPolicyVersionMajor);
488     ok(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n",
489        info->ulPolicyVersionMinor);
490     if(exinfo->has_assembly_dir)
491         ok(info->ulAssemblyDirectoryNameLength != 0,
492            "info->ulAssemblyDirectoryNameLength == 0\n");
493     else
494         ok(info->ulAssemblyDirectoryNameLength == 0,
495            "info->ulAssemblyDirectoryNameLength != 0\n");
496 
497     ok(info->lpAssemblyEncodedAssemblyIdentity != NULL,
498        "info->lpAssemblyEncodedAssemblyIdentity == NULL\n");
499     if(info->lpAssemblyEncodedAssemblyIdentity && exinfo->encoded_assembly_id) {
500         ok(!strcmp_aw(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id),
501            "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
502            strw(info->lpAssemblyEncodedAssemblyIdentity), exinfo->encoded_assembly_id);
503     }
504     if(exinfo->manifest_path) {
505         ok(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
506         if(info->lpAssemblyManifestPath)
507             ok(!lstrcmpiW(info->lpAssemblyManifestPath, exinfo->manifest_path),
508                "unexpected info->lpAssemblyManifestPath\n");
509     }else {
510         ok(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
511     }
512 
513     ok(info->lpAssemblyPolicyPath == NULL, "info->lpAssemblyPolicyPath != NULL\n");
514     if(info->lpAssemblyPolicyPath)
515         ok(*(WORD*)info->lpAssemblyPolicyPath == 0, "info->lpAssemblyPolicyPath is not empty\n");
516     if(exinfo->has_assembly_dir)
517         ok(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n");
518     else
519         ok(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n",
520            strw(info->lpAssemblyDirectoryName));
521     HeapFree(GetProcessHeap(), 0, info);
522 }
523 
524 static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR filename)
525 {
526     ASSEMBLY_FILE_DETAILED_INFORMATION *info, info_tmp;
527     ACTIVATION_CONTEXT_QUERY_INDEX index = {assid, fileid};
528     SIZE_T size, exsize;
529     BOOL b;
530 
531     exsize = sizeof(ASSEMBLY_FILE_DETAILED_INFORMATION)
532         +(lstrlenW(filename)+1)*sizeof(WCHAR);
533 
534     size = 0xdeadbeef;
535     b = pQueryActCtxW(0, handle, &index,
536                       FileInformationInAssemblyOfAssemblyInActivationContext, &info_tmp,
537                       sizeof(info_tmp), &size);
538     ok(!b, "QueryActCtx succeeded\n");
539     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
540     ok(size == exsize, "size=%lu, expected %lu\n", size, exsize);
541 
542     if(size == 0xdeadbeef)
543     {
544         skip("bad size\n");
545         return;
546     }
547 
548     info = HeapAlloc(GetProcessHeap(), 0, size);
549     memset(info, 0xfe, size);
550 
551     b = pQueryActCtxW(0, handle, &index,
552                       FileInformationInAssemblyOfAssemblyInActivationContext, info, size, &size);
553     ok(b, "QueryActCtx failed: %u\n", GetLastError());
554     ok(!size, "size=%lu, expected 0\n", size);
555 
556     ok(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags);
557     ok(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR),
558        "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
559        info->ulFilenameLength, lstrlenW(filename));
560     ok(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength);
561     ok(info->lpFileName != NULL, "info->lpFileName == NULL\n");
562     if(info->lpFileName)
563         ok(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n");
564     ok(info->lpFilePath == NULL, "info->lpFilePath != NULL\n");
565     HeapFree(GetProcessHeap(), 0, info);
566 }
567 
568 static HANDLE test_create(const char *file, const char *manifest)
569 {
570     ACTCTXW actctx;
571     HANDLE handle;
572     WCHAR path[MAX_PATH];
573 
574     MultiByteToWideChar( CP_ACP, 0, file, -1, path, MAX_PATH );
575     memset(&actctx, 0, sizeof(ACTCTXW));
576     actctx.cbSize = sizeof(ACTCTXW);
577     actctx.lpSource = path;
578 
579     handle = pCreateActCtxW(&actctx);
580     ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
581 
582     ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
583     ok(actctx.dwFlags == 0, "actctx.=%d\n", actctx.dwFlags);
584     ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
585     ok(actctx.wProcessorArchitecture == 0,
586        "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
587     ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId);
588     ok(actctx.lpAssemblyDirectory == NULL,
589        "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
590     ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName);
591     ok(actctx.lpApplicationName == NULL, "actctx.lpApplocationName=%p\n",
592        actctx.lpApplicationName);
593     ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule);
594 
595     return handle;
596 }
597 
598 static void test_create_and_fail(const char *manifest, const char *depmanifest, int todo)
599 {
600     ACTCTXW actctx;
601     HANDLE handle;
602     WCHAR path[MAX_PATH];
603 
604     MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH );
605     memset(&actctx, 0, sizeof(ACTCTXW));
606     actctx.cbSize = sizeof(ACTCTXW);
607     actctx.lpSource = path;
608 
609     create_manifest_file("bad.manifest", manifest, -1, "testdep.manifest", depmanifest);
610     handle = pCreateActCtxW(&actctx);
611     if (todo) todo_wine
612     {
613         ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
614         ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
615     }
616     else
617     {
618         ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
619         ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
620     }
621     if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle );
622     DeleteFileA("bad.manifest");
623     DeleteFileA("testdep.manifest");
624 }
625 
626 static void test_create_wide_and_fail(const char *manifest, BOOL fBOM)
627 {
628     ACTCTXW actctx;
629     HANDLE handle;
630     WCHAR path[MAX_PATH];
631 
632     MultiByteToWideChar( CP_ACP, 0, "bad.manifest", -1, path, MAX_PATH );
633     memset(&actctx, 0, sizeof(ACTCTXW));
634     actctx.cbSize = sizeof(ACTCTXW);
635     actctx.lpSource = path;
636 
637     create_wide_manifest("bad.manifest", manifest, fBOM, FALSE);
638     handle = pCreateActCtxW(&actctx);
639     ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
640     ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
641 
642     if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx( handle );
643     DeleteFileA("bad.manifest");
644 }
645 
646 static void test_create_fail(void)
647 {
648     ACTCTXW actctx;
649     HANDLE handle;
650     WCHAR path[MAX_PATH];
651 
652     MultiByteToWideChar( CP_ACP, 0, "nonexistent.manifest", -1, path, MAX_PATH );
653     memset(&actctx, 0, sizeof(ACTCTXW));
654     actctx.cbSize = sizeof(ACTCTXW);
655     actctx.lpSource = path;
656 
657     handle = pCreateActCtxW(&actctx);
658     ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
659     ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError == %u\n", GetLastError());
660 
661     trace("wrong_manifest1\n");
662     test_create_and_fail(wrong_manifest1, NULL, 0 );
663     trace("wrong_manifest2\n");
664     test_create_and_fail(wrong_manifest2, NULL, 0 );
665     trace("wrong_manifest3\n");
666     test_create_and_fail(wrong_manifest3, NULL, 1 );
667     trace("wrong_manifest4\n");
668     test_create_and_fail(wrong_manifest4, NULL, 1 );
669     trace("wrong_manifest5\n");
670     test_create_and_fail(wrong_manifest5, NULL, 0 );
671     trace("wrong_manifest6\n");
672     test_create_and_fail(wrong_manifest6, NULL, 0 );
673     trace("wrong_manifest7\n");
674     test_create_and_fail(wrong_manifest7, NULL, 1 );
675     trace("wrong_manifest8\n");
676     test_create_and_fail(wrong_manifest8, NULL, 0 );
677     trace("UTF-16 manifest1 without BOM\n");
678     test_create_wide_and_fail(manifest1, FALSE );
679     trace("manifest2\n");
680     test_create_and_fail(manifest2, NULL, 0 );
681     trace("manifest2+depmanifest1\n");
682     test_create_and_fail(manifest2, wrong_depmanifest1, 0 );
683 }
684 
685 static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid)
686 {
687     ACTCTX_SECTION_KEYED_DATA data;
688     DWORD *p;
689     BOOL ret;
690 
691     memset(&data, 0xfe, sizeof(data));
692     data.cbSize = sizeof(data);
693 
694     ret = pFindActCtxSectionStringW(0, NULL,
695                                     ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
696                                     libname, &data);
697     ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
698     if(!ret)
699     {
700         skip("couldn't find %s\n",strw(libname));
701         return;
702     }
703 
704     ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
705     ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
706     ok(data.lpData != NULL, "data.lpData == NULL\n");
707     ok(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
708 
709     p = data.lpData;
710     if(ret && p) todo_wine {
711         ok(p[0] == 20 && p[1] == 2 && p[2] == 0 && p[3] == 0 && p[4] == 0,
712            "wrong data %u,%u,%u,%u,%u\n",p[0], p[1], p[2], p[3], p[4]);
713     }
714 
715     ok(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
716     ok(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
717        data.ulSectionGlobalDataLength);
718     ok(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
719     /* ok(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n",
720        data.ulSectionTotalLength); */
721     ok(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
722     ok(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
723        data.ulAssemblyRosterIndex, exid);
724 
725     memset(&data, 0xfe, sizeof(data));
726     data.cbSize = sizeof(data);
727 
728     ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
729                                     ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
730                                     libname, &data);
731     ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
732     if(!ret)
733     {
734         skip("couldn't find\n");
735         return;
736     }
737 
738     ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
739     ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
740     ok(data.lpData != NULL, "data.lpData == NULL\n");
741     ok(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
742     ok(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
743     ok(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
744        data.ulSectionGlobalDataLength);
745     ok(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
746     /* ok(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n",
747        data.ulSectionTotalLength); */
748     ok(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
749     ok(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
750        data.ulAssemblyRosterIndex, exid);
751 
752     pReleaseActCtx(handle);
753 }
754 
755 static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid)
756 {
757     ACTCTX_SECTION_KEYED_DATA data;
758     BOOL ret;
759 
760     memset(&data, 0xfe, sizeof(data));
761     data.cbSize = sizeof(data);
762 
763     ret = pFindActCtxSectionStringW(0, NULL,
764                                     ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
765                                     clsname, &data);
766     ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
767     if(!ret)
768     {
769         skip("couldn't find\n");
770         return;
771     }
772 
773     ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
774     ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
775     ok(data.lpData != NULL, "data.lpData == NULL\n");
776     /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); */
777     ok(data.lpSectionGlobalData == NULL,