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) ...@@ -1210,31 +1210,15 @@ HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj)
return ICLRMetaHost_QueryInterface(&GlobalCLRMetaHost.ICLRMetaHost_iface, riid, 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; HRESULT hr=S_OK;
MonoAssembly *result=NULL;
char *stringname=NULL;
LPWSTR stringnameW;
int stringnameW_size;
IAssemblyCache *asmcache; IAssemblyCache *asmcache;
ASSEMBLY_INFO info; ASSEMBLY_INFO info;
WCHAR path[MAX_PATH];
char *pathA;
MonoImageOpenStatus stat;
static WCHAR fusiondll[] = {'f','u','s','i','o','n',0}; static WCHAR fusiondll[] = {'f','u','s','i','o','n',0};
HMODULE hfusion=NULL; HMODULE hfusion=NULL;
static HRESULT (WINAPI *pCreateAssemblyCache)(IAssemblyCache**,DWORD); 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) if (!pCreateAssemblyCache)
{ {
hr = LoadLibraryShim(fusiondll, NULL, NULL, &hfusion); hr = LoadLibraryShim(fusiondll, NULL, NULL, &hfusion);
...@@ -1252,28 +1236,52 @@ static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char ...@@ -1252,28 +1236,52 @@ static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
info.cbAssemblyInfo = sizeof(info);
info.pszCurrentAssemblyPathBuf = assemblies_path;
info.cchBuf = path_length;
assemblies_path[0] = 0;
hr = IAssemblyCache_QueryAssemblyInfo(asmcache, 0, stringnameW, &info);
IAssemblyCache_Release(asmcache);
}
return hr;
}
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;
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_size = MultiByteToWideChar(CP_UTF8, 0, stringname, -1, NULL, 0);
stringnameW = HeapAlloc(GetProcessHeap(), 0, stringnameW_size * sizeof(WCHAR)); stringnameW = HeapAlloc(GetProcessHeap(), 0, stringnameW_size * sizeof(WCHAR));
if (stringnameW) if (stringnameW)
MultiByteToWideChar(CP_UTF8, 0, stringname, -1, stringnameW, stringnameW_size);
else
hr = E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{ {
info.cbAssemblyInfo = sizeof(info); MultiByteToWideChar(CP_UTF8, 0, stringname, -1, stringnameW, stringnameW_size);
info.pszCurrentAssemblyPathBuf = path;
info.cchBuf = MAX_PATH;
path[0] = 0;
hr = IAssemblyCache_QueryAssemblyInfo(asmcache, 0, stringnameW, &info); hr = get_file_from_strongname(stringnameW, path, MAX_PATH);
}
HeapFree(GetProcessHeap(), 0, stringnameW); HeapFree(GetProcessHeap(), 0, stringnameW);
IAssemblyCache_Release(asmcache);
} }
else
hr = E_OUTOFMEMORY;
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
......
...@@ -204,6 +204,8 @@ extern HRESULT CorDebug_Create(ICLRRuntimeHost *runtimehost, IUnknown** ppUnk) D ...@@ -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 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_init(void);
extern void runtimehost_uninit(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