diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 772d42e02..08f08a80b 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -445,7 +445,7 @@ macro(setupCompilerFlags target) set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -Wall -Wextra -Wpedantic -Werror") endif() - if (UNIX) + if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -rdynamic") endif() diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index 1701620a5..99ccd7e3f 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -63,6 +63,9 @@ namespace hex { [[nodiscard]] std::string to_string(u128 value); [[nodiscard]] std::string to_string(i128 value); + [[nodiscard]] std::string toLower(std::string string); + [[nodiscard]] std::string toUpper(std::string string); + [[nodiscard]] std::vector parseHexString(std::string string); [[nodiscard]] std::optional parseBinaryString(const std::string &string); [[nodiscard]] std::string toByteString(u64 bytes); diff --git a/lib/libimhex/source/helpers/patches.cpp b/lib/libimhex/source/helpers/patches.cpp index 1f26655dd..e32d06fc4 100644 --- a/lib/libimhex/source/helpers/patches.cpp +++ b/lib/libimhex/source/helpers/patches.cpp @@ -43,11 +43,11 @@ namespace hex { return this->m_patches.rbegin()->first; } - void resizeRaw(size_t newSize) override { + void resizeRaw(u64 newSize) override { hex::unused(newSize); } - void insertRaw(u64 offset, size_t size) override { + void insertRaw(u64 offset, u64 size) override { std::vector> patchesToMove; for (auto &[address, value] : this->m_patches) { @@ -61,7 +61,7 @@ namespace hex { this->m_patches.insert({ address + size, value }); } - void removeRaw(u64 offset, size_t size) override { + void removeRaw(u64 offset, u64 size) override { std::vector> patchesToMove; for (auto &[address, value] : this->m_patches) { diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 3c6fe6213..8edf42f17 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -71,6 +71,20 @@ namespace hex { return { data + index + 1 }; } + std::string toLower(std::string string) { + for (char &c : string) + c = std::tolower(c); + + return string; + } + + std::string toUpper(std::string string) { + for (char &c : string) + c = std::toupper(c); + + return string; + } + std::vector parseHexString(std::string string) { if (string.empty()) return { }; diff --git a/main/gui/source/main.cpp b/main/gui/source/main.cpp index 8e5e3eb51..26548cb70 100644 --- a/main/gui/source/main.cpp +++ b/main/gui/source/main.cpp @@ -170,8 +170,8 @@ namespace { emscripten_set_main_loop_arg([](void *arg) { auto splashWindow = reinterpret_cast(arg); - FrameResult res = splashWindow->fullFrame(); - if (res == FrameResult::success) { + FrameResult frameResult = splashWindow->fullFrame(); + if (frameResult == FrameResult::Success) { handleFileOpenRequest(); // Clean up everything after the main window is closed diff --git a/main/gui/source/window/web_window.cpp b/main/gui/source/window/web_window.cpp index 20c738039..01ee8ae3e 100644 --- a/main/gui/source/window/web_window.cpp +++ b/main/gui/source/window/web_window.cpp @@ -34,7 +34,7 @@ EM_JS(bool, isDarkModeEnabled, (), { EMSCRIPTEN_KEEPALIVE extern "C" void handleThemeChange() { - hex::hex::EventOSThemeChanged::post(); + hex::EventOSThemeChanged::post(); } namespace hex { diff --git a/plugins/builtin/include/content/providers/file_provider.hpp b/plugins/builtin/include/content/providers/file_provider.hpp index 4d165ce76..437233a0a 100644 --- a/plugins/builtin/include/content/providers/file_provider.hpp +++ b/plugins/builtin/include/content/providers/file_provider.hpp @@ -20,9 +20,9 @@ namespace hex::plugin::builtin { [[nodiscard]] bool isResizable() const override; [[nodiscard]] bool isSavable() const override; - void resizeRaw(size_t newSize) override; - void insertRaw(u64 offset, size_t size) override; - void removeRaw(u64 offset, size_t size) override; + void resizeRaw(u64 newSize) override; + void insertRaw(u64 offset, u64 size) override; + void removeRaw(u64 offset, u64 size) override; void readRaw(u64 offset, void *buffer, size_t size) override; void writeRaw(u64 offset, const void *buffer, size_t size) override; diff --git a/plugins/builtin/include/content/providers/memory_file_provider.hpp b/plugins/builtin/include/content/providers/memory_file_provider.hpp index d3c6ada9b..7c11baf07 100644 --- a/plugins/builtin/include/content/providers/memory_file_provider.hpp +++ b/plugins/builtin/include/content/providers/memory_file_provider.hpp @@ -23,9 +23,9 @@ namespace hex::plugin::builtin { void writeRaw(u64 offset, const void *buffer, size_t size) override; [[nodiscard]] u64 getActualSize() const override { return this->m_data.size(); } - void resizeRaw(size_t newSize) override; - void insertRaw(u64 offset, size_t size) override; - void removeRaw(u64 offset, size_t size) override; + void resizeRaw(u64 newSize) override; + void insertRaw(u64 offset, u64 size) override; + void removeRaw(u64 offset, u64 size) override; void save() override; diff --git a/plugins/builtin/include/content/providers/view_provider.hpp b/plugins/builtin/include/content/providers/view_provider.hpp index 2a8ec08f5..cee347906 100644 --- a/plugins/builtin/include/content/providers/view_provider.hpp +++ b/plugins/builtin/include/content/providers/view_provider.hpp @@ -53,10 +53,10 @@ namespace hex::plugin::builtin { [[nodiscard]] bool open() override { return true; } void close() override { } - void resizeRaw(size_t newSize) override { + void resizeRaw(u64 newSize) override { this->m_size = newSize; } - void insertRaw(u64 offset, size_t size) override { + void insertRaw(u64 offset, u64 size) override { if (this->m_provider == nullptr) return; @@ -64,7 +64,7 @@ namespace hex::plugin::builtin { this->m_provider->insert(offset + this->m_startAddress, size); } - void removeRaw(u64 offset, size_t size) override { + void removeRaw(u64 offset, u64 size) override { if (this->m_provider == nullptr) return; diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index ba92dc772..bdc7281ea 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -82,7 +82,7 @@ namespace hex::plugin::builtin { Provider::saveAs(path); } - void FileProvider::resizeRaw(size_t newSize) { + void FileProvider::resizeRaw(u64 newSize) { this->close(); { @@ -94,7 +94,7 @@ namespace hex::plugin::builtin { (void)this->open(); } - void FileProvider::insertRaw(u64 offset, size_t size) { + void FileProvider::insertRaw(u64 offset, u64 size) { auto oldSize = this->getActualSize(); this->resizeRaw(oldSize + size); @@ -113,7 +113,7 @@ namespace hex::plugin::builtin { } } - void FileProvider::removeRaw(u64 offset, size_t size) { + void FileProvider::removeRaw(u64 offset, u64 size) { if (offset > this->getActualSize() || size == 0) return; diff --git a/plugins/builtin/source/content/providers/memory_file_provider.cpp b/plugins/builtin/source/content/providers/memory_file_provider.cpp index 4a5a42f13..60ade2901 100644 --- a/plugins/builtin/source/content/providers/memory_file_provider.cpp +++ b/plugins/builtin/source/content/providers/memory_file_provider.cpp @@ -66,11 +66,11 @@ namespace hex::plugin::builtin { }); } - void MemoryFileProvider::resizeRaw(size_t newSize) { + void MemoryFileProvider::resizeRaw(u64 newSize) { this->m_data.resize(newSize); } - void MemoryFileProvider::insertRaw(u64 offset, size_t size) { + void MemoryFileProvider::insertRaw(u64 offset, u64 size) { auto oldSize = this->getActualSize(); this->resizeRaw(oldSize + size); @@ -89,7 +89,7 @@ namespace hex::plugin::builtin { } } - void MemoryFileProvider::removeRaw(u64 offset, size_t size) { + void MemoryFileProvider::removeRaw(u64 offset, u64 size) { auto oldSize = this->getActualSize(); std::vector buffer(0x1000); diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 0a207bb18..701b9005b 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -350,9 +350,7 @@ namespace hex::plugin::builtin { ImGui::Image(s_infoBannerTexture, ImVec2(width, width / s_infoBannerTexture.getAspectRatio())); if (ImGui::IsItemClicked()) { - hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link", - ImHexApi::System::getOSName() | std::views::transform([](char c) { return std::tolower(c); }) - )); + hex::openWebpage(ImHexApiURL + hex::format("/info/{}/link", hex::toLower(ImHexApi::System::getOSName()))); } } ImGuiExt::EndSubWindow(); @@ -644,10 +642,7 @@ namespace hex::plugin::builtin { if (!s_infoBannerTexture.isValid()) { TaskManager::createBackgroundTask("Load banner", [](auto&) { HttpRequest request("GET", - ImHexApiURL + hex::format("/info/{}/image", - ImHexApi::System::getOSName() | std::views::transform([](char c) { return std::tolower(c); }) - ) - ); + ImHexApiURL + hex::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName()))); auto response = request.downloadFile().get();