Hi, Sent to wine-devel so I don't jeopardize my rating too much ;)
.NET dlls cannot be found with the existing logic in winetest, mainly because they are not in the search path. If the normal loading of a dll fails we now check against a fixed set of names (fusion only for now). If it's a .NET dll we check if this one is there (according to .NET's mscoree) and get the file information. We can use to existing version checking stuff for that part as it's a normal dll. Remarks, suggestions? Changelog Make sure we can test .NET dlls on Windows -- Cheers, Paul.
>From 08c17f0e2db536b9ba3b2d841ab73c53781e0f3d Mon Sep 17 00:00:00 2001 From: Paul Vriens <[email protected]> Date: Tue, 3 Feb 2009 12:21:31 +0100 Subject: [PATCH] Make sure we can test .NET dlls on Windows --- programs/winetest/main.c | 78 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 75 insertions(+), 3 deletions(-) diff --git a/programs/winetest/main.c b/programs/winetest/main.c index fc7a378..2df01f2 100644 --- a/programs/winetest/main.c +++ b/programs/winetest/main.c @@ -113,6 +113,52 @@ static char * get_file_version(char * file_name) return version; } +static BOOL get_dotnet_file_version(char * file_name, char * file_version) +{ + HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE *); + HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD *); + HRESULT hr; + HMODULE hmscoree, hdll; + static char version[32]; + char dllnameA[MAX_PATH]; + WCHAR dllnameW[MAX_PATH]; + WCHAR dirW[MAX_PATH]; + DWORD len; + BOOL ret = FALSE; + + sprintf(version, "failed"); + + hmscoree = LoadLibraryA("mscoree.dll"); + if (!hmscoree) + goto done; + + pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim"); + pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory"); + if (!pLoadLibraryShim || !pGetCORSystemDirectory) + goto done; + + strcpy(dllnameA, file_name); + strcat(dllnameA, ".dll"); + MultiByteToWideChar(CP_ACP, 0, dllnameA, -1, dllnameW, MAX_PATH); + hr = pLoadLibraryShim(dllnameW, NULL, NULL, &hdll); + if (FAILED(hr)) + goto done; + + hr = pGetCORSystemDirectory(dirW, MAX_PATH, &len); + if (FAILED(hr)) + goto done; + + lstrcatW(dirW, dllnameW); + WideCharToMultiByte(CP_ACP, 0, dirW, -1, dllnameA, MAX_PATH, 0, 0); + sprintf(version, get_file_version(dllnameA)); + ret = TRUE; + +done: + FreeLibrary(hmscoree); + strcpy(file_version, version); + return ret; +} + static int running_under_wine (void) { HMODULE module = GetModuleHandleA("ntdll.dll"); @@ -492,10 +538,16 @@ static BOOL CALLBACK extract_test_proc (HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam) { + static const char* dotnetdlls[] = { + "fusion", + NULL + }; const char *tempdir = (const char *)lParam; char dllname[MAX_PATH]; HMODULE dll; DWORD err; + BOOL dotnetdll = FALSE; + char dotnetdllversion[32]; if (test_filtered_out( lpszName, NULL )) return TRUE; @@ -506,14 +558,34 @@ extract_test_proc (HMODULE hModule, LPCTSTR lpszType, dll = LoadLibraryExA(dllname, NULL, LOAD_LIBRARY_AS_DATAFILE); if (!dll) { - xprintf (" %s=dll is missing\n", dllname); - return TRUE; + int i; + + for (i = 0; dotnetdlls[i]; i++) + if (!strcmp(dllname, dotnetdlls[i])) { + dotnetdll = TRUE; + break; + } + + if (!dotnetdll) { + xprintf (" %s=dll is missing\n", dllname); + return TRUE; + } + + /* Check the existence of the dll and the version info in one go */ + dotnetdll = get_dotnet_file_version(dllname, dotnetdllversion); + if (!dotnetdll) { + xprintf (" %s=dll is missing\n", dllname); + return TRUE; + } } FreeLibrary(dll); if (!(err = get_subtests( tempdir, &wine_tests[nr_of_files], lpszName ))) { - xprintf (" %s=%s\n", dllname, get_file_version(dllname)); + if (!dotnetdll) + xprintf (" %s=%s\n", dllname, get_file_version(dllname)); + else + xprintf (" %s=%s\n", dllname, dotnetdllversion); nr_of_tests += wine_tests[nr_of_files].subtest_count; nr_of_files++; } -- 1.6.0.6
