| 975 | } |
| 976 | |
| 977 | bool |
| 978 | convert_find_stream_data(CryptContext *con, LPCWSTR pt_path, LPCWSTR path, WIN32_FIND_STREAM_DATA& fdata) |
| 979 | { |
| 980 | |
| 981 | BYTE dir_iv[DIR_IV_LEN]; |
| 982 | |
| 983 | bool plaintext_names = con->GetConfig()->m_PlaintextNames; |
| 984 | |
| 985 | bool reverse = con->GetConfig()->m_reverse; |
| 986 | |
| 987 | if (!plaintext_names && wcscmp(fdata.cStreamName, L"::$DATA")) { |
| 988 | if (reverse) { |
| 989 | wstring dirpath; |
| 990 | if (!get_file_directory(pt_path, dirpath)) |
| 991 | return false; |
| 992 | if (!derive_path_iv(con, dirpath.c_str(), dir_iv, TYPE_DIRIV)) |
| 993 | return false; |
| 994 | |
| 995 | wstring enc_stream; |
| 996 | |
| 997 | if (!encrypt_stream_name(con, dir_iv, fdata.cStreamName, enc_stream)) |
| 998 | return false; |
| 999 | |
| 1000 | wcscpy_s(fdata.cStreamName, enc_stream.c_str()); |
| 1001 | |
| 1002 | } else { |
| 1003 | wstring dirpath; |
| 1004 | if (!get_file_directory(path, dirpath)) |
| 1005 | return false; |
| 1006 | if (!get_dir_iv(con, dirpath.c_str(), dir_iv)) |
| 1007 | return false; |
| 1008 | |
| 1009 | wstring pt_stream; |
| 1010 | |
| 1011 | if (!decrypt_stream_name(con, dir_iv, fdata.cStreamName, pt_stream)) |
| 1012 | return false; |
| 1013 | |
| 1014 | wcscpy_s(fdata.cStreamName, pt_stream.c_str()); |
| 1015 | |
| 1016 | } |
| 1017 | |
| 1018 | } |
| 1019 | |
| 1020 | if (reverse) { |
| 1021 | if (!adjust_file_size_up(fdata.StreamSize)) |
| 1022 | return false; |
| 1023 | } else { |
| 1024 | if (!adjust_file_size_down(fdata.StreamSize)) |
| 1025 | return false; |
| 1026 | } |
| 1027 | |
| 1028 | return true; |
| 1029 | } |
| 1030 | |
| 1031 | #ifdef _WIN32 |
| 1032 | bool is_suitable_mountpoint(LPCWSTR path) |
no test coverage detected