ReactOS 0.4.15-dev-7788-g1ad9096
v6util.h
Go to the documentation of this file.
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
37static const CHAR manifest_name[] = "cc6.manifest";
38
39static 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
63static inline void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
64{
66 ReleaseActCtx(hCtx);
67
69}
70
71static inline BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
72{
73 ACTCTX_SECTION_KEYED_DATA data;
74 DWORD written;
76 ACTCTXA ctx;
78 BOOL ret;
79
80 /* create manifest */
83 {
84 ret = (WriteFile( file, manifest, sizeof(manifest)-1, &written, NULL ) &&
85 written == sizeof(manifest)-1);
87 if (!ret)
88 {
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");
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 {
127 LoadLibraryA("comctl32.dll");
128 }
129
130 return ret;
131}
132
133#undef ARCH
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FreeLibrary(x)
Definition: compat.h:748
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
Definition: actctx.c:28
BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:124
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define CREATE_ALWAYS
Definition: disk.h:72
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:143
#define GENERIC_WRITE
Definition: nt_native.h:90
#define win_skip
Definition: test.h:160
#define memset(x, y, z)
Definition: compat.h:39
Definition: cookie.c:34
Definition: fci.c:127
uint32_t ULONG_PTR
Definition: typedefs.h:65
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:71
#define ARCH
Definition: v6util.h:34
static const CHAR manifest[]
Definition: v6util.h:39
static const CHAR manifest_name[]
Definition: v6util.h:37
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:63
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
char CHAR
Definition: xmlstorage.h:175