#pragma once #include #include #include #include #include #include #include #include #include namespace hex::plugin::builtin { class ProviderExtraData { public: struct Data { bool dataDirty = false; struct PatternLanguage { struct PatternVariable { bool inVariable; bool outVariable; pl::core::Token::ValueType type; pl::core::Token::Literal value; }; enum class EnvVarType { Integer, Float, String, Bool }; struct EnvVar { u64 id; std::string name; pl::core::Token::Literal value; EnvVarType type; bool operator==(const EnvVar &other) const { return this->id == other.id; } }; std::string sourceCode; std::mutex runtimeMutex; std::unique_ptr runtime = std::make_unique(); std::vector> console; bool executionDone = true; std::optional lastEvaluationError; std::vector> lastEvaluationLog; std::map lastEvaluationOutVars; std::map patternVariables; std::map sections; std::list envVarEntries; } patternLanguage; std::list bookmarks; struct DataProcessor { struct Workspace { std::unique_ptr context = { []{ ImNodesContext *ctx = ImNodes::CreateContext(); ctx->Style = ImNodes::GetStyle(); ctx->Io = ImNodes::GetIO(); ctx->AttributeFlagStack = GImNodes->AttributeFlagStack; return ctx; }(), ImNodes::DestroyContext }; std::list> nodes; std::list endNodes; std::list links; std::vector dataOverlays; std::optional currNodeError; }; Workspace mainWorkspace; std::vector workspaceStack; } dataProcessor; struct HexEditor { std::optional selectionStart, selectionEnd; float scrollPosition = 0.0F; } editor; struct Hashes { std::vector hashFunctions; } hashes; struct Yara { struct YaraMatch { std::string identifier; std::string variable; u64 address; size_t size; bool wholeDataMatch; mutable u32 highlightId; mutable u32 tooltipId; }; std::vector> rules; std::vector matches; } yara; }; static Data& getCurrent() { return get(ImHexApi::Provider::get()); } static Data& get(const hex::prv::Provider *provider) { return s_data[provider]; } static void erase(hex::prv::Provider *provider) { s_data.erase(provider); } static bool markDirty() { return getCurrent().dataDirty = true; } private: ProviderExtraData() = default; static inline std::map s_data = {}; }; }