2021-01-20 20:16:24 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <list>
|
2022-02-16 14:57:13 +01:00
|
|
|
#include <optional>
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <string>
|
2022-02-16 14:57:13 +01:00
|
|
|
#include <vector>
|
2022-05-27 20:42:07 +02:00
|
|
|
#include <variant>
|
|
|
|
#include <map>
|
2021-01-20 20:16:24 +01:00
|
|
|
|
2021-09-21 02:29:54 +02:00
|
|
|
#include <hex/helpers/concepts.hpp>
|
2021-12-16 23:48:52 +01:00
|
|
|
#include <hex/api/task.hpp>
|
2021-12-23 15:11:38 +01:00
|
|
|
#include <hex/api/keybinding.hpp>
|
2022-07-02 16:22:38 +02:00
|
|
|
#include <hex/helpers/fs.hpp>
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2022-02-17 11:42:56 +01:00
|
|
|
using ImGuiID = unsigned int;
|
|
|
|
struct ImVec2;
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2021-01-20 20:16:24 +01:00
|
|
|
namespace hex {
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
namespace prv {
|
|
|
|
class Provider;
|
|
|
|
}
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
namespace ImHexApi {
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
namespace Common {
|
2021-01-20 20:16:24 +01:00
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
void closeImHex(bool noQuestions = false);
|
|
|
|
void restartImHex();
|
2021-08-21 13:55:21 +02:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace HexEditor {
|
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
using TooltipFunction = std::function<void(u64, const u8*, size_t)>;
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
class Highlighting {
|
|
|
|
public:
|
|
|
|
Highlighting() = default;
|
2022-05-27 20:42:07 +02:00
|
|
|
Highlighting(Region region, color_t color);
|
|
|
|
|
|
|
|
[[nodiscard]] const Region &getRegion() const { return this->m_region; }
|
|
|
|
[[nodiscard]] const color_t &getColor() const { return this->m_color; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Region m_region = {};
|
|
|
|
color_t m_color = 0x00;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Tooltip {
|
|
|
|
public:
|
|
|
|
Tooltip() = default;
|
|
|
|
Tooltip(Region region, std::string value, color_t color);
|
2022-02-01 18:09:40 +01:00
|
|
|
|
|
|
|
[[nodiscard]] const Region &getRegion() const { return this->m_region; }
|
|
|
|
[[nodiscard]] const color_t &getColor() const { return this->m_color; }
|
2022-05-27 20:42:07 +02:00
|
|
|
[[nodiscard]] const std::string &getValue() const { return this->m_value; }
|
2022-02-01 18:09:40 +01:00
|
|
|
|
|
|
|
private:
|
2022-02-16 14:57:13 +01:00
|
|
|
Region m_region = {};
|
2022-05-27 20:42:07 +02:00
|
|
|
std::string m_value;
|
2022-02-16 14:57:13 +01:00
|
|
|
color_t m_color = 0x00;
|
2022-02-01 18:09:40 +01:00
|
|
|
};
|
|
|
|
|
2022-02-16 14:57:13 +01:00
|
|
|
namespace impl {
|
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
using HighlightingFunction = std::function<std::optional<color_t>(u64, const u8*, size_t)>;
|
2022-02-16 14:57:13 +01:00
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
std::map<u32, Highlighting> &getBackgroundHighlights();
|
|
|
|
std::map<u32, HighlightingFunction> &getBackgroundHighlightingFunctions();
|
|
|
|
std::map<u32, Highlighting> &getForegroundHighlights();
|
|
|
|
std::map<u32, HighlightingFunction> &getForegroundHighlightingFunctions();
|
|
|
|
std::map<u32, Tooltip> &getTooltips();
|
|
|
|
std::map<u32, TooltipFunction> &getTooltipFunctions();
|
2022-02-16 14:57:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
u32 addBackgroundHighlight(const Region ®ion, color_t color);
|
|
|
|
void removeBackgroundHighlight(u32 id);
|
|
|
|
|
|
|
|
u32 addForegroundHighlight(const Region ®ion, color_t color);
|
|
|
|
void removeForegroundHighlight(u32 id);
|
2022-02-16 14:57:13 +01:00
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
u32 addTooltip(Region region, std::string value, color_t color);
|
|
|
|
void removeTooltip(u32 id);
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
u32 addTooltipProvider(TooltipFunction function);
|
|
|
|
void removeTooltipProvider(u32 id);
|
|
|
|
|
|
|
|
u32 addBackgroundHighlightingProvider(const impl::HighlightingFunction &function);
|
|
|
|
void removeBackgroundHighlightingProvider(u32 id);
|
|
|
|
|
|
|
|
u32 addForegroundHighlightingProvider(const impl::HighlightingFunction &function);
|
|
|
|
void removeForegroundHighlightingProvider(u32 id);
|
|
|
|
|
|
|
|
bool isSelectionValid();
|
|
|
|
std::optional<Region> getSelection();
|
2022-02-08 18:38:54 +01:00
|
|
|
void setSelection(const Region ®ion);
|
|
|
|
void setSelection(u64 address, size_t size);
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
}
|
2021-08-21 13:55:21 +02:00
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
namespace Bookmarks {
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2021-01-20 20:16:24 +01:00
|
|
|
struct Entry {
|
|
|
|
Region region;
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
std::string name;
|
|
|
|
std::string comment;
|
2021-01-20 20:16:24 +01:00
|
|
|
u32 color;
|
2021-02-24 21:42:18 +01:00
|
|
|
bool locked;
|
2021-01-20 20:16:24 +01:00
|
|
|
};
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
void add(u64 address, size_t size, const std::string &name, const std::string &comment, color_t color = 0x00000000);
|
2021-01-20 20:16:24 +01:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
}
|
2021-08-21 13:55:21 +02:00
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
namespace Provider {
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
prv::Provider *get();
|
|
|
|
const std::vector<prv::Provider *> &getProviders();
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
void setCurrentProvider(u32 index);
|
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
bool isValid();
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
void add(prv::Provider *provider);
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2022-06-25 12:19:59 +02:00
|
|
|
template<std::derived_from<prv::Provider> T>
|
2022-01-24 20:53:17 +01:00
|
|
|
void add(auto &&...args) {
|
2021-09-21 02:29:54 +02:00
|
|
|
add(new T(std::forward<decltype(args)>(args)...));
|
|
|
|
}
|
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
void remove(prv::Provider *provider);
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
}
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2021-12-16 23:48:52 +01:00
|
|
|
namespace Tasks {
|
|
|
|
|
|
|
|
Task createTask(const std::string &unlocalizedName, u64 maxValue);
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
void doLater(const std::function<void()> &function);
|
2022-02-01 22:09:44 +01:00
|
|
|
std::vector<std::function<void()>> &getDeferredCalls();
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2021-12-16 23:48:52 +01:00
|
|
|
}
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
namespace System {
|
|
|
|
|
|
|
|
namespace impl {
|
|
|
|
|
|
|
|
void setMainWindowPosition(u32 x, u32 y);
|
|
|
|
void setMainWindowSize(u32 width, u32 height);
|
|
|
|
void setMainDockSpaceId(ImGuiID id);
|
|
|
|
|
|
|
|
void setGlobalScale(float scale);
|
|
|
|
|
|
|
|
void setProgramArguments(int argc, char **argv, char **envp);
|
2022-02-15 23:07:48 +01:00
|
|
|
|
|
|
|
void setBorderlessWindowMode(bool enabled);
|
2022-07-02 16:22:38 +02:00
|
|
|
|
|
|
|
void setCustomFontPath(const std::fs::path &path);
|
|
|
|
void setFontSize(float size);
|
2022-07-02 17:53:13 +02:00
|
|
|
|
|
|
|
void setGPUVendor(const std::string &vendor);
|
2022-02-01 18:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ProgramArguments {
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
char **envp;
|
|
|
|
};
|
|
|
|
|
2022-07-02 16:22:38 +02:00
|
|
|
enum class Theme {
|
|
|
|
Dark = 1,
|
|
|
|
Light = 2,
|
|
|
|
Classic = 3
|
|
|
|
};
|
|
|
|
|
2022-02-01 22:09:44 +01:00
|
|
|
const ProgramArguments &getProgramArguments();
|
2022-02-01 18:09:40 +01:00
|
|
|
|
|
|
|
float getTargetFPS();
|
|
|
|
void setTargetFPS(float fps);
|
|
|
|
|
|
|
|
float getGlobalScale();
|
|
|
|
|
|
|
|
ImVec2 getMainWindowPosition();
|
|
|
|
ImVec2 getMainWindowSize();
|
|
|
|
ImGuiID getMainDockSpaceId();
|
|
|
|
|
2022-02-15 23:07:48 +01:00
|
|
|
bool isBorderlessWindowModeEnabled();
|
|
|
|
|
2022-02-01 22:09:44 +01:00
|
|
|
std::map<std::string, std::string> &getInitArguments();
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2022-07-02 16:22:38 +02:00
|
|
|
const std::fs::path &getCustomFontPath();
|
|
|
|
float getFontSize();
|
|
|
|
|
|
|
|
void setTheme(Theme theme);
|
|
|
|
Theme getTheme();
|
|
|
|
|
|
|
|
void enableSystemThemeDetection(bool enabled);
|
|
|
|
bool usesSystemThemeDetection();
|
2022-07-02 17:53:13 +02:00
|
|
|
|
|
|
|
const std::vector<std::fs::path> &getAdditionalFolderPaths();
|
|
|
|
void setAdditionalFolderPaths(const std::vector<std::fs::path> &paths);
|
|
|
|
|
|
|
|
const std::string &getGPUVendor();
|
2022-02-01 18:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-01-20 20:16:24 +01:00
|
|
|
|
|
|
|
}
|