bool GetTrustedPlatformAssembliesList(const std::string& tpaDirectory, bool isNative, std::string& trustedPlatformAssemblies) { size_t cTpaAssemblyNames = 0; LPCTSTR* ppszTpaAssemblyNames = nullptr; CreateTpaBase(&ppszTpaAssemblyNames, &cTpaAssemblyNames, isNative); assert(ppszTpaAssemblyNames != nullptr || cTpaAssemblyNames == 0); //TODO: The Windows version of this actaully ensures the files are present. We just fail for native and assume MSIL is present if (isNative) { return false; } for (size_t i = 0; i < cTpaAssemblyNames; i++) { trustedPlatformAssemblies.append(tpaDirectory); trustedPlatformAssemblies.append("/"); trustedPlatformAssemblies.append(ppszTpaAssemblyNames[i]); trustedPlatformAssemblies.append(":"); } if (ppszTpaAssemblyNames) { FreeTpaBase(ppszTpaAssemblyNames); } return true; }
// Generate a list of trusted platform assembiles. bool GetTrustedPlatformAssembliesList(WCHAR* szDirectory, bool bNative, LPWSTR pszTrustedPlatformAssemblies, size_t cchTrustedPlatformAssemblies) { bool ret = true; errno_t errno = 0; WIN32_FIND_DATA ffd = {}; size_t cTpaAssemblyNames = 0; LPWSTR* ppszTpaAssemblyNames = nullptr; // Build the list of the tpa assemblie CreateTpaBase(&ppszTpaAssemblyNames, &cTpaAssemblyNames, bNative); // Scan the directory to see if all the files in TPA list exist for (size_t i = 0; i < cTpaAssemblyNames; ++i) { WCHAR wszPattern[MAX_PATH]; wszPattern[0] = L'\0'; errno = wcscpy_s(wszPattern, _countof(wszPattern), szDirectory); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED_SETSTATE(errno, ret = false); errno = wcscat_s(wszPattern, _countof(wszPattern), ppszTpaAssemblyNames[i]); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED_SETSTATE(errno, ret = false); HANDLE findHandle = FindFirstFile(wszPattern, &ffd); if ((findHandle == INVALID_HANDLE_VALUE) || (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { // if file is missing or a directory is found, breaks the loop and // set the missing flag to true ret = false; goto Finished; } } for (size_t i = 0; i < cTpaAssemblyNames; ++i) { errno = wcscat_s(pszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies, szDirectory); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED_SETSTATE(errno, ret = false); errno = wcscat_s(pszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies, ppszTpaAssemblyNames[i]); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED_SETSTATE(errno, ret = false); errno = wcscat_s(pszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies, L";"); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED_SETSTATE(errno, ret = false); } Finished: if (ppszTpaAssemblyNames != nullptr) { FreeTpaBase(ppszTpaAssemblyNames, cTpaAssemblyNames); } return ret; }
// Generate a list of trusted platform assemblies. bool GetTrustedPlatformAssembliesList(const std::wstring& core_clr_directory, bool bNative, std::wstring& tpa_paths) { // Build the list of the tpa assemblies auto tpas = CreateTpaBase(bNative); // Scan the directory to see if all the files in TPA list exist for (auto assembly_name : tpas) { if (!dnx::utils::file_exists(dnx::utils::path_combine(core_clr_directory, assembly_name))) { return false; } } for (auto assembly_name : tpas) { tpa_paths.append(dnx::utils::path_combine(core_clr_directory, assembly_name)).append(L";"); } return true; }