Commit 0eaa3ec9 authored by Daniel Jelinski's avatar Daniel Jelinski Committed by Alexandre Julliard

mscoree: Extract a helper function for getting file name from assembly.

parent c8d1d4aa
......@@ -1210,31 +1210,15 @@ HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj)
return ICLRMetaHost_QueryInterface(&GlobalCLRMetaHost.ICLRMetaHost_iface, riid, ppobj);
}
static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data)
HRESULT get_file_from_strongname(WCHAR* stringnameW, WCHAR* assemblies_path, int path_length)
{
loaded_mono *mono = user_data;
HRESULT hr=S_OK;
MonoAssembly *result=NULL;
char *stringname=NULL;
LPWSTR stringnameW;
int stringnameW_size;
IAssemblyCache *asmcache;
ASSEMBLY_INFO info;
WCHAR path[MAX_PATH];
char *pathA;
MonoImageOpenStatus stat;
static WCHAR fusiondll[] = {'f','u','s','i','o','n',0};
HMODULE hfusion=NULL;
static HRESULT (WINAPI *pCreateAssemblyCache)(IAssemblyCache**,DWORD);
stringname = mono->mono_stringify_assembly_name(aname);
TRACE("%s\n", debugstr_a(stringname));
if (!stringname) return NULL;
/* FIXME: We should search the given paths before the GAC. */
if (!pCreateAssemblyCache)
{
hr = LoadLibraryShim(fusiondll, NULL, NULL, &hfusion);
......@@ -1252,28 +1236,52 @@ static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char
if (SUCCEEDED(hr))
{
stringnameW_size = MultiByteToWideChar(CP_UTF8, 0, stringname, -1, NULL, 0);
info.cbAssemblyInfo = sizeof(info);
info.pszCurrentAssemblyPathBuf = assemblies_path;
info.cchBuf = path_length;
assemblies_path[0] = 0;
stringnameW = HeapAlloc(GetProcessHeap(), 0, stringnameW_size * sizeof(WCHAR));
if (stringnameW)
MultiByteToWideChar(CP_UTF8, 0, stringname, -1, stringnameW, stringnameW_size);
else
hr = E_OUTOFMEMORY;
hr = IAssemblyCache_QueryAssemblyInfo(asmcache, 0, stringnameW, &info);
if (SUCCEEDED(hr))
{
info.cbAssemblyInfo = sizeof(info);
info.pszCurrentAssemblyPathBuf = path;
info.cchBuf = MAX_PATH;
path[0] = 0;
IAssemblyCache_Release(asmcache);
}
hr = IAssemblyCache_QueryAssemblyInfo(asmcache, 0, stringnameW, &info);
}
return hr;
}
HeapFree(GetProcessHeap(), 0, stringnameW);
static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data)
{
loaded_mono *mono = user_data;
HRESULT hr;
MonoAssembly *result=NULL;
char *stringname=NULL;
LPWSTR stringnameW;
int stringnameW_size;
WCHAR path[MAX_PATH];
char *pathA;
MonoImageOpenStatus stat;
IAssemblyCache_Release(asmcache);
stringname = mono->mono_stringify_assembly_name(aname);
TRACE("%s\n", debugstr_a(stringname));
if (!stringname) return NULL;
/* FIXME: We should search the given paths before the GAC. */
stringnameW_size = MultiByteToWideChar(CP_UTF8, 0, stringname, -1, NULL, 0);
stringnameW = HeapAlloc(GetProcessHeap(), 0, stringnameW_size * sizeof(WCHAR));
if (stringnameW)
{
MultiByteToWideChar(CP_UTF8, 0, stringname, -1, stringnameW, stringnameW_size);
hr = get_file_from_strongname(stringnameW, path, MAX_PATH);
HeapFree(GetProcessHeap(), 0, stringnameW);
}
else
hr = E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{
......
......@@ -204,6 +204,8 @@ extern HRESULT CorDebug_Create(ICLRRuntimeHost *runtimehost, IUnknown** ppUnk) D
extern HRESULT create_monodata(REFIID riid, LPVOID *ppObj) DECLSPEC_HIDDEN;
extern HRESULT get_file_from_strongname(WCHAR* stringnameW, WCHAR* assemblies_path, int path_length) DECLSPEC_HIDDEN;
extern void runtimehost_init(void);
extern void runtimehost_uninit(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment