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>
|
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>
|
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 {
|
|
|
|
|
|
|
|
class Highlighting {
|
|
|
|
public:
|
|
|
|
Highlighting() = default;
|
2022-02-16 14:57:13 +01:00
|
|
|
Highlighting(Region region, color_t color, std::string tooltip = "");
|
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; }
|
|
|
|
[[nodiscard]] const std::string &getTooltip() const { return this->m_tooltip; }
|
|
|
|
|
|
|
|
private:
|
2022-02-16 14:57:13 +01:00
|
|
|
Region m_region = {};
|
|
|
|
color_t m_color = 0x00;
|
2022-02-01 18:09:40 +01:00
|
|
|
std::string m_tooltip;
|
|
|
|
};
|
|
|
|
|
2022-02-16 14:57:13 +01:00
|
|
|
namespace impl {
|
|
|
|
|
|
|
|
using HighlightingFunction = std::function<std::optional<Highlighting>(u64)>;
|
|
|
|
|
|
|
|
std::map<u32, Highlighting> &getHighlights();
|
|
|
|
std::map<u32, HighlightingFunction> &getHighlightingFunctions();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 addHighlight(const Region ®ion, color_t color, const std::string &tooltip = "");
|
2022-02-01 18:09:40 +01:00
|
|
|
void removeHighlight(u32 id);
|
2022-02-16 14:57:13 +01:00
|
|
|
|
|
|
|
u32 addHighlightingProvider(const impl::HighlightingFunction &function);
|
|
|
|
void removeHighlightingProvider(u32 id);
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2022-02-08 18:38:54 +01:00
|
|
|
Region getSelection();
|
|
|
|
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;
|
2022-02-01 18:09:40 +01:00
|
|
|
|
|
|
|
u32 highlightId;
|
2021-01-20 20:16:24 +01:00
|
|
|
};
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
void add(Region region, const std::string &name, const std::string &comment, color_t color = 0x00000000);
|
|
|
|
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
|
|
|
|
|
|
|
template<hex::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-02-01 18:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ProgramArguments {
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
char **envp;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-01-20 20:16:24 +01:00
|
|
|
|
|
|
|
}
|