1 /* 2 * Utility routines for comctl32 v6 tests 3 * 4 * Copyright 2006 Mike McCormack for CodeWeavers 5 * Copyright 2007 George Gov 6 * Copyright 2009 Owen Rudge for CodeWeavers 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 */ 22 23 #pragma once 24 25 #ifdef __i386__ 26 #define ARCH "x86" 27 #elif defined __x86_64__ 28 #define ARCH "amd64" 29 #elif defined __arm__ 30 #define ARCH "arm" 31 #elif defined __aarch64__ 32 #define ARCH "arm64" 33 #else 34 #define ARCH "none" 35 #endif 36 37 static const CHAR manifest_name[] = "cc6.manifest"; 38 39 static const CHAR manifest[] = 40 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" 41 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n" 42 " <assemblyIdentity\n" 43 " type=\"win32\"\n" 44 " name=\"Wine.ComCtl32.Tests\"\n" 45 " version=\"1.0.0.0\"\n" 46 " processorArchitecture=\"" ARCH "\"\n" 47 " />\n" 48 "<description>Wine comctl32 test suite</description>\n" 49 "<dependency>\n" 50 " <dependentAssembly>\n" 51 " <assemblyIdentity\n" 52 " type=\"win32\"\n" 53 " name=\"microsoft.windows.common-controls\"\n" 54 " version=\"6.0.0.0\"\n" 55 " processorArchitecture=\"" ARCH "\"\n" 56 " publicKeyToken=\"6595b64144ccf1df\"\n" 57 " language=\"*\"\n" 58 " />\n" 59 "</dependentAssembly>\n" 60 "</dependency>\n" 61 "</assembly>\n"; 62 63 static inline void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx) 64 { 65 DeactivateActCtx(0, cookie); 66 ReleaseActCtx(hCtx); 67 68 DeleteFileA(manifest_name); 69 } 70 71 static inline BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx) 72 { 73 ACTCTX_SECTION_KEYED_DATA data; 74 DWORD written; 75 HMODULE hmod; 76 ACTCTXA ctx; 77 HANDLE file; 78 BOOL ret; 79 80 /* create manifest */ 81 file = CreateFileA( manifest_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL ); 82 if (file != INVALID_HANDLE_VALUE) 83 { 84 ret = (WriteFile( file, manifest, sizeof(manifest)-1, &written, NULL ) && 85 written == sizeof(manifest)-1); 86 CloseHandle( file ); 87 if (!ret) 88 { 89 DeleteFileA( manifest_name ); 90 skip("Failed to fill manifest file. Skipping comctl32 V6 tests.\n"); 91 return FALSE; 92 } 93 else 94 trace("created %s\n", manifest_name); 95 } 96 else 97 { 98 skip("Failed to create manifest file. Skipping comctl32 V6 tests.\n"); 99 return FALSE; 100 } 101 102 memset(&ctx, 0, sizeof(ctx)); 103 ctx.cbSize = sizeof(ctx); 104 ctx.lpSource = manifest_name; 105 106 *hCtx = CreateActCtxA(&ctx); 107 ok(*hCtx != 0, "Expected context handle\n"); 108 109 hmod = GetModuleHandleA("comctl32.dll"); 110 111 ret = ActivateActCtx(*hCtx, pcookie); 112 ok(ret, "Failed to activate context, error %d.\n", GetLastError()); 113 114 if (!ret) 115 { 116 win_skip("A problem during context activation occurred.\n"); 117 DeleteFileA(manifest_name); 118 } 119 120 data.cbSize = sizeof(data); 121 ret = FindActCtxSectionStringA(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 122 "comctl32.dll", &data); 123 ok(ret, "failed to find comctl32.dll in active context, %u\n", GetLastError()); 124 if (ret) 125 { 126 FreeLibrary(hmod); 127 LoadLibraryA("comctl32.dll"); 128 } 129 130 return ret; 131 } 132 133 #undef ARCH 134