ReactOS  0.4.13-dev-464-g6b95727
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 
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 
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 */
83  {
84  ret = (WriteFile( file, manifest, sizeof(manifest)-1, &written, NULL ) &&
85  written == sizeof(manifest)-1);
86  CloseHandle( file );
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  {
126  FreeLibrary(hmod);
127  LoadLibraryA("comctl32.dll");
128  }
129 
130  return ret;
131 }
132 
133 #undef ARCH
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
static const CHAR manifest_name[]
Definition: v6util.h:37
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define trace(...)
Definition: kmt_test.h:217
#define CloseHandle
Definition: compat.h:398
#define ARCH
Definition: v6util.h:34
char CHAR
Definition: xmlstorage.h:175
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:63
uint32_t ULONG_PTR
Definition: typedefs.h:63
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:124
#define FreeLibrary(x)
Definition: compat.h:405
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define CREATE_ALWAYS
Definition: disk.h:72
#define skip(...)
HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
Definition: actctx.c:28
static const CHAR manifest[]
Definition: v6util.h:39
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
Definition: fci.c:126