[MSCOREE_WINETEST]

* Add mscoree winetest from Wine 1.3.37.

svn path=/trunk/; revision=55277
This commit is contained in:
Amine Khaldi 2012-01-28 17:34:42 +00:00
parent 53d0c6b010
commit e1632d9cd8
8 changed files with 1067 additions and 0 deletions

View file

@ -43,6 +43,7 @@ add_subdirectory(mapi32)
add_subdirectory(mlang)
add_subdirectory(msacm32)
add_subdirectory(mscms)
add_subdirectory(mscoree)
add_subdirectory(msctf)
if(NOT MSVC)
# FIXME: msvc build.

View file

@ -112,6 +112,9 @@
<directory name="mscms">
<xi:include href="mscms/mscms.rbuild" />
</directory>
<directory name="mscoree">
<xi:include href="mscoree/mscoree.rbuild" />
</directory>
<directory name="msctf">
<xi:include href="msctf/msctf.rbuild" />
</directory>

View file

@ -0,0 +1,15 @@
add_definitions(
-D__ROS_LONG64__
-D_DLL -D__USE_CRTIMP)
add_executable(mscoree_winetest
debugging.c
metahost.c
mscoree.c
testlist.c)
target_link_libraries(mscoree_winetest wine uuid)
set_module_type(mscoree_winetest win32cui)
add_importlibs(mscoree_winetest ole32 shlwapi msvcrt kernel32 ntdll)
add_cd_file(TARGET mscoree_winetest DESTINATION reactos/bin FOR all)

View file

@ -0,0 +1,507 @@
/*
* Copyright 2011 Alistair Leslie-Hughes
*
* 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
*/
#define COBJMACROS
#include <stdio.h>
#include "windows.h"
#include "ole2.h"
#include "corerror.h"
#include "mscoree.h"
#include "corhdr.h"
#include "wine/test.h"
#include "initguid.h"
#include "cordebug.h"
static HMODULE hmscoree;
static HRESULT (WINAPI *pCreateDebuggingInterfaceFromVersion)(int, LPCWSTR, IUnknown **);
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
static const char *debugstr_guid(REFIID riid)
{
static char buf[50];
if(!riid)
return "(null)";
sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
riid->Data4[5], riid->Data4[6], riid->Data4[7]);
return buf;
}
static HRESULT WINAPI ManagedCallback2_QueryInterface(ICorDebugManagedCallback2 *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_ICorDebugManagedCallback2, riid))
{
*ppv = iface;
return S_OK;
}
ok(0, "unexpected riid (%s)\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI ManagedCallback2_AddRef(ICorDebugManagedCallback2 *iface)
{
return 2;
}
static ULONG WINAPI ManagedCallback2_Release(ICorDebugManagedCallback2 *iface)
{
return 1;
}
static HRESULT WINAPI ManagedCallback2_FunctionRemapOpportunity(ICorDebugManagedCallback2 *iface,
ICorDebugAppDomain *pAppDomain, ICorDebugThread *pThread,
ICorDebugFunction *pOldFunction, ICorDebugFunction *pNewFunction,
ULONG32 oldILOffset)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_CreateConnection(ICorDebugManagedCallback2 *iface,
ICorDebugProcess *pProcess, CONNID dwConnectionId, WCHAR *pConnName)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_ChangeConnection(ICorDebugManagedCallback2 *iface,
ICorDebugProcess *pProcess, CONNID dwConnectionId)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_DestroyConnection(ICorDebugManagedCallback2 *iface,
ICorDebugProcess *pProcess, CONNID dwConnectionId)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_Exception(ICorDebugManagedCallback2 *iface,
ICorDebugAppDomain *pAppDomain, ICorDebugThread *pThread,
ICorDebugFrame *pFrame, ULONG32 nOffset,
CorDebugExceptionCallbackType dwEventType, DWORD dwFlags)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_ExceptionUnwind(ICorDebugManagedCallback2 *iface,
ICorDebugAppDomain *pAppDomain, ICorDebugThread *pThread,
CorDebugExceptionUnwindCallbackType dwEventType, DWORD dwFlags)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_FunctionRemapComplete(ICorDebugManagedCallback2 *iface,
ICorDebugAppDomain *pAppDomain, ICorDebugThread *pThread,
ICorDebugFunction *pFunction)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback2_MDANotification(ICorDebugManagedCallback2 *iface,
ICorDebugController *pController, ICorDebugThread *pThread,
ICorDebugMDA *pMDA)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static struct ICorDebugManagedCallback2Vtbl managedCallback2Vtbl = {
ManagedCallback2_QueryInterface,
ManagedCallback2_AddRef,
ManagedCallback2_Release,
ManagedCallback2_FunctionRemapOpportunity,
ManagedCallback2_CreateConnection,
ManagedCallback2_ChangeConnection,
ManagedCallback2_DestroyConnection,
ManagedCallback2_Exception,
ManagedCallback2_ExceptionUnwind,
ManagedCallback2_FunctionRemapComplete,
ManagedCallback2_MDANotification
};
static ICorDebugManagedCallback2 ManagedCallback2 = { &managedCallback2Vtbl };
static HRESULT WINAPI ManagedCallback_QueryInterface(ICorDebugManagedCallback *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_ICorDebugManagedCallback, riid))
{
*ppv = iface;
return S_OK;
}
else if(IsEqualGUID(&IID_ICorDebugManagedCallback2, riid))
{
*ppv = (void**)&ManagedCallback2;
return S_OK;
}
ok(0, "unexpected riid (%s)\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI ManagedCallback_AddRef(ICorDebugManagedCallback *iface)
{
return 2;
}
static ULONG WINAPI ManagedCallback_Release(ICorDebugManagedCallback *iface)
{
return 1;
}
static HRESULT WINAPI ManagedCallback_Breakpoint(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, ICorDebugBreakpoint *pBreakpoint)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_StepComplete(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, ICorDebugStepper *pStepper, CorDebugStepReason reason)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_Break(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *thread)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_Exception(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, BOOL unhandled)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_EvalComplete(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, ICorDebugEval *pEval)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_EvalException(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, ICorDebugEval *pEval)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_CreateProcess(ICorDebugManagedCallback *iface, ICorDebugProcess *pProcess)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_ExitProcess(ICorDebugManagedCallback *iface, ICorDebugProcess *pProcess)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_CreateThread(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *thread)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_ExitThread(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *thread)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_LoadModule(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugModule *pModule)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_UnloadModule(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugModule *pModule)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_LoadClass(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugClass *c)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_UnloadClass(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugClass *c)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_DebuggerError(ICorDebugManagedCallback *iface, ICorDebugProcess *pProcess,
HRESULT errorHR, DWORD errorCode)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_LogMessage(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, LONG lLevel, WCHAR *pLogSwitchName, WCHAR *pMessage)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_LogSwitch(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, LONG lLevel, ULONG ulReason,
WCHAR *pLogSwitchName, WCHAR *pParentName)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_CreateAppDomain(ICorDebugManagedCallback *iface, ICorDebugProcess *pProcess,
ICorDebugAppDomain *pAppDomain)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_ExitAppDomain(ICorDebugManagedCallback *iface, ICorDebugProcess *pProcess,
ICorDebugAppDomain *pAppDomain)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_LoadAssembly(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugAssembly *pAssembly)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_UnloadAssembly(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugAssembly *pAssembly)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_ControlCTrap(ICorDebugManagedCallback *iface, ICorDebugProcess *pProcess)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_NameChange(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_UpdateModuleSymbols(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugModule *pModule, IStream *pSymbolStream)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_EditAndContinueRemap(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, ICorDebugFunction *pFunction, BOOL fAccurate)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ManagedCallback_BreakpointSetError(ICorDebugManagedCallback *iface, ICorDebugAppDomain *pAppDomain,
ICorDebugThread *pThread, ICorDebugBreakpoint *pBreakpoint, DWORD dwError)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static ICorDebugManagedCallbackVtbl managedCallbackVtbl = {
ManagedCallback_QueryInterface,
ManagedCallback_AddRef,
ManagedCallback_Release,
ManagedCallback_Breakpoint,
ManagedCallback_StepComplete,
ManagedCallback_Break,
ManagedCallback_Exception,
ManagedCallback_EvalComplete,
ManagedCallback_EvalException,
ManagedCallback_CreateProcess,
ManagedCallback_ExitProcess,
ManagedCallback_CreateThread,
ManagedCallback_ExitThread,
ManagedCallback_LoadModule,
ManagedCallback_UnloadModule,
ManagedCallback_LoadClass,
ManagedCallback_UnloadClass,
ManagedCallback_DebuggerError,
ManagedCallback_LogMessage,
ManagedCallback_LogSwitch,
ManagedCallback_CreateAppDomain,
ManagedCallback_ExitAppDomain,
ManagedCallback_LoadAssembly,
ManagedCallback_UnloadAssembly,
ManagedCallback_ControlCTrap,
ManagedCallback_NameChange,
ManagedCallback_UpdateModuleSymbols,
ManagedCallback_EditAndContinueRemap,
ManagedCallback_BreakpointSetError
};
static ICorDebugManagedCallback ManagedCallback = { &managedCallbackVtbl };
static BOOL init_functionpointers(void)
{
hmscoree = LoadLibraryA("mscoree.dll");
if (!hmscoree)
{
win_skip("mscoree.dll not available\n");
return FALSE;
}
pCreateDebuggingInterfaceFromVersion = (void *)GetProcAddress(hmscoree, "CreateDebuggingInterfaceFromVersion");
if (!pCreateDebuggingInterfaceFromVersion)
{
win_skip("functions not available\n");
FreeLibrary(hmscoree);
return FALSE;
}
return TRUE;
}
#define check_process_enum(core, e) _check_process_enum(__LINE__, core, e)
static void _check_process_enum(unsigned line, ICorDebug *pCorDebug, ULONG nExpected)
{
HRESULT hr;
ICorDebugProcessEnum *pProcessEnum = NULL;
hr = ICorDebug_EnumerateProcesses(pCorDebug, NULL);
ok_(__FILE__,line) (hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr);
hr = ICorDebug_EnumerateProcesses(pCorDebug, &pProcessEnum);
ok_(__FILE__,line) (hr == S_OK, "expected S_OK got %08x\n", hr);
if(hr == S_OK)
{
ULONG cnt;
hr = ICorDebugProcessEnum_GetCount(pProcessEnum, &cnt);
ok_(__FILE__,line) (hr == S_OK, "expected S_OK got %08x\n", hr);
ok_(__FILE__,line) (cnt == nExpected, "expected %d got %d\n", nExpected, cnt);
ICorDebugProcessEnum_Release(pProcessEnum);
}
}
static void test_createDebugger(void)
{
HRESULT hr;
IUnknown *pUnk;
ICorDebug *pCorDebug;
hr = pCreateDebuggingInterfaceFromVersion(0, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(1, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(2, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(4, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(3, v2_0, NULL);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(3, v2_0, &pUnk);
if(hr == S_OK)
{
hr = IUnknown_QueryInterface(pUnk, &IID_ICorDebug, (void**)&pCorDebug);
ok(hr == S_OK, "expected S_OK got %08x\n", hr);
if(hr == S_OK)
{
hr = ICorDebug_Initialize(pCorDebug);
ok(hr == S_OK, "expected S_OK got %08x\n", hr);
if(hr == S_OK)
{
hr = ICorDebug_SetManagedHandler(pCorDebug, NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr);
hr = ICorDebug_SetManagedHandler(pCorDebug, &ManagedCallback);
ok(hr == S_OK, "expected S_OK got %08x\n", hr);
/* We should have no processes */
check_process_enum(pCorDebug, 0);
}
ICorDebug_Release(pCorDebug);
}
IUnknown_Release(pUnk);
}
else
{
skip(".NET 2.0 or mono not installed.\n");
}
}
START_TEST(debugging)
{
CoInitialize(NULL);
if (!init_functionpointers())
return;
test_createDebugger();
FreeLibrary(hmscoree);
CoUninitialize();
}

View file

@ -0,0 +1,155 @@
/*
* Copyright 2010 Vincent Povirk
*
* 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
*/
#define COBJMACROS
#include <stdarg.h>
#include "windef.h"
#include "ole2.h"
#include "corerror.h"
#include "ocidl.h"
#include "initguid.h"
#include "metahost.h"
#include "wine/test.h"
static HMODULE hmscoree;
static HRESULT (WINAPI *pCLRCreateInstance)(REFCLSID clsid, REFIID riid, LPVOID *ppInterface);
static ICLRMetaHost *metahost;
static BOOL init_pointers(void)
{
HRESULT hr = E_FAIL;
hmscoree = LoadLibraryA("mscoree.dll");
if (hmscoree)
pCLRCreateInstance = (void *)GetProcAddress(hmscoree, "CLRCreateInstance");
if (pCLRCreateInstance)
hr = pCLRCreateInstance(&CLSID_CLRMetaHost, &IID_ICLRMetaHost, (void**)&metahost);
if (FAILED(hr))
{
win_skip(".NET 4 is not installed\n");
FreeLibrary(hmscoree);
return FALSE;
}
return TRUE;
}
static void cleanup(void)
{
ICLRMetaHost_Release(metahost);
FreeLibrary(hmscoree);
}
static void test_enumruntimes(void)
{
IEnumUnknown *runtime_enum;
IUnknown *unk;
DWORD count;
ICLRRuntimeInfo *runtime_info;
HRESULT hr;
WCHAR buf[MAX_PATH];
hr = ICLRMetaHost_EnumerateInstalledRuntimes(metahost, &runtime_enum);
ok(hr == S_OK, "EnumerateInstalledRuntimes returned %x\n", hr);
if (FAILED(hr)) return;
while ((hr = IEnumUnknown_Next(runtime_enum, 1, &unk, &count)) == S_OK)
{
hr = IUnknown_QueryInterface(unk, &IID_ICLRRuntimeInfo, (void**)&runtime_info);
ok(hr == S_OK, "QueryInterface returned %x\n", hr);
count = 1;
hr = ICLRRuntimeInfo_GetVersionString(runtime_info, buf, &count);
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetVersionString returned %x\n", hr);
ok(count > 1, "GetVersionString returned count %u\n", count);
count = 0xdeadbeef;
hr = ICLRRuntimeInfo_GetVersionString(runtime_info, NULL, &count);
ok(hr == S_OK, "GetVersionString returned %x\n", hr);
ok(count > 1 && count != 0xdeadbeef, "GetVersionString returned count %u\n", count);
count = MAX_PATH;
hr = ICLRRuntimeInfo_GetVersionString(runtime_info, buf, &count);
ok(hr == S_OK, "GetVersionString returned %x\n", hr);
ok(count > 1, "GetVersionString returned count %u\n", count);
trace("runtime found: %s\n", wine_dbgstr_w(buf));
ICLRRuntimeInfo_Release(runtime_info);
IUnknown_Release(unk);
}
ok(hr == S_FALSE, "IEnumUnknown_Next returned %x\n", hr);
IEnumUnknown_Release(runtime_enum);
}
static void test_getruntime(void)
{
static const WCHAR twodotzero[] = {'v','2','.','0','.','5','0','7','2','7',0};
static const WCHAR twodotzerodotzero[] = {'v','2','.','0','.','0',0};
HRESULT hr;
ICLRRuntimeInfo *info;
DWORD count;
WCHAR buf[MAX_PATH];
hr = ICLRMetaHost_GetRuntime(metahost, NULL, &IID_ICLRRuntimeInfo, (void**)&info);
ok(hr == E_POINTER, "GetVersion failed, hr=%x\n", hr);
hr = ICLRMetaHost_GetRuntime(metahost, twodotzero, &IID_ICLRRuntimeInfo, (void**)&info);
if (hr == CLR_E_SHIM_RUNTIME)
/* FIXME: Get Mono properly packaged so we can fail here. */
todo_wine ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
else
ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
if (hr != S_OK) return;
count = MAX_PATH;
hr = ICLRRuntimeInfo_GetVersionString(info, buf, &count);
ok(hr == S_OK, "GetVersionString returned %x\n", hr);
ok(count == lstrlenW(buf)+1, "GetVersionString returned count %u but string of length %u\n", count, lstrlenW(buf)+1);
ok(lstrcmpW(buf, twodotzero) == 0, "got unexpected version %s\n", wine_dbgstr_w(buf));
ICLRRuntimeInfo_Release(info);
/* Versions must match exactly. */
hr = ICLRMetaHost_GetRuntime(metahost, twodotzerodotzero, &IID_ICLRRuntimeInfo, (void**)&info);
ok(hr == CLR_E_SHIM_RUNTIME, "GetVersion failed, hr=%x\n", hr);
}
START_TEST(metahost)
{
if (!init_pointers())
return;
test_enumruntimes();
test_getruntime();
cleanup();
}

View file

@ -0,0 +1,356 @@
/*
* Copyright 2010 Louis Lenders
* Copyright 2011 André Hentschel
*
* 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
*/
#define COBJMACROS
#include "corerror.h"
#include "mscoree.h"
#include "shlwapi.h"
#include "wine/test.h"
static HMODULE hmscoree;
static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
static HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD*);
static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD, LPWSTR, DWORD, DWORD*, LPWSTR, DWORD, DWORD*);
static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE*);
static HRESULT (WINAPI *pCreateConfigStream)(LPCWSTR, IStream**);
static BOOL init_functionpointers(void)
{
hmscoree = LoadLibraryA("mscoree.dll");
if (!hmscoree)
{
win_skip("mscoree.dll not available\n");
return FALSE;
}
pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory");
pGetRequestedRuntimeInfo = (void *)GetProcAddress(hmscoree, "GetRequestedRuntimeInfo");
pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
pCreateConfigStream = (void *)GetProcAddress(hmscoree, "CreateConfigStream");
if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim)
{
win_skip("functions not available\n");
FreeLibrary(hmscoree);
return FALSE;
}
return TRUE;
}
static void test_versioninfo(void)
{
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
const WCHAR v1_1[] = {'v','1','.','1','.','4','3','2','2',0};
WCHAR version[MAX_PATH];
WCHAR path[MAX_PATH];
DWORD size, path_len;
HRESULT hr;
if (0) /* crashes on <= w2k3 */
{
hr = pGetCORVersion(NULL, MAX_PATH, &size);
ok(hr == E_POINTER,"GetCORVersion returned %08x\n", hr);
}
hr = pGetCORVersion(version, 1, &size);
if (hr == CLR_E_SHIM_RUNTIME)
{
/* FIXME: Get Mono packaged properly so we can fail here. */
todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
skip("No .NET runtimes are installed\n");
return;
}
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
hr = pGetCORVersion(version, MAX_PATH, &size);
ok(hr == S_OK,"GetCORVersion returned %08x\n", hr);
trace("latest installed .net runtime: %s\n", wine_dbgstr_w(version));
hr = pGetCORSystemDirectory(path, MAX_PATH , &size);
ok(hr == S_OK, "GetCORSystemDirectory returned %08x\n", hr);
/* size includes terminating null-character */
ok(size == (lstrlenW(path) + 1),"size is %d instead of %d\n", size, (lstrlenW(path) + 1));
path_len = size;
hr = pGetCORSystemDirectory(path, path_len-1 , &size);
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
if (0) /* crashes on <= w2k3 */
{
hr = pGetCORSystemDirectory(NULL, MAX_PATH , &size);
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
}
hr = pGetCORSystemDirectory(path, MAX_PATH , NULL);
ok(hr == E_POINTER,"GetCORSystemDirectory returned %08x\n", hr);
trace("latest installed .net installed in directory: %s\n", wine_dbgstr_w(path));
/* test GetRequestedRuntimeInfo, first get info about different versions of runtime */
hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
if(hr == CLR_E_SHIM_RUNTIME) return; /* skipping rest of tests on win2k as .net 2.0 not installed */
ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
trace(" installed in directory %s is .net version %s\n", wine_dbgstr_w(path), wine_dbgstr_w(version));
hr = pGetRequestedRuntimeInfo( NULL, v1_1, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
ok(hr == S_OK || hr == CLR_E_SHIM_RUNTIME /*v1_1 not installed*/, "GetRequestedRuntimeInfo returned %08x\n", hr);
if(hr == S_OK)
trace(" installed in directory %s is .net version %s\n", wine_dbgstr_w(path), wine_dbgstr_w(version));
/* version number NULL not allowed without RUNTIME_INFO_UPGRADE_VERSION flag */
hr = pGetRequestedRuntimeInfo( NULL, NULL, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
ok(hr == CLR_E_SHIM_RUNTIME, "GetRequestedRuntimeInfo returned %08x\n", hr);
/* with RUNTIME_INFO_UPGRADE_VERSION flag and version number NULL, latest installed version is returned */
hr = pGetRequestedRuntimeInfo( NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, 1, &path_len, version, MAX_PATH, &size);
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetRequestedRuntimeInfo returned %08x\n", hr);
/* if one of the buffers is NULL, the other one is still happily filled */
memset(version, 0, sizeof(version));
hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, NULL, MAX_PATH, &path_len, version, MAX_PATH, &size);
ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
ok(!winetest_strcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
/* With NULL-pointer for bufferlength, the buffer itself still gets filled with correct string */
memset(version, 0, sizeof(version));
hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, NULL);
ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
ok(!winetest_strcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
}
static void test_loadlibraryshim(void)
{
const WCHAR v4_0[] = {'v','4','.','0','.','3','0','3','1','9',0};
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
const WCHAR v1_1[] = {'v','1','.','1','.','4','3','2','2',0};
const WCHAR vbogus[] = {'v','b','o','g','u','s',0};
const WCHAR fusion[] = {'f','u','s','i','o','n',0};
const WCHAR fusiondll[] = {'f','u','s','i','o','n','.','d','l','l',0};
const WCHAR nosuchdll[] = {'j','n','v','n','l','.','d','l','l',0};
const WCHAR gdidll[] = {'g','d','i','3','2','.','d','l','l',0};
HRESULT hr;
const WCHAR *latest = NULL;
CHAR latestA[MAX_PATH];
HMODULE hdll;
CHAR dllpath[MAX_PATH];
hr = pLoadLibraryShim(fusion, v1_1, NULL, &hdll);
ok(hr == S_OK || hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
latest = v1_1;
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
todo_wine ok(StrStrIA(dllpath, "v1.1.4322") != 0, "incorrect fusion.dll path %s\n", dllpath);
ok(StrStrIA(dllpath, "fusion.dll") != 0, "incorrect fusion.dll path %s\n", dllpath);
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusion, v2_0, NULL, &hdll);
ok(hr == S_OK || hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
latest = v2_0;
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
todo_wine ok(StrStrIA(dllpath, "v2.0.50727") != 0, "incorrect fusion.dll path %s\n", dllpath);
ok(StrStrIA(dllpath, "fusion.dll") != 0, "incorrect fusion.dll path %s\n", dllpath);
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusion, v4_0, NULL, &hdll);
ok(hr == S_OK || hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
/* LoadLibraryShim with a NULL version prefers 2.0 and earlier */
if (!latest)
latest = v4_0;
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
todo_wine ok(StrStrIA(dllpath, "v4.0.30319") != 0, "incorrect fusion.dll path %s\n", dllpath);
ok(StrStrIA(dllpath, "fusion.dll") != 0, "incorrect fusion.dll path %s\n", dllpath);
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusion, vbogus, NULL, &hdll);
todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
WideCharToMultiByte(CP_ACP, 0, latest, -1, latestA, MAX_PATH, NULL, NULL);
hr = pLoadLibraryShim(fusion, NULL, NULL, &hdll);
ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
if (latest)
todo_wine ok(StrStrIA(dllpath, latestA) != 0, "incorrect fusion.dll path %s\n", dllpath);
ok(StrStrIA(dllpath, "fusion.dll") != 0, "incorrect fusion.dll path %s\n", dllpath);
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusiondll, NULL, NULL, &hdll);
ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
if (latest)
todo_wine ok(StrStrIA(dllpath, latestA) != 0, "incorrect fusion.dll path %s\n", dllpath);
ok(StrStrIA(dllpath, "fusion.dll") != 0, "incorrect fusion.dll path %s\n", dllpath);
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(nosuchdll, latest, NULL, &hdll);
ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
hr = pLoadLibraryShim(gdidll, latest, NULL, &hdll);
todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
}
static const char xmldata[] =
"<?xml version=\"1.0\" ?>\n"
"<!DOCTYPE Config>\n"
"<Configuration>\n"
" <Name>Test</Name>\n"
" <Value>1234</Value>\n"
"</Configuration>";
static void create_xml_file(LPCWSTR filename)
{
DWORD dwNumberOfBytesWritten;
HANDLE hfile = CreateFileW(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
ok(hfile != INVALID_HANDLE_VALUE, "File creation failed\n");
WriteFile(hfile, xmldata, sizeof(xmldata) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hfile);
}
static void test_createconfigstream(void)
{
IStream *stream = NULL;
WCHAR file[] = {'c', 'o', 'n', 'f', '.', 'x', 'm', 'l', 0};
WCHAR nonexistent[] = {'n', 'o', 'n', 'e', 'x', 'i', 's', 't', '.', 'x', 'm', 'l', 0};
WCHAR path[MAX_PATH];
HRESULT hr;
char buffer[256] = {0};
if (!pCreateConfigStream)
{
win_skip("CreateConfigStream not available\n");
return;
}
create_xml_file(file);
GetFullPathNameW(file, MAX_PATH, path, NULL);
hr = pCreateConfigStream(NULL, &stream);
todo_wine ok(hr == E_FAIL ||
broken(hr == HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND)) || /* some WinXP, Win2K3 and Win7 */
broken(hr == S_OK && !stream), /* some Win2K3 */
"CreateConfigStream returned %x\n", hr);
hr = pCreateConfigStream(path, NULL);
todo_wine ok(hr == COR_E_NULLREFERENCE, "CreateConfigStream returned %x\n", hr);
hr = pCreateConfigStream(NULL, NULL);
todo_wine ok(hr == COR_E_NULLREFERENCE, "CreateConfigStream returned %x\n", hr);
hr = pCreateConfigStream(nonexistent, &stream);
todo_wine ok(hr == COR_E_FILENOTFOUND, "CreateConfigStream returned %x\n", hr);
ok(stream == NULL, "Expected stream to be NULL\n");
hr = pCreateConfigStream(path, &stream);
todo_wine ok(hr == S_OK, "CreateConfigStream failed, hr=%x\n", hr);
todo_wine ok(stream != NULL, "Expected non-NULL stream\n");
if (stream)
{
DWORD count;
LARGE_INTEGER pos;
ULARGE_INTEGER size;
IStream *stream2 = NULL;
hr = IStream_Read(stream, buffer, strlen(xmldata), &count);
ok(hr == S_OK, "IStream_Read failed, hr=%x\n", hr);
ok(count == strlen(xmldata), "wrong count: %u\n", count);
ok(!strcmp(buffer, xmldata), "Strings do not match\n");
hr = IStream_Write(stream, xmldata, strlen(xmldata), &count);
ok(hr == E_FAIL, "IStream_Write returned hr=%x\n", hr);
pos.QuadPart = strlen(xmldata);
hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL);
ok(hr == E_NOTIMPL, "IStream_Seek returned hr=%x\n", hr);
size.QuadPart = strlen(xmldata);
hr = IStream_SetSize(stream, size);
ok(hr == E_NOTIMPL, "IStream_SetSize returned hr=%x\n", hr);
hr = IStream_Clone(stream, &stream2);
ok(hr == E_NOTIMPL, "IStream_Clone returned hr=%x\n", hr);
hr = IStream_Commit(stream, STGC_DEFAULT);
ok(hr == E_NOTIMPL, "IStream_Commit returned hr=%x\n", hr);
hr = IStream_Revert(stream);
ok(hr == E_NOTIMPL, "IStream_Revert returned hr=%x\n", hr);
hr = IStream_Release(stream);
ok(hr == S_OK, "IStream_Release returned hr=%x\n", hr);
}
DeleteFileW(file);
}
START_TEST(mscoree)
{
if (!init_functionpointers())
return;
test_versioninfo();
test_loadlibraryshim();
test_createconfigstream();
FreeLibrary(hmscoree);
}

View file

@ -0,0 +1,13 @@
<module name="mscoree_winetest" type="win32cui" installbase="bin" installname="mscoree_winetest.exe" allowwarnings="true">
<include base="mscoree_winetest">.</include>
<define name="__ROS_LONG64__" />
<file>debugging.c</file>
<file>metahost.c</file>
<file>mscoree.c</file>
<file>testlist.c</file>
<library>wine</library>
<library>uuid</library>
<library>ole32</library>
<library>shlwapi</library>
<library>ntdll</library>
</module>

View file

@ -0,0 +1,17 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define STANDALONE
#include "wine/test.h"
extern void func_debugging(void);
extern void func_metahost(void);
extern void func_mscoree(void);
const struct test winetest_testlist[] =
{
{ "debugging", func_debugging },
{ "metahost", func_metahost },
{ "mscoree", func_mscoree },
{ 0, 0 }
};