ReactOS  0.4.14-dev-604-gcfdd483
fusion.c
Go to the documentation of this file.
1 /*
2  * Implementation of the Fusion API
3  *
4  * Copyright 2008 James Hawkins
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #include <stdarg.h>
22 #ifdef __REACTOS__
23 #include <wchar.h>
24 #endif
25 
26 #define COBJMACROS
27 
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "fusion.h"
33 #include "wine/debug.h"
34 
36 
37 
38 /******************************************************************
39  * InitializeFusion (FUSION.@)
40  */
42 {
43  FIXME("\n");
44  return S_OK;
45 }
46 
47 /******************************************************************
48  * ClearDownloadCache (FUSION.@)
49  */
51 {
52  FIXME("stub!\n");
53  return E_NOTIMPL;
54 }
55 
56 /******************************************************************
57  * CopyPDBs (FUSION.@)
58  */
60 {
61  FIXME("(%p) stub!\n", unknown);
62  return E_NOTIMPL;
63 }
64 
65 /******************************************************************
66  * CreateInstallReferenceEnum (FUSION.@)
67  */
71 {
72  FIXME("(%p, %p, %08x, %p) stub!\n", ppRefEnum, pName, dwFlags, pvReserved);
73  return E_NOTIMPL;
74 }
75 
76 /******************************************************************
77  * CreateApplicationContext (FUSION.@)
78  */
80 {
81  FIXME("%p, %p\n", name, ctx);
82  return E_NOTIMPL;
83 }
84 
85 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
86  DWORD *dwLength);
87 
89 {
91  HRESULT hr;
92  DWORD len;
93 
94  hmscoree = LoadLibraryA("mscoree.dll");
95  if (!hmscoree)
96  return E_FAIL;
97 
98  pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
99  if (!pGetCORVersion)
100  hr = E_FAIL;
101  else
102  hr = pGetCORVersion(version, size, &len);
103 
105  return hr;
106 }
107 
108 /******************************************************************
109  * GetCachePath (FUSION.@)
110  */
113 {
114  static const WCHAR assembly[] = {'\\','a','s','s','e','m','b','l','y',0};
115  static const WCHAR gac[] = {'\\','G','A','C',0};
116  static const WCHAR nativeimg[] = {'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
117  static const WCHAR dotnet[] = {'\\','M','i','c','r','o','s','o','f','t','.','N','E','T',0};
118 #ifdef _WIN64
119  static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0};
120 #else
121  static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0};
122 #endif
124  DWORD len;
125  HRESULT hr = S_OK;
126 
127  TRACE("(%08x, %p, %p)\n", dwCacheFlags, pwzCachePath, pcchPath);
128 
129  if (!pcchPath)
130  return E_INVALIDARG;
131 
132  len = GetWindowsDirectoryW(windir, MAX_PATH);
133  lstrcpyW(path, windir);
134 
135  switch (dwCacheFlags)
136  {
137  case ASM_CACHE_ZAP:
138  {
140  if (FAILED(hr))
141  return hr;
142 
143  len = swprintf(path, zapfmt, windir, assembly + 1, nativeimg, version);
144  break;
145  }
146  case ASM_CACHE_GAC:
147  {
149  len += ARRAY_SIZE(assembly) - 1;
150  lstrcpyW(path + len, gac);
151  len += ARRAY_SIZE(gac) - 1;
152  break;
153  }
154  case ASM_CACHE_DOWNLOAD:
155  {
156  FIXME("Download cache not implemented\n");
157  return E_FAIL;
158  }
159  case ASM_CACHE_ROOT:
161  len += ARRAY_SIZE(assembly) - 1;
162  break;
163  case ASM_CACHE_ROOT_EX:
164  lstrcpyW(path + len, dotnet);
165  len += ARRAY_SIZE(dotnet) - 1;
167  len += ARRAY_SIZE(assembly) - 1;
168  break;
169  default:
170  return E_INVALIDARG;
171  }
172 
173  len++;
174  if (*pcchPath <= len || !pwzCachePath)
176  else if (pwzCachePath)
178 
179  *pcchPath = len;
180  return hr;
181 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI CreateApplicationContext(IAssemblyName *name, void *ctx)
Definition: fusion.c:79
HRESULT WINAPI CopyPDBs(void *unknown)
Definition: fusion.c:59
HRESULT WINAPI ClearDownloadCache(void)
Definition: fusion.c:50
#define E_FAIL
Definition: ddrawi.h:102
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
ASM_CACHE_FLAGS
Definition: fusion.idl:26
static DWORD cchBuffer
Definition: fusion.c:85
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
static const WCHAR version[]
Definition: asmname.c:66
static LPWSTR pwzCachePath
Definition: fusion.c:27
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:413
static LPSTR pName
Definition: security.c:75
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:6
static HRESULT(WINAPI *pGetCORVersion)(LPWSTR pbuffer
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI InitializeFusion(void)
Definition: fusion.c:41
Definition: id3.c:18
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath, PDWORD pcchPath)
Definition: fusion.c:111
GLenum GLsizei len
Definition: glext.h:6722
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
static LPWSTR PDWORD pcchPath
Definition: fusion.c:27
#define S_OK
Definition: intsafe.h:59
WINE_DEFAULT_DEBUG_CHANNEL(fusion)
#define lstrcpyW
Definition: compat.h:414
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI CreateInstallReferenceEnum(IInstallReferenceEnum **ppRefEnum, IAssemblyName *pName, DWORD dwFlags, LPVOID pvReserved)
Definition: fusion.c:68
DWORD * PDWORD
Definition: pedump.c:68
static LPCWSTR LPVOID pvReserved
Definition: fusion.c:28
static HMODULE hmscoree
Definition: fusion.c:24
Definition: name.c:38
#define GetProcAddress(x, y)
Definition: compat.h:418
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static HRESULT get_corversion(LPWSTR version, DWORD size)
Definition: fusion.c:88