From e19096f5928d50c1f8b16c480a4fb0047406eef4 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 26 Oct 2010 14:37:28 -0500 Subject: [PATCH 01/20] mscoree: Add tests for LoadLibraryShim. --- dlls/mscoree/tests/mscoree.c | 118 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 117 insertions(+), 1 deletions(-) diff --git a/dlls/mscoree/tests/mscoree.c b/dlls/mscoree/tests/mscoree.c index a50ce97..8fad671 100644 --- a/dlls/mscoree/tests/mscoree.c +++ b/dlls/mscoree/tests/mscoree.c @@ -25,6 +25,19 @@ 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*); + +WCHAR *strstrW( const WCHAR *str, const WCHAR *sub ) +{ + while (*str) + { + const WCHAR *p1 = str, *p2 = sub; + while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; } + if (!*p2) return (WCHAR *)str; + str++; + } + return NULL; +} static BOOL init_functionpointers(void) { @@ -39,8 +52,9 @@ static BOOL init_functionpointers(void) pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion"); pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory"); pGetRequestedRuntimeInfo = (void *)GetProcAddress(hmscoree, "GetRequestedRuntimeInfo"); + pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim"); - if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo) + if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim) { win_skip("functions not available\n"); FreeLibrary(hmscoree); @@ -129,12 +143,114 @@ static void test_versioninfo(void) ok(!lstrcmpW(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 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 gdipdll[] = {'g','d','i','p','l','u','s','.','d','l','l',0}; + const WCHAR gdidll[] = {'g','d','i','3','2','.','d','l','l',0}; + HRESULT hr; + const WCHAR *latest = NULL; + HMODULE hdll; + WCHAR dllpath[MAX_PATH]; + + hr = pLoadLibraryShim(fusion, v1_1, NULL, &hdll); + ok(hr == S_OK || hr == CLR_E_SHIM_RUNTIME, "LoadLibraryShim failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + latest = v1_1; + + GetModuleFileNameW(hdll, dllpath, MAX_PATH); + + todo_wine ok(strstrW(dllpath, v1_1) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + ok(strstrW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + + FreeLibrary(hdll); + } + + hr = pLoadLibraryShim(fusion, v2_0, NULL, &hdll); + ok(hr == S_OK || hr == CLR_E_SHIM_RUNTIME, "LoadLibraryShim failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + latest = v2_0; + + GetModuleFileNameW(hdll, dllpath, MAX_PATH); + + todo_wine ok(strstrW(dllpath, v2_0) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + ok(strstrW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + + FreeLibrary(hdll); + } + + hr = pLoadLibraryShim(fusion, v4_0, NULL, &hdll); + ok(hr == S_OK || hr == CLR_E_SHIM_RUNTIME, "LoadLibraryShim failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + /* LoadLibraryShim with a NULL version prefers 2.0 and earlier */ + if (!latest) + latest = v4_0; + + GetModuleFileNameW(hdll, dllpath, MAX_PATH); + + todo_wine ok(strstrW(dllpath, v4_0) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + ok(strstrW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + + FreeLibrary(hdll); + } + + hr = pLoadLibraryShim(fusion, NULL, NULL, &hdll); + ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + GetModuleFileNameW(hdll, dllpath, MAX_PATH); + + if (latest) + todo_wine ok(strstrW(dllpath, latest) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + ok(strstrW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + + FreeLibrary(hdll); + } + + hr = pLoadLibraryShim(fusiondll, NULL, NULL, &hdll); + ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + GetModuleFileNameW(hdll, dllpath, MAX_PATH); + + if (latest) + todo_wine ok(strstrW(dllpath, latest) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + ok(strstrW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath)); + + FreeLibrary(hdll); + } + + hr = pLoadLibraryShim(nosuchdll, latest, NULL, &hdll); + todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + FreeLibrary(hdll); + + hr = pLoadLibraryShim(gdipdll, latest, NULL, &hdll); + todo_wine 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); +} + START_TEST(mscoree) { if (!init_functionpointers()) return; test_versioninfo(); + test_loadlibraryshim(); FreeLibrary(hmscoree); } -- 1.7.1