| 2017 | } |
| 2018 | |
| 2019 | int mount_crypt_fs(const WCHAR* mountpoint, const WCHAR *path, |
| 2020 | const WCHAR *config_path, const WCHAR *password, |
| 2021 | wstring &mes, bool reverse, bool readonly, const CryptMountOptions& opts) { |
| 2022 | mes.clear(); |
| 2023 | |
| 2024 | if (config_path && *config_path == '\0') |
| 2025 | config_path = NULL; |
| 2026 | |
| 2027 | if (mountpoint == NULL) { |
| 2028 | mes = LocUtils::GetStringFromResources(IDS_INVALID_MPOINT); |
| 2029 | return -1; |
| 2030 | } |
| 2031 | |
| 2032 | bool mount_point_is_a_dir = is_mountpoint_a_dir(mountpoint); |
| 2033 | |
| 2034 | if (mount_point_is_a_dir && !is_suitable_mountpoint(mountpoint)) { |
| 2035 | if (!PathFileExists(mountpoint)) { |
| 2036 | mes = LocUtils::GetStringFromResources(IDS_MPOINT_DIR_NOT_EXIST); |
| 2037 | } else { |
| 2038 | mes = LocUtils::GetStringFromResources(IDS_MPOINT_DIR_EMPTY_NTFS); |
| 2039 | } |
| 2040 | return -1; |
| 2041 | } |
| 2042 | |
| 2043 | wstring dummy; |
| 2044 | bool already_mounted = MountPointManager::getInstance().find(mountpoint, dummy); |
| 2045 | |
| 2046 | if (already_mounted) { |
| 2047 | mes = LocUtils::GetStringFromResources(IDS_LETTER_MPOINT_ALREADY_USE); |
| 2048 | return -1; |
| 2049 | } |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | int retval = 0; |
| 2054 | CryptThreadData *tdata = NULL; |
| 2055 | HANDLE hThread = NULL; |
| 2056 | |
| 2057 | try { |
| 2058 | |
| 2059 | try { |
| 2060 | tdata = new CryptThreadData; |
| 2061 | } catch (...) { |
| 2062 | } |
| 2063 | |
| 2064 | if (!tdata) { |
| 2065 | mes = LocUtils::GetStringFromResources(IDS_FAILED_ALLOCATE_TDATA); |
| 2066 | throw(-1); |
| 2067 | } |
| 2068 | |
| 2069 | if (opts.encryptkeysinmemory) { |
| 2070 | tdata->con.m_encryptKeysInMemory = true; |
| 2071 | tdata->con.m_cacheKeysInMemory = opts.cachekeysinmemory; |
| 2072 | tdata->con.GetConfig()->m_keybuf_manager.Activate(); |
| 2073 | } |
| 2074 | |
| 2075 | tdata->con.m_denyOtherSessions = opts.denyothersessions; |
| 2076 | tdata->con.m_denyServices = opts.denyservices; |
no test coverage detected