Sweden-Number/dlls/mscoree/metahost.c

182 lines
4.6 KiB
C
Raw Normal View History

/*
* ICLRMetaHost - discovery and management of available .NET runtimes
*
* Copyright 2010 Vincent Povirk for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "wine/unicode.h"
#include "wine/library.h"
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "mscoree.h"
#include "metahost.h"
#include "mscoree_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
struct CLRMetaHost
{
const struct ICLRMetaHostVtbl *CLRMetaHost_vtbl;
};
static const struct CLRMetaHost GlobalCLRMetaHost;
static HRESULT WINAPI CLRMetaHost_QueryInterface(ICLRMetaHost* iface,
REFIID riid,
void **ppvObject)
{
TRACE("%s %p\n", debugstr_guid(riid), ppvObject);
if ( IsEqualGUID( riid, &IID_ICLRMetaHost ) ||
IsEqualGUID( riid, &IID_IUnknown ) )
{
*ppvObject = iface;
}
else
{
FIXME("Unsupported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
ICLRMetaHost_AddRef( iface );
return S_OK;
}
static ULONG WINAPI CLRMetaHost_AddRef(ICLRMetaHost* iface)
{
return 2;
}
static ULONG WINAPI CLRMetaHost_Release(ICLRMetaHost* iface)
{
return 1;
}
static HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface,
LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime)
{
FIXME("%s %s %p\n", debugstr_w(pwzVersion), debugstr_guid(iid), ppRuntime);
return E_NOTIMPL;
}
static HRESULT WINAPI CLRMetaHost_GetVersionFromFile(ICLRMetaHost* iface,
LPCWSTR pwzFilePath, LPWSTR pwzBuffer, DWORD *pcchBuffer)
{
ASSEMBLY *assembly;
HRESULT hr;
LPSTR version;
ULONG buffer_size=*pcchBuffer;
TRACE("%s %p %p\n", debugstr_w(pwzFilePath), pwzBuffer, pcchBuffer);
hr = assembly_create(&assembly, pwzFilePath);
if (SUCCEEDED(hr))
{
hr = assembly_get_runtime_version(assembly, &version);
if (SUCCEEDED(hr))
{
*pcchBuffer = MultiByteToWideChar(CP_UTF8, 0, version, -1, NULL, 0);
if (pwzBuffer)
{
if (buffer_size >= *pcchBuffer)
MultiByteToWideChar(CP_UTF8, 0, version, -1, pwzBuffer, buffer_size);
else
hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}
}
assembly_release(assembly);
}
return hr;
}
static HRESULT WINAPI CLRMetaHost_EnumerateInstalledRuntimes(ICLRMetaHost* iface,
IEnumUnknown **ppEnumerator)
{
FIXME("%p\n", ppEnumerator);
return E_NOTIMPL;
}
static HRESULT WINAPI CLRMetaHost_EnumerateLoadedRuntimes(ICLRMetaHost* iface,
HANDLE hndProcess, IEnumUnknown **ppEnumerator)
{
FIXME("%p %p\n", hndProcess, ppEnumerator);
return E_NOTIMPL;
}
static HRESULT WINAPI CLRMetaHost_RequestRuntimeLoadedNotification(ICLRMetaHost* iface,
RuntimeLoadedCallbackFnPtr pCallbackFunction)
{
FIXME("%p\n", pCallbackFunction);
return E_NOTIMPL;
}
static HRESULT WINAPI CLRMetaHost_QueryLegacyV2RuntimeBinding(ICLRMetaHost* iface,
REFIID riid, LPVOID *ppUnk)
{
FIXME("%s %p\n", debugstr_guid(riid), ppUnk);
return E_NOTIMPL;
}
static HRESULT WINAPI CLRMetaHost_ExitProcess(ICLRMetaHost* iface, INT32 iExitCode)
{
FIXME("%i: stub\n", iExitCode);
ExitProcess(iExitCode);
}
static const struct ICLRMetaHostVtbl CLRMetaHost_vtbl =
{
CLRMetaHost_QueryInterface,
CLRMetaHost_AddRef,
CLRMetaHost_Release,
CLRMetaHost_GetRuntime,
CLRMetaHost_GetVersionFromFile,
CLRMetaHost_EnumerateInstalledRuntimes,
CLRMetaHost_EnumerateLoadedRuntimes,
CLRMetaHost_RequestRuntimeLoadedNotification,
CLRMetaHost_QueryLegacyV2RuntimeBinding,
CLRMetaHost_ExitProcess
};
static const struct CLRMetaHost GlobalCLRMetaHost = {
&CLRMetaHost_vtbl
};
extern HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj)
{
return ICLRMetaHost_QueryInterface((ICLRMetaHost*)&GlobalCLRMetaHost, riid, ppobj);
}