ddraw: Separate IDirectDrawSurface2 reference count.
[wine.git] / dlls / fusion / fusion.c
blobad77233048712c34f3eb41b38a5345a886a0c6f7
1 /*
2 * Implementation of the Fusion API
4 * Copyright 2008 James Hawkins
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.
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.
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
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "fusion.h"
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(fusion);
35 /******************************************************************
36 * ClearDownloadCache (FUSION.@)
38 HRESULT WINAPI ClearDownloadCache(void)
40 FIXME("stub!\n");
41 return E_NOTIMPL;
44 /******************************************************************
45 * CreateInstallReferenceEnum (FUSION.@)
47 HRESULT WINAPI CreateInstallReferenceEnum(IInstallReferenceEnum **ppRefEnum,
48 IAssemblyName *pName, DWORD dwFlags,
49 LPVOID pvReserved)
51 FIXME("(%p, %p, %08x, %p) stub!\n", ppRefEnum, pName, dwFlags, pvReserved);
52 return E_NOTIMPL;
55 /******************************************************************
56 * CreateApplicationContext (FUSION.@)
58 HRESULT WINAPI CreateApplicationContext(IAssemblyName *name, void *ctx)
60 FIXME("%p, %p\n", name, ctx);
61 return E_NOTIMPL;
64 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
65 DWORD *dwLength);
67 static HRESULT get_corversion(LPWSTR version, DWORD size)
69 HMODULE hmscoree;
70 HRESULT hr;
71 DWORD len;
73 hmscoree = LoadLibraryA("mscoree.dll");
74 if (!hmscoree)
75 return E_FAIL;
77 pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
78 if (!pGetCORVersion)
79 return E_FAIL;
81 hr = pGetCORVersion(version, size, &len);
83 FreeLibrary(hmscoree);
84 return hr;
87 /******************************************************************
88 * GetCachePath (FUSION.@)
90 HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath,
91 PDWORD pcchPath)
93 WCHAR path[MAX_PATH];
94 WCHAR windir[MAX_PATH];
95 WCHAR version[MAX_PATH];
96 DWORD len;
97 HRESULT hr = S_OK;
99 static const WCHAR backslash[] = {'\\',0};
100 static const WCHAR assembly[] = {'a','s','s','e','m','b','l','y',0};
101 static const WCHAR gac[] = {'G','A','C',0};
102 static const WCHAR nativeimg[] = {
103 'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
104 #ifdef _WIN64
105 static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0};
106 #else
107 static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0};
108 #endif
110 TRACE("(%08x, %p, %p)\n", dwCacheFlags, pwzCachePath, pcchPath);
112 if (!pcchPath)
113 return E_INVALIDARG;
115 GetWindowsDirectoryW(windir, MAX_PATH);
116 lstrcpyW(path, windir);
117 lstrcatW(path, backslash);
118 lstrcatW(path, assembly);
120 switch (dwCacheFlags)
122 case ASM_CACHE_ZAP:
124 hr = get_corversion(version, MAX_PATH);
125 if (FAILED(hr))
126 return hr;
128 sprintfW(path, zapfmt, windir, assembly, nativeimg, version);
129 break;
132 case ASM_CACHE_GAC:
134 lstrcatW(path, backslash);
135 lstrcatW(path, gac);
136 break;
139 case ASM_CACHE_DOWNLOAD:
141 FIXME("Download cache not implemented\n");
142 return E_FAIL;
145 case ASM_CACHE_ROOT:
146 break; /* already set */
148 default:
149 return E_INVALIDARG;
152 len = lstrlenW(path) + 1;
153 if (*pcchPath <= len || !pwzCachePath)
154 hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
155 else if (pwzCachePath)
156 lstrcpyW(pwzCachePath, path);
158 *pcchPath = len;
160 return hr;