2010-08-24 11:48:01 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Louis Lenders
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2010-08-25 23:06:02 +02:00
|
|
|
#include "corerror.h"
|
|
|
|
#include "mscoree.h"
|
2010-11-22 12:01:11 +01:00
|
|
|
#include "shlwapi.h"
|
2010-08-24 11:48:01 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static HMODULE hmscoree;
|
|
|
|
|
|
|
|
static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
|
2010-08-25 14:34:04 +02:00
|
|
|
static HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD*);
|
2010-08-25 23:06:02 +02:00
|
|
|
static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD, LPWSTR, DWORD, DWORD*, LPWSTR, DWORD, DWORD*);
|
2010-10-26 21:37:28 +02:00
|
|
|
static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE*);
|
|
|
|
|
2010-08-24 11:48:01 +02:00
|
|
|
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");
|
2010-08-25 14:34:04 +02:00
|
|
|
pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory");
|
2010-08-25 23:06:02 +02:00
|
|
|
pGetRequestedRuntimeInfo = (void *)GetProcAddress(hmscoree, "GetRequestedRuntimeInfo");
|
2010-10-26 21:37:28 +02:00
|
|
|
pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
|
2010-08-25 23:06:02 +02:00
|
|
|
|
2010-10-26 21:37:28 +02:00
|
|
|
if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim)
|
2010-08-24 11:48:01 +02:00
|
|
|
{
|
|
|
|
win_skip("functions not available\n");
|
|
|
|
FreeLibrary(hmscoree);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_versioninfo(void)
|
|
|
|
{
|
2010-08-25 23:06:02 +02:00
|
|
|
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};
|
|
|
|
|
2010-08-24 11:48:01 +02:00
|
|
|
WCHAR version[MAX_PATH];
|
2010-08-25 14:34:04 +02:00
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
DWORD size, path_len;
|
2010-08-24 11:48:01 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2010-08-27 15:17:29 +02:00
|
|
|
if (0) /* crashes on <= w2k3 */
|
|
|
|
{
|
|
|
|
hr = pGetCORVersion(NULL, MAX_PATH, &size);
|
|
|
|
ok(hr == E_POINTER,"GetCORVersion returned %08x\n", hr);
|
|
|
|
}
|
2010-08-24 11:48:01 +02:00
|
|
|
|
|
|
|
hr = pGetCORVersion(version, 1, &size);
|
2010-10-01 21:18:12 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-08-24 12:51:33 +02:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
|
2010-08-24 11:48:01 +02:00
|
|
|
|
|
|
|
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));
|
2010-08-25 14:34:04 +02:00
|
|
|
|
|
|
|
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);
|
2010-08-25 14:53:05 +02:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
|
2010-08-25 14:34:04 +02:00
|
|
|
|
2010-08-27 15:17:29 +02:00
|
|
|
if (0) /* crashes on <= w2k3 */
|
|
|
|
{
|
|
|
|
hr = pGetCORSystemDirectory(NULL, MAX_PATH , &size);
|
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
|
|
|
|
}
|
2010-08-25 14:34:04 +02:00
|
|
|
|
|
|
|
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));
|
2010-08-25 23:06:02 +02:00
|
|
|
|
|
|
|
/* 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);
|
2010-08-31 11:48:42 +02:00
|
|
|
trace(" installed in directory %s is .net version %s\n", wine_dbgstr_w(path), wine_dbgstr_w(version));
|
2010-08-25 23:06:02 +02:00
|
|
|
|
|
|
|
hr = pGetRequestedRuntimeInfo( NULL, v1_1, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
|
2010-12-23 07:27:55 +01:00
|
|
|
ok(hr == S_OK || hr == CLR_E_SHIM_RUNTIME /*v1_1 not installed*/, "GetRequestedRuntimeInfo returned %08x\n", hr);
|
2010-08-25 23:06:02 +02:00
|
|
|
if(hr == S_OK)
|
2010-08-31 11:48:42 +02:00
|
|
|
trace(" installed in directory %s is .net version %s\n", wine_dbgstr_w(path), wine_dbgstr_w(version));
|
2010-08-25 23:06:02 +02:00
|
|
|
/* 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);
|
2010-08-26 00:14:41 +02:00
|
|
|
ok(hr == CLR_E_SHIM_RUNTIME, "GetRequestedRuntimeInfo returned %08x\n", hr);
|
2010-08-25 23:06:02 +02:00
|
|
|
/* 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);
|
2010-08-26 00:14:41 +02:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetRequestedRuntimeInfo returned %08x\n", hr);
|
2010-08-25 23:06:02 +02:00
|
|
|
|
|
|
|
/* 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);
|
2010-11-22 11:41:13 +01:00
|
|
|
ok(!winetest_strcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
|
2010-08-25 23:06:02 +02:00
|
|
|
/* With NULL-pointer for bufferlength, the buffer itsself 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);
|
2010-08-26 00:14:41 +02:00
|
|
|
ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
|
2010-11-22 11:41:13 +01:00
|
|
|
ok(!winetest_strcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
|
2010-08-24 11:48:01 +02:00
|
|
|
}
|
|
|
|
|
2010-10-26 21:37:28 +02:00
|
|
|
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;
|
2010-11-22 13:31:53 +01:00
|
|
|
CHAR latestA[MAX_PATH];
|
2010-10-26 21:37:28 +02:00
|
|
|
HMODULE hdll;
|
2010-11-22 13:31:53 +01:00
|
|
|
CHAR dllpath[MAX_PATH];
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
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);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
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);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
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);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-11-22 13:31:53 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, latest, -1, latestA, MAX_PATH, NULL, NULL);
|
|
|
|
|
2010-10-26 21:37:28 +02:00
|
|
|
hr = pLoadLibraryShim(fusion, NULL, NULL, &hdll);
|
|
|
|
ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2010-11-22 13:31:53 +01:00
|
|
|
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
if (latest)
|
2010-11-22 13:31:53 +01:00
|
|
|
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);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
FreeLibrary(hdll);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pLoadLibraryShim(fusiondll, NULL, NULL, &hdll);
|
|
|
|
ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2010-11-22 13:31:53 +01:00
|
|
|
GetModuleFileNameA(hdll, dllpath, MAX_PATH);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
if (latest)
|
2010-11-22 13:31:53 +01:00
|
|
|
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);
|
2010-10-26 21:37:28 +02:00
|
|
|
|
|
|
|
FreeLibrary(hdll);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pLoadLibraryShim(nosuchdll, latest, NULL, &hdll);
|
2010-10-27 17:51:19 +02:00
|
|
|
ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
|
2010-10-26 21:37:28 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-08-24 11:48:01 +02:00
|
|
|
START_TEST(mscoree)
|
|
|
|
{
|
|
|
|
if (!init_functionpointers())
|
|
|
|
return;
|
|
|
|
|
|
|
|
test_versioninfo();
|
2010-10-26 21:37:28 +02:00
|
|
|
test_loadlibraryshim();
|
2010-08-24 11:48:01 +02:00
|
|
|
|
|
|
|
FreeLibrary(hmscoree);
|
|
|
|
}
|