mscoree: Use the new search methods for GetCORVersion/GetCORSystemDirectory.

This commit is contained in:
Vincent Povirk 2010-10-01 14:18:12 -05:00 committed by Alexandre Julliard
parent add7454df7
commit 84ef0fca57
2 changed files with 42 additions and 42 deletions

View File

@ -460,56 +460,48 @@ HRESULT WINAPI _CorValidateImage(PVOID* imageBase, LPCWSTR imageName)
HRESULT WINAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength) HRESULT WINAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
{ {
static const WCHAR slash[] = {'\\',0}; ICLRRuntimeInfo *info;
WCHAR system_dir[MAX_PATH]; HRESULT ret;
WCHAR version[MAX_PATH];
FIXME("(%p, %d, %p): semi-stub!\n", pbuffer, cchBuffer, dwLength); TRACE("(%p, %d, %p)!\n", pbuffer, cchBuffer, dwLength);
if (!dwLength)
return E_POINTER;
if (!pbuffer)
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
if (!get_install_root(system_dir))
{
ERR("error reading registry key for installroot, returning empty path\n");
*dwLength = 0;
}
else
{
GetCORVersion(version, MAX_PATH, dwLength);
lstrcatW(system_dir, version);
lstrcatW(system_dir, slash);
*dwLength = lstrlenW(system_dir) + 1;
if (cchBuffer < *dwLength)
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
lstrcpyW(pbuffer, system_dir);
}
return S_OK;
}
HRESULT WINAPI GetCORVersion(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
{
static const WCHAR version[] = {'v','2','.','0','.','5','0','7','2','7',0};
FIXME("(%p, %d, %p): semi-stub!\n", pbuffer, cchBuffer, dwLength);
if (!dwLength || !pbuffer) if (!dwLength || !pbuffer)
return E_POINTER; return E_POINTER;
*dwLength = lstrlenW(version) + 1; ret = get_runtime_info(NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
if (cchBuffer < *dwLength) if (SUCCEEDED(ret))
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); {
*dwLength = cchBuffer;
ret = ICLRRuntimeInfo_GetRuntimeDirectory(info, pbuffer, dwLength);
lstrcpyW(pbuffer, version); ICLRRuntimeInfo_Release(info);
}
return S_OK; return ret;
}
HRESULT WINAPI GetCORVersion(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
{
ICLRRuntimeInfo *info;
HRESULT ret;
TRACE("(%p, %d, %p)!\n", pbuffer, cchBuffer, dwLength);
if (!dwLength || !pbuffer)
return E_POINTER;
ret = get_runtime_info(NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
if (SUCCEEDED(ret))
{
*dwLength = cchBuffer;
ret = ICLRRuntimeInfo_GetVersionString(info, pbuffer, dwLength);
ICLRRuntimeInfo_Release(info);
}
return ret;
} }
HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile, HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile,

View File

@ -87,6 +87,14 @@ static void test_versioninfo(void)
} }
hr = pGetCORVersion(version, 1, &size); 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); ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
hr = pGetCORVersion(version, MAX_PATH, &size); hr = pGetCORVersion(version, MAX_PATH, &size);