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 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
31 //#include "winuser.h"
34 #include <wine/debug.h>
35 #include <wine/unicode.h>
37 WINE_DEFAULT_DEBUG_CHANNEL(fusion
);
40 /******************************************************************
41 * InitializeFusion (FUSION.@)
43 HRESULT WINAPI
InitializeFusion(void)
49 /******************************************************************
50 * ClearDownloadCache (FUSION.@)
52 HRESULT WINAPI
ClearDownloadCache(void)
58 /******************************************************************
59 * CreateInstallReferenceEnum (FUSION.@)
61 HRESULT WINAPI
CreateInstallReferenceEnum(IInstallReferenceEnum
**ppRefEnum
,
62 IAssemblyName
*pName
, DWORD dwFlags
,
65 FIXME("(%p, %p, %08x, %p) stub!\n", ppRefEnum
, pName
, dwFlags
, pvReserved
);
69 /******************************************************************
70 * CreateApplicationContext (FUSION.@)
72 HRESULT WINAPI
CreateApplicationContext(IAssemblyName
*name
, void *ctx
)
74 FIXME("%p, %p\n", name
, ctx
);
78 static HRESULT (WINAPI
*pGetCORVersion
)(LPWSTR pbuffer
, DWORD cchBuffer
,
81 static HRESULT
get_corversion(LPWSTR version
, DWORD size
)
87 hmscoree
= LoadLibraryA("mscoree.dll");
91 pGetCORVersion
= (void *)GetProcAddress(hmscoree
, "GetCORVersion");
95 hr
= pGetCORVersion(version
, size
, &len
);
97 FreeLibrary(hmscoree
);
101 /******************************************************************
102 * GetCachePath (FUSION.@)
104 HRESULT WINAPI
GetCachePath(ASM_CACHE_FLAGS dwCacheFlags
, LPWSTR pwzCachePath
,
107 static const WCHAR assembly
[] = {'\\','a','s','s','e','m','b','l','y',0};
108 static const WCHAR gac
[] = {'\\','G','A','C',0};
109 static const WCHAR nativeimg
[] = {'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
110 static const WCHAR dotnet
[] = {'\\','M','i','c','r','o','s','o','f','t','.','N','E','T',0};
112 static const WCHAR zapfmt
[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0};
114 static const WCHAR zapfmt
[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0};
116 WCHAR path
[MAX_PATH
], windir
[MAX_PATH
], version
[MAX_PATH
];
120 TRACE("(%08x, %p, %p)\n", dwCacheFlags
, pwzCachePath
, pcchPath
);
125 len
= GetWindowsDirectoryW(windir
, MAX_PATH
);
126 strcpyW(path
, windir
);
128 switch (dwCacheFlags
)
132 hr
= get_corversion(version
, MAX_PATH
);
136 len
= sprintfW(path
, zapfmt
, windir
, assembly
+ 1, nativeimg
, version
);
141 strcpyW(path
+ len
, assembly
);
142 len
+= sizeof(assembly
)/sizeof(WCHAR
) - 1;
143 strcpyW(path
+ len
, gac
);
144 len
+= sizeof(gac
)/sizeof(WCHAR
) - 1;
147 case ASM_CACHE_DOWNLOAD
:
149 FIXME("Download cache not implemented\n");
153 strcpyW(path
+ len
, assembly
);
154 len
+= sizeof(assembly
)/sizeof(WCHAR
) - 1;
156 case ASM_CACHE_ROOT_EX
:
157 strcpyW(path
+ len
, dotnet
);
158 len
+= sizeof(dotnet
)/sizeof(WCHAR
) - 1;
159 strcpyW(path
+ len
, assembly
);
160 len
+= sizeof(assembly
)/sizeof(WCHAR
) - 1;
167 if (*pcchPath
<= len
|| !pwzCachePath
)
168 hr
= HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
169 else if (pwzCachePath
)
170 strcpyW(pwzCachePath
, path
);