From 0dafb3d230f7a79472a5d44bb4992012538a91da Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 12 Mar 2023 18:27:29 +0100 Subject: [PATCH] sys: Replaced many helper functions with libwolv --- .gitmodules | 3 + cmake/build_helpers.cmake | 2 + lib/external/libwolv | 1 + lib/external/pattern_language | 2 +- lib/libimhex/CMakeLists.txt | 4 +- .../include/hex/data_processor/node.hpp | 3 +- .../include/hex/helpers/encoding_file.hpp | 5 +- lib/libimhex/include/hex/helpers/file.hpp | 83 ------ lib/libimhex/include/hex/helpers/fs.hpp | 67 +---- lib/libimhex/include/hex/helpers/socket.hpp | 55 ---- lib/libimhex/include/hex/helpers/utils.hpp | 102 ------- .../include/hex/providers/buffered_reader.hpp | 279 +----------------- lib/libimhex/source/api/content_registry.cpp | 10 +- lib/libimhex/source/api/plugin_manager.cpp | 2 +- .../source/api/project_file_manager.cpp | 5 +- lib/libimhex/source/data_processor/node.cpp | 4 +- lib/libimhex/source/helpers/crypto.cpp | 7 +- lib/libimhex/source/helpers/encoding_file.cpp | 5 +- lib/libimhex/source/helpers/file.cpp | 185 ------------ lib/libimhex/source/helpers/fs.cpp | 82 ++--- lib/libimhex/source/helpers/logger.cpp | 9 +- lib/libimhex/source/helpers/magic.cpp | 4 +- lib/libimhex/source/helpers/net.cpp | 12 +- lib/libimhex/source/helpers/opengl.cpp | 2 + lib/libimhex/source/helpers/socket.cpp | 104 ------- lib/libimhex/source/helpers/tar.cpp | 11 +- main/source/init/splash_window.cpp | 2 + main/source/init/tasks.cpp | 10 +- main/source/main.cpp | 8 +- main/source/window/window.cpp | 4 +- .../include/content/helpers/diagrams.hpp | 6 +- .../content/providers/file_provider.hpp | 5 +- .../content/providers/gdb_provider.hpp | 8 +- .../source/content/data_formatters.cpp | 6 +- .../source/content/data_processor_nodes.cpp | 15 +- plugins/builtin/source/content/events.cpp | 5 +- .../source/content/main_menu_items.cpp | 21 +- plugins/builtin/source/content/providers.cpp | 5 +- .../content/providers/file_provider.cpp | 9 +- .../source/content/providers/gdb_provider.cpp | 38 ++- .../content/providers/intel_hex_provider.cpp | 7 +- .../providers/memory_file_provider.cpp | 5 +- .../providers/motorola_srec_provider.cpp | 8 +- .../source/content/settings_entries.cpp | 6 +- plugins/builtin/source/content/themes.cpp | 5 +- .../builtin/source/content/tools_entries.cpp | 16 +- .../source/content/views/view_about.cpp | 2 +- .../source/content/views/view_bookmarks.cpp | 8 +- .../source/content/views/view_constants.cpp | 2 +- .../content/views/view_data_inspector.cpp | 5 +- .../content/views/view_data_processor.cpp | 13 +- .../source/content/views/view_diff.cpp | 4 +- .../source/content/views/view_find.cpp | 8 +- .../source/content/views/view_hex_editor.cpp | 4 +- .../source/content/views/view_information.cpp | 4 +- .../content/views/view_pattern_editor.cpp | 15 +- .../source/content/views/view_store.cpp | 15 +- .../content/views/view_theme_manager.cpp | 4 +- .../source/content/views/view_yara.cpp | 13 +- .../builtin/source/content/welcome_screen.cpp | 15 +- .../providers/process_memory_provider.cpp | 3 + .../windows/source/views/view_tty_console.cpp | 2 + 62 files changed, 263 insertions(+), 1091 deletions(-) create mode 160000 lib/external/libwolv delete mode 100644 lib/libimhex/include/hex/helpers/file.hpp delete mode 100644 lib/libimhex/include/hex/helpers/socket.hpp delete mode 100644 lib/libimhex/source/helpers/file.cpp delete mode 100644 lib/libimhex/source/helpers/socket.cpp diff --git a/.gitmodules b/.gitmodules index c67fa6aae..deba2ee8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -29,3 +29,6 @@ [submodule "lib/external/pattern_language"] path = lib/external/pattern_language url = https://github.com/WerWolv/PatternLanguage +[submodule "lib/external/libwolv"] + path = lib/external/libwolv + url = https://github.com/WerWolv/libwolv diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 3b0c090a8..e92000ad1 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -419,6 +419,8 @@ macro(addBundledLibraries) add_subdirectory(${EXTERN_LIBS_FOLDER}/intervaltree EXCLUDE_FROM_ALL) set_target_properties(intervaltree PROPERTIES POSITION_INDEPENDENT_CODE ON) + add_subdirectory(${EXTERN_LIBS_FOLDER}/libwolv EXCLUDE_FROM_ALL) + set(XDGPP_INCLUDE_DIRS "${EXTERN_LIBS_FOLDER}/xdgpp") set(CURL_USE_MBEDTLS ON) set(BUILD_CURL_EXE OFF) diff --git a/lib/external/libwolv b/lib/external/libwolv new file mode 160000 index 000000000..6742cbb5c --- /dev/null +++ b/lib/external/libwolv @@ -0,0 +1 @@ +Subproject commit 6742cbb5c464ae4dcd7c1d5d1a573403258000bd diff --git a/lib/external/pattern_language b/lib/external/pattern_language index 572a48180..714fb62cf 160000 --- a/lib/external/pattern_language +++ b/lib/external/pattern_language @@ -1 +1 @@ -Subproject commit 572a481803aa19c5bd0c3ccce08d63666d01499c +Subproject commit 714fb62cf47b171dae58bf2c5a95e82d4d8310a7 diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 4260cbaf8..6ca6da81b 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -25,8 +25,6 @@ set(LIBIMHEX_SOURCES source/helpers/crypto.cpp source/helpers/net.cpp source/helpers/opengl.cpp - source/helpers/file.cpp - source/helpers/socket.cpp source/helpers/patches.cpp source/helpers/encoding_file.cpp source/helpers/logger.cpp @@ -72,4 +70,4 @@ elseif (APPLE) endif () target_link_libraries(libimhex PRIVATE ${FMT_LIBRARIES}) -target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${LIBCURL_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} libpl intervaltree ${MINIAUDIO_LIBRARIES}) \ No newline at end of file +target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${LIBCURL_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} libpl intervaltree ${MINIAUDIO_LIBRARIES} libwolv-utils libwolv-io libwolv-hash) \ No newline at end of file diff --git a/lib/libimhex/include/hex/data_processor/node.hpp b/lib/libimhex/include/hex/data_processor/node.hpp index 66f2ddf82..747b4dfaf 100644 --- a/lib/libimhex/include/hex/data_processor/node.hpp +++ b/lib/libimhex/include/hex/data_processor/node.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -77,7 +78,7 @@ namespace hex::dp { const i128& getIntegerOnInput(u32 index); const long double& getFloatOnInput(u32 index); - void setBufferOnOutput(u32 index, const std::vector &data); + void setBufferOnOutput(u32 index, std::span data); void setIntegerOnOutput(u32 index, i128 integer); void setFloatOnOutput(u32 index, long double floatingPoint); diff --git a/lib/libimhex/include/hex/helpers/encoding_file.hpp b/lib/libimhex/include/hex/helpers/encoding_file.hpp index 0d260e42b..5e3e88a7c 100644 --- a/lib/libimhex/include/hex/helpers/encoding_file.hpp +++ b/lib/libimhex/include/hex/helpers/encoding_file.hpp @@ -8,7 +8,8 @@ #include #include -#include + +#include namespace hex { @@ -28,7 +29,7 @@ namespace hex { [[nodiscard]] bool valid() const { return this->m_valid; } private: - void parseThingyFile(fs::File &file); + void parseThingyFile(wolv::io::File &file); bool m_valid = false; diff --git a/lib/libimhex/include/hex/helpers/file.hpp b/lib/libimhex/include/hex/helpers/file.hpp deleted file mode 100644 index 07844cf9a..000000000 --- a/lib/libimhex/include/hex/helpers/file.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -#include - -#include -#include -#include - -#include - -#include - -#if defined(OS_MACOS) - #include - #include - - #define off64_t off_t - #define fopen64 fopen - #define fseeko64 fseek - #define ftello64 ftell - #define ftruncate64 ftruncate -#elif defined(OS_LINUX) - #include - #include -#endif - -namespace hex::fs { - - class File { - public: - enum class Mode - { - Read, - Write, - Create - }; - - explicit File(const std::fs::path &path, Mode mode) noexcept; - File() noexcept; - File(const File &) = delete; - File(File &&other) noexcept; - - ~File(); - - File &operator=(File &&other) noexcept; - - - [[nodiscard]] bool isValid() const { - return this->m_file != nullptr && fs::exists(this->m_path) && !fs::isDirectory(this->m_path); - } - - void seek(u64 offset); - void close(); - - size_t readBuffer(u8 *buffer, size_t size); - std::vector readBytes(size_t numBytes = 0); - std::string readString(size_t numBytes = 0); - std::u8string readU8String(size_t numBytes = 0); - - void write(const u8 *buffer, size_t size); - void write(const std::vector &bytes); - void write(const std::string &string); - void write(const std::u8string &string); - - [[nodiscard]] size_t getSize() const; - void setSize(u64 size); - - void flush(); - bool remove(); - - auto getHandle() { return this->m_file; } - const std::fs::path &getPath() { return this->m_path; } - - void disableBuffering(); - - std::optional getFileInfo(); - - private: - FILE *m_file; - std::fs::path m_path; - }; - -} \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/fs.hpp b/lib/libimhex/include/hex/helpers/fs.hpp index 208c8cb50..c3859927e 100644 --- a/lib/libimhex/include/hex/helpers/fs.hpp +++ b/lib/libimhex/include/hex/helpers/fs.hpp @@ -10,73 +10,10 @@ #include -namespace std::fs { - using namespace std::filesystem; -} +#include namespace hex::fs { - [[maybe_unused]] - static inline bool exists(const std::fs::path &path) { - std::error_code error; - return std::filesystem::exists(path, error) && !error; - } - - [[maybe_unused]] - static inline bool createDirectories(const std::fs::path &path) { - std::error_code error; - return std::filesystem::create_directories(path, error) && !error; - } - - [[maybe_unused]] - static inline bool isRegularFile(const std::fs::path &path) { - std::error_code error; - return std::filesystem::is_regular_file(path, error) && !error; - } - - [[maybe_unused]] - static inline bool copyFile(const std::fs::path &from, const std::fs::path &to, std::fs::copy_options = std::fs::copy_options::none) { - std::error_code error; - return std::filesystem::copy_file(from, to, error) && !error; - } - - [[maybe_unused]] - static inline bool isDirectory(const std::fs::path &path) { - std::error_code error; - return std::filesystem::is_directory(path, error) && !error; - } - - [[maybe_unused]] - static inline bool remove(const std::fs::path &path) { - std::error_code error; - return std::filesystem::remove(path, error) && !error; - } - - [[maybe_unused]] - static inline bool removeAll(const std::fs::path &path) { - std::error_code error; - return std::filesystem::remove_all(path, error) && !error; - } - - [[maybe_unused]] - static inline uintmax_t getFileSize(const std::fs::path &path) { - std::error_code error; - auto size = std::filesystem::file_size(path, error); - - if (error) return 0; - else return size; - } - - static inline bool isSubPath(const std::fs::path& base, const std::fs::path& destination) { - const auto relative = std::fs::relative(destination, base).u8string(); - - return relative.size() == 1 || (relative[0] != '.' && relative[1] != '.'); - } - - bool isPathWritable(const std::fs::path &path); - - std::fs::path toShortPath(const std::fs::path &path); - enum class DialogMode { Open, Save, @@ -107,7 +44,7 @@ namespace hex::fs { END }; - std::optional getExecutablePath(); + bool isPathWritable(const std::fs::path &path); std::vector getDefaultPaths(ImHexPath path, bool listNonExisting = false); diff --git a/lib/libimhex/include/hex/helpers/socket.hpp b/lib/libimhex/include/hex/helpers/socket.hpp deleted file mode 100644 index 982217def..000000000 --- a/lib/libimhex/include/hex/helpers/socket.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include - -#include -#include - -#if defined(OS_WINDOWS) - #include - #include - #include - - #define SOCKET_NONE INVALID_SOCKET -#else - #include - #include - #include - #include - #include - - #define SOCKET_NONE -1 -#endif - -namespace hex { - - class Socket { - public: - Socket() = default; - Socket(const Socket &) = delete; - Socket(Socket &&other) noexcept; - - Socket(const std::string &address, u16 port); - ~Socket(); - - void connect(const std::string &address, u16 port); - void disconnect(); - - [[nodiscard]] bool isConnected() const; - - [[nodiscard]] std::string readString(size_t size = 0x1000) const; - [[nodiscard]] std::vector readBytes(size_t size = 0x1000) const; - - void writeString(const std::string &string) const; - void writeBytes(const std::vector &bytes) const; - - private: - bool m_connected = false; -#if defined(OS_WINDOWS) - SOCKET m_socket = SOCKET_NONE; -#else - int m_socket = SOCKET_NONE; -#endif - }; - -} \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index d9e62ade9..6c699344b 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -19,10 +19,6 @@ #include #include -#define TOKEN_CONCAT_IMPL(x, y) x##y -#define TOKEN_CONCAT(x, y) TOKEN_CONCAT_IMPL(x, y) -#define ANONYMOUS_VARIABLE(prefix) TOKEN_CONCAT(prefix, __COUNTER__) - struct ImVec2; namespace hex { @@ -116,11 +112,6 @@ namespace hex { return i; } - template - struct overloaded : Ts... { using Ts::operator()...; }; - template - overloaded(Ts...) -> overloaded; - template struct SizeTypeImpl { }; @@ -220,14 +211,6 @@ namespace hex { std::string toEngineeringString(double value); - template - std::vector toBytes(T value) { - std::vector bytes(sizeof(T)); - std::memcpy(bytes.data(), &value, sizeof(T)); - - return bytes; - } - inline std::vector parseByteString(const std::string &string) { auto byteString = std::string(string); byteString.erase(std::remove(byteString.begin(), byteString.end(), ' '), byteString.end()); @@ -327,89 +310,4 @@ namespace hex { return string.substr(0, maxLength - 3) + "..."; } - namespace scope_guard { - -#define SCOPE_GUARD ::hex::scope_guard::ScopeGuardOnExit() + [&]() -#define ON_SCOPE_EXIT [[maybe_unused]] auto ANONYMOUS_VARIABLE(SCOPE_EXIT_) = SCOPE_GUARD - - template - class ScopeGuard { - private: - F m_func; - bool m_active; - - public: - explicit constexpr ScopeGuard(F func) : m_func(std::move(func)), m_active(true) { } - ~ScopeGuard() { - if (this->m_active) { this->m_func(); } - } - void release() { this->m_active = false; } - - ScopeGuard(ScopeGuard &&other) noexcept : m_func(std::move(other.m_func)), m_active(other.m_active) { - other.cancel(); - } - - ScopeGuard &operator=(ScopeGuard &&) = delete; - }; - - enum class ScopeGuardOnExit - { - }; - - template - constexpr ScopeGuard operator+(ScopeGuardOnExit, F &&f) { - return ScopeGuard(std::forward(f)); - } - - } - - namespace first_time_exec { - - #define FIRST_TIME [[maybe_unused]] static auto ANONYMOUS_VARIABLE(FIRST_TIME_) = ::hex::first_time_exec::FirstTimeExecutor() + [&]() - - template - class FirstTimeExecute { - public: - explicit constexpr FirstTimeExecute(F func) { func(); } - - FirstTimeExecute &operator=(FirstTimeExecute &&) = delete; - }; - - enum class FirstTimeExecutor - { - }; - - template - constexpr FirstTimeExecute operator+(FirstTimeExecutor, F &&f) { - return FirstTimeExecute(std::forward(f)); - } - - } - - namespace final_cleanup { - - #define FINAL_CLEANUP [[maybe_unused]] static auto ANONYMOUS_VARIABLE(ON_EXIT_) = ::hex::final_cleanup::FinalCleanupExecutor() + [&]() - - template - class FinalCleanupExecute { - F m_func; - - public: - explicit constexpr FinalCleanupExecute(F func) : m_func(func) { } - constexpr ~FinalCleanupExecute() { this->m_func(); } - - FinalCleanupExecute &operator=(FinalCleanupExecute &&) = delete; - }; - - enum class FinalCleanupExecutor - { - }; - - template - constexpr FinalCleanupExecute operator+(FinalCleanupExecutor, F &&f) { - return FinalCleanupExecute(std::forward(f)); - } - - } - } diff --git a/lib/libimhex/include/hex/providers/buffered_reader.hpp b/lib/libimhex/include/hex/providers/buffered_reader.hpp index f320ed58c..d96347e16 100644 --- a/lib/libimhex/include/hex/providers/buffered_reader.hpp +++ b/lib/libimhex/include/hex/providers/buffered_reader.hpp @@ -6,282 +6,21 @@ #include #include +#include + namespace hex::prv { using namespace hex::literals; - class BufferedReader { + inline void providerReaderFunction(Provider *provider, void *buffer, u64 address, size_t size) { + provider->read(address, buffer, size); + } + + class ProviderReader : public wolv::io::BufferedReader { public: - explicit BufferedReader(Provider *provider, size_t bufferSize = 16_MiB) - : m_provider(provider), m_bufferAddress(provider->getBaseAddress()), m_maxBufferSize(bufferSize), - m_startAddress(provider->getBaseAddress()), m_endAddress(provider->getBaseAddress() + provider->getActualSize() - 1LLU), - m_buffer(bufferSize) { + using BufferedReader::BufferedReader; - } - - void seek(u64 address) { - this->m_startAddress = address; - } - - void setEndAddress(u64 address) { - if (address >= this->m_provider->getActualSize()) - address = this->m_provider->getActualSize() - 1; - - this->m_endAddress = address; - } - - [[nodiscard]] std::vector read(u64 address, size_t size) { - if (size > this->m_buffer.size()) { - std::vector result; - result.resize(size); - - this->m_provider->read(address, result.data(), result.size()); - - return result; - } - - this->updateBuffer(address, size); - - auto result = &this->m_buffer[address - this->m_bufferAddress]; - - return { result, result + std::min(size, this->m_buffer.size()) }; - } - - [[nodiscard]] std::vector readReverse(u64 address, size_t size) { - if (size > this->m_buffer.size()) { - std::vector result; - result.resize(size); - - this->m_provider->read(address, result.data(), result.size()); - - return result; - } - - this->updateBuffer(address - std::min(address, this->m_buffer.size()), size); - - auto result = &this->m_buffer[address - this->m_bufferAddress]; - - return { result, result + std::min(size, this->m_buffer.size()) }; - } - - class Iterator { - public: - using iterator_category = std::forward_iterator_tag; - using difference_type = std::ptrdiff_t; - using value_type = u8; - using pointer = const value_type*; - using reference = const value_type&; - - Iterator(BufferedReader *reader, u64 address) : m_reader(reader), m_address(address) {} - - Iterator& operator++() { - this->m_address++; - - return *this; - } - - Iterator operator++(int) { - auto copy = *this; - this->m_address++; - - return copy; - } - - Iterator& operator--() { - this->m_address--; - - return *this; - } - - Iterator operator--(int) { - auto copy = *this; - this->m_address--; - - return copy; - } - - Iterator& operator+=(i64 offset) { - this->m_address += offset; - - return *this; - } - - Iterator& operator-=(i64 offset) { - this->m_address -= offset; - - return *this; - } - - value_type operator*() const { - return (*this)[0]; - } - - [[nodiscard]] u64 getAddress() const { - return this->m_address; - } - - void setAddress(u64 address) { - this->m_address = address; - } - - difference_type operator-(const Iterator &other) const { - return this->m_address - other.m_address; - } - - Iterator operator+(i64 offset) const { - return { this->m_reader, this->m_address + offset }; - } - - value_type operator[](i64 offset) const { - auto result = this->m_reader->read(this->m_address + offset, 1); - if (result.empty()) - return 0x00; - - return result[0]; - } - - friend bool operator== (const Iterator& left, const Iterator& right) { return left.m_address == right.m_address; }; - friend bool operator!= (const Iterator& left, const Iterator& right) { return left.m_address != right.m_address; }; - friend bool operator> (const Iterator& left, const Iterator& right) { return left.m_address > right.m_address; }; - friend bool operator< (const Iterator& left, const Iterator& right) { return left.m_address < right.m_address; }; - friend bool operator>= (const Iterator& left, const Iterator& right) { return left.m_address >= right.m_address; }; - friend bool operator<= (const Iterator& left, const Iterator& right) { return left.m_address <= right.m_address; }; - - private: - BufferedReader *m_reader; - u64 m_address; - }; - - class ReverseIterator { - public: - using iterator_category = std::forward_iterator_tag; - using difference_type = std::ptrdiff_t; - using value_type = u8; - using pointer = const value_type*; - using reference = const value_type&; - - ReverseIterator(BufferedReader *reader, u64 address) : m_reader(reader), m_address(address) {} - - ReverseIterator& operator++() { - this->m_address--; - - return *this; - } - - ReverseIterator operator++(int) { - auto copy = *this; - this->m_address--; - - return copy; - } - - ReverseIterator& operator--() { - this->m_address++; - - return *this; - } - - ReverseIterator operator--(int) { - auto copy = *this; - this->m_address++; - - return copy; - } - - ReverseIterator& operator+=(i64 offset) { - this->m_address -= offset; - - return *this; - } - - ReverseIterator& operator-=(i64 offset) { - this->m_address += offset; - - return *this; - } - - value_type operator*() const { - return (*this)[0]; - } - - [[nodiscard]] u64 getAddress() const { - return this->m_address; - } - - void setAddress(u64 address) { - this->m_address = address; - } - - difference_type operator-(const ReverseIterator &other) const { - return other.m_address - this->m_address; - } - - ReverseIterator operator+(i64 offset) const { - return { this->m_reader, this->m_address - offset }; - } - - value_type operator[](i64 offset) const { - auto result = this->m_reader->readReverse(this->m_address - offset, 1); - if (result.empty()) - return 0x00; - - return result[0]; - } - - friend bool operator== (const ReverseIterator& left, const ReverseIterator& right) { return left.m_address == right.m_address; }; - friend bool operator!= (const ReverseIterator& left, const ReverseIterator& right) { return left.m_address != right.m_address; }; - friend bool operator> (const ReverseIterator& left, const ReverseIterator& right) { return left.m_address > right.m_address; }; - friend bool operator< (const ReverseIterator& left, const ReverseIterator& right) { return left.m_address < right.m_address; }; - friend bool operator>= (const ReverseIterator& left, const ReverseIterator& right) { return left.m_address >= right.m_address; }; - friend bool operator<= (const ReverseIterator& left, const ReverseIterator& right) { return left.m_address <= right.m_address; }; - - private: - BufferedReader *m_reader; - u64 m_address = 0x00; - }; - - Iterator begin() { - return { this, this->m_startAddress }; - } - - Iterator end() { - return { this, this->m_endAddress + 1 }; - } - - ReverseIterator rbegin() { - return { this, this->m_startAddress }; - } - - ReverseIterator rend() { - return { this, 0 }; - } - - private: - void updateBuffer(u64 address, size_t size) { - if (address > this->m_endAddress) - return; - - if (!this->m_bufferValid || address < this->m_bufferAddress || address + size > (this->m_bufferAddress + this->m_buffer.size())) { - const auto remainingBytes = (this->m_endAddress - address) + 1; - if (remainingBytes < this->m_maxBufferSize) - this->m_buffer.resize(remainingBytes); - else - this->m_buffer.resize(this->m_maxBufferSize); - - this->m_provider->read(address, this->m_buffer.data(), this->m_buffer.size()); - this->m_bufferAddress = address; - this->m_bufferValid = true; - } - } - - private: - Provider *m_provider; - - u64 m_bufferAddress = 0x00; - size_t m_maxBufferSize; - bool m_bufferValid = false; - u64 m_startAddress = 0x00, m_endAddress; - std::vector m_buffer; + ProviderReader(Provider *provider, size_t bufferSize = 0x100000) : BufferedReader(provider, provider->getActualSize(), bufferSize) { } }; } \ No newline at end of file diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 6a4cdd1b6..5479d7d32 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -1,17 +1,17 @@ #include #include -#include #include #include +#include #include #include #include -#include +#include namespace hex { @@ -22,7 +22,7 @@ namespace hex { void load() { bool loaded = false; for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) { - fs::File file(dir / SettingsFile, fs::File::Mode::Read); + wolv::io::File file(dir / SettingsFile, wolv::io::File::Mode::Read); if (file.isValid()) { getSettingsData() = nlohmann::json::parse(file.readString()); @@ -37,7 +37,7 @@ namespace hex { void store() { for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) { - fs::File file(dir / SettingsFile, fs::File::Mode::Create); + wolv::io::File file(dir / SettingsFile, wolv::io::File::Mode::Create); if (file.isValid()) { file.write(getSettingsData().dump(4)); @@ -48,7 +48,7 @@ namespace hex { void clear() { for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) { - hex::fs::remove(dir / SettingsFile); + wolv::io::fs::remove(dir / SettingsFile); } } diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 3f902485f..77cb43785 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -145,7 +145,7 @@ namespace hex { std::vector PluginManager::s_plugins; bool PluginManager::load(const std::fs::path &pluginFolder) { - if (!fs::exists(pluginFolder)) + if (!wolv::io::fs::exists(pluginFolder)) return false; PluginManager::s_pluginFolder = pluginFolder; diff --git a/lib/libimhex/source/api/project_file_manager.cpp b/lib/libimhex/source/api/project_file_manager.cpp index 5a73cc3e3..145b5fd8c 100644 --- a/lib/libimhex/source/api/project_file_manager.cpp +++ b/lib/libimhex/source/api/project_file_manager.cpp @@ -6,6 +6,9 @@ #include +#include +#include + namespace hex { constexpr static auto MetadataHeaderMagic = "HEX"; @@ -24,7 +27,7 @@ namespace hex { ProjectFile::s_currProjectPath = originalPath; }; - if (!fs::exists(filePath) || !fs::isRegularFile(filePath)) + if (!wolv::io::fs::exists(filePath) || !wolv::io::fs::isRegularFile(filePath)) return false; if (filePath.extension() != ".hexproj") return false; diff --git a/lib/libimhex/source/data_processor/node.cpp b/lib/libimhex/source/data_processor/node.cpp index b55baa33f..681ec26ac 100644 --- a/lib/libimhex/source/data_processor/node.cpp +++ b/lib/libimhex/source/data_processor/node.cpp @@ -86,7 +86,7 @@ namespace hex::dp { return *reinterpret_cast(outputData.data()); } - void Node::setBufferOnOutput(u32 index, const std::vector &data) { + void Node::setBufferOnOutput(u32 index, std::span data) { if (index >= this->getAttributes().size()) throwNodeError("Attribute index out of bounds!"); @@ -95,7 +95,7 @@ namespace hex::dp { if (attribute.getIOType() != Attribute::IOType::Out) throwNodeError("Tried to set output data of an input attribute!"); - attribute.getOutputData() = data; + attribute.getOutputData() = { data.begin(), data.end() }; } void Node::setIntegerOnOutput(u32 index, i128 integer) { diff --git a/lib/libimhex/source/helpers/crypto.cpp b/lib/libimhex/source/helpers/crypto.cpp index 5b3de4da9..9d9498c0b 100644 --- a/lib/libimhex/source/helpers/crypto.cpp +++ b/lib/libimhex/source/helpers/crypto.cpp @@ -1,8 +1,8 @@ #include #include -#include -#include + +#include #include #include @@ -11,13 +11,10 @@ #include #include #include -#include #include #include -#include #include -#include #include #include #include diff --git a/lib/libimhex/source/helpers/encoding_file.cpp b/lib/libimhex/source/helpers/encoding_file.cpp index 1b0ab8b45..7dd2c5854 100644 --- a/lib/libimhex/source/helpers/encoding_file.cpp +++ b/lib/libimhex/source/helpers/encoding_file.cpp @@ -1,11 +1,12 @@ #include #include +#include namespace hex { EncodingFile::EncodingFile(Type type, const std::fs::path &path) { - auto file = fs::File(path, fs::File::Mode::Read); + auto file = wolv::io::File(path, wolv::io::File::Mode::Read); switch (type) { case Type::Thingy: parseThingyFile(file); @@ -31,7 +32,7 @@ namespace hex { return { ".", 1 }; } - void EncodingFile::parseThingyFile(fs::File &file) { + void EncodingFile::parseThingyFile(wolv::io::File &file) { for (const auto &line : splitString(file.readString(), "\n")) { std::string from, to; diff --git a/lib/libimhex/source/helpers/file.cpp b/lib/libimhex/source/helpers/file.cpp deleted file mode 100644 index 35db190cd..000000000 --- a/lib/libimhex/source/helpers/file.cpp +++ /dev/null @@ -1,185 +0,0 @@ -#include - -#include - -#include - -namespace hex::fs { - - File::File(const std::fs::path &path, Mode mode) noexcept : m_path(path) { - #if defined(OS_WINDOWS) - if (mode == File::Mode::Read) - this->m_file = _wfopen(path.c_str(), L"rb"); - else if (mode == File::Mode::Write) - this->m_file = _wfopen(path.c_str(), L"r+b"); - - if (mode == File::Mode::Create || (mode == File::Mode::Write && this->m_file == nullptr)) - this->m_file = _wfopen(path.c_str(), L"w+b"); - #else - if (mode == File::Mode::Read) - this->m_file = fopen64(hex::toUTF8String(path).c_str(), "rb"); - else if (mode == File::Mode::Write) - this->m_file = fopen64(hex::toUTF8String(path).c_str(), "r+b"); - - if (mode == File::Mode::Create || (mode == File::Mode::Write && this->m_file == nullptr)) - this->m_file = fopen64(hex::toUTF8String(path).c_str(), "w+b"); - #endif - } - - File::File() noexcept { - this->m_file = nullptr; - } - - File::File(File &&other) noexcept { - this->m_file = other.m_file; - other.m_file = nullptr; - } - - File::~File() { - this->close(); - } - - File &File::operator=(File &&other) noexcept { - this->m_file = other.m_file; - other.m_file = nullptr; - - this->m_path = std::move(other.m_path); - - return *this; - } - - - void File::seek(u64 offset) { - fseeko64(this->m_file, offset, SEEK_SET); - } - - void File::close() { - if (isValid()) { - std::fclose(this->m_file); - this->m_file = nullptr; - } - } - - size_t File::readBuffer(u8 *buffer, size_t size) { - if (!isValid()) return 0; - - return fread(buffer, size, 1, this->m_file); - } - - std::vector File::readBytes(size_t numBytes) { - if (!isValid()) return {}; - - auto size = numBytes == 0 ? getSize() : numBytes; - if (size == 0) return {}; - - std::vector bytes(size); - auto bytesRead = fread(bytes.data(), 1, bytes.size(), this->m_file); - - bytes.resize(bytesRead); - - return bytes; - } - - std::string File::readString(size_t numBytes) { - if (!isValid()) return {}; - - if (getSize() == 0) return {}; - - auto bytes = readBytes(numBytes); - - if (bytes.empty()) - return ""; - - auto cString = reinterpret_cast(bytes.data()); - return { cString, hex::strnlen(cString, bytes.size()) }; - } - - std::u8string File::readU8String(size_t numBytes) { - if (!isValid()) return {}; - - if (getSize() == 0) return {}; - - auto bytes = readBytes(numBytes); - - if (bytes.empty()) - return u8""; - - auto cString = reinterpret_cast(bytes.data()); - return { cString, hex::strnlen(reinterpret_cast(bytes.data()), bytes.size()) }; - } - - void File::write(const u8 *buffer, size_t size) { - if (!isValid()) return; - - std::fwrite(buffer, size, 1, this->m_file); - } - - void File::write(const std::vector &bytes) { - if (!isValid()) return; - - std::fwrite(bytes.data(), 1, bytes.size(), this->m_file); - } - - void File::write(const std::string &string) { - if (!isValid()) return; - - std::fwrite(string.data(), string.size(), 1, this->m_file); - } - - void File::write(const std::u8string &string) { - if (!isValid()) return; - - std::fwrite(string.data(), string.size(), 1, this->m_file); - } - - size_t File::getSize() const { - if (!isValid()) return 0; - - auto startPos = ftello64(this->m_file); - fseeko64(this->m_file, 0, SEEK_END); - auto size = ftello64(this->m_file); - fseeko64(this->m_file, startPos, SEEK_SET); - - if (size < 0) - return 0; - - return size; - } - - void File::setSize(u64 size) { - if (!isValid()) return; - - auto result = ftruncate64(fileno(this->m_file), size); - hex::unused(result); - } - - void File::flush() { - std::fflush(this->m_file); - } - - bool File::remove() { - this->close(); - return std::remove(hex::toUTF8String(this->m_path).c_str()) == 0; - } - - void File::disableBuffering() { - if (!isValid()) return; - - std::setvbuf(this->m_file, nullptr, _IONBF, 0); - } - - std::optional File::getFileInfo() { - struct stat fileInfo = { }; - - #if defined(OS_WINDOWS) - if (wstat(this->m_path.c_str(), &fileInfo) != 0) - return std::nullopt; - #else - if (stat(hex::toUTF8String(this->m_path).c_str(), &fileInfo) != 0) - return std::nullopt; - #endif - - return fileInfo; - } - -} \ No newline at end of file diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 6cf254c6c..d9fa62ecc 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -3,11 +3,6 @@ #include #include -#include -#include -#include -#include - #include #if defined(OS_WINDOWS) @@ -21,61 +16,10 @@ #include #include +#include + namespace hex::fs { - std::optional getExecutablePath() { -#if defined(OS_WINDOWS) - std::wstring exePath(MAX_PATH, '\0'); - if (GetModuleFileNameW(nullptr, exePath.data(), exePath.length()) == 0) - return std::nullopt; - - hex::trim(exePath); - - return exePath; -#elif defined(OS_LINUX) - std::string exePath(PATH_MAX, '\0'); - if (readlink("/proc/self/exe", exePath.data(), PATH_MAX) < 0) - return std::nullopt; - - hex::trim(exePath); - - return exePath; -#elif defined(OS_MACOS) - std::string exePath; - - { - auto string = getMacExecutableDirectoryPath(); - exePath = string; - macFree(string); - } - - hex::trim(exePath); - - return exePath; -#else - return std::nullopt; -#endif - } - - - bool isPathWritable(const std::fs::path &path) { - constexpr static auto TestFileName = "__imhex__tmp__"; - { - File file(path / TestFileName, File::Mode::Read); - if (file.isValid()) { - if (!file.remove()) - return false; - } - } - - File file(path / TestFileName, File::Mode::Create); - bool result = file.isValid(); - if (!file.remove()) - return false; - - return result; - } - static std::function s_fileBrowserErrorCallback; void setFileBrowserErrorCallback(const std::function &callback) { s_fileBrowserErrorCallback = callback; @@ -171,7 +115,7 @@ namespace hex::fs { #else - if (auto executablePath = fs::getExecutablePath(); executablePath.has_value()) + if (auto executablePath = wolv::io::fs::getExecutablePath(); executablePath.has_value()) paths.push_back(executablePath->parent_path()); #endif @@ -281,13 +225,31 @@ namespace hex::fs { if (!listNonExisting) { result.erase(std::remove_if(result.begin(), result.end(), [](const auto &path) { - return !fs::isDirectory(path); + return !wolv::io::fs::isDirectory(path); }), result.end()); } return result; } + bool isPathWritable(const std::fs::path &path) { + constexpr static auto TestFileName = "__imhex__tmp__"; + { + wolv::io::File file(path / TestFileName, wolv::io::File::Mode::Read); + if (file.isValid()) { + if (!file.remove()) + return false; + } + } + + wolv::io::File file(path / TestFileName, wolv::io::File::Mode::Create); + bool result = file.isValid(); + if (!file.remove()) + return false; + + return result; + } + std::fs::path toShortPath(const std::fs::path &path) { #if defined(OS_WINDOWS) size_t size = GetShortPathNameW(path.c_str(), nullptr, 0); diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp index 0aba6b4e8..13f6f7871 100644 --- a/lib/libimhex/source/helpers/logger.cpp +++ b/lib/libimhex/source/helpers/logger.cpp @@ -1,13 +1,12 @@ #include -#include #include #include -#include +#include namespace hex::log { - static fs::File g_loggerFile; + static wolv::io::File g_loggerFile; FILE *getDestination() { if (g_loggerFile.isValid()) @@ -24,8 +23,8 @@ namespace hex::log { if (g_loggerFile.isValid()) return; for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Logs, true)) { - fs::createDirectories(path); - g_loggerFile = fs::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", fmt::localtime(std::chrono::system_clock::now())), fs::File::Mode::Create); + wolv::io::fs::createDirectories(path); + g_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", fmt::localtime(std::chrono::system_clock::now())), wolv::io::File::Mode::Create); g_loggerFile.disableBuffering(); if (g_loggerFile.isValid()) break; diff --git a/lib/libimhex/source/helpers/magic.cpp b/lib/libimhex/source/helpers/magic.cpp index 3898c6b0d..1bd4173a3 100644 --- a/lib/libimhex/source/helpers/magic.cpp +++ b/lib/libimhex/source/helpers/magic.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include @@ -27,7 +29,7 @@ namespace hex::magic { for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Magic)) { for (const auto &entry : std::fs::directory_iterator(dir, error)) { if (entry.is_regular_file() && ((sourceFiles && entry.path().extension().empty()) || (!sourceFiles && entry.path().extension() == ".mgc"))) { - magicFiles += hex::toUTF8String(fs::toShortPath(entry.path())) + MAGIC_PATH_SEPARATOR; + magicFiles += hex::toUTF8String(wolv::io::fs::toShortPath(entry.path())) + MAGIC_PATH_SEPARATOR; } } } diff --git a/lib/libimhex/source/helpers/net.cpp b/lib/libimhex/source/helpers/net.cpp index 8f706b3e4..90ce677ed 100644 --- a/lib/libimhex/source/helpers/net.cpp +++ b/lib/libimhex/source/helpers/net.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include @@ -11,15 +10,18 @@ #include +#include +#include + namespace hex { Net::Net() { - FIRST_TIME { + AT_FIRST_TIME { curl_global_sslset(CURLSSLBACKEND_MBEDTLS, nullptr, nullptr); curl_global_init(CURL_GLOBAL_ALL); }; - FINAL_CLEANUP { + AT_FINAL_CLEANUP { curl_global_cleanup(); }; @@ -202,7 +204,7 @@ namespace hex { ON_SCOPE_EXIT { this->m_transmissionActive.unlock(); }; - fs::File file(filePath, fs::File::Mode::Read); + wolv::io::File file(filePath, wolv::io::File::Mode::Read); if (!file.isValid()) return Response { 400, {} }; @@ -251,7 +253,7 @@ namespace hex { ON_SCOPE_EXIT { this->m_transmissionActive.unlock(); }; - fs::File file(filePath, fs::File::Mode::Create); + wolv::io::File file(filePath, wolv::io::File::Mode::Create); if (!file.isValid()) return Response { 400 }; diff --git a/lib/libimhex/source/helpers/opengl.cpp b/lib/libimhex/source/helpers/opengl.cpp index d10c37cef..81ac3c6bd 100644 --- a/lib/libimhex/source/helpers/opengl.cpp +++ b/lib/libimhex/source/helpers/opengl.cpp @@ -3,6 +3,8 @@ #include #include +#include + namespace hex::gl { Shader::Shader(std::string_view vertexSource, std::string_view fragmentSource) { diff --git a/lib/libimhex/source/helpers/socket.cpp b/lib/libimhex/source/helpers/socket.cpp deleted file mode 100644 index 66fd9c550..000000000 --- a/lib/libimhex/source/helpers/socket.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include - -#include -#include - -namespace hex { - - Socket::Socket(const std::string &address, u16 port) { -#if defined(OS_WINDOWS) - FIRST_TIME { - WSAData wsa; - WSAStartup(MAKEWORD(2, 2), &wsa); - }; - - FINAL_CLEANUP { - WSACleanup(); - }; -#endif - - this->connect(address, port); - } - - Socket::Socket(Socket &&other) noexcept { - this->m_socket = other.m_socket; - this->m_connected = other.m_connected; - - other.m_socket = SOCKET_NONE; - } - - Socket::~Socket() { - this->disconnect(); - } - - void Socket::writeBytes(const std::vector &bytes) const { - if (!this->isConnected()) return; - - ::send(this->m_socket, reinterpret_cast(bytes.data()), bytes.size(), 0); - } - - void Socket::writeString(const std::string &string) const { - if (!this->isConnected()) return; - - ::send(this->m_socket, string.c_str(), string.length(), 0); - } - - std::vector Socket::readBytes(size_t size) const { - std::vector data; - data.resize(size); - - auto receivedSize = ::recv(this->m_socket, reinterpret_cast(data.data()), size, 0); - - if (receivedSize < 0) - return {}; - - data.resize(receivedSize); - - return data; - } - - std::string Socket::readString(size_t size) const { - auto bytes = readBytes(size); - - std::string result; - std::copy(bytes.begin(), bytes.end(), std::back_inserter(result)); - - return result; - } - - bool Socket::isConnected() const { - return this->m_connected; - } - - void Socket::connect(const std::string &address, u16 port) { - this->m_socket = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (this->m_socket == SOCKET_NONE) - return; - - sockaddr_in client = { }; - - client.sin_family = AF_INET; - client.sin_port = htons(port); - -#if defined(OS_WINDOWS) - client.sin_addr.S_un.S_addr = ::inet_addr(address.c_str()); -#else - client.sin_addr.s_addr = ::inet_addr(address.c_str()); -#endif - - this->m_connected = ::connect(this->m_socket, reinterpret_cast(&client), sizeof(client)) == 0; - } - - void Socket::disconnect() { - if (this->m_socket != SOCKET_NONE) { -#if defined(OS_WINDOWS) - closesocket(this->m_socket); -#else - close(this->m_socket); -#endif - } - - this->m_connected = false; - } - -} \ No newline at end of file diff --git a/lib/libimhex/source/helpers/tar.cpp b/lib/libimhex/source/helpers/tar.cpp index 261c55873..05255a7e0 100644 --- a/lib/libimhex/source/helpers/tar.cpp +++ b/lib/libimhex/source/helpers/tar.cpp @@ -1,8 +1,9 @@ #include #include -#include #include +#include + namespace hex { using namespace hex::literals; @@ -12,11 +13,11 @@ namespace hex { // Explicitly create file so a short path gets generated if (mode == Mode::Create) { - fs::File file(path, fs::File::Mode::Create); + wolv::io::File file(path, wolv::io::File::Mode::Create); file.flush(); } - auto shortPath = hex::fs::toShortPath(path); + auto shortPath = wolv::io::fs::toShortPath(path); if (mode == Tar::Mode::Read) error = mtar_open(&this->m_ctx, shortPath.string().c_str(), "r"); else if (mode == Tar::Mode::Write) @@ -58,7 +59,7 @@ namespace hex { mtar_header_t header; while (mtar_read_header(&this->m_ctx, &header) != MTAR_ENULLRECORD) { std::fs::path path = header.name; - if (header.name != PaxHeaderName && fs::isSubPath(basePath, path)) { + if (header.name != PaxHeaderName && wolv::io::fs::isSubPath(basePath, path)) { result.emplace_back(header.name); } @@ -132,7 +133,7 @@ namespace hex { static void writeFile(mtar_t *ctx, mtar_header_t *header, const std::fs::path &path) { constexpr static u64 BufferSize = 1_MiB; - fs::File outputFile(path, fs::File::Mode::Create); + wolv::io::File outputFile(path, wolv::io::File::Mode::Create); std::vector buffer; for (u64 offset = 0; offset < header->size; offset += BufferSize) { diff --git a/main/source/init/splash_window.cpp b/main/source/init/splash_window.cpp index 9f198a014..a4740e92f 100644 --- a/main/source/init/splash_window.cpp +++ b/main/source/init/splash_window.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include diff --git a/main/source/init/tasks.cpp b/main/source/init/tasks.cpp index d6d26a439..e79e8d7a4 100644 --- a/main/source/init/tasks.cpp +++ b/main/source/init/tasks.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -23,6 +22,9 @@ #include +#include +#include + namespace hex::init { using namespace std::literals::string_literals; @@ -78,7 +80,7 @@ namespace hex::init { // If a custom certificate was found, use it, otherwise use the one from the romfs if (!caCertPath.empty()) - Net::setCACert(fs::File(caCertPath, fs::File::Mode::Read).readString()); + Net::setCACert(wolv::io::File(caCertPath, wolv::io::File::Mode::Read).readString()); else Net::setCACert(std::string(romfs::get(CaCertPath).string())); @@ -94,7 +96,7 @@ namespace hex::init { for (u32 path = 0; path < u32(fs::ImHexPath::END); path++) { for (auto &folder : fs::getDefaultPaths(static_cast(path), true)) { try { - fs::createDirectories(folder); + wolv::io::fs::createDirectories(folder); } catch (...) { log::error("Failed to create folder {}!", hex::toUTF8String(folder)); result = false; @@ -300,7 +302,7 @@ namespace hex::init { return false; } - const auto shouldLoadPlugin = [executablePath = hex::fs::getExecutablePath()](const Plugin &plugin) { + const auto shouldLoadPlugin = [executablePath = wolv::io::fs::getExecutablePath()](const Plugin &plugin) { // In debug builds, ignore all plugins that are not part of the executable directory #if !defined(DEBUG) return true; diff --git a/main/source/main.cpp b/main/source/main.cpp index dbf825e1b..25bdea9f2 100644 --- a/main/source/main.cpp +++ b/main/source/main.cpp @@ -1,6 +1,5 @@ #include -#include #include #include "window.hpp" @@ -10,16 +9,19 @@ #include +#include +#include + int main(int argc, char **argv, char **envp) { using namespace hex; ImHexApi::System::impl::setProgramArguments(argc, argv, envp); // Check if ImHex is installed in portable mode { - if (const auto executablePath = fs::getExecutablePath(); executablePath.has_value()) { + if (const auto executablePath = wolv::io::fs::getExecutablePath(); executablePath.has_value()) { const auto flagFile = executablePath->parent_path() / "PORTABLE"; - if (fs::exists(flagFile) && fs::isRegularFile(flagFile)) + if (wolv::io::fs::exists(flagFile) && wolv::io::fs::isRegularFile(flagFile)) ImHexApi::System::impl::setPortableVersion(true); } } diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index c6cd95b6d..3fd85f8d4 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -443,7 +443,7 @@ namespace hex { ImGui::TableNextColumn(); ImGui::TextUnformatted(hex::toUTF8String(filePath).c_str()); ImGui::TableNextColumn(); - ImGui::TextUnformatted(fs::exists(filePath) ? ICON_VS_CHECK : ICON_VS_CLOSE); + ImGui::TextUnformatted(wolv::io::fs::exists(filePath) ? ICON_VS_CHECK : ICON_VS_CLOSE); } ImGui::EndTable(); } @@ -867,7 +867,7 @@ namespace hex { } } - if (!this->m_imguiSettingsPath.empty() && fs::exists(this->m_imguiSettingsPath)) + if (!this->m_imguiSettingsPath.empty() && wolv::io::fs::exists(this->m_imguiSettingsPath)) ImGui::LoadIniSettingsFromDisk(hex::toUTF8String(this->m_imguiSettingsPath).c_str()); } diff --git a/plugins/builtin/include/content/helpers/diagrams.hpp b/plugins/builtin/include/content/helpers/diagrams.hpp index 0d5050c10..feb74285f 100644 --- a/plugins/builtin/include/content/helpers/diagrams.hpp +++ b/plugins/builtin/include/content/helpers/diagrams.hpp @@ -338,7 +338,7 @@ namespace hex { this->m_fileSize = provider->getSize(); // Get a file reader - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); std::vector bytes = reader.read(this->m_startAddress, this->m_endAddress - this->m_startAddress); this->processImpl(bytes); @@ -572,7 +572,7 @@ namespace hex { this->m_endAddress = endAddress; // Get a file reader - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); std::vector bytes = reader.read(this->m_startAddress, this->m_endAddress - this->m_startAddress); this->processImpl(bytes); @@ -685,7 +685,7 @@ namespace hex { this->m_fileSize = provider->getSize(); // Get a file reader - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); std::vector bytes = reader.read(this->m_startAddress, this->m_endAddress - this->m_startAddress); this->processImpl(bytes); diff --git a/plugins/builtin/include/content/providers/file_provider.hpp b/plugins/builtin/include/content/providers/file_provider.hpp index 9cb6f5cd7..d58cfba80 100644 --- a/plugins/builtin/include/content/providers/file_provider.hpp +++ b/plugins/builtin/include/content/providers/file_provider.hpp @@ -1,7 +1,8 @@ #pragma once #include -#include + +#include #include @@ -56,7 +57,7 @@ namespace hex::plugin::builtin { protected: std::fs::path m_path; - fs::File m_file; + wolv::io::File m_file; size_t m_fileSize = 0; std::optional m_fileStats; diff --git a/plugins/builtin/include/content/providers/gdb_provider.hpp b/plugins/builtin/include/content/providers/gdb_provider.hpp index a5d3e0f9f..b5cf85c9a 100644 --- a/plugins/builtin/include/content/providers/gdb_provider.hpp +++ b/plugins/builtin/include/content/providers/gdb_provider.hpp @@ -1,8 +1,9 @@ #pragma once -#include #include +#include + #include #include #include @@ -53,14 +54,14 @@ namespace hex::plugin::builtin { std::variant queryInformation(const std::string &category, const std::string &argument) override; protected: - hex::Socket m_socket; + wolv::util::Socket m_socket; std::string m_ipAddress; int m_port = 0; u64 m_size = 0; - constexpr static size_t CacheLineSize = 0x1000; + constexpr static size_t CacheLineSize = 0x10; struct CacheLine { u64 address; @@ -69,6 +70,7 @@ namespace hex::plugin::builtin { }; std::list m_cache; + std::atomic m_resetCache = false; std::thread m_cacheUpdateThread; std::mutex m_cacheLock; diff --git a/plugins/builtin/source/content/data_formatters.cpp b/plugins/builtin/source/content/data_formatters.cpp index 96614450e..4fff9aaf0 100644 --- a/plugins/builtin/source/content/data_formatters.cpp +++ b/plugins/builtin/source/content/data_formatters.cpp @@ -16,7 +16,7 @@ namespace hex::plugin::builtin { result += start; - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(offset); reader.setEndAddress(offset + size - 1); @@ -107,7 +107,7 @@ namespace hex::plugin::builtin { result += HeaderLine; - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(offset); reader.setEndAddress((offset + size) - 1); @@ -158,7 +158,7 @@ namespace hex::plugin::builtin { " \n" " Hex View  00 01 02 03 04 05 06 07  08 09 0A 0B 0C 0D 0E 0F"; - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(offset); reader.setEndAddress((offset + size) - 1); diff --git a/plugins/builtin/source/content/data_processor_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes.cpp index 1ec58bfe7..91a17447f 100644 --- a/plugins/builtin/source/content/data_processor_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes.cpp @@ -21,6 +21,9 @@ #include #include +#include +#include + namespace hex::plugin::builtin { class NodeNullptr : public dp::Node { @@ -167,10 +170,10 @@ namespace hex::plugin::builtin { } void process() override { - this->setBufferOnOutput(0, hex::toBytes(u8(this->m_color.Value.x * 0xFF))); - this->setBufferOnOutput(1, hex::toBytes(u8(this->m_color.Value.y * 0xFF))); - this->setBufferOnOutput(2, hex::toBytes(u8(this->m_color.Value.z * 0xFF))); - this->setBufferOnOutput(3, hex::toBytes(u8(this->m_color.Value.w * 0xFF))); + this->setBufferOnOutput(0, wolv::util::toBytes(u8(this->m_color.Value.x * 0xFF))); + this->setBufferOnOutput(1, wolv::util::toBytes(u8(this->m_color.Value.y * 0xFF))); + this->setBufferOnOutput(2, wolv::util::toBytes(u8(this->m_color.Value.z * 0xFF))); + this->setBufferOnOutput(3, wolv::util::toBytes(u8(this->m_color.Value.w * 0xFF))); } void store(nlohmann::json &j) const override { @@ -1169,7 +1172,7 @@ namespace hex::plugin::builtin { const auto &outVars = pl.runtime->getOutVariables(); if (outVars.contains(this->m_name)) { - std::visit(overloaded { + std::visit(wolv::util::overloaded { [](const std::string &) {}, [](pl::ptrn::Pattern *) {}, [this](auto &&value) { @@ -1231,7 +1234,7 @@ namespace hex::plugin::builtin { } void process() override { - std::visit(overloaded { + std::visit(wolv::util::overloaded { [this](i128 value) { this->setIntegerOnOutput(0, value); }, [this](long double value) { this->setFloatOnOutput(0, value); }, [this](const std::vector &value) { this->setBufferOnOutput(0, value); } diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 85a989027..e7fd24be1 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -1,20 +1,19 @@ #include -#include #include #include #include -#include #include #include #include -#include #include #include +#include + namespace hex::plugin::builtin { static void openFile(const std::fs::path &path) { diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index 100e28ab7..6c15cedf6 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -6,11 +6,14 @@ #include #include #include -#include + #include #include + #include "content/global_actions.hpp" +#include + using namespace std::literals::string_literals; namespace hex::plugin::builtin { @@ -122,7 +125,7 @@ namespace hex::plugin::builtin { if (ImGui::MenuItem("hex.builtin.menu.file.import.base64"_lang)) { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - fs::File inputFile(path, fs::File::Mode::Read); + wolv::io::File inputFile(path, wolv::io::File::Mode::Read); if (!inputFile.isValid()) { View::showErrorPopup("hex.builtin.menu.file.import.base64.popup.open_error"_lang); return; @@ -137,7 +140,7 @@ namespace hex::plugin::builtin { View::showErrorPopup("hex.builtin.menu.file.import.base64.popup.import_error"_lang); else { fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const std::fs::path &path) { - fs::File outputFile(path, fs::File::Mode::Create); + wolv::io::File outputFile(path, wolv::io::File::Mode::Create); if (!outputFile.isValid()) View::showErrorPopup("hex.builtin.menu.file.import.base64.popup.import_error"_lang); @@ -157,7 +160,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &task) { - auto patchData = fs::File(path, fs::File::Mode::Read).readBytes(); + auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readBytes(); auto patch = hex::loadIPSPatch(patchData); if (!patch.has_value()) { handleIPSError(patch.error()); @@ -183,7 +186,7 @@ namespace hex::plugin::builtin { if (ImGui::MenuItem("hex.builtin.menu.file.import.ips32"_lang, nullptr, false)) { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &task) { - auto patchData = fs::File(path, fs::File::Mode::Read).readBytes(); + auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readBytes(); auto patch = hex::loadIPS32Patch(patchData); if (!patch.has_value()) { handleIPSError(patch.error()); @@ -212,7 +215,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &task) { auto provider = ImHexApi::Provider::get(); - auto patchData = fs::File(path, fs::File::Mode::Read).readBytes(); + auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readBytes(); if (patchData.size() != provider->getActualSize()) { View::showErrorPopup("hex.builtin.menu.file.import.modified_file.popup.invalid_size"_lang); @@ -254,7 +257,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &) { - fs::File outputFile(path, fs::File::Mode::Create); + wolv::io::File outputFile(path, wolv::io::File::Mode::Create); if (!outputFile.isValid()) { TaskManager::doLater([] { View::showErrorPopup("hex.builtin.menu.file.export.base64.popup.export_error"_lang); @@ -291,7 +294,7 @@ namespace hex::plugin::builtin { TaskManager::doLater([data] { fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const auto &path) { - auto file = fs::File(path, fs::File::Mode::Create); + auto file = wolv::io::File(path, wolv::io::File::Mode::Create); if (!file.isValid()) { View::showErrorPopup("hex.builtin.menu.file.export.ips.popup.export_error"_lang); return; @@ -322,7 +325,7 @@ namespace hex::plugin::builtin { TaskManager::doLater([data] { fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const auto &path) { - auto file = fs::File(path, fs::File::Mode::Create); + auto file = wolv::io::File(path, wolv::io::File::Mode::Create); if (!file.isValid()) { View::showErrorPopup("hex.builtin.menu.file.export.ips.popup.export_error"_lang); return; diff --git a/plugins/builtin/source/content/providers.cpp b/plugins/builtin/source/content/providers.cpp index 33f8704cc..a88264927 100644 --- a/plugins/builtin/source/content/providers.cpp +++ b/plugins/builtin/source/content/providers.cpp @@ -10,9 +10,12 @@ #include "content/providers/view_provider.hpp" #include -#include #include +#include + +#include + namespace hex::plugin::builtin { void registerProviders() { diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 11ff7d072..f24a82391 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -77,7 +76,7 @@ namespace hex::plugin::builtin { return; std::scoped_lock lock(this->m_mutex); - fs::File writeFile(this->m_path, fs::File::Mode::Write); + wolv::io::File writeFile(this->m_path, wolv::io::File::Mode::Write); if (!writeFile.isValid()) return; @@ -91,7 +90,7 @@ namespace hex::plugin::builtin { } void FileProvider::saveAs(const std::fs::path &path) { - fs::File file(path, fs::File::Mode::Create); + wolv::io::File file(path, wolv::io::File::Mode::Create); if (file.isValid()) { auto provider = ImHexApi::Provider::get(); @@ -113,7 +112,7 @@ namespace hex::plugin::builtin { this->close(); { - fs::File file(this->m_path, fs::File::Mode::Write); + wolv::io::File file(this->m_path, wolv::io::File::Mode::Write); file.setSize(newSize); } @@ -221,7 +220,7 @@ namespace hex::plugin::builtin { this->m_readable = true; this->m_writable = true; - fs::File file(this->m_path, fs::File::Mode::Read); + wolv::io::File file(this->m_path, wolv::io::File::Mode::Read); if (!file.isValid()) { this->m_writable = false; this->m_readable = false; diff --git a/plugins/builtin/source/content/providers/gdb_provider.cpp b/plugins/builtin/source/content/providers/gdb_provider.cpp index c456af311..5691688e8 100644 --- a/plugins/builtin/source/content/providers/gdb_provider.cpp +++ b/plugins/builtin/source/content/providers/gdb_provider.cpp @@ -56,11 +56,15 @@ namespace hex::plugin::builtin { } - void sendAck(Socket &socket) { + void sendAck(wolv::util::Socket &socket) { socket.writeString("+"); } - std::vector readMemory(Socket &socket, u64 address, size_t size) { + void continueExecution(wolv::util::Socket &socket) { + socket.writeString(createPacket("vCont;c")); + } + + std::vector readMemory(wolv::util::Socket &socket, u64 address, size_t size) { std::string packet = createPacket(hex::format("m{:X},{:X}", address, size)); socket.writeString(packet); @@ -84,7 +88,7 @@ namespace hex::plugin::builtin { return data; } - void writeMemory(Socket &socket, u64 address, const void *buffer, size_t size) { + void writeMemory(wolv::util::Socket &socket, u64 address, const void *buffer, size_t size) { std::vector bytes(size); std::memcpy(bytes.data(), buffer, size); @@ -94,10 +98,10 @@ namespace hex::plugin::builtin { socket.writeString(packet); - auto receivedPacket = socket.readString(3); + auto receivedPacket = socket.readString(6); } - bool enableNoAckMode(Socket &socket) { + bool enableNoAckMode(wolv::util::Socket &socket) { socket.writeString(createPacket("QStartNoAckMode")); auto ack = socket.readString(1); @@ -131,7 +135,7 @@ namespace hex::plugin::builtin { } bool GDBProvider::isWritable() const { - return false; + return true; } bool GDBProvider::isResizable() const { @@ -168,7 +172,7 @@ namespace hex::plugin::builtin { } if (cacheLine != this->m_cache.end()) - std::memcpy(buffer, &cacheLine->data[0] + (offset % CacheLineSize), size); + std::memcpy(buffer, &cacheLine->data[0] + (offset % CacheLineSize), std::min(size, cacheLine->data.size())); } else { while (size > 0) { size_t readSize = std::min(size, CacheLineSize); @@ -251,22 +255,24 @@ namespace hex::plugin::builtin { } if (this->m_socket.isConnected()) { + gdb::continueExecution(this->m_socket); + this->m_cacheUpdateThread = std::thread([this]() { auto cacheLine = this->m_cache.begin(); while (this->isConnected()) { { std::scoped_lock lock(this->m_cacheLock); + if (this->m_resetCache) { + this->m_cache.clear(); + this->m_resetCache = false; + cacheLine = this->m_cache.begin(); + } + if (cacheLine != this->m_cache.end()) { - auto data = gdb::readMemory(this->m_socket, cacheLine->address, 0x1000); + std::vector data = gdb::readMemory(this->m_socket, cacheLine->address, CacheLineSize); - if (data.empty()) { - this->m_cache.erase(cacheLine); - cacheLine = this->m_cache.begin(); - continue; - } - - while (this->m_cache.size() > 5) { + while (std::count_if(this->m_cache.begin(), this->m_cache.end(), [&](auto &line) { return !line.data.empty(); }) > 100) { this->m_cache.pop_front(); cacheLine = this->m_cache.begin(); } @@ -279,7 +285,7 @@ namespace hex::plugin::builtin { else cacheLine++; } - std::this_thread::sleep_for(100ms); + std::this_thread::sleep_for(10ms); } }); diff --git a/plugins/builtin/source/content/providers/intel_hex_provider.cpp b/plugins/builtin/source/content/providers/intel_hex_provider.cpp index 0204e8dd3..9bd9a90b8 100644 --- a/plugins/builtin/source/content/providers/intel_hex_provider.cpp +++ b/plugins/builtin/source/content/providers/intel_hex_provider.cpp @@ -5,11 +5,12 @@ #include #include #include -#include #include #include +#include + namespace hex::plugin::builtin { namespace intel_hex { @@ -192,7 +193,7 @@ namespace hex::plugin::builtin { } bool IntelHexProvider::open() { - auto file = fs::File(this->m_sourceFilePath, fs::File::Mode::Read); + auto file = wolv::io::File(this->m_sourceFilePath, wolv::io::File::Mode::Read); if (!file.isValid()) return false; @@ -245,7 +246,7 @@ namespace hex::plugin::builtin { if (!picked) return false; - if (!fs::isRegularFile(this->m_sourceFilePath)) + if (!wolv::io::fs::isRegularFile(this->m_sourceFilePath)) return false; return true; diff --git a/plugins/builtin/source/content/providers/memory_file_provider.cpp b/plugins/builtin/source/content/providers/memory_file_provider.cpp index 50a2732bb..f882afe07 100644 --- a/plugins/builtin/source/content/providers/memory_file_provider.cpp +++ b/plugins/builtin/source/content/providers/memory_file_provider.cpp @@ -6,7 +6,8 @@ #include #include #include -#include + +#include namespace hex::plugin::builtin { @@ -50,7 +51,7 @@ namespace hex::plugin::builtin { } void MemoryFileProvider::saveAs(const std::fs::path &path) { - fs::File file(path, fs::File::Mode::Create); + wolv::io::File file(path, wolv::io::File::Mode::Create); if (file.isValid()) { auto provider = ImHexApi::Provider::get(); diff --git a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp index 4a8374fc8..b1f81afe8 100644 --- a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp +++ b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp @@ -3,9 +3,11 @@ #include #include -#include #include +#include +#include + namespace hex::plugin::builtin { namespace motorola_srec { @@ -168,7 +170,7 @@ namespace hex::plugin::builtin { } bool MotorolaSRECProvider::open() { - auto file = fs::File(this->m_sourceFilePath, fs::File::Mode::Read); + auto file = wolv::io::File(this->m_sourceFilePath, wolv::io::File::Mode::Read); if (!file.isValid()) return false; @@ -222,7 +224,7 @@ namespace hex::plugin::builtin { if (!picked) return false; - if (!fs::isRegularFile(this->m_sourceFilePath)) + if (!wolv::io::fs::isRegularFile(this->m_sourceFilePath)) return false; return true; diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 38b4949a9..a6490a42a 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -16,6 +16,8 @@ #include +#include + namespace { std::vector userFolders; @@ -566,14 +568,14 @@ namespace hex::plugin::builtin { static void loadFontSettings() { std::fs::path fontFile = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_path", ""); - if (!fs::exists(fontFile) || !fs::isRegularFile(fontFile)) + if (!wolv::io::fs::exists(fontFile) || !wolv::io::fs::isRegularFile(fontFile)) fontFile.clear(); // If no custom font has been specified, search for a file called "font.ttf" in one of the resource folders if (fontFile.empty()) { for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Resources)) { auto path = dir / "font.ttf"; - if (fs::exists(path)) { + if (wolv::io::fs::exists(path)) { log::info("Loading custom front from {}", hex::toUTF8String(path)); fontFile = path; diff --git a/plugins/builtin/source/content/themes.cpp b/plugins/builtin/source/content/themes.cpp index 109411fc3..15fbb70e9 100644 --- a/plugins/builtin/source/content/themes.cpp +++ b/plugins/builtin/source/content/themes.cpp @@ -10,10 +10,11 @@ #include #include -#include #include +#include + namespace hex::plugin::builtin { void registerThemeHandlers() { @@ -334,7 +335,7 @@ namespace hex::plugin::builtin { for (const auto &themeFolder : fs::getDefaultPaths(fs::ImHexPath::Themes)) { for (const auto &theme : std::fs::directory_iterator(themeFolder)) { if (theme.is_regular_file()) - api::ThemeManager::addTheme(fs::File(theme.path(), fs::File::Mode::Read).readString()); + api::ThemeManager::addTheme(wolv::io::File(theme.path(), wolv::io::File::Mode::Read).readString()); } } } diff --git a/plugins/builtin/source/content/tools_entries.cpp b/plugins/builtin/source/content/tools_entries.cpp index 26d8e4d4d..a82f14c96 100644 --- a/plugins/builtin/source/content/tools_entries.cpp +++ b/plugins/builtin/source/content/tools_entries.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,9 @@ #include +#include +#include + namespace hex::plugin::builtin { namespace { @@ -747,7 +749,7 @@ namespace hex::plugin::builtin { ON_SCOPE_EXIT { selectedFile.clear(); }; - fs::File file(selectedFile, fs::File::Mode::Write); + wolv::io::File file(selectedFile, wolv::io::File::Mode::Write); if (!file.isValid()) { View::showErrorPopup("hex.builtin.tools.file_tools.shredder.error.open"_lang); @@ -912,7 +914,7 @@ namespace hex::plugin::builtin { baseOutputPath.clear(); }; - fs::File file(selectedFile, fs::File::Mode::Read); + wolv::io::File file(selectedFile, wolv::io::File::Mode::Read); if (!file.isValid()) { View::showErrorPopup("hex.builtin.tools.file_tools.splitter.picker.error.open"_lang); @@ -933,7 +935,7 @@ namespace hex::plugin::builtin { std::fs::path path = baseOutputPath; path += hex::format(".{:05}", index); - fs::File partFile(path, fs::File::Mode::Create); + wolv::io::File partFile(path, wolv::io::File::Mode::Create); if (!partFile.isValid()) { View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.splitter.picker.error.create"_lang, index)); @@ -1046,7 +1048,7 @@ namespace hex::plugin::builtin { else { if (ImGui::Button("hex.builtin.tools.file_tools.combiner.combine"_lang)) { combinerTask = TaskManager::createTask("hex.builtin.tools.file_tools.combiner.combining", 0, [](auto &task) { - fs::File output(outputPath, fs::File::Mode::Create); + wolv::io::File output(outputPath, wolv::io::File::Mode::Create); if (!output.isValid()) { View::showErrorPopup("hex.builtin.tools.file_tools.combiner.error.open_output"_lang); @@ -1060,14 +1062,14 @@ namespace hex::plugin::builtin { task.update(fileIndex); fileIndex++; - fs::File input(file, fs::File::Mode::Read); + wolv::io::File input(file, wolv::io::File::Mode::Read); if (!input.isValid()) { View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.combiner.open_input"_lang, hex::toUTF8String(file))); return; } constexpr static auto BufferSize = 0xFF'FFFF; - auto inputSize = input.getSize(); + auto inputSize = input.getSize(); for (u64 inputOffset = 0; inputOffset < inputSize; inputOffset += BufferSize) { output.write(input.readBytes(std::min(BufferSize, inputSize - inputOffset))); output.flush(); diff --git a/plugins/builtin/source/content/views/view_about.cpp b/plugins/builtin/source/content/views/view_about.cpp index 2baa0d1c7..1d14fc3bd 100644 --- a/plugins/builtin/source/content/views/view_about.cpp +++ b/plugins/builtin/source/content/views/view_about.cpp @@ -171,7 +171,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); for (auto &path : fs::getDefaultPaths(type, true)){ - if(fs::isDirectory(path)){ + if(wolv::io::fs::isDirectory(path)){ ImGui::TextUnformatted(hex::toUTF8String(path).c_str()); }else{ ImGui::TextFormattedColored(ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarRed), hex::toUTF8String(path).c_str()); diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index 39fd8d137..cf492edfe 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -4,13 +4,15 @@ #include #include #include -#include #include #include #include +#include +#include + namespace hex::plugin::builtin { ViewBookmarks::ViewBookmarks() : View("hex.builtin.view.bookmarks.name") { @@ -388,7 +390,7 @@ namespace hex::plugin::builtin { if (ImGui::MenuItem("hex.builtin.menu.file.bookmark.import"_lang, nullptr, false, providerValid)) { fs::openFileBrowser(fs::DialogMode::Open, { { "Bookmarks File", "hexbm"} }, [&](const std::fs::path &path) { try { - importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(fs::File(path, fs::File::Mode::Read).readString())); + importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString())); } catch (...) { } }); } @@ -397,7 +399,7 @@ namespace hex::plugin::builtin { nlohmann::json json; exportBookmarks(ImHexApi::Provider::get(), json); - fs::File(path, fs::File::Mode::Create).write(json.dump(4)); + wolv::io::File(path, wolv::io::File::Mode::Create).write(json.dump(4)); }); } }); diff --git a/plugins/builtin/source/content/views/view_constants.cpp b/plugins/builtin/source/content/views/view_constants.cpp index 3ccd94f4b..4422fee0e 100644 --- a/plugins/builtin/source/content/views/view_constants.cpp +++ b/plugins/builtin/source/content/views/view_constants.cpp @@ -22,7 +22,7 @@ namespace hex::plugin::builtin { this->m_filterIndices.clear(); for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Constants)) { - if (!fs::exists(path)) continue; + if (!wolv::io::fs::exists(path)) continue; std::error_code error; for (auto &file : std::fs::directory_iterator(path, error)) { diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 625a16c33..7e5474fb4 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -7,12 +7,13 @@ #include #include -#include #include #include #include +#include + namespace hex::plugin::builtin { using NumberDisplayStyle = ContentRegistry::DataInspector::NumberDisplayStyle; @@ -106,7 +107,7 @@ namespace hex::plugin::builtin { if (!filePath.exists() || !filePath.is_regular_file() || filePath.path().extension() != ".hexpat") continue; - fs::File file(filePath, fs::File::Mode::Read); + wolv::io::File file(filePath, wolv::io::File::Mode::Read); if (file.isValid()) { auto inspectorCode = file.readString(); diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 66d548c4b..bd8564793 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -2,7 +2,6 @@ #include -#include #include #include @@ -14,6 +13,8 @@ #include +#include + namespace hex::plugin::builtin { ViewDataProcessor::ViewDataProcessor() : View("hex.builtin.view.data_processor.name") { @@ -73,7 +74,7 @@ namespace hex::plugin::builtin { if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.load_processor"_lang, nullptr, false, providerValid)) { fs::openFileBrowser(fs::DialogMode::Open, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } }, [&](const std::fs::path &path) { - fs::File file(path, fs::File::Mode::Read); + wolv::io::File file(path, wolv::io::File::Mode::Read); if (file.isValid()) { ViewDataProcessor::loadNodes(data.mainWorkspace, file.readString()); this->m_updateNodePositions = true; @@ -84,7 +85,7 @@ namespace hex::plugin::builtin { if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.save_processor"_lang, nullptr, false, !data.workspaceStack.empty() && !data.workspaceStack.back()->nodes.empty() && providerValid)) { fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } }, [&](const std::fs::path &path) { - fs::File file(path, fs::File::Mode::Create); + wolv::io::File file(path, wolv::io::File::Mode::Create); if (file.isValid()) file.write(ViewDataProcessor::saveNodes(data.mainWorkspace).dump(4)); }); @@ -92,7 +93,7 @@ namespace hex::plugin::builtin { }); ContentRegistry::FileHandler::add({ ".hexnode" }, [this](const auto &path) { - fs::File file(path, fs::File::Mode::Read); + wolv::io::File file(path, wolv::io::File::Mode::Read); if (!file.isValid()) return false; auto &data = ProviderExtraData::getCurrent().dataProcessor; @@ -204,7 +205,7 @@ namespace hex::plugin::builtin { for (const auto &entry : std::fs::recursive_directory_iterator(basePath)) { if (entry.path().extension() == ".hexnode") { try { - nlohmann::json nodeJson = nlohmann::json::parse(fs::File(entry.path(), fs::File::Mode::Read).readString()); + nlohmann::json nodeJson = nlohmann::json::parse(wolv::io::File(entry.path(), wolv::io::File::Mode::Read).readString()); this->m_customNodes.push_back(CustomNode { LangEntry(nodeJson["name"]), nodeJson }); } catch (nlohmann::json::exception &e) { @@ -320,7 +321,7 @@ namespace hex::plugin::builtin { if (it != workspace.nodes.end()) { auto &node = *it; fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } }, [&](const std::fs::path &path){ - fs::File outputFile(path, fs::File::Mode::Create); + wolv::io::File outputFile(path, wolv::io::File::Mode::Create); outputFile.write(ViewDataProcessor::saveNode(node.get()).dump(4)); }); } diff --git a/plugins/builtin/source/content/views/view_diff.cpp b/plugins/builtin/source/content/views/view_diff.cpp index 158a4a2dd..fe633c640 100644 --- a/plugins/builtin/source/content/views/view_diff.cpp +++ b/plugins/builtin/source/content/views/view_diff.cpp @@ -141,8 +141,8 @@ namespace hex::plugin::builtin { this->m_diffTask = TaskManager::createTask("Diffing...", commonSize, [this, providerA, providerB](Task &task) { std::vector differences; - auto readerA = prv::BufferedReader(providerA); - auto readerB = prv::BufferedReader(providerB); + auto readerA = prv::ProviderReader(providerA); + auto readerB = prv::ProviderReader(providerB); for (auto itA = readerA.begin(), itB = readerB.begin(); itA < readerA.end() && itB < readerB.end(); itA++, itB++) { if (task.wasInterrupted()) diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index b2d514b97..f093459c5 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -236,7 +236,7 @@ namespace hex::plugin::builtin { return results; } - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(searchRegion.getStartAddress()); reader.setEndAddress(searchRegion.getEndAddress()); @@ -295,7 +295,7 @@ namespace hex::plugin::builtin { std::vector ViewFind::searchSequence(Task &task, prv::Provider *provider, hex::Region searchRegion, const SearchSettings::Sequence &settings) { std::vector results; - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(searchRegion.getStartAddress()); reader.setEndAddress(searchRegion.getEndAddress()); @@ -353,7 +353,7 @@ namespace hex::plugin::builtin { std::vector ViewFind::searchBinaryPattern(Task &task, prv::Provider *provider, hex::Region searchRegion, const SearchSettings::BinaryPattern &settings) { std::vector results; - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(searchRegion.getStartAddress()); reader.setEndAddress(searchRegion.getEndAddress()); @@ -386,7 +386,7 @@ namespace hex::plugin::builtin { std::vector ViewFind::searchValue(Task &task, prv::Provider *provider, Region searchRegion, const SearchSettings::Value &settings) { std::vector results; - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(searchRegion.getStartAddress()); reader.setEndAddress(searchRegion.getEndAddress()); diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 20ce9c3e4..46aca20b4 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -292,7 +292,7 @@ namespace hex::plugin::builtin { std::optional findSequence(const std::vector &sequence, bool backwards) { auto provider = ImHexApi::Provider::get(); - hex::prv::BufferedReader reader(provider); + prv::ProviderReader reader(provider); reader.seek(this->m_searchPosition.value_or(provider->getBaseAddress())); @@ -605,7 +605,7 @@ namespace hex::plugin::builtin { auto provider = ImHexApi::Provider::get(); - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader (provider); reader.seek(selection.getStartAddress()); reader.setEndAddress(selection.getEndAddress()); diff --git a/plugins/builtin/source/content/views/view_information.cpp b/plugins/builtin/source/content/views/view_information.cpp index b62f4b280..7f96a3442 100644 --- a/plugins/builtin/source/content/views/view_information.cpp +++ b/plugins/builtin/source/content/views/view_information.cpp @@ -47,7 +47,7 @@ namespace hex::plugin::builtin { ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) { for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Magic)) { - if (fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { + if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { View::showInfoPopup("hex.builtin.view.information.magic_db_added"_lang); return true; } @@ -110,7 +110,7 @@ namespace hex::plugin::builtin { provider->getBaseAddress(), provider->getSize()); // Create a handle to the file - auto reader = prv::BufferedReader(provider); + auto reader = prv::ProviderReader(provider); reader.seek(provider->getBaseAddress() + this->m_inputStartAddress); reader.setEndAddress(provider->getBaseAddress() + this->m_inputEndAddress); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index f4014d96a..d89a24167 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -20,6 +19,10 @@ #include #include +#include +#include +#include + namespace hex::plugin::builtin { using namespace hex::literals; @@ -633,7 +636,7 @@ namespace hex::plugin::builtin { void ViewPatternEditor::loadPatternFile(const std::fs::path &path, prv::Provider *provider) { - fs::File file(path, fs::File::Mode::Read); + wolv::io::File file(path, wolv::io::File::Mode::Read); if (file.isValid()) { auto code = file.readString(); @@ -808,7 +811,7 @@ namespace hex::plugin::builtin { if (!entry.is_regular_file()) continue; - fs::File file(entry.path(), fs::File::Mode::Read); + wolv::io::File file(entry.path(), wolv::io::File::Mode::Read); if (!file.isValid()) continue; @@ -871,7 +874,7 @@ namespace hex::plugin::builtin { std::vector paths; for (const auto &imhexPath : fs::getDefaultPaths(fs::ImHexPath::Patterns)) { - if (!fs::exists(imhexPath)) continue; + if (!wolv::io::fs::exists(imhexPath)) continue; std::error_code error; for (auto &entry : std::fs::recursive_directory_iterator(imhexPath, error)) { @@ -890,7 +893,7 @@ namespace hex::plugin::builtin { if (ImGui::MenuItem("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, nullptr, false, providerValid)) { fs::openFileBrowser(fs::DialogMode::Save, { {"Pattern", "hexpat"} }, [this](const auto &path) { - fs::File file(path, fs::File::Mode::Create); + wolv::io::File file(path, wolv::io::File::Mode::Create); file.write(this->m_textEditor.GetText()); }); @@ -969,7 +972,7 @@ namespace hex::plugin::builtin { void ViewPatternEditor::registerHandlers() { ContentRegistry::FileHandler::add({ ".hexpat", ".pat" }, [](const std::fs::path &path) -> bool { - fs::File file(path, fs::File::Mode::Read); + wolv::io::File file(path, wolv::io::File::Mode::Read); if (file.isValid()) { EventManager::post(file.readString()); diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index d1c2c417a..eea31e04f 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -19,6 +18,8 @@ #include #include +#include + namespace hex::plugin::builtin { using namespace std::literals::string_literals; @@ -166,11 +167,11 @@ namespace hex::plugin::builtin { auto path = folder / std::fs::path(storeEntry.fileName); - if (fs::exists(path) && fs::isPathWritable(folder)) { + if (wolv::io::fs::exists(path) && fs::isPathWritable(folder)) { storeEntry.installed = true; std::ifstream file(path, std::ios::in | std::ios::binary); - std::vector data(fs::getFileSize(path), 0x00); + std::vector data(wolv::io::fs::getFileSize(path), 0x00); file.read(reinterpret_cast(data.data()), data.size()); auto fileHash = crypt::sha256(data); @@ -227,7 +228,7 @@ namespace hex::plugin::builtin { auto fullPath = path / std::fs::path(fileName); - if (!update || fs::exists(fullPath)) { + if (!update || wolv::io::fs::exists(fullPath)) { downloading = true; this->m_downloadPath = fullPath; this->m_download = this->m_net.downloadFile(url, fullPath, 30'0000); @@ -249,10 +250,10 @@ namespace hex::plugin::builtin { const auto filePath = path / fileName; const auto folderPath = (path / std::fs::path(fileName).stem()); - fs::remove(filePath); - fs::removeAll(folderPath); + wolv::io::fs::remove(filePath); + wolv::io::fs::removeAll(folderPath); - removed = removed && !fs::exists(filePath) && !fs::exists(folderPath); + removed = removed && !wolv::io::fs::exists(filePath) && !wolv::io::fs::exists(folderPath); } return removed; diff --git a/plugins/builtin/source/content/views/view_theme_manager.cpp b/plugins/builtin/source/content/views/view_theme_manager.cpp index cfc6d5453..0c786394e 100644 --- a/plugins/builtin/source/content/views/view_theme_manager.cpp +++ b/plugins/builtin/source/content/views/view_theme_manager.cpp @@ -2,7 +2,7 @@ #include -#include +#include namespace hex::plugin::builtin { @@ -59,7 +59,7 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Save, { { "ImHex Theme", "json" } }, [this](const std::fs::path &path){ auto json = api::ThemeManager::exportCurrentTheme(this->m_themeName); - fs::File outputFile(path, fs::File::Mode::Create); + wolv::io::File outputFile(path, wolv::io::File::Mode::Create); outputFile.write(json.dump(4)); }); } diff --git a/plugins/builtin/source/content/views/view_yara.cpp b/plugins/builtin/source/content/views/view_yara.cpp index e799d1f6a..08a15a8f8 100644 --- a/plugins/builtin/source/content/views/view_yara.cpp +++ b/plugins/builtin/source/content/views/view_yara.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include "content/helpers/provider_extra_data.hpp" @@ -18,6 +17,10 @@ #include #include +#include +#include +#include + namespace hex::plugin::builtin { ViewYara::ViewYara() : View("hex.builtin.view.yara.name") { @@ -25,7 +28,7 @@ namespace hex::plugin::builtin { ContentRegistry::FileHandler::add({ ".yar", ".yara" }, [](const auto &path) { for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Yara)) { - if (fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { + if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { View::showInfoPopup("hex.builtin.view.yara.rule_added"_lang); return true; } @@ -261,12 +264,12 @@ namespace hex::plugin::builtin { yr_compiler_destroy(compiler); }; - auto currFilePath = hex::toUTF8String(fs::toShortPath(filePath)); + auto currFilePath = hex::toUTF8String(wolv::io::fs::toShortPath(filePath)); yr_compiler_set_include_callback( compiler, [](const char *includeName, const char *, const char *, void *userData) -> const char * { - fs::File file(std::fs::path(static_cast(userData)).parent_path() / includeName, fs::File::Mode::Read); + wolv::io::File file(std::fs::path(static_cast(userData)).parent_path() / includeName, wolv::io::File::Mode::Read); if (!file.isValid()) return nullptr; @@ -285,7 +288,7 @@ namespace hex::plugin::builtin { currFilePath.data() ); - fs::File file(rules[this->m_selectedRule].second, fs::File::Mode::Read); + wolv::io::File file(rules[this->m_selectedRule].second, wolv::io::File::Mode::Read); if (!file.isValid()) return; if (yr_compiler_add_file(compiler, file.getHandle(), nullptr, nullptr) != 0) { diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 8d863cff1..6001d704e 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include @@ -18,6 +17,10 @@ #include #include +#include +#include +#include + #include #include @@ -85,7 +88,7 @@ namespace hex::plugin::builtin { for (u32 i = 0; i < recentFilePaths.size() && uniqueProviders.size() < 5; i++) { auto &path = recentFilePaths[i]; try { - auto jsonData = nlohmann::json::parse(fs::File(path, fs::File::Mode::Read).readString()); + auto jsonData = nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString()); uniqueProviders.insert(RecentProvider { .displayName = jsonData["displayName"], .type = jsonData["type"], @@ -179,14 +182,14 @@ namespace hex::plugin::builtin { for (const auto &provider : ImHexApi::Provider::getProviders()) provider->markDirty(); - fs::remove(s_safetyBackupPath); + wolv::io::fs::remove(s_safetyBackupPath); ImGui::CloseCurrentPopup(); } ImGui::SameLine(); ImGui::SetCursorPosX(width / 9 * 5); if (ImGui::Button("hex.builtin.welcome.safety_backup.delete"_lang, ImVec2(width / 3, 0))) { - fs::remove(s_safetyBackupPath); + wolv::io::fs::remove(s_safetyBackupPath); ImGui::CloseCurrentPopup(); } @@ -476,7 +479,7 @@ namespace hex::plugin::builtin { { for (const auto &recentPath : fs::getDefaultPaths(fs::ImHexPath::Recent)) { auto fileName = hex::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now())); - fs::File recentFile(recentPath / fileName, fs::File::Mode::Create); + wolv::io::File recentFile(recentPath / fileName, wolv::io::File::Mode::Create); if (!recentFile.isValid()) continue; @@ -550,7 +553,7 @@ namespace hex::plugin::builtin { constexpr static auto CrashBackupFileName = "crash_backup.hexproj"; for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Config)) { - if (auto filePath = std::fs::path(path) / CrashBackupFileName; fs::exists(filePath)) { + if (auto filePath = std::fs::path(path) / CrashBackupFileName; wolv::io::fs::exists(filePath)) { s_safetyBackupPath = filePath; TaskManager::doLater([] { ImGui::OpenPopup("hex.builtin.welcome.safety_backup.title"_lang); }); } diff --git a/plugins/windows/source/content/providers/process_memory_provider.cpp b/plugins/windows/source/content/providers/process_memory_provider.cpp index f84fc76b6..2f07d013f 100644 --- a/plugins/windows/source/content/providers/process_memory_provider.cpp +++ b/plugins/windows/source/content/providers/process_memory_provider.cpp @@ -10,6 +10,9 @@ #include #include +#include +#include + namespace hex::plugin::windows { bool ProcessMemoryProvider::open() { diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index 93a81a17e..00fe587b3 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -4,6 +4,8 @@ #include +#include + namespace hex::plugin::windows { ViewTTYConsole::ViewTTYConsole() : View("hex.windows.view.tty_console.name") {