mscoree: Implement ICLRRuntimeInfo_GetInterface.
This commit is contained in:
parent
0d1c687563
commit
d54b800793
|
@ -29,20 +29,24 @@
|
|||
|
||||
#include "cor.h"
|
||||
#include "mscoree.h"
|
||||
#include "mscoree_private.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
|
||||
|
||||
typedef struct _corruntimehost
|
||||
struct RuntimeHost
|
||||
{
|
||||
const struct ICorRuntimeHostVtbl *lpVtbl;
|
||||
const CLRRuntimeInfo *version;
|
||||
const loaded_mono *mono;
|
||||
LONG ref;
|
||||
} corruntimehost;
|
||||
BOOL legacy; /* if True, this was created by create_corruntimehost, and Release frees it */
|
||||
};
|
||||
|
||||
static inline corruntimehost *impl_from_ICorRuntimeHost( ICorRuntimeHost *iface )
|
||||
static inline RuntimeHost *impl_from_ICorRuntimeHost( ICorRuntimeHost *iface )
|
||||
{
|
||||
return (corruntimehost *)((char*)iface - FIELD_OFFSET(corruntimehost, lpVtbl));
|
||||
return (RuntimeHost *)((char*)iface - FIELD_OFFSET(RuntimeHost, lpVtbl));
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
|
@ -50,7 +54,7 @@ static HRESULT WINAPI corruntimehost_QueryInterface(ICorRuntimeHost* iface,
|
|||
REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
corruntimehost *This = impl_from_ICorRuntimeHost( iface );
|
||||
RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
|
||||
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
||||
|
||||
if ( IsEqualGUID( riid, &IID_ICorRuntimeHost ) ||
|
||||
|
@ -71,19 +75,19 @@ static HRESULT WINAPI corruntimehost_QueryInterface(ICorRuntimeHost* iface,
|
|||
|
||||
static ULONG WINAPI corruntimehost_AddRef(ICorRuntimeHost* iface)
|
||||
{
|
||||
corruntimehost *This = impl_from_ICorRuntimeHost( iface );
|
||||
RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
|
||||
return InterlockedIncrement( &This->ref );
|
||||
}
|
||||
|
||||
static ULONG WINAPI corruntimehost_Release(ICorRuntimeHost* iface)
|
||||
{
|
||||
corruntimehost *This = impl_from_ICorRuntimeHost( iface );
|
||||
RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
|
||||
ULONG ref;
|
||||
|
||||
ref = InterlockedDecrement( &This->ref );
|
||||
if ( ref == 0 )
|
||||
if ( ref == 0 && This->legacy )
|
||||
{
|
||||
HeapFree( GetProcessHeap(), 0, This );
|
||||
RuntimeHost_Destroy(This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
|
@ -271,18 +275,64 @@ static const struct ICorRuntimeHostVtbl corruntimehost_vtbl =
|
|||
corruntimehost_CurrentDomain
|
||||
};
|
||||
|
||||
IUnknown* create_corruntimehost(void)
|
||||
HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
|
||||
const loaded_mono *loaded_mono, RuntimeHost** result)
|
||||
{
|
||||
corruntimehost *This;
|
||||
RuntimeHost *This;
|
||||
|
||||
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
|
||||
if ( !This )
|
||||
return NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
This->lpVtbl = &corruntimehost_vtbl;
|
||||
This->ref = 1;
|
||||
This->version = runtime_version;
|
||||
This->mono = loaded_mono;
|
||||
This->legacy = FALSE;
|
||||
|
||||
FIXME("return iface %p\n", This);
|
||||
|
||||
return (IUnknown*) &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv)
|
||||
{
|
||||
IUnknown *unk;
|
||||
|
||||
if (IsEqualGUID(clsid, &CLSID_CorRuntimeHost))
|
||||
unk = (IUnknown*)&This->lpVtbl;
|
||||
else
|
||||
unk = NULL;
|
||||
|
||||
if (unk)
|
||||
return IUnknown_QueryInterface(unk, riid, ppv);
|
||||
else
|
||||
FIXME("not implemented for class %s\n", debugstr_guid(clsid));
|
||||
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
}
|
||||
|
||||
HRESULT RuntimeHost_Destroy(RuntimeHost *This)
|
||||
{
|
||||
HeapFree( GetProcessHeap(), 0, This );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
IUnknown* create_corruntimehost(void)
|
||||
{
|
||||
RuntimeHost *This;
|
||||
IUnknown *result;
|
||||
|
||||
if (FAILED(RuntimeHost_Construct(NULL, NULL, &This)))
|
||||
return NULL;
|
||||
|
||||
This->legacy = TRUE;
|
||||
|
||||
if (FAILED(RuntimeHost_GetInterface(This, &CLSID_CorRuntimeHost, &IID_IUnknown, (void**)&result)))
|
||||
{
|
||||
RuntimeHost_Destroy(This);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FIXME("return iface %p\n", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -43,16 +43,6 @@ static const WCHAR net_11_subdir[] = {'1','.','0',0};
|
|||
static const WCHAR net_20_subdir[] = {'2','.','0',0};
|
||||
static const WCHAR net_40_subdir[] = {'4','.','0',0};
|
||||
|
||||
struct CLRRuntimeInfo
|
||||
{
|
||||
const struct ICLRRuntimeInfoVtbl *ICLRRuntimeInfo_vtbl;
|
||||
LPCWSTR mono_libdir;
|
||||
DWORD major;
|
||||
DWORD minor;
|
||||
DWORD build;
|
||||
int mono_abi_version;
|
||||
};
|
||||
|
||||
const struct ICLRRuntimeInfoVtbl CLRRuntimeInfoVtbl;
|
||||
|
||||
#define NUM_RUNTIMES 3
|
||||
|
@ -75,6 +65,53 @@ static CRITICAL_SECTION_DEBUG runtime_list_cs_debug =
|
|||
};
|
||||
static CRITICAL_SECTION runtime_list_cs = { &runtime_list_cs_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result)
|
||||
{
|
||||
/* FIXME: stub */
|
||||
*result = NULL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
loaded_mono *ploaded_mono;
|
||||
|
||||
if (This->loaded_runtime)
|
||||
{
|
||||
*result = This->loaded_runtime;
|
||||
return hr;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&runtime_list_cs);
|
||||
|
||||
if (!This->loaded_runtime)
|
||||
goto end;
|
||||
|
||||
hr = load_mono(This, &ploaded_mono);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = RuntimeHost_Construct(This, ploaded_mono, &This->loaded_runtime);
|
||||
|
||||
end:
|
||||
LeaveCriticalSection(&runtime_list_cs);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
*result = This->loaded_runtime;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
void unload_all_runtimes(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<NUM_RUNTIMES; i++)
|
||||
if (runtimes[i].loaded_runtime)
|
||||
RuntimeHost_Destroy(runtimes[i].loaded_runtime);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI CLRRuntimeInfo_QueryInterface(ICLRRuntimeInfo* iface,
|
||||
REFIID riid,
|
||||
void **ppvObject)
|
||||
|
@ -178,9 +215,18 @@ static HRESULT WINAPI CLRRuntimeInfo_GetProcAddress(ICLRRuntimeInfo* iface,
|
|||
static HRESULT WINAPI CLRRuntimeInfo_GetInterface(ICLRRuntimeInfo* iface,
|
||||
REFCLSID rclsid, REFIID riid, LPVOID *ppUnk)
|
||||
{
|
||||
FIXME("%p %s %s %p\n", iface, debugstr_guid(rclsid), debugstr_guid(riid), ppUnk);
|
||||
struct CLRRuntimeInfo *This = (struct CLRRuntimeInfo*)iface;
|
||||
RuntimeHost *host;
|
||||
HRESULT hr;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p %s %s %p\n", iface, debugstr_guid(rclsid), debugstr_guid(riid), ppUnk);
|
||||
|
||||
hr = CLRRuntimeInfo_GetRuntimeHost(This, &host);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = RuntimeHost_GetInterface(host, rclsid, riid, ppUnk);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI CLRRuntimeInfo_IsLoadable(ICLRRuntimeInfo* iface,
|
||||
|
@ -404,6 +450,9 @@ static void find_runtimes(void)
|
|||
{
|
||||
runtimes[i].mono_abi_version = abi_version;
|
||||
|
||||
strcpyW(runtimes[i].mono_path, mono_path);
|
||||
strcpyW(runtimes[i].mscorlib_path, lib_path);
|
||||
|
||||
any_runtimes_found = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -343,6 +343,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
DisableThreadLibraryCalls(hinstDLL);
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
unload_all_runtimes();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
@ -30,6 +30,21 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file);
|
|||
HRESULT assembly_release(ASSEMBLY *assembly);
|
||||
HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version);
|
||||
|
||||
typedef struct RuntimeHost RuntimeHost;
|
||||
|
||||
typedef struct CLRRuntimeInfo
|
||||
{
|
||||
const struct ICLRRuntimeInfoVtbl *ICLRRuntimeInfo_vtbl;
|
||||
LPCWSTR mono_libdir;
|
||||
DWORD major;
|
||||
DWORD minor;
|
||||
DWORD build;
|
||||
int mono_abi_version;
|
||||
WCHAR mono_path[MAX_PATH];
|
||||
WCHAR mscorlib_path[MAX_PATH];
|
||||
struct RuntimeHost *loaded_runtime;
|
||||
} CLRRuntimeInfo;
|
||||
|
||||
/* Mono 2.6 embedding */
|
||||
typedef struct _MonoDomain MonoDomain;
|
||||
typedef struct _MonoAssembly MonoAssembly;
|
||||
|
@ -44,4 +59,18 @@ extern MonoDomain* (*mono_jit_init)(const char *file);
|
|||
extern int (*mono_jit_set_trace_options)(const char* options);
|
||||
extern void (*mono_set_dirs)(const char *assembly_dir, const char *config_dir);
|
||||
|
||||
typedef struct loaded_mono
|
||||
{
|
||||
} loaded_mono;
|
||||
|
||||
/* loaded runtime interfaces */
|
||||
extern void unload_all_runtimes(void);
|
||||
|
||||
extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
|
||||
const loaded_mono *loaded_mono, RuntimeHost** result);
|
||||
|
||||
extern HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv);
|
||||
|
||||
extern HRESULT RuntimeHost_Destroy(RuntimeHost *This);
|
||||
|
||||
#endif /* __MSCOREE_PRIVATE__ */
|
||||
|
|
|
@ -131,6 +131,8 @@ interface IHostControl : IUnknown
|
|||
[in] IUnknown* appDomainManager);
|
||||
}
|
||||
|
||||
cpp_quote("DEFINE_GUID(CLSID_CorRuntimeHost, 0xcb2f6723,0xab3a,0x11d2,0x9c,0x40,0x00,0xc0,0x4f,0xa3,0x0a,0x3e);")
|
||||
|
||||
[
|
||||
uuid(CB2F6722-AB3A-11d2-9C40-00C04FA30A3E),
|
||||
version(1.0),
|
||||
|
|
Loading…
Reference in New Issue