sys: Enable -Wall, -Wextra, -Werror and fix all warnings on all Platforms (#483)
* sys: Make ImHex compile with -Wall -Wextra -Werror * sys: Fixed various build errors on Linux * sys: Explicitly ignore return value of `system` function * sys: More fixes for the warnings GitHub Actions enables somehow * sys: More fixes * sys: Remove -Werror again to see all GitHub Actions warnings * sys: Hopefully fixed all remaining warnings * sys: Added back -Werror * git: Change windows icon in GitHub Actions
This commit is contained in:
parent
965207d688
commit
0462cc3d0c
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
||||
# Windows build
|
||||
win:
|
||||
runs-on: windows-2022
|
||||
name: 🟦 Windows MINGW64
|
||||
name: 🪟 Windows MINGW64
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <hex.hpp>
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -278,7 +279,7 @@ struct MemoryEditor
|
||||
if (OptMidColsCount > 0)
|
||||
byte_pos_x += (float)(i / OptMidColsCount) * s.SpacingBetweenMidCols;
|
||||
ImGui::SameLine(byte_pos_x);
|
||||
ImGui::Text("%02llX", i + (base_display_addr % Cols));
|
||||
ImGui::TextFormatted("{:02X}", i + (base_display_addr % Cols));
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
@ -324,7 +325,7 @@ struct MemoryEditor
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = std::min<i64>(mem_size - 1, DataEditingAddr + visible_count); DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home)) && DataEditingAddr > 0) { data_editing_addr_next = 0; DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = mem_size - 1; DataEditingTakeFocus = true; }
|
||||
} else if (DataPreviewAddr != -1) {
|
||||
} else if (DataPreviewAddr != (size_t)-1) {
|
||||
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)) && DataPreviewAddr >= (size_t)Cols) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr - Cols; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && DataPreviewAddr < mem_size - Cols) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr + Cols; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr - 1; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
@ -717,7 +718,6 @@ struct MemoryEditor
|
||||
void DrawOptionsLine(const Sizes& s, void* mem_data, size_t mem_size, size_t base_display_addr)
|
||||
{
|
||||
IM_UNUSED(mem_data);
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
const char* format_range = OptUpperCaseHex ? "Range 0x%0*" _PRISizeT "X..0x%0*" _PRISizeT "X" : "Range 0x%0*" _PRISizeT "x..0x%0*" _PRISizeT "x";
|
||||
const char* format_selection = OptUpperCaseHex ? "Selection 0x%0*" _PRISizeT "X..0x%0*" _PRISizeT "X (%ld [0x%lX] %s)" : "Range 0x%0*" _PRISizeT "x..0x%0*" _PRISizeT "x (%ld [0x%lX] %s)";
|
||||
|
||||
|
@ -156,6 +156,7 @@ add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||
|
||||
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
||||
set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_compile_options(libimhex PRIVATE -Wall -Wextra -Werror)
|
||||
|
||||
target_include_directories(libimhex PUBLIC include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${Python_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${YARA_INCLUDE_DIRS})
|
||||
target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#include <hex/helpers/intrinsics.hpp>
|
||||
|
||||
constexpr static const auto ImHexApiURL = "https://api.werwolv.net/imhex";
|
||||
constexpr static const auto GitHubApiURL = "https://api.github.com/repos/WerWolv/ImHex";
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
explicit event_name(Callback func) noexcept : Event(std::move(func)) { } \
|
||||
}
|
||||
|
||||
class GLFWwindow;
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace hex {
|
||||
|
||||
|
@ -11,7 +11,7 @@ struct ImGuiWindow;
|
||||
|
||||
namespace hex {
|
||||
|
||||
struct View;
|
||||
class View;
|
||||
|
||||
enum class Keys
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <hex.hpp>
|
||||
|
||||
#include <hex/helpers/intrinsics.hpp>
|
||||
#include <hex/data_processor/attribute.hpp>
|
||||
|
||||
#include <set>
|
||||
@ -38,8 +39,8 @@ namespace hex::dp {
|
||||
virtual void drawNode() { }
|
||||
virtual void process() = 0;
|
||||
|
||||
virtual void store(nlohmann::json &j) { }
|
||||
virtual void load(nlohmann::json &j) { }
|
||||
virtual void store(nlohmann::json &j) { hex::unused(j); }
|
||||
virtual void load(nlohmann::json &j) { hex::unused(j); }
|
||||
|
||||
using NodeError = std::pair<Node *, std::string>;
|
||||
|
||||
@ -90,11 +91,11 @@ namespace hex::dp {
|
||||
}
|
||||
|
||||
std::vector<u8> getBufferOnInput(u32 index);
|
||||
u64 getIntegerOnInput(u32 index);
|
||||
i64 getIntegerOnInput(u32 index);
|
||||
float getFloatOnInput(u32 index);
|
||||
|
||||
void setBufferOnOutput(u32 index, const std::vector<u8> &data);
|
||||
void setIntegerOnOutput(u32 index, u64 integer);
|
||||
void setIntegerOnOutput(u32 index, i64 integer);
|
||||
void setFloatOnOutput(u32 index, float floatingPoint);
|
||||
|
||||
void setOverlayData(u64 address, const std::vector<u8> &data);
|
||||
|
@ -14,36 +14,43 @@ namespace std::fs {
|
||||
|
||||
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 uintmax_t getFileSize(const std::fs::path &path) {
|
||||
std::error_code error;
|
||||
auto size = std::filesystem::file_size(path, error);
|
||||
@ -61,7 +68,7 @@ namespace hex::fs {
|
||||
Folder
|
||||
};
|
||||
|
||||
bool openFileBrowser(const std::string &title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback, const std::string &defaultPath = {});
|
||||
bool openFileBrowser(DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback, const std::string &defaultPath = {});
|
||||
|
||||
enum class ImHexPath
|
||||
{
|
||||
|
@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/helpers/concepts.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
[[noreturn]] inline void unreachable() {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
inline void unused(auto && ... x) {
|
||||
((void)x, ...);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <fmt/core.h>
|
||||
@ -13,7 +15,7 @@ namespace hex::log {
|
||||
|
||||
namespace {
|
||||
|
||||
void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level) {
|
||||
[[maybe_unused]] void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level) {
|
||||
const auto now = fmt::localtime(std::chrono::system_clock::now());
|
||||
|
||||
fmt::print(dest, "[{0:%H:%M:%S}] ", now);
|
||||
@ -27,7 +29,7 @@ namespace hex::log {
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
void print(const fmt::text_style &ts, const std::string &level, const std::string &fmt, auto... args) {
|
||||
[[maybe_unused]] void print(const fmt::text_style &ts, const std::string &level, const std::string &fmt, auto... args) {
|
||||
auto dest = getDestination();
|
||||
|
||||
printPrefix(dest, ts, level);
|
||||
@ -37,28 +39,30 @@ namespace hex::log {
|
||||
|
||||
}
|
||||
|
||||
void debug(const std::string &fmt, auto &&...args) {
|
||||
[[maybe_unused]] void debug(const std::string &fmt, auto &&...args) {
|
||||
#if defined(DEBUG)
|
||||
log::print(fg(fmt::color::green_yellow) | fmt::emphasis::bold, "[DEBUG]", fmt, args...);
|
||||
print(fg(fmt::color::green_yellow) | fmt::emphasis::bold, "[DEBUG]", fmt, args...);
|
||||
#else
|
||||
hex::unused(fmt, args...);
|
||||
#endif
|
||||
}
|
||||
|
||||
void info(const std::string &fmt, auto &&...args) {
|
||||
log::print(fg(fmt::color::cadet_blue) | fmt::emphasis::bold, "[INFO] ", fmt, args...);
|
||||
[[maybe_unused]] void info(const std::string &fmt, auto &&...args) {
|
||||
print(fg(fmt::color::cadet_blue) | fmt::emphasis::bold, "[INFO] ", fmt, args...);
|
||||
}
|
||||
|
||||
void warn(const std::string &fmt, auto &&...args) {
|
||||
log::print(fg(fmt::color::orange) | fmt::emphasis::bold, "[WARN] ", fmt, args...);
|
||||
[[maybe_unused]] void warn(const std::string &fmt, auto &&...args) {
|
||||
print(fg(fmt::color::orange) | fmt::emphasis::bold, "[WARN] ", fmt, args...);
|
||||
}
|
||||
|
||||
void error(const std::string &fmt, auto &&...args) {
|
||||
log::print(fg(fmt::color::red) | fmt::emphasis::bold, "[ERROR]", fmt, args...);
|
||||
[[maybe_unused]] void error(const std::string &fmt, auto &&...args) {
|
||||
print(fg(fmt::color::red) | fmt::emphasis::bold, "[ERROR]", fmt, args...);
|
||||
}
|
||||
|
||||
void fatal(const std::string &fmt, auto &&...args) {
|
||||
log::print(fg(fmt::color::purple) | fmt::emphasis::bold, "[FATAL]", fmt, args...);
|
||||
[[maybe_unused]] void fatal(const std::string &fmt, auto &&...args) {
|
||||
print(fg(fmt::color::purple) | fmt::emphasis::bold, "[FATAL]", fmt, args...);
|
||||
}
|
||||
|
||||
void redirectToFile();
|
||||
[[maybe_unused]] void redirectToFile();
|
||||
|
||||
}
|
@ -55,9 +55,6 @@ namespace hex {
|
||||
[[nodiscard]] inline u64 extract(u32 from, u32 to, const std::vector<u8> &bytes) {
|
||||
u8 index = 0;
|
||||
while (from > 32 && to > 32) {
|
||||
if (from - 8 < 0 || to - 8 < 0)
|
||||
return 0;
|
||||
|
||||
from -= 8;
|
||||
to -= 8;
|
||||
index++;
|
||||
@ -297,7 +294,7 @@ namespace hex {
|
||||
namespace scope_guard {
|
||||
|
||||
#define SCOPE_GUARD ::hex::scope_guard::ScopeGuardOnExit() + [&]()
|
||||
#define ON_SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_) = SCOPE_GUARD
|
||||
#define ON_SCOPE_EXIT [[maybe_unused]] auto ANONYMOUS_VARIABLE(SCOPE_EXIT_) = SCOPE_GUARD
|
||||
|
||||
template<class F>
|
||||
class ScopeGuard {
|
||||
@ -332,7 +329,7 @@ namespace hex {
|
||||
|
||||
namespace first_time_exec {
|
||||
|
||||
#define FIRST_TIME static auto ANONYMOUS_VARIABLE(FIRST_TIME_) = ::hex::first_time_exec::FirstTimeExecutor() + [&]()
|
||||
#define FIRST_TIME [[maybe_unused]] static auto ANONYMOUS_VARIABLE(FIRST_TIME_) = ::hex::first_time_exec::FirstTimeExecutor() + [&]()
|
||||
|
||||
template<class F>
|
||||
class FirstTimeExecute {
|
||||
@ -355,7 +352,7 @@ namespace hex {
|
||||
|
||||
namespace final_cleanup {
|
||||
|
||||
#define FINAL_CLEANUP static auto ANONYMOUS_VARIABLE(ON_EXIT_) = ::hex::final_cleanup::FinalCleanupExecutor() + [&]()
|
||||
#define FINAL_CLEANUP [[maybe_unused]] static auto ANONYMOUS_VARIABLE(ON_EXIT_) = ::hex::final_cleanup::FinalCleanupExecutor() + [&]()
|
||||
|
||||
template<class F>
|
||||
class FinalCleanupExecute {
|
||||
|
@ -22,12 +22,24 @@ namespace hex::pl {
|
||||
|
||||
[[maybe_unused]] constexpr void setLineNumber(u32 lineNumber) { this->m_lineNumber = lineNumber; }
|
||||
|
||||
[[nodiscard]] virtual std::unique_ptr<ASTNode> evaluate(Evaluator *evaluator) const { return this->clone(); }
|
||||
[[nodiscard]] virtual std::unique_ptr<ASTNode> evaluate(Evaluator *evaluator) const {
|
||||
hex::unused(evaluator);
|
||||
|
||||
[[nodiscard]] virtual std::vector<std::unique_ptr<Pattern>> createPatterns(Evaluator *evaluator) const { return {}; }
|
||||
return this->clone();
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual std::vector<std::unique_ptr<Pattern>> createPatterns(Evaluator *evaluator) const {
|
||||
hex::unused(evaluator);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
using FunctionResult = std::optional<Token::Literal>;
|
||||
virtual FunctionResult execute(Evaluator *evaluator) const { LogConsole::abortEvaluation("cannot execute non-function statement", this); }
|
||||
virtual FunctionResult execute(Evaluator *evaluator) const {
|
||||
hex::unused(evaluator);
|
||||
|
||||
LogConsole::abortEvaluation("cannot execute non-function statement", this);
|
||||
}
|
||||
|
||||
private:
|
||||
u32 m_lineNumber = 1;
|
||||
|
@ -305,7 +305,7 @@ namespace hex::pl {
|
||||
arrayPattern->setEntries(std::move(entries));
|
||||
arrayPattern->setSize(size);
|
||||
|
||||
return std::move(arrayPattern);
|
||||
return arrayPattern;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -24,8 +24,6 @@ namespace hex::pl {
|
||||
auto literal = dynamic_cast<ASTNodeLiteral *>(evaluatedValue.get());
|
||||
auto type = dynamic_cast<ASTNodeBuiltinType *>(evaluatedType.get())->getType();
|
||||
|
||||
auto startOffset = evaluator->dataOffset();
|
||||
|
||||
auto typePatterns = this->m_type->createPatterns(evaluator);
|
||||
auto &typePattern = typePatterns.front();
|
||||
|
||||
|
@ -6,14 +6,17 @@ namespace hex::pl {
|
||||
|
||||
#define FLOAT_BIT_OPERATION(name) \
|
||||
auto name(hex::floating_point auto left, auto right) const { \
|
||||
hex::unused(left, right); \
|
||||
LogConsole::abortEvaluation("invalid floating point operation", this); \
|
||||
return 0; \
|
||||
} \
|
||||
auto name(auto left, hex::floating_point auto right) const { \
|
||||
hex::unused(left, right); \
|
||||
LogConsole::abortEvaluation("invalid floating point operation", this); \
|
||||
return 0; \
|
||||
} \
|
||||
auto name(hex::floating_point auto left, hex::floating_point auto right) const { \
|
||||
hex::unused(left, right); \
|
||||
LogConsole::abortEvaluation("invalid floating point operation", this); \
|
||||
return 0; \
|
||||
} \
|
||||
@ -42,7 +45,9 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
FLOAT_BIT_OPERATION(bitNot) {
|
||||
return ~right;
|
||||
hex::unused(left);
|
||||
|
||||
return ~static_cast<u128>(right);
|
||||
}
|
||||
|
||||
FLOAT_BIT_OPERATION(modulus) {
|
||||
@ -76,27 +81,30 @@ namespace hex::pl {
|
||||
|
||||
return std::unique_ptr<ASTNode>(std::visit(overloaded {
|
||||
// TODO: :notlikethis:
|
||||
[this](u128 left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](i128 left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](double left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](char left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](bool left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](const std::string &left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, u128 right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, i128 right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, double right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, char right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, bool right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, const std::string &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &left, Pattern *const &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](u128, Pattern *const ) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](i128, Pattern *const &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](double, Pattern *const &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](char, Pattern *const &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](bool, Pattern *const &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](const std::string &, Pattern *const &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, u128) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, i128) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, double) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, char) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, bool) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, const std::string &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](Pattern *const &, Pattern *const &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
|
||||
[this](auto &&left, const std::string &right) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](auto &&, const std::string &) -> ASTNode * { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](const std::string &left, auto &&right) -> ASTNode * {
|
||||
switch (this->getOperator()) {
|
||||
case Token::Operator::Star:
|
||||
{
|
||||
if (static_cast<i128>(right) < 0)
|
||||
LogConsole::abortEvaluation("cannot repeat string a negative number of times", this);
|
||||
|
||||
std::string result;
|
||||
for (auto i = 0; i < right; i++)
|
||||
for (u128 i = 0; i < static_cast<u128>(right); i++)
|
||||
result += left;
|
||||
return new ASTNodeLiteral(result);
|
||||
}
|
||||
@ -167,21 +175,21 @@ namespace hex::pl {
|
||||
case Token::Operator::BitNot:
|
||||
return new ASTNodeLiteral(bitNot(left, right));
|
||||
case Token::Operator::BoolEquals:
|
||||
return new ASTNodeLiteral(bool(left == right));
|
||||
return new ASTNodeLiteral(bool(left == static_cast<decltype(left)>(right)));
|
||||
case Token::Operator::BoolNotEquals:
|
||||
return new ASTNodeLiteral(bool(left != right));
|
||||
return new ASTNodeLiteral(bool(left != static_cast<decltype(left)>(right)));
|
||||
case Token::Operator::BoolGreaterThan:
|
||||
return new ASTNodeLiteral(bool(left > right));
|
||||
return new ASTNodeLiteral(bool(left > static_cast<decltype(left)>(right)));
|
||||
case Token::Operator::BoolLessThan:
|
||||
return new ASTNodeLiteral(bool(left < right));
|
||||
return new ASTNodeLiteral(bool(left < static_cast<decltype(left)>(right)));
|
||||
case Token::Operator::BoolGreaterThanOrEquals:
|
||||
return new ASTNodeLiteral(bool(left >= right));
|
||||
return new ASTNodeLiteral(bool(left >= static_cast<decltype(left)>(right)));
|
||||
case Token::Operator::BoolLessThanOrEquals:
|
||||
return new ASTNodeLiteral(bool(left <= right));
|
||||
return new ASTNodeLiteral(bool(left <= static_cast<decltype(left)>(right)));
|
||||
case Token::Operator::BoolAnd:
|
||||
return new ASTNodeLiteral(bool(left && right));
|
||||
case Token::Operator::BoolXor:
|
||||
return new ASTNodeLiteral(bool(left && !right || !left && right));
|
||||
return new ASTNodeLiteral(bool((left && !right) || (!left && right)));
|
||||
case Token::Operator::BoolOr:
|
||||
return new ASTNodeLiteral(bool(left || right));
|
||||
case Token::Operator::BoolNot:
|
||||
|
@ -105,7 +105,7 @@ namespace hex::pl {
|
||||
|
||||
readVariable(evaluator, value, assignmentValue);
|
||||
},
|
||||
[&, this](auto &&assignmentValue) { LogConsole::abortEvaluation(hex::format("cannot assign '{}' to string", pattern->getTypeName()), this); } },
|
||||
[&, this](auto &&) { LogConsole::abortEvaluation(hex::format("cannot assign '{}' to string", pattern->getTypeName()), this); } },
|
||||
variableValue);
|
||||
} else {
|
||||
value.resize(pattern->getSize());
|
||||
@ -158,7 +158,7 @@ namespace hex::pl {
|
||||
if (name == "parent") {
|
||||
scopeIndex--;
|
||||
|
||||
if (-scopeIndex >= evaluator->getScopeCount())
|
||||
if (static_cast<size_t>(std::abs(scopeIndex)) >= evaluator->getScopeCount())
|
||||
LogConsole::abortEvaluation("cannot access parent of global scope", this);
|
||||
|
||||
searchScope = *evaluator->getScope(scopeIndex).scope;
|
||||
@ -208,12 +208,12 @@ namespace hex::pl {
|
||||
[this](Pattern *) { LogConsole::abortEvaluation("cannot use custom type to index array", this); },
|
||||
[&, this](auto &&index) {
|
||||
if (auto dynamicArrayPattern = dynamic_cast<PatternArrayDynamic *>(currPattern.get())) {
|
||||
if (index >= searchScope.size() || index < 0)
|
||||
if (static_cast<u128>(index) >= searchScope.size() || static_cast<i128>(index) < 0)
|
||||
LogConsole::abortEvaluation("array index out of bounds", this);
|
||||
|
||||
currPattern = searchScope[index]->clone();
|
||||
} else if (auto staticArrayPattern = dynamic_cast<PatternArrayStatic *>(currPattern.get())) {
|
||||
if (index >= staticArrayPattern->getEntryCount() || index < 0)
|
||||
if (static_cast<u128>(index) >= staticArrayPattern->getEntryCount() || static_cast<i128>(index) < 0)
|
||||
LogConsole::abortEvaluation("array index out of bounds", this);
|
||||
|
||||
auto newPattern = searchScope.front()->clone();
|
||||
|
@ -40,7 +40,7 @@ namespace hex::pl {
|
||||
|
||||
return std::visit(overloaded {
|
||||
[condition]<typename T>(const T &second, const T &third) -> std::unique_ptr<ASTNode> { return std::unique_ptr<ASTNode>(new ASTNodeLiteral(condition ? second : third)); },
|
||||
[this](auto &&second, auto &&third) -> std::unique_ptr<ASTNode> { LogConsole::abortEvaluation("operands to ternary expression have different types", this); } },
|
||||
[this](auto &&, auto &&) -> std::unique_ptr<ASTNode> { LogConsole::abortEvaluation("operands to ternary expression have different types", this); } },
|
||||
second->getValue(),
|
||||
third->getValue());
|
||||
}
|
||||
|
@ -64,13 +64,14 @@ namespace hex::pl {
|
||||
std::vector<std::shared_ptr<Pattern>> *scope;
|
||||
std::optional<ParameterPack> parameterPack;
|
||||
};
|
||||
|
||||
void pushScope(Pattern *parent, std::vector<std::shared_ptr<Pattern>> &scope) {
|
||||
if (this->m_scopes.size() > this->getEvaluationDepth())
|
||||
LogConsole::abortEvaluation(hex::format("evaluation depth exceeded set limit of {}", this->getEvaluationDepth()));
|
||||
|
||||
this->handleAbort();
|
||||
|
||||
this->m_scopes.push_back({ parent, &scope });
|
||||
this->m_scopes.push_back({ parent, &scope, { } });
|
||||
}
|
||||
|
||||
void popScope() {
|
||||
@ -85,19 +86,19 @@ namespace hex::pl {
|
||||
return this->m_scopes[this->m_scopes.size() - 1 + index];
|
||||
}
|
||||
|
||||
Scope &getGlobalScope() {
|
||||
[[nodiscard]] Scope &getGlobalScope() {
|
||||
return this->m_scopes.front();
|
||||
}
|
||||
|
||||
const Scope &getGlobalScope() const {
|
||||
[[nodiscard]] const Scope &getGlobalScope() const {
|
||||
return this->m_scopes.front();
|
||||
}
|
||||
|
||||
size_t getScopeCount() {
|
||||
[[nodiscard]] size_t getScopeCount() {
|
||||
return this->m_scopes.size();
|
||||
}
|
||||
|
||||
bool isGlobalScope() {
|
||||
[[nodiscard]] bool isGlobalScope() {
|
||||
return this->m_scopes.size() == 1;
|
||||
}
|
||||
|
||||
@ -179,7 +180,7 @@ namespace hex::pl {
|
||||
|
||||
bool addCustomFunction(const std::string &name, ContentRegistry::PatternLanguage::ParameterCount numParams, std::vector<Token::Literal> defaultParameters, const ContentRegistry::PatternLanguage::Callback &function) {
|
||||
const auto [iter, inserted] = this->m_customFunctions.insert({
|
||||
name, {numParams, std::move(defaultParameters), function}
|
||||
name, {numParams, std::move(defaultParameters), function, false}
|
||||
});
|
||||
|
||||
return inserted;
|
||||
|
@ -138,7 +138,7 @@ namespace hex::pl {
|
||||
for (auto &[entryValueLiteral, entryName] : pattern.getEnumValues()) {
|
||||
auto visitor = overloaded {
|
||||
[&, name = entryName](auto &entryValue) {
|
||||
if (value == entryValue) {
|
||||
if (static_cast<decltype(entryValue)>(value) == entryValue) {
|
||||
valueString += name;
|
||||
foundValue = true;
|
||||
return true;
|
||||
@ -175,17 +175,20 @@ namespace hex::pl {
|
||||
void visit(PatternFloat& pattern) override {
|
||||
if (pattern.getSize() == 4) {
|
||||
float f32 = pattern.getValue(m_provider);
|
||||
u32 data = *reinterpret_cast<u32 *>(&f32);
|
||||
this->createDefaultEntry(pattern, hex::format("{:e} (0x{:0{}X})", f32, data, pattern.getSize() * 2), f32);
|
||||
u32 integerResult = 0;
|
||||
std::memcpy(&integerResult, &f32, sizeof(float));
|
||||
this->createDefaultEntry(pattern, hex::format("{:e} (0x{:0{}X})", f32, integerResult, pattern.getSize() * 2), f32);
|
||||
} else if (pattern.getSize() == 8) {
|
||||
double f64 = pattern.getValue(m_provider);
|
||||
u64 data = *reinterpret_cast<u64 *>(&f64);
|
||||
this->createDefaultEntry(pattern, hex::format("{:e} (0x{:0{}X})", f64, data, pattern.getSize() * 2), f64);
|
||||
u64 integerResult = 0;
|
||||
std::memcpy(&integerResult, &f64, sizeof(double));
|
||||
this->createDefaultEntry(pattern, hex::format("{:e} (0x{:0{}X})", f64, integerResult, pattern.getSize() * 2), f64);
|
||||
}
|
||||
}
|
||||
|
||||
void visit(PatternPadding& pattern) override {
|
||||
// Do nothing
|
||||
hex::unused(pattern);
|
||||
}
|
||||
|
||||
void visit(PatternPointer& pattern) override {
|
||||
|
@ -126,9 +126,13 @@ namespace hex::pl {
|
||||
this->getEvaluator()->handleAbort();
|
||||
}
|
||||
|
||||
virtual void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) { }
|
||||
virtual void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) {
|
||||
hex::unused(sortSpecs, provider);
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual std::string toString(prv::Provider *provider) const {
|
||||
hex::unused(provider);
|
||||
|
||||
return hex::format("{} {} @ 0x{:X}", this->getTypeName(), this->getVariableName(), this->getOffset());
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,6 @@ namespace hex::pl {
|
||||
if (this->m_bitField->getEndian() != std::endian::native)
|
||||
std::reverse(value.begin(), value.end());
|
||||
|
||||
u8 numBytes = (this->m_bitSize / 8) + 1;
|
||||
|
||||
return hex::extract(this->m_bitOffset + (this->m_bitSize - 1), this->m_bitOffset, value);
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,18 @@ namespace hex::pl {
|
||||
u32 data = 0;
|
||||
provider->read(this->getOffset(), &data, 4);
|
||||
data = hex::changeEndianess(data, 4, this->getEndian());
|
||||
return *reinterpret_cast<float *>(&data);
|
||||
|
||||
float result = 0;
|
||||
std::memcpy(&result, &data, sizeof(float));
|
||||
return result;
|
||||
} else if (this->getSize() == 8) {
|
||||
u64 data = 0;
|
||||
provider->read(this->getOffset(), &data, 8);
|
||||
data = hex::changeEndianess(data, 8, this->getEndian());
|
||||
return *reinterpret_cast<double *>(&data);
|
||||
|
||||
double result = 0;
|
||||
std::memcpy(&result, &data, sizeof(double));
|
||||
return result;
|
||||
} else {
|
||||
assert(false);
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
|
@ -132,7 +132,6 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] const std::string &get() const { return this->m_identifier; }
|
||||
|
||||
auto operator<=>(const Identifier &) const = default;
|
||||
bool operator==(const Identifier &) const = default;
|
||||
|
||||
private:
|
||||
|
@ -34,7 +34,7 @@ namespace hex::dp {
|
||||
return outputData.value();
|
||||
}
|
||||
|
||||
u64 Node::getIntegerOnInput(u32 index) {
|
||||
i64 Node::getIntegerOnInput(u32 index) {
|
||||
auto attribute = this->getConnectedInputAttribute(index);
|
||||
|
||||
if (attribute == nullptr)
|
||||
@ -54,7 +54,7 @@ namespace hex::dp {
|
||||
if (outputData->size() < sizeof(u64))
|
||||
throw std::runtime_error("Not enough data provided for integer");
|
||||
|
||||
return *reinterpret_cast<u64 *>(outputData->data());
|
||||
return *reinterpret_cast<i64 *>(outputData->data());
|
||||
}
|
||||
|
||||
float Node::getFloatOnInput(u32 index) {
|
||||
@ -77,7 +77,9 @@ namespace hex::dp {
|
||||
if (outputData->size() < sizeof(float))
|
||||
throw std::runtime_error("Not enough data provided for float");
|
||||
|
||||
return *reinterpret_cast<float *>(outputData->data());
|
||||
float result = 0;
|
||||
std::memcpy(&result, outputData->data(), sizeof(float));
|
||||
return result;
|
||||
}
|
||||
|
||||
void Node::setBufferOnOutput(u32 index, const std::vector<u8> &data) {
|
||||
@ -92,7 +94,7 @@ namespace hex::dp {
|
||||
attribute.getOutputData() = data;
|
||||
}
|
||||
|
||||
void Node::setIntegerOnOutput(u32 index, u64 integer) {
|
||||
void Node::setIntegerOnOutput(u32 index, i64 integer) {
|
||||
if (index >= this->getAttributes().size())
|
||||
throw std::runtime_error("Attribute index out of bounds!");
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <bit>
|
||||
|
||||
#if MBEDTLS_VERSION_MAJOR <= 2
|
||||
|
||||
@ -82,27 +83,24 @@ namespace hex::crypt {
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t NumBits> requires (std::has_single_bit(NumBits))
|
||||
class Crc {
|
||||
// use reflected algorithm, so we reflect only if refin / refout is FALSE
|
||||
// mask values, 0b1 << 64 is UB, so use 0b10 << 63
|
||||
|
||||
public:
|
||||
using calc_type = uint64_t;
|
||||
|
||||
Crc(int bits, calc_type polynomial, calc_type init, calc_type xorout, bool refin, bool refout) : m_bits(bits),
|
||||
m_init(init & ((0b10ull << (bits - 1)) - 1)),
|
||||
m_xorout(xorout & ((0b10ull << (bits - 1)) - 1)),
|
||||
m_refin(refin),
|
||||
m_refout(refout),
|
||||
table([polynomial, bits]() {
|
||||
auto reflectedpoly = reflect(polynomial & ((0b10ull << (bits - 1)) - 1), bits);
|
||||
constexpr Crc(u64 polynomial, u64 init, u64 xorOut, bool reflectInput, bool reflectOutput)
|
||||
: m_value(0x00), m_init(init & ((0b10ull << (NumBits - 1)) - 1)), m_xorOut(xorOut & ((0b10ull << (NumBits - 1)) - 1)),
|
||||
m_reflectInput(reflectInput), m_reflectOutput(reflectOutput),
|
||||
m_table([polynomial]() {
|
||||
auto reflectedPoly = reflect(polynomial & ((0b10ull << (NumBits - 1)) - 1), NumBits);
|
||||
std::array<uint64_t, 256> table = { 0 };
|
||||
|
||||
for (uint32_t i = 0; i < 256; i++) {
|
||||
uint64_t c = i;
|
||||
for (std::size_t j = 0; j < 8; j++) {
|
||||
if (c & 0b1)
|
||||
c = reflectedpoly ^ (c >> 1);
|
||||
c = reflectedPoly ^ (c >> 1);
|
||||
else
|
||||
c >>= 1;
|
||||
}
|
||||
@ -114,59 +112,61 @@ namespace hex::crypt {
|
||||
reset();
|
||||
};
|
||||
|
||||
void reset() {
|
||||
c = reflect(m_init, m_bits);
|
||||
constexpr void reset() {
|
||||
this->m_value = reflect(m_init, NumBits);
|
||||
}
|
||||
|
||||
void processBytes(const unsigned char *data, std::size_t size) {
|
||||
constexpr void processBytes(const unsigned char *data, std::size_t size) {
|
||||
for (std::size_t i = 0; i < size; i++) {
|
||||
unsigned char d;
|
||||
if (m_refin)
|
||||
d = data[i];
|
||||
u8 byte;
|
||||
if (this->m_reflectInput)
|
||||
byte = data[i];
|
||||
else
|
||||
d = reflect(data[i]);
|
||||
byte = reflect(data[i]);
|
||||
|
||||
c = table[(c ^ d) & 0xFFL] ^ (c >> 8);
|
||||
this->m_value = this->m_table[(this->m_value ^ byte) & 0xFFL] ^ (this->m_value >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
calc_type checksum() const {
|
||||
if (m_refout)
|
||||
return c ^ m_xorout;
|
||||
[[nodiscard]]
|
||||
constexpr u64 checksum() const {
|
||||
if (this->m_reflectOutput)
|
||||
return this->m_value ^ m_xorOut;
|
||||
else
|
||||
return reflect(c, m_bits) ^ m_xorout;
|
||||
return reflect(this->m_value, NumBits) ^ m_xorOut;
|
||||
}
|
||||
|
||||
private:
|
||||
const int m_bits;
|
||||
const calc_type m_init;
|
||||
const calc_type m_xorout;
|
||||
const bool m_refin;
|
||||
const bool m_refout;
|
||||
const std::array<uint64_t, 256> table;
|
||||
u64 m_value;
|
||||
|
||||
calc_type c;
|
||||
u64 m_init;
|
||||
u64 m_xorOut;
|
||||
bool m_reflectInput;
|
||||
bool m_reflectOutput;
|
||||
|
||||
std::array<uint64_t, 256> m_table;
|
||||
};
|
||||
|
||||
template<int bits>
|
||||
template<size_t NumBits>
|
||||
auto calcCrc(prv::Provider *data, u64 offset, std::size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut) {
|
||||
Crc crc(bits, polynomial, init, xorout, reflectIn, reflectOut);
|
||||
using Crc = Crc<NumBits>;
|
||||
Crc crc(polynomial, init, xorout, reflectIn, reflectOut);
|
||||
|
||||
processDataByChunks(data, offset, size, std::bind(&Crc::processBytes, &crc, _1, _2));
|
||||
|
||||
return crc.checksum();
|
||||
}
|
||||
|
||||
u16 crc8(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut) {
|
||||
return calcCrc<8>(data, offset, size, polynomial, init, xorout, reflectIn, reflectOut);
|
||||
u16 crc8(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorOut, bool reflectIn, bool reflectOut) {
|
||||
return calcCrc<8>(data, offset, size, polynomial, init, xorOut, reflectIn, reflectOut);
|
||||
}
|
||||
|
||||
u16 crc16(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut) {
|
||||
return calcCrc<16>(data, offset, size, polynomial, init, xorout, reflectIn, reflectOut);
|
||||
u16 crc16(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorOut, bool reflectIn, bool reflectOut) {
|
||||
return calcCrc<16>(data, offset, size, polynomial, init, xorOut, reflectIn, reflectOut);
|
||||
}
|
||||
|
||||
u32 crc32(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut) {
|
||||
return calcCrc<32>(data, offset, size, polynomial, init, xorout, reflectIn, reflectOut);
|
||||
u32 crc32(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorOut, bool reflectIn, bool reflectOut) {
|
||||
return calcCrc<32>(data, offset, size, polynomial, init, xorOut, reflectIn, reflectOut);
|
||||
}
|
||||
|
||||
|
||||
@ -414,7 +414,7 @@ namespace hex::crypt {
|
||||
|
||||
std::string output(input.size() * 2, '\0');
|
||||
|
||||
for (int i = 0; i < input.size(); i++) {
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
output[2 * i + 0] = "0123456789ABCDEF"[input[i] / 16];
|
||||
output[2 * i + 1] = "0123456789ABCDEF"[input[i] % 16];
|
||||
}
|
||||
@ -427,13 +427,15 @@ namespace hex::crypt {
|
||||
|
||||
if (input.empty())
|
||||
return {};
|
||||
if (key.size() > 256)
|
||||
return {};
|
||||
|
||||
mbedtls_cipher_context_t ctx;
|
||||
auto cipherInfo = mbedtls_cipher_info_from_type(type);
|
||||
|
||||
|
||||
mbedtls_cipher_setup(&ctx, cipherInfo);
|
||||
mbedtls_cipher_setkey(&ctx, key.data(), key.size() * 8, operation);
|
||||
mbedtls_cipher_setkey(&ctx, key.data(), static_cast<int>(key.size() * 8), operation);
|
||||
|
||||
std::array<u8, 16> nonceCounter = { 0 };
|
||||
std::copy(nonce.begin(), nonce.end(), nonceCounter.begin());
|
||||
|
@ -115,7 +115,8 @@ namespace hex::fs {
|
||||
void File::setSize(u64 size) {
|
||||
if (!isValid()) return;
|
||||
|
||||
ftruncate64(fileno(this->m_file), size);
|
||||
auto result = ftruncate64(fileno(this->m_file), size);
|
||||
hex::unused(result);
|
||||
}
|
||||
|
||||
void File::flush() {
|
||||
|
@ -59,7 +59,7 @@ namespace hex::fs {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool openFileBrowser(const std::string &title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback, const std::string &defaultPath) {
|
||||
bool openFileBrowser(DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback, const std::string &defaultPath) {
|
||||
NFD::Init();
|
||||
|
||||
nfdchar_t *outPath;
|
||||
@ -95,6 +95,7 @@ namespace hex::fs {
|
||||
const std::string settingName { "hex.builtin.setting.folders" };
|
||||
auto userDirs = ContentRegistry::Settings::read(settingName, settingName, std::vector<std::string> {});
|
||||
|
||||
[[maybe_unused]]
|
||||
auto addUserDirs = [&userDirs](auto &paths) {
|
||||
std::transform(userDirs.begin(), userDirs.end(), std::back_inserter(paths), [](auto &item) {
|
||||
return std::move(item);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/intrinsics.hpp>
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
@ -18,10 +19,14 @@ using namespace std::literals::string_literals;
|
||||
namespace hex {
|
||||
|
||||
PyObject *LoaderScript::Py_getFilePath(PyObject *self, PyObject *args) {
|
||||
hex::unused(self, args);
|
||||
|
||||
return PyUnicode_FromString(LoaderScript::s_filePath.string().c_str());
|
||||
}
|
||||
|
||||
PyObject *LoaderScript::Py_addPatch(PyObject *self, PyObject *args) {
|
||||
hex::unused(self);
|
||||
|
||||
u64 address;
|
||||
u8 *patches;
|
||||
Py_ssize_t count;
|
||||
@ -47,6 +52,8 @@ namespace hex {
|
||||
}
|
||||
|
||||
PyObject *LoaderScript::Py_addBookmark(PyObject *self, PyObject *args) {
|
||||
hex::unused(self);
|
||||
|
||||
u64 address;
|
||||
size_t size;
|
||||
|
||||
@ -171,10 +178,14 @@ namespace hex {
|
||||
}
|
||||
|
||||
PyObject *LoaderScript::Py_addStruct(PyObject *self, PyObject *args) {
|
||||
hex::unused(self);
|
||||
|
||||
return createStructureType("struct", args);
|
||||
}
|
||||
|
||||
PyObject *LoaderScript::Py_addUnion(PyObject *self, PyObject *args) {
|
||||
hex::unused(self);
|
||||
|
||||
return createStructureType("union", args);
|
||||
}
|
||||
|
||||
|
@ -38,19 +38,16 @@ namespace hex {
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
static size_t readFromFile(void *contents, size_t size, size_t nmemb, void *userdata) {
|
||||
FILE *file = static_cast<FILE *>(userdata);
|
||||
|
||||
return fread(contents, size, nmemb, file);
|
||||
}
|
||||
|
||||
static size_t writeToFile(void *contents, size_t size, size_t nmemb, void *userdata) {
|
||||
FILE *file = static_cast<FILE *>(userdata);
|
||||
|
||||
return fwrite(contents, size, nmemb, file);
|
||||
}
|
||||
|
||||
static CURLcode sslCtxFunction(CURL *ctx, void *sslctx, void *userdata) {
|
||||
[[maybe_unused]]
|
||||
static CURLcode sslCtxFunction(CURL *ctx, void *sslctx, void *userData) {
|
||||
hex::unused(ctx, userData);
|
||||
|
||||
auto *cfg = static_cast<mbedtls_ssl_config *>(sslctx);
|
||||
|
||||
static mbedtls_x509_crt crt;
|
||||
|
@ -75,7 +75,7 @@ namespace hex {
|
||||
if (this->m_socket == SOCKET_NONE)
|
||||
return;
|
||||
|
||||
sockaddr_in client = { 0 };
|
||||
sockaddr_in client = { };
|
||||
|
||||
client.sin_family = AF_INET;
|
||||
client.sin_port = htons(port);
|
||||
|
@ -249,14 +249,13 @@ namespace hex {
|
||||
void runCommand(const std::string &command) {
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
system(hex::format("start {0}", command).c_str());
|
||||
auto result = system(hex::format("start {0}", command).c_str());
|
||||
#elif defined(OS_MACOS)
|
||||
system(hex::format("open {0}", command).c_str());
|
||||
auto result = system(hex::format("open {0}", command).c_str());
|
||||
#elif defined(OS_LINUX)
|
||||
system(hex::format("xdg-open {0}", command).c_str());
|
||||
#else
|
||||
#warning "Unknown OS, can't open webpages"
|
||||
auto result = system(hex::format("xdg-open {0}", command).c_str());
|
||||
#endif
|
||||
hex::unused(result);
|
||||
}
|
||||
|
||||
void openWebpage(std::string url) {
|
||||
@ -271,7 +270,8 @@ namespace hex {
|
||||
LSOpenCFURLRef(urlRef, nullptr);
|
||||
CFRelease(urlRef);
|
||||
#elif defined(OS_LINUX)
|
||||
system(hex::format("xdg-open {0}", url).c_str());
|
||||
auto result = system(hex::format("xdg-open {0}", url).c_str());
|
||||
hex::unused(result);
|
||||
#else
|
||||
#warning "Unknown OS, can't open webpages"
|
||||
#endif
|
||||
@ -399,7 +399,7 @@ namespace hex {
|
||||
u32 exponent = (float16 >> 10) & 0x1F;
|
||||
u32 mantissa = float16 & 0x3FF;
|
||||
|
||||
u32 result;
|
||||
u32 result = 0x00;
|
||||
|
||||
if (exponent == 0) {
|
||||
if (mantissa == 0) {
|
||||
@ -425,7 +425,10 @@ namespace hex {
|
||||
result = (sign << 31) | ((exponent + (0x7F - 15)) << 23) | (mantissa << 13);
|
||||
}
|
||||
|
||||
return reinterpret_cast<float &>(result);
|
||||
float floatResult = 0;
|
||||
std::memcpy(&floatResult, &result, sizeof(float));
|
||||
|
||||
return floatResult;
|
||||
}
|
||||
|
||||
bool isProcessElevated() {
|
||||
@ -447,7 +450,7 @@ namespace hex {
|
||||
return elevated;
|
||||
|
||||
#elif defined(OS_LINUX) || defined(OS_MACOS)
|
||||
return getuid() < 0 || getuid() != geteuid();
|
||||
return getuid() == 0 || getuid() != geteuid();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,7 @@ namespace hex::pl {
|
||||
|
||||
std::optional<Token::Literal> lexIntegerLiteral(std::string_view string) {
|
||||
bool hasFloatSuffix = string.ends_with('D') || string.ends_with('F') || string.ends_with('d') || string.ends_with('f');
|
||||
bool isFloat = std::count(string.begin(), string.end(), '.') == 1 ||
|
||||
!string.starts_with("0x") && hasFloatSuffix;
|
||||
bool isFloat = std::count(string.begin(), string.end(), '.') == 1 || (!string.starts_with("0x") && hasFloatSuffix);
|
||||
|
||||
if (isFloat) {
|
||||
// Parse double
|
||||
|
@ -215,7 +215,7 @@ namespace hex::pl {
|
||||
});
|
||||
|
||||
for (const auto &[define, value, defineLine] : sortedDefines) {
|
||||
i32 index = 0;
|
||||
size_t index = 0;
|
||||
while ((index = output.find(define, index)) != std::string::npos) {
|
||||
output.replace(index, define.length(), value);
|
||||
index += value.length();
|
||||
|
@ -29,6 +29,8 @@ namespace hex::prv {
|
||||
}
|
||||
|
||||
void Provider::read(u64 offset, void *buffer, size_t size, bool overlays) {
|
||||
hex::unused(overlays);
|
||||
|
||||
this->readRaw(offset - this->getBaseAddress(), buffer, size);
|
||||
}
|
||||
|
||||
@ -37,9 +39,13 @@ namespace hex::prv {
|
||||
}
|
||||
|
||||
void Provider::save() { }
|
||||
void Provider::saveAs(const std::fs::path &path) { }
|
||||
void Provider::saveAs(const std::fs::path &path) {
|
||||
hex::unused(path);
|
||||
}
|
||||
|
||||
void Provider::resize(size_t newSize) { }
|
||||
void Provider::resize(size_t newSize) {
|
||||
hex::unused(newSize);
|
||||
}
|
||||
|
||||
void Provider::insert(u64 offset, size_t size) {
|
||||
auto &patches = getPatches();
|
||||
@ -54,7 +60,7 @@ namespace hex::prv {
|
||||
for (const auto &[address, value] : patchesToMove)
|
||||
patches.erase(address);
|
||||
for (const auto &[address, value] : patchesToMove)
|
||||
patches.insert({ address + offset, value });
|
||||
patches.insert({ address + size, value });
|
||||
}
|
||||
|
||||
void Provider::applyOverlays(u64 offset, void *buffer, size_t size) {
|
||||
@ -72,7 +78,7 @@ namespace hex::prv {
|
||||
|
||||
std::map<u64, u8> &Provider::getPatches() {
|
||||
auto iter = this->m_patches.end();
|
||||
for (auto i = 0; i < this->m_patchTreeOffset + 1; i++)
|
||||
for (u32 i = 0; i < this->m_patchTreeOffset + 1; i++)
|
||||
iter--;
|
||||
|
||||
return *(iter);
|
||||
@ -80,7 +86,7 @@ namespace hex::prv {
|
||||
|
||||
const std::map<u64, u8> &Provider::getPatches() const {
|
||||
auto iter = this->m_patches.end();
|
||||
for (auto i = 0; i < this->m_patchTreeOffset + 1; i++)
|
||||
for (u32 i = 0; i < this->m_patchTreeOffset + 1; i++)
|
||||
iter--;
|
||||
|
||||
return *(iter);
|
||||
@ -149,7 +155,7 @@ namespace hex::prv {
|
||||
void Provider::addPatch(u64 offset, const void *buffer, size_t size, bool createUndo) {
|
||||
if (this->m_patchTreeOffset > 0) {
|
||||
auto iter = this->m_patches.end();
|
||||
for (auto i = 0; i < this->m_patchTreeOffset; i++)
|
||||
for (u32 i = 0; i < this->m_patchTreeOffset; i++)
|
||||
iter--;
|
||||
|
||||
this->m_patches.erase(iter, this->m_patches.end());
|
||||
|
@ -32,7 +32,6 @@ namespace ImGui {
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
ImVec2 label_size = CalcTextSize(icon, NULL, false);
|
||||
label_size.x += CalcTextSize(" ", NULL, false).x + CalcTextSize(label, NULL, false).x;
|
||||
@ -67,7 +66,6 @@ namespace ImGui {
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
@ -554,7 +552,6 @@ namespace ImGui {
|
||||
fraction = ImSaturate(fraction);
|
||||
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
||||
const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
|
||||
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace hex {
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("hex.builtin.common.browse"_lang)) {
|
||||
fs::openFileBrowser("hex.builtin.common.open"_lang, fs::DialogMode::Open, View::s_selectableFilesValidExtensions, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, View::s_selectableFilesValidExtensions, [](const auto &path) {
|
||||
View::s_selectableFileOpenCallback(path);
|
||||
ImGui::CloseCurrentPopup();
|
||||
});
|
||||
@ -147,7 +147,7 @@ namespace hex {
|
||||
|
||||
void View::showFileChooserPopup(const std::vector<std::fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback) {
|
||||
if (paths.empty()) {
|
||||
fs::openFileBrowser("hex.builtin.common.open"_lang, fs::DialogMode::Open, validExtensions, [callback](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, validExtensions, [callback](const auto &path) {
|
||||
callback(path);
|
||||
});
|
||||
} else {
|
||||
|
@ -15,6 +15,7 @@ add_executable(main ${APPLICATION_TYPE}
|
||||
)
|
||||
|
||||
target_include_directories(main PUBLIC include)
|
||||
target_compile_options(main PRIVATE -Wall -Wextra -Werror)
|
||||
|
||||
set_target_properties(main PROPERTIES
|
||||
OUTPUT_NAME "imhex"
|
||||
@ -29,3 +30,7 @@ if (WIN32)
|
||||
else ()
|
||||
target_link_libraries(main PUBLIC libimhex pthread)
|
||||
endif ()
|
||||
|
||||
if (APPLE)
|
||||
add_compile_definitions(GL_SILENCE_DEPRECATION)
|
||||
endif ()
|
@ -27,7 +27,6 @@ namespace hex {
|
||||
static LONG_PTR g_oldWndProc;
|
||||
static float g_titleBarHeight;
|
||||
static ImGuiMouseCursor g_mouseCursorIcon;
|
||||
static BOOL g_compositionEnabled = false;
|
||||
|
||||
static LRESULT windowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
@ -42,7 +41,9 @@ namespace hex {
|
||||
CallWindowProc((WNDPROC)g_oldWndProc, hwnd, uMsg, wParam, lParam);
|
||||
|
||||
if (IsMaximized(hwnd)) {
|
||||
WINDOWINFO windowInfo = { .cbSize = sizeof(WINDOWINFO) };
|
||||
WINDOWINFO windowInfo = { };
|
||||
windowInfo.cbSize = sizeof(WINDOWINFO);
|
||||
|
||||
GetWindowInfo(hwnd, &windowInfo);
|
||||
rect = RECT {
|
||||
.left = static_cast<LONG>(client.left + windowInfo.cyWindowBorders),
|
||||
@ -209,7 +210,7 @@ namespace hex {
|
||||
globalMutex = CreateMutex(nullptr, FALSE, UniqueMutexId);
|
||||
} else {
|
||||
if (ImHexApi::System::getProgramArguments().argc > 1) {
|
||||
::EnumWindows([](HWND hWnd, LPARAM lparam) -> BOOL {
|
||||
::EnumWindows([](HWND hWnd, LPARAM) -> BOOL {
|
||||
auto &programArgs = ImHexApi::System::getProgramArguments();
|
||||
|
||||
auto length = ::GetWindowTextLength(hWnd);
|
||||
|
@ -9,12 +9,10 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <csignal>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <cassert>
|
||||
@ -26,24 +24,17 @@
|
||||
#include <imgui_internal.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#include <imgui_freetype.h>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
#include <implot.h>
|
||||
#include <implot_internal.h>
|
||||
#include <imnodes.h>
|
||||
#include <imnodes_internal.h>
|
||||
|
||||
#include <fontawesome_font.h>
|
||||
#include <codicons_font.h>
|
||||
#include <unifont_font.h>
|
||||
|
||||
#include <hex/helpers/project_file_handler.hpp>
|
||||
#include "init/tasks.hpp"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
@ -53,14 +44,14 @@ namespace hex {
|
||||
return ctx; // Unused, but the return value has to be non-null
|
||||
}
|
||||
|
||||
void ImHexSettingsHandler_ReadLine(ImGuiContext *, ImGuiSettingsHandler *handler, void *, const char *line) {
|
||||
void ImHexSettingsHandler_ReadLine(ImGuiContext *, ImGuiSettingsHandler *, void *, const char *line) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
|
||||
std::string format = std::string(view->getUnlocalizedName()) + "=%d";
|
||||
sscanf(line, format.c_str(), &view->getWindowOpenState());
|
||||
}
|
||||
}
|
||||
|
||||
void ImHexSettingsHandler_WriteAll(ImGuiContext *ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf) {
|
||||
void ImHexSettingsHandler_WriteAll(ImGuiContext *, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf) {
|
||||
buf->reserve(buf->size() + 0x20); // Ballpark reserve
|
||||
|
||||
buf->appendf("[%s][General]\n", handler->TypeName);
|
||||
@ -120,7 +111,7 @@ namespace hex {
|
||||
|
||||
constexpr auto CrashBackupFileName = "crash_backup.hexproj";
|
||||
|
||||
EventManager::subscribe<EventAbnormalTermination>(this, [this, CrashBackupFileName](int signal) {
|
||||
EventManager::subscribe<EventAbnormalTermination>(this, [this, CrashBackupFileName](int) {
|
||||
ImGui::SaveIniSettingsToDisk(this->m_imguiSettingsPath.string().c_str());
|
||||
|
||||
if (!ProjectFile::hasUnsavedChanges())
|
||||
@ -263,7 +254,7 @@ namespace hex {
|
||||
ImGui::BeginDisabled(!ImHexApi::Provider::isValid());
|
||||
{
|
||||
if (ImGui::Button(icon.c_str(), ImVec2(sidebarWidth, sidebarWidth))) {
|
||||
if (openWindow == index)
|
||||
if (static_cast<u32>(openWindow) == index)
|
||||
openWindow = -1;
|
||||
else
|
||||
openWindow = index;
|
||||
@ -273,7 +264,7 @@ namespace hex {
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
|
||||
bool open = openWindow == index;
|
||||
bool open = static_cast<u32>(openWindow) == index;
|
||||
if (open) {
|
||||
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + sidebarPos + ImVec2(sidebarWidth - 2_scaled, 0));
|
||||
ImGui::SetNextWindowSize(ImVec2(250_scaled, dockSpaceSize.y + ImGui::GetStyle().FramePadding.y + 2_scaled));
|
||||
@ -601,11 +592,11 @@ namespace hex {
|
||||
}
|
||||
});
|
||||
|
||||
glfwSetDropCallback(this->m_window, [](GLFWwindow *window, int count, const char **paths) {
|
||||
glfwSetDropCallback(this->m_window, [](GLFWwindow *, int count, const char **paths) {
|
||||
if (count != 1)
|
||||
return;
|
||||
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
auto path = std::fs::path(reinterpret_cast<const char8_t *>(paths[i]));
|
||||
|
||||
bool handled = false;
|
||||
|
@ -73,3 +73,4 @@ endif()
|
||||
|
||||
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
|
||||
|
@ -60,7 +60,7 @@ namespace hex::plugin::builtin::prv {
|
||||
void *m_mappedFile = nullptr;
|
||||
size_t m_fileSize = 0;
|
||||
|
||||
struct stat m_fileStats = { 0 };
|
||||
struct stat m_fileStats = { };
|
||||
bool m_fileStatsValid = false;
|
||||
bool m_emptyFile = false;
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
bool m_greyedOutZeros = true;
|
||||
bool m_upperCaseHex = true;
|
||||
int m_columnCount = 16;
|
||||
u32 m_columnCount = 16;
|
||||
};
|
||||
|
||||
}
|
@ -58,9 +58,12 @@ namespace hex {
|
||||
struct Token {
|
||||
TokenType type;
|
||||
|
||||
union {
|
||||
long double number;
|
||||
Operator op;
|
||||
BracketType bracketType;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<long double> arguments;
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ namespace hex::plugin::builtin {
|
||||
result += hex::format("{0:08X} ", col << 4);
|
||||
for (u64 i = 0; i < 16; i++) {
|
||||
|
||||
if (col == (offset >> 4) && i < (offset & 0xF) || col == (end >> 4) && i > (end & 0xF))
|
||||
if ((col == (offset >> 4) && i < (offset & 0xF)) || (col == (end >> 4) && i > (end & 0xF)))
|
||||
result += " ";
|
||||
else
|
||||
result += hex::format("{0:02X} ", buffer[((col << 4) - offset) + i]);
|
||||
@ -90,7 +90,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
for (u64 i = 0; i < 16; i++) {
|
||||
|
||||
if (col == (offset >> 4) && i < (offset & 0xF) || col == (end >> 4) && i > (end & 0xF))
|
||||
if ((col == (offset >> 4) && i < (offset & 0xF)) || (col == (end >> 4) && i > (end & 0xF)))
|
||||
result += " ";
|
||||
else {
|
||||
u8 c = buffer[((col << 4) - offset) + i];
|
||||
@ -129,7 +129,7 @@ namespace hex::plugin::builtin {
|
||||
result += hex::format(" <span class=\"offsetcolumn\">{0:08X}</span>  <span class=\"hexcolumn\">", col << 4);
|
||||
for (u64 i = 0; i < 16; i++) {
|
||||
|
||||
if (col == (offset >> 4) && i < (offset & 0xF) || col == (end >> 4) && i > (end & 0xF))
|
||||
if ((col == (offset >> 4) && i < (offset & 0xF)) || (col == (end >> 4) && i > (end & 0xF)))
|
||||
result += "   ";
|
||||
else
|
||||
result += hex::format("{0:02X} ", buffer[((col << 4) - offset) + i]);
|
||||
@ -142,7 +142,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
for (u64 i = 0; i < 16; i++) {
|
||||
|
||||
if (col == (offset >> 4) && i < (offset & 0xF) || col == (end >> 4) && i > (end & 0xF))
|
||||
if ((col == (offset >> 4) && i < (offset & 0xF)) || (col == (end >> 4) && i > (end & 0xF)))
|
||||
result += " ";
|
||||
else {
|
||||
u8 c = buffer[((col << 4) - offset) + i];
|
||||
|
@ -82,6 +82,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.binary", sizeof(u8),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(endian, style);
|
||||
|
||||
std::string binary = "0b";
|
||||
for (u8 i = 0; i < 8; i++)
|
||||
binary += ((buffer[0] << i) & 0x80) == 0 ? '0' : '1';
|
||||
@ -91,6 +93,7 @@ namespace hex::plugin::builtin {
|
||||
return binary;
|
||||
};
|
||||
}, [](std::string value, std::endian endian) -> std::vector<u8> {
|
||||
hex::unused(endian);
|
||||
if (value.starts_with("0b"))
|
||||
value = value.substr(2);
|
||||
|
||||
@ -113,6 +116,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.u8", sizeof(u8),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(endian);
|
||||
|
||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:02X}" : "0o{0:03o}");
|
||||
|
||||
auto value = hex::format(format, *reinterpret_cast<u8 *>(buffer.data()));
|
||||
@ -209,6 +214,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.float16", sizeof(u16),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
auto value = hex::format("{0:G}", hex::changeEndianess(float16ToFloat32(*reinterpret_cast<u16 *>(buffer.data())), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
}
|
||||
@ -216,6 +222,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.float", sizeof(float),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<float *>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
},
|
||||
@ -224,7 +232,12 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.double", sizeof(double),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<double *>(buffer.data()), endian));
|
||||
hex::unused(style);
|
||||
|
||||
double result = 0;
|
||||
std::memcpy(&result, buffer.data(), sizeof(double));
|
||||
|
||||
auto value = hex::format("{0:G}", hex::changeEndianess(result, endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
},
|
||||
stringToFloat<double>
|
||||
@ -232,6 +245,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.long_double", sizeof(long double),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<long double *>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
},
|
||||
@ -240,10 +255,14 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii", sizeof(char8_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(endian, style);
|
||||
|
||||
auto value = makePrintable(*reinterpret_cast<char8_t *>(buffer.data()));
|
||||
return [value] { ImGui::TextFormatted("'{0}'", value.c_str()); return value; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
hex::unused(endian);
|
||||
|
||||
if (value.length() > 1) return { };
|
||||
|
||||
return { u8(value[0]) };
|
||||
@ -252,6 +271,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(wchar_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
wchar_t wideChar = '\x00';
|
||||
std::memcpy(&wideChar, buffer.data(), std::min(sizeof(wchar_t), buffer.size()));
|
||||
|
||||
@ -278,6 +299,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4,
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(endian, style);
|
||||
|
||||
char utf8Buffer[5] = { 0 };
|
||||
char codepointString[5] = { 0 };
|
||||
u32 codepoint = 0;
|
||||
@ -296,12 +319,14 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.string", 1,
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
Region currSelection = { 0 };
|
||||
hex::unused(endian, style);
|
||||
|
||||
Region currSelection = { 0, 0 };
|
||||
EventManager::post<QuerySelection>(currSelection);
|
||||
|
||||
constexpr static auto MaxStringLength = 32;
|
||||
|
||||
std::vector<u8> stringBuffer(std::min<ssize_t>(MaxStringLength, currSelection.size), 0x00);
|
||||
std::vector<u8> stringBuffer(std::min<size_t>(MaxStringLength, currSelection.size), 0x00);
|
||||
ImHexApi::Provider::get()->read(currSelection.address, stringBuffer.data(), stringBuffer.size());
|
||||
|
||||
auto value = hex::encodeByteString(stringBuffer);
|
||||
@ -313,6 +338,8 @@ namespace hex::plugin::builtin {
|
||||
return [value, copyValue] { ImGui::TextFormatted("\"{0}\"", value.c_str()); return copyValue; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
hex::unused(endian);
|
||||
|
||||
return hex::decodeByteString(value);
|
||||
}
|
||||
);
|
||||
@ -320,6 +347,8 @@ namespace hex::plugin::builtin {
|
||||
#if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<u32 *>(buffer.data()), endian);
|
||||
|
||||
std::string value;
|
||||
@ -333,6 +362,8 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(u64), [](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<u64 *>(buffer.data()), endian);
|
||||
|
||||
std::string value;
|
||||
@ -348,6 +379,8 @@ namespace hex::plugin::builtin {
|
||||
#else
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<time_t *>(buffer.data()), endian);
|
||||
|
||||
std::string value;
|
||||
@ -363,7 +396,9 @@ namespace hex::plugin::builtin {
|
||||
#endif
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.guid", sizeof(GUID), [](auto buffer, auto endian, auto style) {
|
||||
GUID guid = { 0 };
|
||||
hex::unused(style);
|
||||
|
||||
GUID guid = { };
|
||||
std::memcpy(&guid, buffer.data(), sizeof(GUID));
|
||||
auto value = hex::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
|
||||
(hex::changeEndianess(guid.data3, endian) >> 12) <= 5 && ((guid.data4[0] >> 4) >= 8 || (guid.data4[0] >> 4) == 0) ? "" : "Invalid ",
|
||||
@ -383,6 +418,8 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
hex::unused(style);
|
||||
|
||||
ImColor value(hex::changeEndianess(*reinterpret_cast<u32 *>(buffer.data()), endian));
|
||||
|
||||
auto copyValue = hex::format("#{:02X}{:02X}{:02X}{:02X}", u8(0xFF * (value.Value.x)), u8(0xFF * (value.Value.y)), u8(0xFF * (value.Value.z)), u8(0xFF * (value.Value.w)));
|
||||
|
@ -530,9 +530,9 @@ namespace hex::plugin::builtin {
|
||||
auto from = this->getIntegerOnInput(1);
|
||||
auto to = this->getIntegerOnInput(2);
|
||||
|
||||
if (from < 0 || from >= input.size())
|
||||
if (from < 0 || static_cast<u64>(from) >= input.size())
|
||||
throwNodeError("'from' input out of range");
|
||||
if (to < 0 || from >= input.size())
|
||||
if (to < 0 || static_cast<u64>(from) >= input.size())
|
||||
throwNodeError("'to' input out of range");
|
||||
if (to <= from)
|
||||
throwNodeError("'to' input needs to be greater than 'from' input");
|
||||
|
@ -75,12 +75,12 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* pack_size(...) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStd, "sizeof_pack", ParameterCount::atLeast(0), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStd, "sizeof_pack", ParameterCount::atLeast(0), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return u128(params.size());
|
||||
});
|
||||
|
||||
/* error(message) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStd, "error", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStd, "error", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
LogConsole::abortEvaluation(Token::literalToString(params[0], true));
|
||||
|
||||
return std::nullopt;
|
||||
@ -99,11 +99,15 @@ namespace hex::plugin::builtin {
|
||||
|
||||
/* base_address() */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMem, "base_address", ParameterCount::none(), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
hex::unused(params);
|
||||
|
||||
return u128(ctx->getProvider()->getBaseAddress());
|
||||
});
|
||||
|
||||
/* size() */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMem, "size", ParameterCount::none(), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
hex::unused(params);
|
||||
|
||||
return u128(ctx->getProvider()->getActualSize());
|
||||
});
|
||||
|
||||
@ -185,14 +189,14 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::PatternLanguage::Namespace nsStdString = { "builtin", "std", "string" };
|
||||
{
|
||||
/* length(string) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "length", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "length", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
auto string = Token::literalToString(params[0], false);
|
||||
|
||||
return u128(string.length());
|
||||
});
|
||||
|
||||
/* at(string, index) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "at", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "at", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
auto string = Token::literalToString(params[0], false);
|
||||
auto index = Token::literalToSigned(params[1]);
|
||||
|
||||
@ -213,7 +217,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* substr(string, pos, count) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "substr", ParameterCount::exactly(3), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "substr", ParameterCount::exactly(3), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
auto string = Token::literalToString(params[0], false);
|
||||
auto pos = Token::literalToUnsigned(params[1]);
|
||||
auto size = Token::literalToUnsigned(params[2]);
|
||||
@ -225,7 +229,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* parse_int(string, base) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "parse_int", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "parse_int", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
auto string = Token::literalToString(params[0], false);
|
||||
auto base = Token::literalToUnsigned(params[1]);
|
||||
|
||||
@ -233,7 +237,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* parse_float(string) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "parse_float", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdString, "parse_float", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
auto string = Token::literalToString(params[0], false);
|
||||
|
||||
return double(std::strtod(string.c_str(), nullptr));
|
||||
@ -243,7 +247,7 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::PatternLanguage::Namespace nsStdHttp = { "builtin", "std", "http" };
|
||||
{
|
||||
/* get(url) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdHttp, "get", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdHttp, "get", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto url = Token::literalToString(params[0], false);
|
||||
|
||||
hex::Net net;
|
||||
@ -258,7 +262,7 @@ namespace hex::plugin::builtin {
|
||||
static std::map<u32, fs::File> openFiles;
|
||||
|
||||
/* open(path, mode) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "open", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "open", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto path = Token::literalToString(params[0], false);
|
||||
const auto modeEnum = Token::literalToUnsigned(params[1]);
|
||||
|
||||
@ -289,7 +293,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* close(file) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "close", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "close", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
|
||||
if (!openFiles.contains(file))
|
||||
@ -301,7 +305,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* read(file, size) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "read", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "read", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
const auto size = Token::literalToUnsigned(params[1]);
|
||||
|
||||
@ -312,7 +316,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* write(file, data) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "write", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "write", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
const auto data = Token::literalToString(params[1], true);
|
||||
|
||||
@ -325,7 +329,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* seek(file, offset) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "seek", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "seek", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
const auto offset = Token::literalToUnsigned(params[1]);
|
||||
|
||||
@ -338,7 +342,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* size(file) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "size", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "size", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
|
||||
if (!openFiles.contains(file))
|
||||
@ -348,7 +352,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* resize(file, size) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "resize", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "resize", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
const auto size = Token::literalToUnsigned(params[1]);
|
||||
|
||||
@ -361,7 +365,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* flush(file) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "flush", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "flush", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
|
||||
if (!openFiles.contains(file))
|
||||
@ -373,7 +377,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
/* remove(file) */
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "remove", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "remove", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
const auto file = Token::literalToUnsigned(params[0]);
|
||||
|
||||
if (!openFiles.contains(file))
|
||||
@ -389,126 +393,126 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::PatternLanguage::Namespace nsStdMath = { "builtin", "std", "math" };
|
||||
{
|
||||
/* floor(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "floor", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "floor", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::floor(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* ceil(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "ceil", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "ceil", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::ceil(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* round(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "round", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "round", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::round(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* trunc(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "trunc", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "trunc", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::trunc(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
|
||||
/* log10(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "log10", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "log10", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::log10(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* log2(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "log2", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "log2", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::log2(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* ln(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "ln", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "ln", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::log(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
|
||||
/* fmod(x, y) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "fmod", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "fmod", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::fmod(Token::literalToFloatingPoint(params[0]), Token::literalToFloatingPoint(params[1]));
|
||||
});
|
||||
|
||||
/* pow(base, exp) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "pow", ParameterCount::exactly(2), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "pow", ParameterCount::exactly(2), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::pow(Token::literalToFloatingPoint(params[0]), Token::literalToFloatingPoint(params[1]));
|
||||
});
|
||||
|
||||
/* sqrt(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "sqrt", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "sqrt", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::sqrt(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* cbrt(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "cbrt", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "cbrt", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::cbrt(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
|
||||
/* sin(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "sin", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "sin", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::sin(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* cos(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "cos", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "cos", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::cos(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* tan(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "tan", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "tan", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::tan(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* asin(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "asin", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "asin", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::asin(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* acos(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "acos", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "acos", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::acos(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* atan(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atan", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atan", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::atan(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* atan2(y, x) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atan", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atan", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::atan2(Token::literalToFloatingPoint(params[0]), Token::literalToFloatingPoint(params[1]));
|
||||
});
|
||||
|
||||
|
||||
/* sinh(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "sinh", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "sinh", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::sinh(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* cosh(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "cosh", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "cosh", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::cosh(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* tanh(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "tanh", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "tanh", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::tanh(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* asinh(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "asinh", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "asinh", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::asinh(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* acosh(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "acosh", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "acosh", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::acosh(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
|
||||
/* atanh(value) */
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atanh", ParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atanh", ParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
|
||||
return std::atanh(Token::literalToFloatingPoint(params[0]));
|
||||
});
|
||||
}
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
#include <bitset>
|
||||
#include <filesystem>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include <fcntl.h>
|
||||
@ -82,7 +82,7 @@ namespace hex::plugin::builtin::prv {
|
||||
}
|
||||
|
||||
{
|
||||
DISK_GEOMETRY_EX diskGeometry = { 0 };
|
||||
DISK_GEOMETRY_EX diskGeometry = { };
|
||||
DWORD bytesRead = 0;
|
||||
if (DeviceIoControl(
|
||||
this->m_diskHandle,
|
||||
@ -113,8 +113,11 @@ namespace hex::plugin::builtin::prv {
|
||||
|
||||
struct stat driveStat;
|
||||
|
||||
::stat(path.c_str(), &driveStat) == 0;
|
||||
if (::stat(path.c_str(), &driveStat) == 0)
|
||||
this->m_diskSize = driveStat.st_size;
|
||||
else
|
||||
this->m_diskSize = 0;
|
||||
|
||||
this->m_sectorSize = 0;
|
||||
|
||||
this->m_diskHandle = ::open(path.c_str(), O_RDWR);
|
||||
@ -158,7 +161,7 @@ namespace hex::plugin::builtin::prv {
|
||||
seekPosition.LowPart = (offset & 0xFFFF'FFFF) - (offset % this->m_sectorSize);
|
||||
seekPosition.HighPart = offset >> 32;
|
||||
|
||||
if (this->m_sectorBufferAddress != seekPosition.QuadPart) {
|
||||
if (this->m_sectorBufferAddress != static_cast<u64>(seekPosition.QuadPart)) {
|
||||
::SetFilePointer(this->m_diskHandle, seekPosition.LowPart, &seekPosition.HighPart, FILE_BEGIN);
|
||||
::ReadFile(this->m_diskHandle, this->m_sectorBuffer.data(), this->m_sectorBuffer.size(), &bytesRead, nullptr);
|
||||
this->m_sectorBufferAddress = seekPosition.QuadPart;
|
||||
@ -177,7 +180,9 @@ namespace hex::plugin::builtin::prv {
|
||||
|
||||
if (this->m_sectorBufferAddress != seekPosition) {
|
||||
::lseek(this->m_diskHandle, seekPosition, SEEK_SET);
|
||||
::read(this->m_diskHandle, buffer, size);
|
||||
if (::read(this->m_diskHandle, buffer, size) < 0)
|
||||
break;
|
||||
|
||||
this->m_sectorBufferAddress = seekPosition;
|
||||
}
|
||||
|
||||
@ -231,7 +236,8 @@ namespace hex::plugin::builtin::prv {
|
||||
std::memcpy(modifiedSectorBuffer.data() + ((offset - sectorBase) % this->m_sectorSize), reinterpret_cast<const u8 *>(buffer) + (startOffset - offset), currSize);
|
||||
|
||||
::lseek(this->m_diskHandle, sectorBase, SEEK_SET);
|
||||
::write(this->m_diskHandle, modifiedSectorBuffer.data(), modifiedSectorBuffer.size());
|
||||
if (::write(this->m_diskHandle, modifiedSectorBuffer.data(), modifiedSectorBuffer.size()) < 0)
|
||||
break;
|
||||
|
||||
offset += currSize;
|
||||
size -= currSize;
|
||||
@ -272,7 +278,7 @@ namespace hex::plugin::builtin::prv {
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE) continue;
|
||||
|
||||
VOLUME_DISK_EXTENTS diskExtents = { 0 };
|
||||
VOLUME_DISK_EXTENTS diskExtents = { };
|
||||
DWORD bytesRead = 0;
|
||||
auto result = ::DeviceIoControl(
|
||||
handle,
|
||||
@ -314,7 +320,7 @@ namespace hex::plugin::builtin::prv {
|
||||
|
||||
#else
|
||||
|
||||
if (ImGui::InputText("hex.builtin.provider.disk.selected_disk"_lang, this->m_pathBuffer))
|
||||
if (ImGui::InputText("hex.builtin.provider.disk.selected_disk"_lang, this->m_pathBuffer.data(), this->m_pathBuffer.size(), ImGuiInputTextFlags_CallbackResize, ImGui::UpdateStringSizeCallback, &this->m_pathBuffer))
|
||||
this->m_path = this->m_pathBuffer;
|
||||
|
||||
#endif
|
||||
|
@ -111,7 +111,7 @@ namespace hex::plugin::builtin::prv {
|
||||
this->m_fileSize = file.getSize();
|
||||
}
|
||||
|
||||
this->open();
|
||||
(void)this->open();
|
||||
}
|
||||
|
||||
void FileProvider::insert(u64 offset, size_t size) {
|
||||
@ -171,7 +171,7 @@ namespace hex::plugin::builtin::prv {
|
||||
|
||||
this->m_fileStatsValid = wstat(path.c_str(), &this->m_fileStats) == 0;
|
||||
|
||||
LARGE_INTEGER fileSize = { 0 };
|
||||
LARGE_INTEGER fileSize = { };
|
||||
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
|
||||
|
||||
GetFileSizeEx(this->m_file, &fileSize);
|
||||
|
@ -218,6 +218,7 @@ namespace hex::plugin::builtin::prv {
|
||||
}
|
||||
|
||||
void GDBProvider::saveAs(const std::fs::path &path) {
|
||||
hex::unused(path);
|
||||
}
|
||||
|
||||
size_t GDBProvider::getActualSize() const {
|
||||
|
@ -238,7 +238,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::IconButton(ICON_VS_FOLDER_OPENED, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
||||
return fs::openFileBrowser("hex.builtin.setting.font.font_path", fs::DialogMode::Open, { {"TTF Font", "ttf"} },
|
||||
return fs::openFileBrowser(fs::DialogMode::Open, { {"TTF Font", "ttf"} },
|
||||
[&](const std::fs::path &path) {
|
||||
fontPath = path.string();
|
||||
setting = fontPath;
|
||||
@ -275,8 +275,10 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::Settings::addCategoryDescription(dirsSetting, "hex.builtin.setting.folders.description");
|
||||
|
||||
ContentRegistry::Settings::add(dirsSetting, dirsSetting, std::vector<std::string> {}, [](auto name, nlohmann::json &setting) {
|
||||
hex::unused(name);
|
||||
|
||||
static std::vector<std::string> folders = setting;
|
||||
static int currentItemIndex = 0;
|
||||
static size_t currentItemIndex = 0;
|
||||
|
||||
if (!ImGui::BeginListBox("", ImVec2(-38, -FLT_MIN))) {
|
||||
return false;
|
||||
@ -292,7 +294,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::BeginGroup();
|
||||
|
||||
if (ImGui::IconButton(ICON_VS_NEW_FOLDER, ImGui::GetCustomColorVec4(ImGuiCustomCol_DescButton), ImVec2(30, 30))) {
|
||||
fs::openFileBrowser("Select include folder", fs::DialogMode::Folder, {}, [&](const std::fs::path &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Folder, {}, [&](const std::fs::path &path) {
|
||||
auto pathStr = path.string();
|
||||
|
||||
if (std::find(folders.begin(), folders.end(), pathStr) == folders.end()) {
|
||||
|
@ -142,6 +142,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
evaluator.setFunction(
|
||||
"clear", [&](auto args) -> std::optional<long double> {
|
||||
hex::unused(args);
|
||||
|
||||
mathHistory.clear();
|
||||
lastMathError.clear();
|
||||
mathEvaluator.getVariables().clear();
|
||||
@ -185,16 +187,16 @@ namespace hex::plugin::builtin {
|
||||
2,
|
||||
2);
|
||||
|
||||
return std::move(evaluator);
|
||||
return evaluator;
|
||||
}();
|
||||
|
||||
enum class MathDisplayType
|
||||
{
|
||||
enum class MathDisplayType : u8 {
|
||||
Standard,
|
||||
Scientific,
|
||||
Engineering,
|
||||
Programmer
|
||||
} mathDisplayType;
|
||||
} mathDisplayType = MathDisplayType::Standard;
|
||||
|
||||
if (ImGui::BeginTabBar("##mathFormatTabBar")) {
|
||||
if (ImGui::BeginTabItem("hex.builtin.tools.format.standard"_lang)) {
|
||||
mathDisplayType = MathDisplayType::Standard;
|
||||
@ -235,8 +237,10 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::Button("CE", buttonSize)) mathInput.clear();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_BACKSPACE, buttonSize)) mathInput.clear();
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::NewLine();
|
||||
|
||||
switch (mathDisplayType) {
|
||||
case MathDisplayType::Standard:
|
||||
case MathDisplayType::Scientific:
|
||||
@ -339,7 +343,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::TableHeadersRow();
|
||||
while (clipper.Step()) {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
if (i == 0)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImU32(ImColor(0xA5, 0x45, 0x45)));
|
||||
|
||||
@ -438,7 +442,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void drawBaseConverter() {
|
||||
static char buffer[4][0xFFF] = { { '0' }, { '0' }, { '0' }, { '0' } };
|
||||
static char buffer[4][0x1000] = { { '0' }, { '0' }, { '0' }, { '0' } };
|
||||
|
||||
static auto CharFilter = [](ImGuiInputTextCallbackData *data) -> int {
|
||||
switch (*static_cast<u32 *>(data->UserData)) {
|
||||
@ -481,10 +485,15 @@ namespace hex::plugin::builtin {
|
||||
auto base8String = hex::format("{0:#o}", number);
|
||||
auto base2String = hex::toBinaryString(number);
|
||||
|
||||
std::strncpy(buffer[0], base10String.c_str(), sizeof(buffer[0]));
|
||||
std::strncpy(buffer[1], base16String.c_str(), sizeof(buffer[1]));
|
||||
std::strncpy(buffer[2], base8String.c_str(), sizeof(buffer[2]));
|
||||
std::strncpy(buffer[3], base2String.c_str(), sizeof(buffer[3]));
|
||||
std::strncpy(buffer[0], base10String.c_str(), sizeof(buffer[0]) - 1);
|
||||
std::strncpy(buffer[1], base16String.c_str(), sizeof(buffer[1]) - 1);
|
||||
std::strncpy(buffer[2], base8String.c_str(), sizeof(buffer[2]) - 1);
|
||||
std::strncpy(buffer[3], base2String.c_str(), sizeof(buffer[3]) - 1);
|
||||
|
||||
buffer[0][0xFFF] = '\x00';
|
||||
buffer[1][0xFFF] = '\x00';
|
||||
buffer[2][0xFFF] = '\x00';
|
||||
buffer[3][0xFFF] = '\x00';
|
||||
};
|
||||
|
||||
u8 base = 10;
|
||||
@ -579,7 +588,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::Header("hex.builtin.tools.file_uploader.control"_lang, true);
|
||||
if (!uploading) {
|
||||
if (ImGui::Button("hex.builtin.tools.file_uploader.upload"_lang)) {
|
||||
fs::openFileBrowser("hex.builtin.tools.file_uploader.done"_lang, fs::DialogMode::Open, {}, [&](auto path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [&](auto path) {
|
||||
uploadProcess = net.uploadFile("https://api.anonfiles.com/upload", path);
|
||||
currFile = path;
|
||||
});
|
||||
@ -678,7 +687,7 @@ namespace hex::plugin::builtin {
|
||||
startSearch = ImGui::InputText("##search", searchString, ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::BeginDisabled(searchProcess.valid() && searchProcess.wait_for(0s) != std::future_status::ready || searchString.empty());
|
||||
ImGui::BeginDisabled((searchProcess.valid() && searchProcess.wait_for(0s) != std::future_status::ready) || searchString.empty());
|
||||
startSearch = ImGui::Button("hex.builtin.tools.wiki_explain.search"_lang) || startSearch;
|
||||
ImGui::EndDisabled();
|
||||
|
||||
@ -744,7 +753,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InputText("##path", selectedFile);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("...")) {
|
||||
fs::openFileBrowser("hex.builtin.tools.file_tools.shredder.picker"_lang, fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
selectedFile = path.string();
|
||||
});
|
||||
}
|
||||
@ -886,7 +895,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InputText("##path", selectedFile);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("...##input")) {
|
||||
fs::openFileBrowser("hex.builtin.tools.file_tools.splitter.picker.input"_lang, fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
selectedFile = path.string();
|
||||
});
|
||||
}
|
||||
@ -896,7 +905,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InputText("##base_path", baseOutputPath);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("...##output")) {
|
||||
fs::openFileBrowser("hex.builtin.tools.file_tools.splitter.picker.output"_lang, fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
baseOutputPath = path.string();
|
||||
});
|
||||
}
|
||||
@ -979,7 +988,7 @@ namespace hex::plugin::builtin {
|
||||
static bool combining = false;
|
||||
static std::vector<std::string> files;
|
||||
static auto outputPath = [] { std::string s; s.reserve(0x1000); return s; }();
|
||||
static i32 selectedIndex;
|
||||
static u32 selectedIndex;
|
||||
|
||||
if (ImGui::BeginTable("files_table", 2, ImGuiTableFlags_SizingStretchProp)) {
|
||||
ImGui::TableSetupColumn("file list", ImGuiTableColumnFlags_NoHeaderLabel, 10);
|
||||
@ -989,7 +998,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::BeginListBox("##files", { -FLT_MIN, 10 * ImGui::GetTextLineHeightWithSpacing() })) {
|
||||
|
||||
i32 index = 0;
|
||||
u32 index = 0;
|
||||
for (auto &file : files) {
|
||||
if (ImGui::Selectable(std::fs::path(file).filename().string().c_str(), index == selectedIndex))
|
||||
selectedIndex = index;
|
||||
@ -1025,7 +1034,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::BeginDisabled(combining);
|
||||
{
|
||||
if (ImGui::Button("hex.builtin.tools.file_tools.combiner.add"_lang)) {
|
||||
fs::openFileBrowser("hex.builtin.tools.file_tools.combiner.add.picker"_lang, fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
files.push_back(path.string());
|
||||
});
|
||||
}
|
||||
@ -1049,7 +1058,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InputText("##output_path", outputPath);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("...")) {
|
||||
fs::openFileBrowser("hex.builtin.tools.file_tools.combiner.output.picker"_lang, fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
outputPath = path.string();
|
||||
});
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ namespace hex::plugin::builtin {
|
||||
// Save file as
|
||||
ImGui::Disabled([&provider] {
|
||||
if (ImGui::ToolBarButton(ICON_VS_SAVE_AS, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue)))
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.save_as"_lang, fs::DialogMode::Save, {}, [&provider](auto path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [&provider](auto path) {
|
||||
provider->saveAs(path);
|
||||
});
|
||||
},
|
||||
@ -118,7 +118,7 @@ namespace hex::plugin::builtin {
|
||||
// Create bookmark
|
||||
ImGui::Disabled([] {
|
||||
if (ImGui::ToolBarButton(ICON_VS_BOOKMARK, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarGreen))) {
|
||||
Region region = { 0 };
|
||||
Region region = { };
|
||||
EventManager::post<QuerySelection>(region);
|
||||
|
||||
ImHexApi::Bookmarks::add(region.address, region.size, {}, {});
|
||||
@ -141,7 +141,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::SetNextItemWidth(200_scaled);
|
||||
if (ImGui::BeginCombo("", preview.c_str())) {
|
||||
|
||||
for (int i = 0; i < providers.size(); i++) {
|
||||
for (size_t i = 0; i < providers.size(); i++) {
|
||||
if (ImGui::Selectable(providers[i]->getName().c_str())) {
|
||||
ImHexApi::Provider::setCurrentProvider(i);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ namespace hex::plugin::builtin {
|
||||
clipper.Begin(this->m_filterIndices.size());
|
||||
|
||||
while (clipper.Step()) {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
auto &constant = this->m_constants[this->m_filterIndices[i]];
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
@ -42,6 +42,8 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventFileLoaded>(this, [this](const std::fs::path &path) {
|
||||
hex::unused(path);
|
||||
|
||||
for (auto &node : this->m_nodes) {
|
||||
node->setCurrentOverlay(nullptr);
|
||||
}
|
||||
@ -56,7 +58,7 @@ namespace hex::plugin::builtin {
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.load_processor"_lang, nullptr, false, providerValid)) {
|
||||
fs::openFileBrowser("hex.builtin.view.data_processor.menu.file.load_processor"_lang, fs::DialogMode::Open, { {"hex.builtin.view.data_processor.name"_lang, "hexnode"} },
|
||||
fs::openFileBrowser(fs::DialogMode::Open, { {"hex.builtin.view.data_processor.name"_lang, "hexnode"} },
|
||||
[this](const std::fs::path &path) {
|
||||
fs::File file(path, fs::File::Mode::Read);
|
||||
if (file.isValid())
|
||||
@ -65,7 +67,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.save_processor"_lang, nullptr, false, !this->m_nodes.empty() && providerValid)) {
|
||||
fs::openFileBrowser("hex.builtin.view.data_processor.menu.file.save_processor"_lang, fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode"} },
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode"} },
|
||||
[this](const std::fs::path &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
if (file.isValid())
|
||||
@ -114,7 +116,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void ViewDataProcessor::eraseNodes(const std::vector<int> &ids) {
|
||||
for (const int id : ids) {
|
||||
for (u32 id : ids) {
|
||||
auto node = std::find_if(this->m_nodes.begin(), this->m_nodes.end(), [&id](auto node) { return node->getId() == id; });
|
||||
|
||||
for (auto &attr : (*node)->getAttributes()) {
|
||||
@ -127,7 +129,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
for (const int id : ids) {
|
||||
for (u32 id : ids) {
|
||||
auto node = std::find_if(this->m_nodes.begin(), this->m_nodes.end(), [&id](auto node) { return node->getId() == id; });
|
||||
|
||||
std::erase_if(this->m_endNodes, [&id](auto node) { return node->getId() == id; });
|
||||
@ -275,7 +277,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
{
|
||||
int nodeId;
|
||||
if (ImNodes::IsNodeHovered(&nodeId) && this->m_currNodeError.has_value() && this->m_currNodeError->first->getId() == nodeId) {
|
||||
if (ImNodes::IsNodeHovered(&nodeId) && this->m_currNodeError.has_value() && this->m_currNodeError->first->getId() == static_cast<u32>(nodeId)) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextUnformatted("hex.builtin.common.error"_lang);
|
||||
ImGui::Separator();
|
||||
@ -305,6 +307,7 @@ namespace hex::plugin::builtin {
|
||||
ImNodesPinShape pinShape;
|
||||
|
||||
switch (attribute.getType()) {
|
||||
default:
|
||||
case dp::Attribute::Type::Integer:
|
||||
pinShape = ImNodesPinShape_Circle;
|
||||
break;
|
||||
@ -366,9 +369,9 @@ namespace hex::plugin::builtin {
|
||||
dp::Attribute *fromAttr, *toAttr;
|
||||
for (auto &node : this->m_nodes) {
|
||||
for (auto &attribute : node->getAttributes()) {
|
||||
if (attribute.getId() == from)
|
||||
if (attribute.getId() == static_cast<u32>(from))
|
||||
fromAttr = &attribute;
|
||||
else if (attribute.getId() == to)
|
||||
else if (attribute.getId() == static_cast<u32>(to))
|
||||
toAttr = &attribute;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::SetNextItemWidth(200_scaled);
|
||||
if (ImGui::BeginCombo("", preview.c_str())) {
|
||||
|
||||
for (int i = 0; i < providers.size(); i++) {
|
||||
for (size_t i = 0; i < providers.size(); i++) {
|
||||
if (ImGui::Selectable(providers[i]->getName().c_str())) {
|
||||
provider = i;
|
||||
}
|
||||
@ -130,7 +130,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableNextColumn();
|
||||
auto other = !curr;
|
||||
|
||||
std::optional<ImVec2> lastHighlightEnd;
|
||||
bool hasLastHighlight = false;
|
||||
ImVec2 lastHighlightEnd = { };
|
||||
|
||||
for (i64 col = 0; col < lineInfo[curr].validBytes; col++) {
|
||||
auto pos = ImGui::GetCursorScreenPos();
|
||||
@ -162,10 +163,15 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Draw highlighting
|
||||
if (highlightColor.has_value()) {
|
||||
drawList->AddRectFilled(lastHighlightEnd.value_or(pos), pos + highlightSize, highlightColor.value());
|
||||
if (hasLastHighlight)
|
||||
drawList->AddRectFilled(lastHighlightEnd, pos + highlightSize, highlightColor.value());
|
||||
else
|
||||
drawList->AddRectFilled(pos, pos + highlightSize, highlightColor.value());
|
||||
|
||||
hasLastHighlight = true;
|
||||
lastHighlightEnd = pos + ImVec2((glyphWidth - 1) * 2, 0);
|
||||
} else {
|
||||
lastHighlightEnd.reset();
|
||||
hasLastHighlight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,7 +223,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Draw diff lines
|
||||
while (clipper.Step()) {
|
||||
for (u64 row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
|
||||
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
|
||||
ImGui::TableNextRow();
|
||||
drawDiffLine({ this->m_providerA, this->m_providerB }, row);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace hex::plugin::builtin {
|
||||
u64 usedBytes = 0;
|
||||
for (u32 i = 0; i < instructionCount; i++) {
|
||||
const auto &instr = instructions[i];
|
||||
Disassembly disassembly = { 0 };
|
||||
Disassembly disassembly = { };
|
||||
disassembly.address = instr.address;
|
||||
disassembly.offset = this->m_codeRegion[0] + address + usedBytes;
|
||||
disassembly.size = instr.size;
|
||||
@ -169,7 +169,7 @@ namespace hex::plugin::builtin {
|
||||
static bool microMode;
|
||||
ImGui::Checkbox("hex.builtin.view.disassembler.mips.micro"_lang, µMode);
|
||||
|
||||
this->m_mode = cs_mode(mode | (microMode ? CS_MODE_MICRO : 0));
|
||||
this->m_mode = cs_mode(mode | (microMode ? CS_MODE_MICRO : cs_mode(0)));
|
||||
}
|
||||
break;
|
||||
case Architecture::X86:
|
||||
@ -198,7 +198,7 @@ namespace hex::plugin::builtin {
|
||||
static bool booke = false;
|
||||
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.booke"_lang, &booke);
|
||||
|
||||
this->m_mode = cs_mode(mode | (qpx ? CS_MODE_QPX : 0) | (spe ? CS_MODE_SPE : 0) | (booke ? CS_MODE_BOOKE : 0));
|
||||
this->m_mode = cs_mode(mode | (qpx ? CS_MODE_QPX : cs_mode(0)) | (spe ? CS_MODE_SPE : cs_mode(0)) | (booke ? CS_MODE_BOOKE : cs_mode(0)));
|
||||
}
|
||||
break;
|
||||
case Architecture::SPARC:
|
||||
@ -206,7 +206,7 @@ namespace hex::plugin::builtin {
|
||||
static bool v9Mode = false;
|
||||
ImGui::Checkbox("hex.builtin.view.disassembler.sparc.v9"_lang, &v9Mode);
|
||||
|
||||
this->m_mode = cs_mode(v9Mode ? CS_MODE_V9 : 0);
|
||||
this->m_mode = cs_mode(v9Mode ? CS_MODE_V9 : cs_mode(0));
|
||||
}
|
||||
break;
|
||||
case Architecture::RISCV:
|
||||
@ -219,7 +219,7 @@ namespace hex::plugin::builtin {
|
||||
static bool compressed = false;
|
||||
ImGui::Checkbox("hex.builtin.view.disassembler.riscv.compressed"_lang, &compressed);
|
||||
|
||||
this->m_mode = cs_mode(mode | (compressed ? CS_MODE_RISCVC : 0));
|
||||
this->m_mode = cs_mode(mode | (compressed ? CS_MODE_RISCVC : cs_mode(0)));
|
||||
}
|
||||
break;
|
||||
case Architecture::M68K:
|
||||
@ -351,7 +351,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::TableHeadersRow();
|
||||
while (clipper.Step()) {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
const auto &instruction = this->m_disassembly[i];
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
@ -34,7 +34,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
template<size_t Size>
|
||||
static void formatBigHexInt(std::array<u8, Size> dataArray, char *buffer, size_t bufferSize) {
|
||||
for (int i = 0; i < dataArray.size(); i++)
|
||||
for (size_t i = 0; i < dataArray.size(); i++)
|
||||
snprintf(buffer + 2 * i, bufferSize - 2 * i, "%02X", dataArray[i]);
|
||||
}
|
||||
|
||||
@ -64,8 +64,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, hashFunctionNames[this->m_currHashFunction].second, 0)) {
|
||||
for (int i = 0; i < hashFunctionNames.size(); i++) {
|
||||
bool is_selected = (this->m_currHashFunction == i);
|
||||
for (size_t i = 0; i < hashFunctionNames.size(); i++) {
|
||||
bool is_selected = (static_cast<size_t>(this->m_currHashFunction) == i);
|
||||
if (ImGui::Selectable(hashFunctionNames[i].second, is_selected))
|
||||
this->m_currHashFunction = i;
|
||||
if (is_selected)
|
||||
|
@ -39,7 +39,7 @@ namespace hex::plugin::builtin {
|
||||
return true;
|
||||
});
|
||||
|
||||
this->m_memoryEditor.ReadFn = [](const ImU8 *data, size_t off) -> ImU8 {
|
||||
this->m_memoryEditor.ReadFn = [](const ImU8 *, size_t off) -> ImU8 {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
if (!provider->isAvailable() || !provider->isReadable())
|
||||
return 0x00;
|
||||
@ -50,7 +50,7 @@ namespace hex::plugin::builtin {
|
||||
return byte;
|
||||
};
|
||||
|
||||
this->m_memoryEditor.WriteFn = [](ImU8 *data, size_t off, ImU8 d) -> void {
|
||||
this->m_memoryEditor.WriteFn = [](ImU8 *, size_t off, ImU8 d) -> void {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
if (!provider->isAvailable() || !provider->isWritable())
|
||||
return;
|
||||
@ -269,7 +269,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
static void saveAs() {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.save_as"_lang, fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
ImHexApi::Provider::get()->saveAs(path);
|
||||
});
|
||||
}
|
||||
@ -299,7 +299,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InputText("##nolabel", this->m_loaderScriptScriptPath.data(), this->m_loaderScriptScriptPath.length(), ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("hex.builtin.view.hex_editor.script.script"_lang)) {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.script.script.title"_lang, fs::DialogMode::Open, { {"Python Script", "py"} },
|
||||
fs::openFileBrowser(fs::DialogMode::Open, { {"Python Script", "py"} },
|
||||
[this](const auto &path) {
|
||||
this->m_loaderScriptScriptPath = path.string();
|
||||
});
|
||||
@ -307,7 +307,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InputText("##nolabel", this->m_loaderScriptFilePath.data(), this->m_loaderScriptFilePath.length(), ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("hex.builtin.view.hex_editor.script.file"_lang)) {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.script.file.title"_lang, fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
this->m_loaderScriptFilePath = path.string();
|
||||
});
|
||||
}
|
||||
@ -801,7 +801,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
bool bytesSelected = this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1;
|
||||
bool bytesSelected = this->m_memoryEditor.DataPreviewAddr != static_cast<size_t>(-1) && this->m_memoryEditor.DataPreviewAddrEnd != static_cast<size_t>(-1);
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.edit.copy"_lang, "CTRL + C", false, bytesSelected))
|
||||
this->copyBytes();
|
||||
@ -834,7 +834,9 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.edit.bookmark"_lang, nullptr, false, this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.edit.bookmark"_lang, nullptr, false,
|
||||
this->m_memoryEditor.DataPreviewAddr != static_cast<size_t>(-1) && this->m_memoryEditor.DataPreviewAddrEnd != static_cast<size_t>(-1)))
|
||||
{
|
||||
auto base = provider->getBaseAddress();
|
||||
|
||||
size_t start = base + std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
|
||||
@ -898,7 +900,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
EventManager::subscribe<RequestOpenWindow>(this, [this](const std::string &name) {
|
||||
if (name == "Create File") {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.create_file"_lang, fs::DialogMode::Save, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [this](const auto &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
|
||||
if (!file.isValid()) {
|
||||
@ -912,12 +914,12 @@ namespace hex::plugin::builtin {
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
} else if (name == "Open File") {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.open_file"_lang, fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
} else if (name == "Open Project") {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.open_project"_lang, fs::DialogMode::Open, { {"Project File", "hexproj"} },
|
||||
fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"} },
|
||||
[this](const auto &path) {
|
||||
ProjectFile::load(path);
|
||||
this->getWindowOpenState() = true;
|
||||
@ -1033,7 +1035,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
ShortcutManager::addShortcut(this, CTRL + Keys::O, [] {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.open_file"_lang, fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
});
|
||||
});
|
||||
@ -1092,7 +1094,7 @@ namespace hex::plugin::builtin {
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.open_project"_lang, "")) {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.menu.file.open_project"_lang, fs::DialogMode::Open, { {"Project File", "hexproj"}
|
||||
fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"}
|
||||
},
|
||||
[](const auto &path) {
|
||||
ProjectFile::load(path);
|
||||
@ -1101,7 +1103,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.save_project"_lang, "", false, providerValid && provider->isWritable())) {
|
||||
if (ProjectFile::getProjectFilePath() == "") {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.save_project"_lang, fs::DialogMode::Save, { {"Project File", "hexproj"}
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"Project File", "hexproj"}
|
||||
},
|
||||
[](std::fs::path path) {
|
||||
if (path.extension() != ".hexproj") {
|
||||
@ -1142,7 +1144,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hex_editor.menu.file.import"_lang)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.import.base64"_lang)) {
|
||||
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.menu.file.import.base64"_lang, fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
fs::File file(path, fs::File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hex_editor.error.open"_lang);
|
||||
@ -1167,7 +1169,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.import.ips"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.open_file"_lang, fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, path] {
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hex_editor.processing", 0);
|
||||
@ -1195,7 +1197,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.import.ips32"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.open_file"_lang, fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [this](const auto &path) {
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, path] {
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hex_editor.processing", 0);
|
||||
@ -1250,7 +1252,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_processingImportExport = false;
|
||||
|
||||
ImHexApi::Tasks::doLater([this] {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.menu.file.export.title"_lang, fs::DialogMode::Save, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [this](const auto &path) {
|
||||
auto file = fs::File(path, fs::File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hex_editor.error.create"_lang);
|
||||
@ -1279,7 +1281,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_processingImportExport = false;
|
||||
|
||||
ImHexApi::Tasks::doLater([this] {
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.menu.file.export.title"_lang, fs::DialogMode::Save, {}, [this](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [this](const auto &path) {
|
||||
auto file = fs::File(path, fs::File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hex_editor.error.create"_lang);
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <cinttypes>
|
||||
#include <filesystem>
|
||||
#include <numeric>
|
||||
#include <span>
|
||||
@ -156,7 +157,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (this->m_dataValid) {
|
||||
|
||||
ImGui::LabelText("hex.builtin.view.information.region"_lang, "0x%llx - 0x%llx", this->m_analyzedRegion.first, this->m_analyzedRegion.second);
|
||||
ImGui::LabelText("hex.builtin.view.information.region"_lang, "%s", hex::format("0x{:X} - 0x{:X}", this->m_analyzedRegion.first, this->m_analyzedRegion.second).c_str());
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <hex/pattern_language/preprocessor.hpp>
|
||||
#include <hex/pattern_language/patterns/pattern.hpp>
|
||||
#include <hex/pattern_language/ast/ast_node.hpp>
|
||||
#include <hex/pattern_language/ast/ast_node_variable_decl.hpp>
|
||||
#include <hex/pattern_language/ast/ast_node_type_decl.hpp>
|
||||
#include <hex/pattern_language/ast/ast_node_builtin_type.hpp>
|
||||
@ -101,6 +100,8 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventFileLoaded>(this, [this](const std::fs::path &path) {
|
||||
hex::unused(path);
|
||||
|
||||
if (!ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_load_patterns", 1))
|
||||
return;
|
||||
|
||||
@ -217,7 +218,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, nullptr, false, providerValid)) {
|
||||
fs::openFileBrowser("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, fs::DialogMode::Save, { {"Pattern", "hexpat"} },
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"Pattern", "hexpat"} },
|
||||
[this](const auto &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
|
||||
@ -379,7 +380,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::BeginChild("##console", size, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar)) {
|
||||
ImGuiListClipper clipper(this->m_console.size());
|
||||
while (clipper.Step())
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
const auto &[level, message] = this->m_console[i];
|
||||
|
||||
switch (level) {
|
||||
@ -639,7 +640,8 @@ namespace hex::plugin::builtin {
|
||||
PatternVariable variable = {
|
||||
.inVariable = variableDecl->isInVariable(),
|
||||
.outVariable = variableDecl->isOutVariable(),
|
||||
.type = builtinType->getType()
|
||||
.type = builtinType->getType(),
|
||||
.value = { }
|
||||
};
|
||||
|
||||
if (variable.inVariable || variable.outVariable) {
|
||||
|
@ -81,7 +81,7 @@ namespace hex::plugin::builtin {
|
||||
if (buffer[i] >= ' ' && buffer[i] <= '~' && offset < provider->getActualSize() - 1)
|
||||
foundCharacters++;
|
||||
else {
|
||||
if (foundCharacters >= this->m_minimumLength) {
|
||||
if (foundCharacters >= static_cast<u32>(this->m_minimumLength)) {
|
||||
FoundString foundString = {
|
||||
offset + i - foundCharacters + provider->getBaseAddress(),
|
||||
foundCharacters
|
||||
@ -212,7 +212,7 @@ namespace hex::plugin::builtin {
|
||||
clipper.Begin(this->m_filterIndices.size());
|
||||
|
||||
while (clipper.Step()) {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
auto &foundString = this->m_foundStrings[this->m_filterIndices[i]];
|
||||
auto string = readString(foundString);
|
||||
|
||||
|
@ -2,18 +2,14 @@
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <yara.h>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
|
||||
#include <hex/helpers/fs.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
ViewYara::ViewYara() : View("hex.builtin.view.yara.name") {
|
||||
@ -94,7 +90,7 @@ namespace hex::plugin::builtin {
|
||||
clipper.Begin(this->m_matches.size());
|
||||
|
||||
while (clipper.Step()) {
|
||||
for (u32 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
auto &[identifier, variableName, address, size, wholeDataMatch, highlightId] = this->m_matches[i];
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
@ -133,7 +129,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::BeginChild("##console", consoleSize, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar)) {
|
||||
ImGuiListClipper clipper(this->m_consoleMessages.size());
|
||||
while (clipper.Step())
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
const auto &message = this->m_consoleMessages[i];
|
||||
|
||||
if (ImGui::Selectable(message.c_str()))
|
||||
@ -189,7 +185,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
yr_compiler_set_include_callback(
|
||||
compiler,
|
||||
[](const char *includeName, const char *callingRuleFileName, const char *callingRuleNamespace, void *userData) -> const char * {
|
||||
[](const char *includeName, const char *, const char *, void *userData) -> const char * {
|
||||
auto currFilePath = static_cast<const char *>(userData);
|
||||
|
||||
fs::File file((std::fs::path(currFilePath).parent_path() / includeName).string(), fs::File::Mode::Read);
|
||||
@ -204,6 +200,8 @@ namespace hex::plugin::builtin {
|
||||
return buffer;
|
||||
},
|
||||
[](const char *ptr, void *userData) {
|
||||
hex::unused(userData);
|
||||
|
||||
delete[] ptr;
|
||||
},
|
||||
this->m_rules[this->m_selectedRule].second.data());
|
||||
@ -257,6 +255,8 @@ namespace hex::plugin::builtin {
|
||||
return context.buffer.data();
|
||||
};
|
||||
iterator.file_size = [](auto *iterator) -> u64 {
|
||||
hex::unused(iterator);
|
||||
|
||||
return ImHexApi::Provider::get()->getActualSize();
|
||||
};
|
||||
|
||||
@ -310,11 +310,11 @@ namespace hex::plugin::builtin {
|
||||
if (rule->strings != nullptr) {
|
||||
yr_rule_strings_foreach(rule, string) {
|
||||
yr_string_matches_foreach(context, string, match) {
|
||||
results.newMatches.push_back({ rule->identifier, string->identifier, u64(match->offset), size_t(match->match_length), false });
|
||||
results.newMatches.push_back({ rule->identifier, string->identifier, u64(match->offset), size_t(match->match_length), false, 0 });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
results.newMatches.push_back({ rule->identifier, "", 0, 0, true });
|
||||
results.newMatches.push_back({ rule->identifier, "", 0, 0, true, 0 });
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -200,7 +200,7 @@ namespace hex::plugin::builtin {
|
||||
clipper.Begin(plugins.size());
|
||||
|
||||
while (clipper.Step()) {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
const auto &plugin = plugins[i];
|
||||
|
||||
ImGui::TableNextRow();
|
||||
@ -420,7 +420,7 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1050, [&] {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.open_file"_lang, "CTRL + O")) {
|
||||
|
||||
fs::openFileBrowser("hex.builtin.view.hex_editor.open_file"_lang, fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
});
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace hex {
|
||||
if (currToken.type == TokenType::Number || currToken.type == TokenType::Variable || currToken.type == TokenType::Function)
|
||||
outputQueue.push(currToken);
|
||||
else if (currToken.type == TokenType::Operator) {
|
||||
while ((!operatorStack.empty()) && (operatorStack.top().type == TokenType::Operator && currToken.type == TokenType::Operator && (comparePrecedence(operatorStack.top().op, currToken.op) > 0) || (comparePrecedence(operatorStack.top().op, currToken.op) == 0 && isLeftAssociative(currToken.op))) && operatorStack.top().type != TokenType::Bracket) {
|
||||
while ((!operatorStack.empty()) && ((operatorStack.top().type == TokenType::Operator && currToken.type == TokenType::Operator && (comparePrecedence(operatorStack.top().op, currToken.op) > 0)) || (comparePrecedence(operatorStack.top().op, currToken.op) == 0 && isLeftAssociative(currToken.op))) && operatorStack.top().type != TokenType::Bracket) {
|
||||
outputQueue.push(operatorStack.top());
|
||||
operatorStack.pop();
|
||||
}
|
||||
@ -109,12 +109,12 @@ namespace hex {
|
||||
number = std::strtoull(pos, &pos, 0);
|
||||
}
|
||||
|
||||
inputQueue.push(Token { .type = TokenType::Number, .number = number });
|
||||
inputQueue.push(Token { .type = TokenType::Number, .number = number, .name = "", .arguments = { } });
|
||||
} else if (*pos == '(') {
|
||||
inputQueue.push(Token { .type = TokenType::Bracket, .bracketType = BracketType::Left });
|
||||
inputQueue.push(Token { .type = TokenType::Bracket, .bracketType = BracketType::Left, .name = "", .arguments = { } });
|
||||
pos++;
|
||||
} else if (*pos == ')') {
|
||||
inputQueue.push(Token { .type = TokenType::Bracket, .bracketType = BracketType::Right });
|
||||
inputQueue.push(Token { .type = TokenType::Bracket, .bracketType = BracketType::Right, .name = "", .arguments = { } });
|
||||
pos++;
|
||||
} else if (std::isspace(*pos)) {
|
||||
pos++;
|
||||
@ -122,7 +122,7 @@ namespace hex {
|
||||
auto [op, width] = toOperator(pos);
|
||||
|
||||
if (op != Operator::Invalid) {
|
||||
inputQueue.push(Token { .type = TokenType::Operator, .op = op });
|
||||
inputQueue.push(Token { .type = TokenType::Operator, .op = op, .name = "", .arguments = { } });
|
||||
pos += width;
|
||||
} else {
|
||||
Token token;
|
||||
|
@ -27,3 +27,4 @@ endif()
|
||||
|
||||
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
|
@ -37,5 +37,6 @@ if (WIN32)
|
||||
|
||||
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
|
||||
|
||||
endif ()
|
@ -1,7 +1,6 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
@ -14,18 +13,6 @@
|
||||
|
||||
namespace hex::plugin::windows {
|
||||
|
||||
static ULONGLONG subtractTimes(const FILETIME &left, const FILETIME &right) {
|
||||
LARGE_INTEGER a, b;
|
||||
|
||||
a.LowPart = left.dwLowDateTime;
|
||||
a.HighPart = left.dwHighDateTime;
|
||||
|
||||
b.LowPart = right.dwLowDateTime;
|
||||
b.HighPart = right.dwHighDateTime;
|
||||
|
||||
return a.QuadPart - b.QuadPart;
|
||||
}
|
||||
|
||||
void addTitleBarButtons() {
|
||||
#if defined(DEBUG)
|
||||
ContentRegistry::Interface::addTitleBarButton(ICON_VS_DEBUG, "hex.windows.title_bar_button.debug_build", []{
|
||||
@ -59,8 +46,9 @@ namespace hex::plugin::windows {
|
||||
static u32 numProcessors;
|
||||
static HANDLE self = GetCurrentProcess();
|
||||
|
||||
FILETIME ftime, fsys, fuser;
|
||||
ULARGE_INTEGER now, sys, user;
|
||||
{
|
||||
FILETIME ftime, fsys, fuser;
|
||||
|
||||
GetSystemTimeAsFileTime(&ftime);
|
||||
memcpy(&now, &ftime, sizeof(FILETIME));
|
||||
@ -68,6 +56,7 @@ namespace hex::plugin::windows {
|
||||
GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
|
||||
memcpy(&sys, &fsys, sizeof(FILETIME));
|
||||
memcpy(&user, &fuser, sizeof(FILETIME));
|
||||
}
|
||||
|
||||
if (lastCPU.QuadPart == 0) {
|
||||
SYSTEM_INFO sysInfo;
|
||||
|
@ -40,6 +40,8 @@ namespace hex::plugin::windows {
|
||||
|
||||
ImGui::Combo(
|
||||
"hex.windows.view.tty_console.baud"_lang, &this->m_selectedBaudRate, [](void *data, int idx, const char **out_text) -> bool {
|
||||
hex::unused(data);
|
||||
|
||||
*out_text = ViewTTYConsole::BaudRates[idx];
|
||||
return true;
|
||||
},
|
||||
@ -48,6 +50,7 @@ namespace hex::plugin::windows {
|
||||
|
||||
ImGui::Combo(
|
||||
"hex.windows.view.tty_console.num_bits"_lang, &this->m_selectedNumBits, [](void *data, int idx, const char **out_text) -> bool {
|
||||
hex::unused(data);
|
||||
*out_text = ViewTTYConsole::NumBits[idx];
|
||||
return true;
|
||||
},
|
||||
@ -56,6 +59,7 @@ namespace hex::plugin::windows {
|
||||
|
||||
ImGui::Combo(
|
||||
"hex.windows.view.tty_console.stop_bits"_lang, &this->m_selectedStopBits, [](void *data, int idx, const char **out_text) -> bool {
|
||||
hex::unused(data);
|
||||
*out_text = ViewTTYConsole::StopBits[idx];
|
||||
return true;
|
||||
},
|
||||
@ -64,6 +68,7 @@ namespace hex::plugin::windows {
|
||||
|
||||
ImGui::Combo(
|
||||
"hex.windows.view.tty_console.parity_bits"_lang, &this->m_selectedParityBits, [](void *data, int idx, const char **out_text) -> bool {
|
||||
hex::unused(data);
|
||||
*out_text = ViewTTYConsole::ParityBits[idx];
|
||||
return true;
|
||||
},
|
||||
@ -113,12 +118,12 @@ namespace hex::plugin::windows {
|
||||
while (clipper.Step()) {
|
||||
std::scoped_lock lock(this->m_receiveBufferMutex);
|
||||
|
||||
for (u32 i = clipper.DisplayStart + 1; i < clipper.DisplayEnd; i++) {
|
||||
for (int i = clipper.DisplayStart + 1; i < clipper.DisplayEnd; i++) {
|
||||
ImGui::TextUnformatted(this->m_receiveDataBuffer.data() + this->m_wrapPositions[i - 1], this->m_receiveDataBuffer.data() + this->m_wrapPositions[i]);
|
||||
}
|
||||
|
||||
if (!this->m_receiveDataBuffer.empty() && !this->m_wrapPositions.empty())
|
||||
if (clipper.DisplayEnd >= this->m_wrapPositions.size() - 1)
|
||||
if (static_cast<size_t>(clipper.DisplayEnd) >= this->m_wrapPositions.size() - 1)
|
||||
ImGui::TextUnformatted(this->m_receiveDataBuffer.data() + this->m_wrapPositions.back());
|
||||
|
||||
if (this->m_shouldAutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
|
||||
@ -182,7 +187,7 @@ namespace hex::plugin::windows {
|
||||
}
|
||||
|
||||
bool ViewTTYConsole::connect() {
|
||||
if (this->m_comPorts.empty() || this->m_selectedPort >= this->m_comPorts.size()) {
|
||||
if (this->m_comPorts.empty() || static_cast<size_t>(this->m_selectedPort) >= this->m_comPorts.size()) {
|
||||
View::showErrorPopup("hex.windows.view.tty_console.no_available_port"_lang);
|
||||
return true; // If false, connect_error error popup will override this error popup
|
||||
}
|
||||
@ -231,7 +236,7 @@ namespace hex::plugin::windows {
|
||||
|
||||
this->m_receiveThread = std::jthread([this](const std::stop_token &token) {
|
||||
bool waitingOnRead = false;
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
OVERLAPPED overlapped = { };
|
||||
|
||||
overlapped.hEvent = ::CreateEvent(nullptr, true, false, nullptr);
|
||||
ON_SCOPE_EXIT { ::CloseHandle(&overlapped); };
|
||||
@ -298,7 +303,7 @@ namespace hex::plugin::windows {
|
||||
return;
|
||||
|
||||
auto transmitThread = std::thread([&, this] {
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
OVERLAPPED overlapped = { };
|
||||
|
||||
overlapped.hEvent = ::CreateEvent(nullptr, true, false, nullptr);
|
||||
ON_SCOPE_EXIT { ::CloseHandle(&overlapped); };
|
||||
|
Loading…
Reference in New Issue
Block a user