ReactOS 0.4.17-dev-966-gf06eace
fusion.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 James Hawkins
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 <windows.h>
20#include <fusion.h>
21
22#include "wine/test.h"
23
25
26static HRESULT (WINAPI *pGetCachePath)(ASM_CACHE_FLAGS dwCacheFlags,
28static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR szDllName, LPCWSTR szVersion,
30static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
32
34{
35 HRESULT hr;
36 HMODULE hfusion;
37
38 hmscoree = LoadLibraryA("mscoree.dll");
39 if (!hmscoree)
40 {
41 win_skip("mscoree.dll not available\n");
42 return FALSE;
43 }
44
45 pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
46 if (!pLoadLibraryShim)
47 {
48 win_skip("LoadLibraryShim not available\n");
50 return FALSE;
51 }
52
53 pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
54
55 hr = pLoadLibraryShim(L"fusion.dll", NULL, NULL, &hfusion);
56 if (FAILED(hr))
57 {
58 win_skip("fusion.dll not available\n");
60 return FALSE;
61 }
62
63 pGetCachePath = (void *)GetProcAddress(hfusion, "GetCachePath");
64 return TRUE;
65}
66
67static void test_GetCachePath(void)
68{
69 CHAR windirA[MAX_PATH];
70 WCHAR windir[MAX_PATH];
71 WCHAR cachepath[MAX_PATH];
74 DWORD size;
75 HRESULT hr;
76
77 if (!pGetCachePath)
78 {
79 win_skip("GetCachePath not implemented\n");
80 return;
81 }
82
84 MultiByteToWideChar(CP_ACP, 0, windirA, -1, windir, MAX_PATH);
85 lstrcpyW(cachepath, windir);
86 lstrcatW(cachepath, L"\\assembly\\GAC");
87
88 /* NULL pwzCachePath, pcchPath is 0 */
89 size = 0;
90 hr = pGetCachePath(ASM_CACHE_GAC, NULL, &size);
91 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Expected E_NOT_SUFFICIENT_BUFFER, got %08lx\n", hr);
92 ok(size == lstrlenW(cachepath) + 1,
93 "Expected %d, got %ld\n", lstrlenW(cachepath) + 1, size);
94
95 /* NULL pwszCachePath, pcchPath is MAX_PATH */
96 size = MAX_PATH;
97 hr = pGetCachePath(ASM_CACHE_GAC, NULL, &size);
98 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Expected E_NOT_SUFFICIENT_BUFFER, got %08lx\n", hr);
99 ok(size == lstrlenW(cachepath) + 1,
100 "Expected %d, got %ld\n", lstrlenW(cachepath) + 1, size);
101
102 /* both pwszCachePath and pcchPath NULL */
103 hr = pGetCachePath(ASM_CACHE_GAC, NULL, NULL);
104 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", hr);
105
106 /* NULL pcchPath */
107 lstrcpyW(path, L"nochange");
108 hr = pGetCachePath(ASM_CACHE_GAC, path, NULL);
109 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", hr);
110 ok(!lstrcmpW(L"nochange", path), "Expected %s, got %s\n", wine_dbgstr_w(L"nochange"),
112
113 /* get the cache path */
114 lstrcpyW(path, L"nochange");
115 size = MAX_PATH;
116 hr = pGetCachePath(ASM_CACHE_GAC, path, &size);
117 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
118 ok( !lstrcmpW( cachepath, path ), "Expected %s, got %s\n", wine_dbgstr_w(cachepath), wine_dbgstr_w(path));
119
120 /* pcchPath has no room for NULL terminator */
121 lstrcpyW(path, L"nochange");
122 size = lstrlenW(cachepath);
123 hr = pGetCachePath(ASM_CACHE_GAC, path, &size);
124 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Expected E_NOT_SUFFICIENT_BUFFER, got %08lx\n", hr);
125 ok(!lstrcmpW(L"nochange", path), "Expected %s, got %s\n", wine_dbgstr_w(L"nochange"),
127
128 lstrcpyW(cachepath, windir);
129 lstrcatW(cachepath, L"\\assembly");
130
131 /* ASM_CACHE_ROOT */
132 lstrcpyW(path, L"nochange");
133 size = MAX_PATH;
134 hr = pGetCachePath(ASM_CACHE_ROOT, path, &size);
135 ok(hr == S_OK ||
136 broken(hr == E_INVALIDARG), /* .NET 1.1 */
137 "Expected S_OK, got %08lx\n", hr);
138 if (hr == S_OK)
139 ok( !lstrcmpW( cachepath, path ), "Expected %s, got %s\n", wine_dbgstr_w(cachepath), wine_dbgstr_w(path));
140
141 if (pGetCORVersion)
142 {
143 CHAR versionA[MAX_PATH];
144 CHAR cachepathA[MAX_PATH];
145 CHAR nativeimgA[MAX_PATH];
146 CHAR zapfmtA[MAX_PATH];
147
148 if (hr == S_OK)
149 {
150 lstrcpyA(nativeimgA, "NativeImages_");
151#ifdef _WIN64
152 lstrcpyA(zapfmtA, "%s\\%s\\%s%s_64");
153#else
154 lstrcpyA(zapfmtA, "%s\\%s\\%s%s_32");
155#endif
156 }
157 else
158 {
159 lstrcpyA(nativeimgA, "NativeImages1_");
160 lstrcpyA(zapfmtA, "%s\\%s\\%s%s");
161 }
162
163 pGetCORVersion(version, MAX_PATH, &size);
164 WideCharToMultiByte(CP_ACP, 0, version, -1, versionA, MAX_PATH, 0, 0);
165
166 wsprintfA(cachepathA, zapfmtA, windirA, "assembly", nativeimgA, versionA);
167 MultiByteToWideChar(CP_ACP, 0, cachepathA, -1, cachepath, MAX_PATH);
168
169 /* ASM_CACHE_ZAP */
170 lstrcpyW(path, L"nochange");
171 size = MAX_PATH;
172 hr = pGetCachePath(ASM_CACHE_ZAP, path, &size);
173 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
174 ok( !lstrcmpW( cachepath, path ), "Expected %s, got %s\n", wine_dbgstr_w(cachepath), wine_dbgstr_w(path));
175 }
176
177 /* two flags at once */
178 lstrcpyW(path, L"nochange");
179 size = MAX_PATH;
180 hr = pGetCachePath(ASM_CACHE_GAC | ASM_CACHE_ROOT, path, &size);
181 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", hr);
182 ok(!lstrcmpW(L"nochange", path), "Expected %s, got %s\n", wine_dbgstr_w(L"nochange"),
184}
185
187{
189 return;
190
192
194}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
static const WCHAR version[]
Definition: asmname.c:66
static DWORD DWORD * dwLength
Definition: fusion.c:86
static DWORD cchBuffer
Definition: fusion.c:85
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2355
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
static const WCHAR szDllName[]
Definition: system.c:43
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
ASM_CACHE_FLAGS
Definition: fusion.idl:27
@ ASM_CACHE_ROOT
Definition: fusion.idl:31
@ ASM_CACHE_GAC
Definition: fusion.idl:29
@ ASM_CACHE_ZAP
Definition: fusion.idl:28
GLsizeiptr size
Definition: glext.h:5919
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define win_skip
Definition: minitest.h:67
static LPWSTR pwzCachePath
Definition: asmcache.c:747
static LPCWSTR LPVOID pvReserved
Definition: asmcache.c:749
static LPWSTR PDWORD pcchPath
Definition: asmcache.c:747
static BOOL init_functionpointers(void)
Definition: fusion.c:33
static void test_GetCachePath(void)
Definition: fusion.c:67
static HMODULE hmscoree
Definition: fusion.c:24
static LPCWSTR szVersion
Definition: fusion.c:28
static LPCWSTR LPVOID HMODULE * phModDll
Definition: fusion.c:29
short WCHAR
Definition: pedump.c:58
DWORD * PDWORD
Definition: pedump.c:68
char CHAR
Definition: pedump.c:57
int WINAPIV wsprintfA(_Out_ LPSTR, _In_ _Printf_format_string_ LPCSTR,...)
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437