mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
sys: Reformat all
This commit is contained in:
@@ -3,19 +3,19 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
constexpr static const auto ImHexApiURL = "https://api.werwolv.net/imhex";
|
||||
constexpr static const auto ImHexApiURL = "https://api.werwolv.net/imhex";
|
||||
constexpr static const auto GitHubApiURL = "https://api.github.com/repos/WerWolv/ImHex";
|
||||
|
||||
using u8 = std::uint8_t;
|
||||
using u16 = std::uint16_t;
|
||||
using u32 = std::uint32_t;
|
||||
using u64 = std::uint64_t;
|
||||
using u8 = std::uint8_t;
|
||||
using u16 = std::uint16_t;
|
||||
using u32 = std::uint32_t;
|
||||
using u64 = std::uint64_t;
|
||||
using u128 = __uint128_t;
|
||||
|
||||
using i8 = std::int8_t;
|
||||
using i16 = std::int16_t;
|
||||
using i32 = std::int32_t;
|
||||
using i64 = std::int64_t;
|
||||
using i8 = std::int8_t;
|
||||
using i16 = std::int16_t;
|
||||
using i32 = std::int32_t;
|
||||
using i64 = std::int64_t;
|
||||
using i128 = __int128_t;
|
||||
|
||||
using color_t = u32;
|
||||
|
||||
@@ -85,7 +85,11 @@ namespace hex {
|
||||
};
|
||||
|
||||
void add(
|
||||
Type type, const std::string &command, const std::string &unlocalizedDescription, const DisplayCallback &displayCallback, const ExecuteCallback &executeCallback = [](auto) {});
|
||||
Type type,
|
||||
const std::string &command,
|
||||
const std::string &unlocalizedDescription,
|
||||
const DisplayCallback &displayCallback,
|
||||
const ExecuteCallback &executeCallback = [](auto) {});
|
||||
std::vector<Entry> &getEntries();
|
||||
}
|
||||
|
||||
@@ -101,14 +105,14 @@ namespace hex {
|
||||
|
||||
}
|
||||
|
||||
constexpr static u32 UnlimitedParameters = 0xFFFF'FFFF;
|
||||
constexpr static u32 MoreParametersThan = 0x8000'0000;
|
||||
constexpr static u32 LessParametersThan = 0x4000'0000;
|
||||
constexpr static u32 ExactlyOrMoreParametersThan = 0x2000'0000;
|
||||
constexpr static u32 NoParameters = 0x0000'0000;
|
||||
constexpr static u32 UnlimitedParameters = 0xFFFF'FFFF;
|
||||
constexpr static u32 MoreParametersThan = 0x8000'0000;
|
||||
constexpr static u32 LessParametersThan = 0x4000'0000;
|
||||
constexpr static u32 ExactlyOrMoreParametersThan = 0x2000'0000;
|
||||
constexpr static u32 NoParameters = 0x0000'0000;
|
||||
|
||||
using Namespace = std::vector<std::string>;
|
||||
using Callback = std::function<std::optional<hex::pl::Token::Literal>(hex::pl::Evaluator *, const std::vector<hex::pl::Token::Literal> &)>;
|
||||
using Callback = std::function<std::optional<hex::pl::Token::Literal>(hex::pl::Evaluator *, const std::vector<hex::pl::Token::Literal> &)>;
|
||||
|
||||
struct Function {
|
||||
u32 parameterCount;
|
||||
@@ -120,7 +124,7 @@ namespace hex {
|
||||
void addDangerousFunction(const Namespace &ns, const std::string &name, u32 parameterCount, const Callback &func);
|
||||
std::map<std::string, ContentRegistry::PatternLanguage::Function> &getFunctions();
|
||||
|
||||
std::vector<impl::ColorPalette>& getPalettes();
|
||||
std::vector<impl::ColorPalette> &getPalettes();
|
||||
void addColorPalette(const std::string &unlocalizedName, const std::vector<u32> &colors);
|
||||
void setSelectedPalette(u32 index);
|
||||
u32 getNextColor();
|
||||
@@ -177,7 +181,7 @@ namespace hex {
|
||||
|
||||
namespace impl {
|
||||
|
||||
using DisplayFunction = std::function<std::string()>;
|
||||
using DisplayFunction = std::function<std::string()>;
|
||||
using GeneratorFunction = std::function<DisplayFunction(const std::vector<u8> &, std::endian, NumberDisplayStyle)>;
|
||||
|
||||
struct Entry {
|
||||
@@ -240,7 +244,7 @@ namespace hex {
|
||||
|
||||
namespace impl {
|
||||
|
||||
using DrawCallback = std::function<void()>;
|
||||
using DrawCallback = std::function<void()>;
|
||||
using LayoutFunction = std::function<void(u32)>;
|
||||
|
||||
struct Layout {
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace hex {
|
||||
Task createTask(const std::string &unlocalizedName, u64 maxValue);
|
||||
|
||||
void doLater(const std::function<void()> &function);
|
||||
std::vector<std::function<void()>>& getDeferredCalls();
|
||||
std::vector<std::function<void()>> &getDeferredCalls();
|
||||
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace hex {
|
||||
char **envp;
|
||||
};
|
||||
|
||||
const ProgramArguments& getProgramArguments();
|
||||
const ProgramArguments &getProgramArguments();
|
||||
|
||||
float getTargetFPS();
|
||||
void setTargetFPS(float fps);
|
||||
@@ -127,7 +127,7 @@ namespace hex {
|
||||
ImVec2 getMainWindowSize();
|
||||
ImGuiID getMainDockSpaceId();
|
||||
|
||||
std::map<std::string, std::string>& getInitArguments();
|
||||
std::map<std::string, std::string> &getInitArguments();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,118 +14,118 @@ namespace hex {
|
||||
struct View;
|
||||
|
||||
enum class Keys {
|
||||
Space = GLFW_KEY_SPACE,
|
||||
Apostrophe = GLFW_KEY_APOSTROPHE,
|
||||
Comma = GLFW_KEY_COMMA,
|
||||
Minus = GLFW_KEY_MINUS,
|
||||
Period = GLFW_KEY_PERIOD,
|
||||
Slash = GLFW_KEY_SLASH,
|
||||
Num0 = GLFW_KEY_0,
|
||||
Num1 = GLFW_KEY_1,
|
||||
Num2 = GLFW_KEY_2,
|
||||
Num3 = GLFW_KEY_3,
|
||||
Num4 = GLFW_KEY_4,
|
||||
Num5 = GLFW_KEY_5,
|
||||
Num6 = GLFW_KEY_6,
|
||||
Num7 = GLFW_KEY_7,
|
||||
Num8 = GLFW_KEY_8,
|
||||
Num9 = GLFW_KEY_9,
|
||||
Semicolon = GLFW_KEY_SEMICOLON,
|
||||
Equals = GLFW_KEY_EQUAL,
|
||||
A = GLFW_KEY_A,
|
||||
B = GLFW_KEY_B,
|
||||
C = GLFW_KEY_C,
|
||||
D = GLFW_KEY_D,
|
||||
E = GLFW_KEY_E,
|
||||
F = GLFW_KEY_F,
|
||||
G = GLFW_KEY_G,
|
||||
H = GLFW_KEY_H,
|
||||
I = GLFW_KEY_I,
|
||||
J = GLFW_KEY_J,
|
||||
K = GLFW_KEY_K,
|
||||
L = GLFW_KEY_L,
|
||||
M = GLFW_KEY_M,
|
||||
N = GLFW_KEY_N,
|
||||
O = GLFW_KEY_O,
|
||||
P = GLFW_KEY_P,
|
||||
Q = GLFW_KEY_Q,
|
||||
R = GLFW_KEY_R,
|
||||
S = GLFW_KEY_S,
|
||||
T = GLFW_KEY_T,
|
||||
U = GLFW_KEY_U,
|
||||
V = GLFW_KEY_V,
|
||||
W = GLFW_KEY_W,
|
||||
X = GLFW_KEY_X,
|
||||
Y = GLFW_KEY_Y,
|
||||
Z = GLFW_KEY_Z,
|
||||
LeftBracket = GLFW_KEY_LEFT_BRACKET,
|
||||
Backslash = GLFW_KEY_BACKSLASH,
|
||||
RightBracket = GLFW_KEY_RIGHT_BRACKET,
|
||||
GraveAccent = GLFW_KEY_GRAVE_ACCENT,
|
||||
World1 = GLFW_KEY_WORLD_1,
|
||||
World2 = GLFW_KEY_WORLD_2,
|
||||
Escape = GLFW_KEY_ESCAPE,
|
||||
Enter = GLFW_KEY_ENTER,
|
||||
Tab = GLFW_KEY_TAB,
|
||||
Backspace = GLFW_KEY_BACKSPACE,
|
||||
Insert = GLFW_KEY_INSERT,
|
||||
Delete = GLFW_KEY_DELETE,
|
||||
Right = GLFW_KEY_RIGHT,
|
||||
Left = GLFW_KEY_LEFT,
|
||||
Down = GLFW_KEY_DOWN,
|
||||
Up = GLFW_KEY_UP,
|
||||
PageUp = GLFW_KEY_PAGE_UP,
|
||||
PageDown = GLFW_KEY_PAGE_DOWN,
|
||||
Home = GLFW_KEY_HOME,
|
||||
End = GLFW_KEY_END,
|
||||
CapsLock = GLFW_KEY_CAPS_LOCK,
|
||||
ScrollLock = GLFW_KEY_SCROLL_LOCK,
|
||||
NumLock = GLFW_KEY_NUM_LOCK,
|
||||
PrintScreen = GLFW_KEY_PRINT_SCREEN,
|
||||
Pause = GLFW_KEY_PAUSE,
|
||||
F1 = GLFW_KEY_F1,
|
||||
F2 = GLFW_KEY_F2,
|
||||
F3 = GLFW_KEY_F3,
|
||||
F4 = GLFW_KEY_F4,
|
||||
F5 = GLFW_KEY_F5,
|
||||
F6 = GLFW_KEY_F6,
|
||||
F7 = GLFW_KEY_F7,
|
||||
F8 = GLFW_KEY_F8,
|
||||
F9 = GLFW_KEY_F9,
|
||||
F10 = GLFW_KEY_F10,
|
||||
F11 = GLFW_KEY_F11,
|
||||
F12 = GLFW_KEY_F12,
|
||||
F13 = GLFW_KEY_F13,
|
||||
F14 = GLFW_KEY_F14,
|
||||
F15 = GLFW_KEY_F15,
|
||||
F16 = GLFW_KEY_F16,
|
||||
F17 = GLFW_KEY_F17,
|
||||
F18 = GLFW_KEY_F18,
|
||||
F19 = GLFW_KEY_F19,
|
||||
F20 = GLFW_KEY_F20,
|
||||
F21 = GLFW_KEY_F21,
|
||||
F22 = GLFW_KEY_F22,
|
||||
F23 = GLFW_KEY_F23,
|
||||
F24 = GLFW_KEY_F24,
|
||||
F25 = GLFW_KEY_F25,
|
||||
KeyPad0 = GLFW_KEY_KP_0,
|
||||
KeyPad1 = GLFW_KEY_KP_1,
|
||||
KeyPad2 = GLFW_KEY_KP_2,
|
||||
KeyPad3 = GLFW_KEY_KP_3,
|
||||
KeyPad4 = GLFW_KEY_KP_4,
|
||||
KeyPad5 = GLFW_KEY_KP_5,
|
||||
KeyPad6 = GLFW_KEY_KP_6,
|
||||
KeyPad7 = GLFW_KEY_KP_7,
|
||||
KeyPad8 = GLFW_KEY_KP_8,
|
||||
KeyPad9 = GLFW_KEY_KP_9,
|
||||
KeyPadDecimal = GLFW_KEY_KP_DECIMAL,
|
||||
KeyPadDivide = GLFW_KEY_KP_DIVIDE,
|
||||
Space = GLFW_KEY_SPACE,
|
||||
Apostrophe = GLFW_KEY_APOSTROPHE,
|
||||
Comma = GLFW_KEY_COMMA,
|
||||
Minus = GLFW_KEY_MINUS,
|
||||
Period = GLFW_KEY_PERIOD,
|
||||
Slash = GLFW_KEY_SLASH,
|
||||
Num0 = GLFW_KEY_0,
|
||||
Num1 = GLFW_KEY_1,
|
||||
Num2 = GLFW_KEY_2,
|
||||
Num3 = GLFW_KEY_3,
|
||||
Num4 = GLFW_KEY_4,
|
||||
Num5 = GLFW_KEY_5,
|
||||
Num6 = GLFW_KEY_6,
|
||||
Num7 = GLFW_KEY_7,
|
||||
Num8 = GLFW_KEY_8,
|
||||
Num9 = GLFW_KEY_9,
|
||||
Semicolon = GLFW_KEY_SEMICOLON,
|
||||
Equals = GLFW_KEY_EQUAL,
|
||||
A = GLFW_KEY_A,
|
||||
B = GLFW_KEY_B,
|
||||
C = GLFW_KEY_C,
|
||||
D = GLFW_KEY_D,
|
||||
E = GLFW_KEY_E,
|
||||
F = GLFW_KEY_F,
|
||||
G = GLFW_KEY_G,
|
||||
H = GLFW_KEY_H,
|
||||
I = GLFW_KEY_I,
|
||||
J = GLFW_KEY_J,
|
||||
K = GLFW_KEY_K,
|
||||
L = GLFW_KEY_L,
|
||||
M = GLFW_KEY_M,
|
||||
N = GLFW_KEY_N,
|
||||
O = GLFW_KEY_O,
|
||||
P = GLFW_KEY_P,
|
||||
Q = GLFW_KEY_Q,
|
||||
R = GLFW_KEY_R,
|
||||
S = GLFW_KEY_S,
|
||||
T = GLFW_KEY_T,
|
||||
U = GLFW_KEY_U,
|
||||
V = GLFW_KEY_V,
|
||||
W = GLFW_KEY_W,
|
||||
X = GLFW_KEY_X,
|
||||
Y = GLFW_KEY_Y,
|
||||
Z = GLFW_KEY_Z,
|
||||
LeftBracket = GLFW_KEY_LEFT_BRACKET,
|
||||
Backslash = GLFW_KEY_BACKSLASH,
|
||||
RightBracket = GLFW_KEY_RIGHT_BRACKET,
|
||||
GraveAccent = GLFW_KEY_GRAVE_ACCENT,
|
||||
World1 = GLFW_KEY_WORLD_1,
|
||||
World2 = GLFW_KEY_WORLD_2,
|
||||
Escape = GLFW_KEY_ESCAPE,
|
||||
Enter = GLFW_KEY_ENTER,
|
||||
Tab = GLFW_KEY_TAB,
|
||||
Backspace = GLFW_KEY_BACKSPACE,
|
||||
Insert = GLFW_KEY_INSERT,
|
||||
Delete = GLFW_KEY_DELETE,
|
||||
Right = GLFW_KEY_RIGHT,
|
||||
Left = GLFW_KEY_LEFT,
|
||||
Down = GLFW_KEY_DOWN,
|
||||
Up = GLFW_KEY_UP,
|
||||
PageUp = GLFW_KEY_PAGE_UP,
|
||||
PageDown = GLFW_KEY_PAGE_DOWN,
|
||||
Home = GLFW_KEY_HOME,
|
||||
End = GLFW_KEY_END,
|
||||
CapsLock = GLFW_KEY_CAPS_LOCK,
|
||||
ScrollLock = GLFW_KEY_SCROLL_LOCK,
|
||||
NumLock = GLFW_KEY_NUM_LOCK,
|
||||
PrintScreen = GLFW_KEY_PRINT_SCREEN,
|
||||
Pause = GLFW_KEY_PAUSE,
|
||||
F1 = GLFW_KEY_F1,
|
||||
F2 = GLFW_KEY_F2,
|
||||
F3 = GLFW_KEY_F3,
|
||||
F4 = GLFW_KEY_F4,
|
||||
F5 = GLFW_KEY_F5,
|
||||
F6 = GLFW_KEY_F6,
|
||||
F7 = GLFW_KEY_F7,
|
||||
F8 = GLFW_KEY_F8,
|
||||
F9 = GLFW_KEY_F9,
|
||||
F10 = GLFW_KEY_F10,
|
||||
F11 = GLFW_KEY_F11,
|
||||
F12 = GLFW_KEY_F12,
|
||||
F13 = GLFW_KEY_F13,
|
||||
F14 = GLFW_KEY_F14,
|
||||
F15 = GLFW_KEY_F15,
|
||||
F16 = GLFW_KEY_F16,
|
||||
F17 = GLFW_KEY_F17,
|
||||
F18 = GLFW_KEY_F18,
|
||||
F19 = GLFW_KEY_F19,
|
||||
F20 = GLFW_KEY_F20,
|
||||
F21 = GLFW_KEY_F21,
|
||||
F22 = GLFW_KEY_F22,
|
||||
F23 = GLFW_KEY_F23,
|
||||
F24 = GLFW_KEY_F24,
|
||||
F25 = GLFW_KEY_F25,
|
||||
KeyPad0 = GLFW_KEY_KP_0,
|
||||
KeyPad1 = GLFW_KEY_KP_1,
|
||||
KeyPad2 = GLFW_KEY_KP_2,
|
||||
KeyPad3 = GLFW_KEY_KP_3,
|
||||
KeyPad4 = GLFW_KEY_KP_4,
|
||||
KeyPad5 = GLFW_KEY_KP_5,
|
||||
KeyPad6 = GLFW_KEY_KP_6,
|
||||
KeyPad7 = GLFW_KEY_KP_7,
|
||||
KeyPad8 = GLFW_KEY_KP_8,
|
||||
KeyPad9 = GLFW_KEY_KP_9,
|
||||
KeyPadDecimal = GLFW_KEY_KP_DECIMAL,
|
||||
KeyPadDivide = GLFW_KEY_KP_DIVIDE,
|
||||
KeyPadMultiply = GLFW_KEY_KP_MULTIPLY,
|
||||
KeyPadSubtract = GLFW_KEY_KP_SUBTRACT,
|
||||
KeyPadAdd = GLFW_KEY_KP_ADD,
|
||||
KeyPadEnter = GLFW_KEY_KP_ENTER,
|
||||
KeyPadEqual = GLFW_KEY_KP_EQUAL,
|
||||
Menu = GLFW_KEY_MENU,
|
||||
KeyPadAdd = GLFW_KEY_KP_ADD,
|
||||
KeyPadEnter = GLFW_KEY_KP_ENTER,
|
||||
KeyPadEqual = GLFW_KEY_KP_EQUAL,
|
||||
Menu = GLFW_KEY_MENU,
|
||||
};
|
||||
|
||||
|
||||
@@ -175,8 +175,8 @@ namespace hex {
|
||||
return result;
|
||||
}
|
||||
|
||||
static constexpr auto CTRL = Key(static_cast<Keys>(0x1000'0000));
|
||||
static constexpr auto ALT = Key(static_cast<Keys>(0x2000'0000));
|
||||
static constexpr auto CTRL = Key(static_cast<Keys>(0x1000'0000));
|
||||
static constexpr auto ALT = Key(static_cast<Keys>(0x2000'0000));
|
||||
static constexpr auto SHIFT = Key(static_cast<Keys>(0x3000'0000));
|
||||
static constexpr auto SUPER = Key(static_cast<Keys>(0x4000'0000));
|
||||
|
||||
@@ -187,6 +187,7 @@ namespace hex {
|
||||
static void process(View *currentView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode);
|
||||
|
||||
static void clearShortcuts();
|
||||
|
||||
private:
|
||||
static std::map<Shortcut, std::function<void()>> s_globalShortcuts;
|
||||
};
|
||||
|
||||
@@ -31,26 +31,26 @@ namespace hex {
|
||||
[[nodiscard]] bool isLoaded() const;
|
||||
|
||||
private:
|
||||
using InitializePluginFunc = void (*)();
|
||||
using GetPluginNameFunc = const char *(*)();
|
||||
using GetPluginAuthorFunc = const char *(*)();
|
||||
using InitializePluginFunc = void (*)();
|
||||
using GetPluginNameFunc = const char *(*)();
|
||||
using GetPluginAuthorFunc = const char *(*)();
|
||||
using GetPluginDescriptionFunc = const char *(*)();
|
||||
using GetCompatibleVersionFunc = const char *(*)();
|
||||
using SetImGuiContextFunc = void (*)(ImGuiContext *);
|
||||
using IsBuiltinPluginFunc = bool(*)();
|
||||
using SetImGuiContextFunc = void (*)(ImGuiContext *);
|
||||
using IsBuiltinPluginFunc = bool (*)();
|
||||
|
||||
void *m_handle = nullptr;
|
||||
fs::path m_path;
|
||||
|
||||
mutable bool m_initialized = false;
|
||||
|
||||
InitializePluginFunc m_initializePluginFunction = nullptr;
|
||||
GetPluginNameFunc m_getPluginNameFunction = nullptr;
|
||||
GetPluginAuthorFunc m_getPluginAuthorFunction = nullptr;
|
||||
InitializePluginFunc m_initializePluginFunction = nullptr;
|
||||
GetPluginNameFunc m_getPluginNameFunction = nullptr;
|
||||
GetPluginAuthorFunc m_getPluginAuthorFunction = nullptr;
|
||||
GetPluginDescriptionFunc m_getPluginDescriptionFunction = nullptr;
|
||||
GetCompatibleVersionFunc m_getCompatibleVersionFunction = nullptr;
|
||||
SetImGuiContextFunc m_setImGuiContextFunction = nullptr;
|
||||
IsBuiltinPluginFunc m_isBuiltinPluginFunction = nullptr;
|
||||
SetImGuiContextFunc m_setImGuiContextFunction = nullptr;
|
||||
IsBuiltinPluginFunc m_isBuiltinPluginFunction = nullptr;
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] auto getPluginFunction(const std::string &symbol) {
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace hex {
|
||||
[[nodiscard]] bool isPending() const;
|
||||
|
||||
static size_t getRunningTaskCount();
|
||||
static std::list<Task *>& getRunningTasks() { return Task::s_runningTasks; }
|
||||
static std::mutex& getTaskMutex() { return Task::s_taskMutex; }
|
||||
static std::list<Task *> &getRunningTasks() { return Task::s_runningTasks; }
|
||||
static std::mutex &getTaskMutex() { return Task::s_taskMutex; }
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace hex {
|
||||
template<typename T>
|
||||
class Cloneable {
|
||||
public:
|
||||
[[nodiscard]] virtual T* clone() const = 0;
|
||||
[[nodiscard]] virtual T *clone() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -40,14 +40,14 @@ namespace hex::crypt {
|
||||
std::string encode16(const std::vector<u8> &input);
|
||||
|
||||
enum class AESMode : u8 {
|
||||
ECB = 0,
|
||||
CBC = 1,
|
||||
ECB = 0,
|
||||
CBC = 1,
|
||||
CFB128 = 2,
|
||||
CTR = 3,
|
||||
GCM = 4,
|
||||
CCM = 5,
|
||||
OFB = 6,
|
||||
XTS = 7
|
||||
CTR = 3,
|
||||
GCM = 4,
|
||||
CCM = 5,
|
||||
OFB = 6,
|
||||
XTS = 7
|
||||
};
|
||||
|
||||
enum class KeyLength : u8 {
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace hex {
|
||||
curl_slist *m_headers = nullptr;
|
||||
|
||||
std::mutex m_transmissionActive;
|
||||
float m_progress = 0.0F;
|
||||
float m_progress = 0.0F;
|
||||
bool m_shouldCancel = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace hex {
|
||||
|
||||
class Socket {
|
||||
public:
|
||||
Socket() = default;
|
||||
Socket() = default;
|
||||
Socket(const Socket &) = delete;
|
||||
Socket(Socket &&other);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace hex {
|
||||
if (from < to) std::swap(from, to);
|
||||
|
||||
using ValueType = std::remove_cvref_t<decltype(value)>;
|
||||
ValueType mask = (std::numeric_limits<ValueType>::max() >> (((sizeof(value) * 8) - 1) - (from - to))) << to;
|
||||
ValueType mask = (std::numeric_limits<ValueType>::max() >> (((sizeof(value) * 8) - 1) - (from - to))) << to;
|
||||
|
||||
return (value & mask) >> to;
|
||||
}
|
||||
@@ -111,23 +111,23 @@ namespace hex {
|
||||
static_assert(always_false<T>::value, "Invalid type provided!");
|
||||
|
||||
switch (Size) {
|
||||
case 1:
|
||||
swapped = unswapped;
|
||||
break;
|
||||
case 2:
|
||||
swapped = __builtin_bswap16(unswapped);
|
||||
break;
|
||||
case 4:
|
||||
swapped = __builtin_bswap32(unswapped);
|
||||
break;
|
||||
case 8:
|
||||
swapped = __builtin_bswap64(unswapped);
|
||||
break;
|
||||
case 16:
|
||||
swapped = (u128(__builtin_bswap64(unswapped & 0xFFFF'FFFF'FFFF'FFFF)) << 64) | __builtin_bswap64(u128(unswapped) >> 64);
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
case 1:
|
||||
swapped = unswapped;
|
||||
break;
|
||||
case 2:
|
||||
swapped = __builtin_bswap16(unswapped);
|
||||
break;
|
||||
case 4:
|
||||
swapped = __builtin_bswap32(unswapped);
|
||||
break;
|
||||
case 8:
|
||||
swapped = __builtin_bswap64(unswapped);
|
||||
break;
|
||||
case 16:
|
||||
swapped = (u128(__builtin_bswap64(unswapped & 0xFFFF'FFFF'FFFF'FFFF)) << 64) | __builtin_bswap64(u128(unswapped) >> 64);
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
T result;
|
||||
@@ -151,23 +151,23 @@ namespace hex {
|
||||
u128 swapped;
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
swapped = unswapped;
|
||||
break;
|
||||
case 2:
|
||||
swapped = __builtin_bswap16(unswapped);
|
||||
break;
|
||||
case 4:
|
||||
swapped = __builtin_bswap32(unswapped);
|
||||
break;
|
||||
case 8:
|
||||
swapped = __builtin_bswap64(unswapped);
|
||||
break;
|
||||
case 16:
|
||||
swapped = (u128(__builtin_bswap64(unswapped & 0xFFFF'FFFF'FFFF'FFFF)) << 64) | __builtin_bswap64(u128(unswapped) >> 64);
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
case 1:
|
||||
swapped = unswapped;
|
||||
break;
|
||||
case 2:
|
||||
swapped = __builtin_bswap16(unswapped);
|
||||
break;
|
||||
case 4:
|
||||
swapped = __builtin_bswap32(unswapped);
|
||||
break;
|
||||
case 8:
|
||||
swapped = __builtin_bswap64(unswapped);
|
||||
break;
|
||||
case 16:
|
||||
swapped = (u128(__builtin_bswap64(unswapped & 0xFFFF'FFFF'FFFF'FFFF)) << 64) | __builtin_bswap64(u128(unswapped) >> 64);
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
T result = 0;
|
||||
@@ -231,15 +231,15 @@ namespace hex {
|
||||
|
||||
inline void trimLeft(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
|
||||
return !std::isspace(ch) && ch >= 0x20;
|
||||
}));
|
||||
return !std::isspace(ch) && ch >= 0x20;
|
||||
}));
|
||||
}
|
||||
|
||||
inline void trimRight(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch) && ch >= 0x20;
|
||||
}).base(),
|
||||
s.end());
|
||||
return !std::isspace(ch) && ch >= 0x20;
|
||||
}).base(),
|
||||
s.end());
|
||||
}
|
||||
|
||||
inline void trim(std::string &s) {
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace hex::pl {
|
||||
|
||||
ASTNodeAttribute(const ASTNodeAttribute &other) : ASTNode(other) {
|
||||
this->m_attribute = other.m_attribute;
|
||||
this->m_value = other.m_value;
|
||||
this->m_value = other.m_value;
|
||||
}
|
||||
|
||||
[[nodiscard]] ASTNode *clone() const override {
|
||||
@@ -81,7 +81,7 @@ namespace hex::pl {
|
||||
|
||||
Attributable(const Attributable &other) {
|
||||
for (auto &attribute : other.m_attributes) {
|
||||
if (auto node = dynamic_cast<ASTNodeAttribute*>(attribute->clone()))
|
||||
if (auto node = dynamic_cast<ASTNodeAttribute *>(attribute->clone()))
|
||||
this->m_attributes.push_back(node);
|
||||
else
|
||||
delete node;
|
||||
@@ -175,8 +175,8 @@ namespace hex::pl {
|
||||
|
||||
ASTNodeMathematicalExpression(const ASTNodeMathematicalExpression &other) : ASTNode(other) {
|
||||
this->m_operator = other.m_operator;
|
||||
this->m_left = other.m_left->clone();
|
||||
this->m_right = other.m_right->clone();
|
||||
this->m_left = other.m_left->clone();
|
||||
this->m_right = other.m_right->clone();
|
||||
}
|
||||
|
||||
[[nodiscard]] ASTNode *clone() const override {
|
||||
@@ -187,7 +187,7 @@ namespace hex::pl {
|
||||
if (this->getLeftOperand() == nullptr || this->getRightOperand() == nullptr)
|
||||
LogConsole::abortEvaluation("attempted to use void expression in mathematical expression", this);
|
||||
|
||||
auto *left = dynamic_cast<ASTNodeLiteral *>(this->getLeftOperand()->evaluate(evaluator));
|
||||
auto *left = dynamic_cast<ASTNodeLiteral *>(this->getLeftOperand()->evaluate(evaluator));
|
||||
auto *right = dynamic_cast<ASTNodeLiteral *>(this->getRightOperand()->evaluate(evaluator));
|
||||
ON_SCOPE_EXIT {
|
||||
delete left;
|
||||
@@ -213,105 +213,105 @@ namespace hex::pl {
|
||||
[this](auto &&left, const std::string &right) -> 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:
|
||||
{
|
||||
std::string result;
|
||||
for (auto i = 0; i < right; i++)
|
||||
result += left;
|
||||
return new ASTNodeLiteral(result);
|
||||
}
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
case Token::Operator::Star:
|
||||
{
|
||||
std::string result;
|
||||
for (auto i = 0; i < right; i++)
|
||||
result += left;
|
||||
return new ASTNodeLiteral(result);
|
||||
}
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
}
|
||||
},
|
||||
[this](const std::string &left, const std::string &right) -> ASTNode * {
|
||||
switch (this->getOperator()) {
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
case Token::Operator::BoolEquals:
|
||||
return new ASTNodeLiteral(left == right);
|
||||
case Token::Operator::BoolNotEquals:
|
||||
return new ASTNodeLiteral(left != right);
|
||||
case Token::Operator::BoolGreaterThan:
|
||||
return new ASTNodeLiteral(left > right);
|
||||
case Token::Operator::BoolLessThan:
|
||||
return new ASTNodeLiteral(left < right);
|
||||
case Token::Operator::BoolGreaterThanOrEquals:
|
||||
return new ASTNodeLiteral(left >= right);
|
||||
case Token::Operator::BoolLessThanOrEquals:
|
||||
return new ASTNodeLiteral(left <= right);
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
case Token::Operator::BoolEquals:
|
||||
return new ASTNodeLiteral(left == right);
|
||||
case Token::Operator::BoolNotEquals:
|
||||
return new ASTNodeLiteral(left != right);
|
||||
case Token::Operator::BoolGreaterThan:
|
||||
return new ASTNodeLiteral(left > right);
|
||||
case Token::Operator::BoolLessThan:
|
||||
return new ASTNodeLiteral(left < right);
|
||||
case Token::Operator::BoolGreaterThanOrEquals:
|
||||
return new ASTNodeLiteral(left >= right);
|
||||
case Token::Operator::BoolLessThanOrEquals:
|
||||
return new ASTNodeLiteral(left <= right);
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
}
|
||||
},
|
||||
[this](const std::string &left, char right) -> ASTNode * {
|
||||
switch (this->getOperator()) {
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
}
|
||||
},
|
||||
[this](char left, const std::string &right) -> ASTNode * {
|
||||
switch (this->getOperator()) {
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
}
|
||||
},
|
||||
[this](auto &&left, auto &&right) -> ASTNode * {
|
||||
switch (this->getOperator()) {
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
case Token::Operator::Minus:
|
||||
return new ASTNodeLiteral(left - right);
|
||||
case Token::Operator::Star:
|
||||
return new ASTNodeLiteral(left * right);
|
||||
case Token::Operator::Slash:
|
||||
if (right == 0) LogConsole::abortEvaluation("division by zero!", this);
|
||||
return new ASTNodeLiteral(left / right);
|
||||
case Token::Operator::Percent:
|
||||
if (right == 0) LogConsole::abortEvaluation("division by zero!", this);
|
||||
return new ASTNodeLiteral(modulus(left, right));
|
||||
case Token::Operator::ShiftLeft:
|
||||
return new ASTNodeLiteral(shiftLeft(left, right));
|
||||
case Token::Operator::ShiftRight:
|
||||
return new ASTNodeLiteral(shiftRight(left, right));
|
||||
case Token::Operator::BitAnd:
|
||||
return new ASTNodeLiteral(bitAnd(left, right));
|
||||
case Token::Operator::BitXor:
|
||||
return new ASTNodeLiteral(bitXor(left, right));
|
||||
case Token::Operator::BitOr:
|
||||
return new ASTNodeLiteral(bitOr(left, right));
|
||||
case Token::Operator::BitNot:
|
||||
return new ASTNodeLiteral(bitNot(left, right));
|
||||
case Token::Operator::BoolEquals:
|
||||
return new ASTNodeLiteral(bool(left == right));
|
||||
case Token::Operator::BoolNotEquals:
|
||||
return new ASTNodeLiteral(bool(left != right));
|
||||
case Token::Operator::BoolGreaterThan:
|
||||
return new ASTNodeLiteral(bool(left > right));
|
||||
case Token::Operator::BoolLessThan:
|
||||
return new ASTNodeLiteral(bool(left < right));
|
||||
case Token::Operator::BoolGreaterThanOrEquals:
|
||||
return new ASTNodeLiteral(bool(left >= right));
|
||||
case Token::Operator::BoolLessThanOrEquals:
|
||||
return new ASTNodeLiteral(bool(left <= right));
|
||||
case Token::Operator::BoolAnd:
|
||||
return new ASTNodeLiteral(bool(left && right));
|
||||
case Token::Operator::BoolXor:
|
||||
return new ASTNodeLiteral(bool(left && !right || !left && right));
|
||||
case Token::Operator::BoolOr:
|
||||
return new ASTNodeLiteral(bool(left || right));
|
||||
case Token::Operator::BoolNot:
|
||||
return new ASTNodeLiteral(bool(!right));
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
case Token::Operator::Plus:
|
||||
return new ASTNodeLiteral(left + right);
|
||||
case Token::Operator::Minus:
|
||||
return new ASTNodeLiteral(left - right);
|
||||
case Token::Operator::Star:
|
||||
return new ASTNodeLiteral(left * right);
|
||||
case Token::Operator::Slash:
|
||||
if (right == 0) LogConsole::abortEvaluation("division by zero!", this);
|
||||
return new ASTNodeLiteral(left / right);
|
||||
case Token::Operator::Percent:
|
||||
if (right == 0) LogConsole::abortEvaluation("division by zero!", this);
|
||||
return new ASTNodeLiteral(modulus(left, right));
|
||||
case Token::Operator::ShiftLeft:
|
||||
return new ASTNodeLiteral(shiftLeft(left, right));
|
||||
case Token::Operator::ShiftRight:
|
||||
return new ASTNodeLiteral(shiftRight(left, right));
|
||||
case Token::Operator::BitAnd:
|
||||
return new ASTNodeLiteral(bitAnd(left, right));
|
||||
case Token::Operator::BitXor:
|
||||
return new ASTNodeLiteral(bitXor(left, right));
|
||||
case Token::Operator::BitOr:
|
||||
return new ASTNodeLiteral(bitOr(left, right));
|
||||
case Token::Operator::BitNot:
|
||||
return new ASTNodeLiteral(bitNot(left, right));
|
||||
case Token::Operator::BoolEquals:
|
||||
return new ASTNodeLiteral(bool(left == right));
|
||||
case Token::Operator::BoolNotEquals:
|
||||
return new ASTNodeLiteral(bool(left != right));
|
||||
case Token::Operator::BoolGreaterThan:
|
||||
return new ASTNodeLiteral(bool(left > right));
|
||||
case Token::Operator::BoolLessThan:
|
||||
return new ASTNodeLiteral(bool(left < right));
|
||||
case Token::Operator::BoolGreaterThanOrEquals:
|
||||
return new ASTNodeLiteral(bool(left >= right));
|
||||
case Token::Operator::BoolLessThanOrEquals:
|
||||
return new ASTNodeLiteral(bool(left <= right));
|
||||
case Token::Operator::BoolAnd:
|
||||
return new ASTNodeLiteral(bool(left && right));
|
||||
case Token::Operator::BoolXor:
|
||||
return new ASTNodeLiteral(bool(left && !right || !left && right));
|
||||
case Token::Operator::BoolOr:
|
||||
return new ASTNodeLiteral(bool(left || right));
|
||||
case Token::Operator::BoolNot:
|
||||
return new ASTNodeLiteral(bool(!right));
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid operand used in mathematical expression", this);
|
||||
}
|
||||
} },
|
||||
left->getValue(),
|
||||
right->getValue());
|
||||
left->getValue(),
|
||||
right->getValue());
|
||||
}
|
||||
|
||||
[[nodiscard]] ASTNode *getLeftOperand() const { return this->m_left; }
|
||||
@@ -336,9 +336,9 @@ namespace hex::pl {
|
||||
|
||||
ASTNodeTernaryExpression(const ASTNodeTernaryExpression &other) : ASTNode(other) {
|
||||
this->m_operator = other.m_operator;
|
||||
this->m_first = other.m_first->clone();
|
||||
this->m_second = other.m_second->clone();
|
||||
this->m_third = other.m_third->clone();
|
||||
this->m_first = other.m_first->clone();
|
||||
this->m_second = other.m_second->clone();
|
||||
this->m_third = other.m_third->clone();
|
||||
}
|
||||
|
||||
[[nodiscard]] ASTNode *clone() const override {
|
||||
@@ -349,9 +349,9 @@ namespace hex::pl {
|
||||
if (this->getFirstOperand() == nullptr || this->getSecondOperand() == nullptr || this->getThirdOperand() == nullptr)
|
||||
LogConsole::abortEvaluation("attempted to use void expression in mathematical expression", this);
|
||||
|
||||
auto *first = dynamic_cast<ASTNodeLiteral *>(this->getFirstOperand()->evaluate(evaluator));
|
||||
auto *first = dynamic_cast<ASTNodeLiteral *>(this->getFirstOperand()->evaluate(evaluator));
|
||||
auto *second = dynamic_cast<ASTNodeLiteral *>(this->getSecondOperand()->evaluate(evaluator));
|
||||
auto *third = dynamic_cast<ASTNodeLiteral *>(this->getThirdOperand()->evaluate(evaluator));
|
||||
auto *third = dynamic_cast<ASTNodeLiteral *>(this->getThirdOperand()->evaluate(evaluator));
|
||||
ON_SCOPE_EXIT {
|
||||
delete first;
|
||||
delete second;
|
||||
@@ -362,13 +362,13 @@ namespace hex::pl {
|
||||
[](const std::string &value) -> bool { return !value.empty(); },
|
||||
[this](PatternData *const &) -> bool { LogConsole::abortEvaluation("cannot cast custom type to bool", this); },
|
||||
[](auto &&value) -> bool { return bool(value); } },
|
||||
first->getValue());
|
||||
first->getValue());
|
||||
|
||||
return std::visit(overloaded {
|
||||
[condition]<typename T>(const T &second, const T &third) -> ASTNode * { return new ASTNodeLiteral(condition ? second : third); },
|
||||
[this](auto &&second, auto &&third) -> ASTNode * { LogConsole::abortEvaluation("operands to ternary expression have different types", this); } },
|
||||
second->getValue(),
|
||||
third->getValue());
|
||||
second->getValue(),
|
||||
third->getValue());
|
||||
}
|
||||
|
||||
[[nodiscard]] ASTNode *getFirstOperand() const { return this->m_first; }
|
||||
@@ -394,7 +394,7 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] std::vector<PatternData *> createPatterns(Evaluator *evaluator) const override {
|
||||
auto offset = evaluator->dataOffset();
|
||||
auto size = Token::getTypeSize(this->m_type);
|
||||
auto size = Token::getTypeSize(this->m_type);
|
||||
|
||||
evaluator->dataOffset() += size;
|
||||
|
||||
@@ -436,8 +436,8 @@ namespace hex::pl {
|
||||
: ASTNode(), m_name(std::move(name)), m_type(type), m_endian(endian) { }
|
||||
|
||||
ASTNodeTypeDecl(const ASTNodeTypeDecl &other) : ASTNode(other), Attributable(other) {
|
||||
this->m_name = other.m_name;
|
||||
this->m_type = other.m_type;
|
||||
this->m_name = other.m_name;
|
||||
this->m_type = other.m_type;
|
||||
this->m_endian = other.m_endian;
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ namespace hex::pl {
|
||||
|
||||
if (auto attributable = dynamic_cast<Attributable *>(type)) {
|
||||
for (auto &attribute : this->getAttributes()) {
|
||||
if (auto node = dynamic_cast<ASTNodeAttribute*>(attribute->clone()))
|
||||
if (auto node = dynamic_cast<ASTNodeAttribute *>(attribute->clone()))
|
||||
attributable->addAttribute(node);
|
||||
else
|
||||
delete node;
|
||||
@@ -493,7 +493,7 @@ namespace hex::pl {
|
||||
ASTNodeCast(ASTNode *value, ASTNode *type) : m_value(value), m_type(type) { }
|
||||
ASTNodeCast(const ASTNodeCast &other) : ASTNode(other) {
|
||||
this->m_value = other.m_value->clone();
|
||||
this->m_type = other.m_type->clone();
|
||||
this->m_type = other.m_type->clone();
|
||||
}
|
||||
|
||||
~ASTNodeCast() override {
|
||||
@@ -507,7 +507,7 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] ASTNode *evaluate(Evaluator *evaluator) const override {
|
||||
auto literal = dynamic_cast<ASTNodeLiteral *>(this->m_value->evaluate(evaluator));
|
||||
auto type = dynamic_cast<ASTNodeBuiltinType *>(this->m_type->evaluate(evaluator))->getType();
|
||||
auto type = dynamic_cast<ASTNodeBuiltinType *>(this->m_type->evaluate(evaluator))->getType();
|
||||
|
||||
auto startOffset = evaluator->dataOffset();
|
||||
|
||||
@@ -523,53 +523,53 @@ namespace hex::pl {
|
||||
[&, this](auto &&value) -> ASTNode * {
|
||||
auto endianAdjustedValue = hex::changeEndianess(value, typePattern->getSize(), typePattern->getEndian());
|
||||
switch (type) {
|
||||
case Token::ValueType::Unsigned8Bit:
|
||||
return new ASTNodeLiteral(u128(u8(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned16Bit:
|
||||
return new ASTNodeLiteral(u128(u16(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned32Bit:
|
||||
return new ASTNodeLiteral(u128(u32(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned64Bit:
|
||||
return new ASTNodeLiteral(u128(u64(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned128Bit:
|
||||
return new ASTNodeLiteral(u128(endianAdjustedValue));
|
||||
case Token::ValueType::Signed8Bit:
|
||||
return new ASTNodeLiteral(i128(i8(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed16Bit:
|
||||
return new ASTNodeLiteral(i128(i16(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed32Bit:
|
||||
return new ASTNodeLiteral(i128(i32(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed64Bit:
|
||||
return new ASTNodeLiteral(i128(i64(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed128Bit:
|
||||
return new ASTNodeLiteral(i128(endianAdjustedValue));
|
||||
case Token::ValueType::Float:
|
||||
return new ASTNodeLiteral(double(float(endianAdjustedValue)));
|
||||
case Token::ValueType::Double:
|
||||
return new ASTNodeLiteral(double(endianAdjustedValue));
|
||||
case Token::ValueType::Character:
|
||||
return new ASTNodeLiteral(char(endianAdjustedValue));
|
||||
case Token::ValueType::Character16:
|
||||
return new ASTNodeLiteral(u128(char16_t(endianAdjustedValue)));
|
||||
case Token::ValueType::Boolean:
|
||||
return new ASTNodeLiteral(bool(endianAdjustedValue));
|
||||
case Token::ValueType::String:
|
||||
{
|
||||
std::string string(sizeof(value), '\x00');
|
||||
std::memcpy(string.data(), &value, string.size());
|
||||
hex::trim(string);
|
||||
case Token::ValueType::Unsigned8Bit:
|
||||
return new ASTNodeLiteral(u128(u8(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned16Bit:
|
||||
return new ASTNodeLiteral(u128(u16(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned32Bit:
|
||||
return new ASTNodeLiteral(u128(u32(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned64Bit:
|
||||
return new ASTNodeLiteral(u128(u64(endianAdjustedValue)));
|
||||
case Token::ValueType::Unsigned128Bit:
|
||||
return new ASTNodeLiteral(u128(endianAdjustedValue));
|
||||
case Token::ValueType::Signed8Bit:
|
||||
return new ASTNodeLiteral(i128(i8(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed16Bit:
|
||||
return new ASTNodeLiteral(i128(i16(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed32Bit:
|
||||
return new ASTNodeLiteral(i128(i32(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed64Bit:
|
||||
return new ASTNodeLiteral(i128(i64(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed128Bit:
|
||||
return new ASTNodeLiteral(i128(endianAdjustedValue));
|
||||
case Token::ValueType::Float:
|
||||
return new ASTNodeLiteral(double(float(endianAdjustedValue)));
|
||||
case Token::ValueType::Double:
|
||||
return new ASTNodeLiteral(double(endianAdjustedValue));
|
||||
case Token::ValueType::Character:
|
||||
return new ASTNodeLiteral(char(endianAdjustedValue));
|
||||
case Token::ValueType::Character16:
|
||||
return new ASTNodeLiteral(u128(char16_t(endianAdjustedValue)));
|
||||
case Token::ValueType::Boolean:
|
||||
return new ASTNodeLiteral(bool(endianAdjustedValue));
|
||||
case Token::ValueType::String:
|
||||
{
|
||||
std::string string(sizeof(value), '\x00');
|
||||
std::memcpy(string.data(), &value, string.size());
|
||||
hex::trim(string);
|
||||
|
||||
if (typePattern->getEndian() != std::endian::native)
|
||||
std::reverse(string.begin(), string.end());
|
||||
if (typePattern->getEndian() != std::endian::native)
|
||||
std::reverse(string.begin(), string.end());
|
||||
|
||||
return new ASTNodeLiteral(string);
|
||||
}
|
||||
default:
|
||||
LogConsole::abortEvaluation(hex::format("cannot cast value to '{}'", Token::getTypeName(type)), this);
|
||||
return new ASTNodeLiteral(string);
|
||||
}
|
||||
default:
|
||||
LogConsole::abortEvaluation(hex::format("cannot cast value to '{}'", Token::getTypeName(type)), this);
|
||||
}
|
||||
},
|
||||
},
|
||||
literal->getValue());
|
||||
literal->getValue());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -621,8 +621,8 @@ namespace hex::pl {
|
||||
while (evaluateCondition(evaluator)) {
|
||||
evaluator->handleAbort();
|
||||
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
auto parameterPack = evaluator->getScope(0).parameterPack;
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
auto parameterPack = evaluator->getScope(0).parameterPack;
|
||||
u32 startVariableCount = variables.size();
|
||||
ON_SCOPE_EXIT {
|
||||
ssize_t stackSize = evaluator->getStack().size();
|
||||
@@ -676,7 +676,7 @@ namespace hex::pl {
|
||||
[](const std::string &value) -> bool { return !value.empty(); },
|
||||
[this](PatternData *const &) -> bool { LogConsole::abortEvaluation("cannot cast custom type to bool", this); },
|
||||
[](auto &&value) -> bool { return value != 0; } },
|
||||
literal->getValue());
|
||||
literal->getValue());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -686,7 +686,7 @@ namespace hex::pl {
|
||||
};
|
||||
|
||||
inline void applyVariableAttributes(Evaluator *evaluator, const Attributable *attributable, PatternData *pattern) {
|
||||
auto endOffset = evaluator->dataOffset();
|
||||
auto endOffset = evaluator->dataOffset();
|
||||
evaluator->dataOffset() = pattern->getOffset();
|
||||
ON_SCOPE_EXIT { evaluator->dataOffset() = endOffset; };
|
||||
|
||||
@@ -787,7 +787,7 @@ namespace hex::pl {
|
||||
else
|
||||
this->m_placementOffset = nullptr;
|
||||
|
||||
this->m_inVariable = other.m_inVariable;
|
||||
this->m_inVariable = other.m_inVariable;
|
||||
this->m_outVariable = other.m_outVariable;
|
||||
}
|
||||
|
||||
@@ -816,7 +816,7 @@ namespace hex::pl {
|
||||
[this](const std::string &) -> u64 { LogConsole::abortEvaluation("placement offset cannot be a string", this); },
|
||||
[this](PatternData *const &) -> u64 { LogConsole::abortEvaluation("placement offset cannot be a custom type", this); },
|
||||
[](auto &&offset) -> u64 { return offset; } },
|
||||
offset->getValue());
|
||||
offset->getValue());
|
||||
}
|
||||
|
||||
auto pattern = this->m_type->createPatterns(evaluator).front();
|
||||
@@ -880,7 +880,7 @@ namespace hex::pl {
|
||||
[this](const std::string &) -> u64 { LogConsole::abortEvaluation("placement offset cannot be a string", this); },
|
||||
[this](PatternData *const &) -> u64 { LogConsole::abortEvaluation("placement offset cannot be a custom type", this); },
|
||||
[](auto &&offset) -> u64 { return offset; } },
|
||||
offset->getValue());
|
||||
offset->getValue());
|
||||
}
|
||||
|
||||
auto type = this->m_type->evaluate(evaluator);
|
||||
@@ -938,7 +938,7 @@ namespace hex::pl {
|
||||
[this](const std::string &) -> u128 { LogConsole::abortEvaluation("cannot use string to index array", this); },
|
||||
[this](PatternData *) -> u128 { LogConsole::abortEvaluation("cannot use custom type to index array", this); },
|
||||
[](auto &&size) -> u128 { return size; } },
|
||||
literal->getValue());
|
||||
literal->getValue());
|
||||
} else if (auto whileStatement = dynamic_cast<ASTNodeWhileStatement *>(sizeNode)) {
|
||||
while (whileStatement->evaluateCondition(evaluator)) {
|
||||
entryCount++;
|
||||
@@ -1004,7 +1004,7 @@ namespace hex::pl {
|
||||
delete entry;
|
||||
};
|
||||
|
||||
size_t size = 0;
|
||||
size_t size = 0;
|
||||
u64 entryIndex = 0;
|
||||
|
||||
auto addEntries = [&](const std::vector<PatternData *> &patterns) {
|
||||
@@ -1037,7 +1037,7 @@ namespace hex::pl {
|
||||
[this](const std::string &) -> u128 { LogConsole::abortEvaluation("cannot use string to index array", this); },
|
||||
[this](PatternData *) -> u128 { LogConsole::abortEvaluation("cannot use custom type to index array", this); },
|
||||
[](auto &&size) -> u128 { return size; } },
|
||||
literal->getValue());
|
||||
literal->getValue());
|
||||
|
||||
auto limit = evaluator->getArrayLimit();
|
||||
if (entryCount > limit)
|
||||
@@ -1085,7 +1085,7 @@ namespace hex::pl {
|
||||
} else {
|
||||
while (true) {
|
||||
bool reachedEnd = true;
|
||||
auto limit = evaluator->getArrayLimit();
|
||||
auto limit = evaluator->getArrayLimit();
|
||||
if (entryIndex > limit)
|
||||
LogConsole::abortEvaluation(hex::format("array grew past set limit of {}", limit), this);
|
||||
|
||||
@@ -1150,8 +1150,8 @@ namespace hex::pl {
|
||||
: ASTNode(), m_name(std::move(name)), m_type(type), m_sizeType(sizeType), m_placementOffset(placementOffset) { }
|
||||
|
||||
ASTNodePointerVariableDecl(const ASTNodePointerVariableDecl &other) : ASTNode(other), Attributable(other) {
|
||||
this->m_name = other.m_name;
|
||||
this->m_type = other.m_type->clone();
|
||||
this->m_name = other.m_name;
|
||||
this->m_type = other.m_type->clone();
|
||||
this->m_sizeType = other.m_sizeType->clone();
|
||||
|
||||
if (other.m_placementOffset != nullptr)
|
||||
@@ -1184,7 +1184,7 @@ namespace hex::pl {
|
||||
[this](const std::string &) -> u64 { LogConsole::abortEvaluation("placement offset cannot be a string", this); },
|
||||
[this](PatternData *) -> u64 { LogConsole::abortEvaluation("placement offset cannot be a custom type", this); },
|
||||
[](auto &&offset) -> u64 { return u64(offset); } },
|
||||
offset->getValue());
|
||||
offset->getValue());
|
||||
}
|
||||
|
||||
auto startOffset = evaluator->dataOffset();
|
||||
@@ -1430,7 +1430,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
[[nodiscard]] std::vector<PatternData *> createPatterns(Evaluator *evaluator) const override {
|
||||
auto pattern = new PatternDataEnum(evaluator, evaluator->dataOffset(), 0);
|
||||
auto pattern = new PatternDataEnum(evaluator, evaluator->dataOffset(), 0);
|
||||
auto enumCleanup = SCOPE_GUARD { delete pattern; };
|
||||
|
||||
|
||||
@@ -1507,7 +1507,7 @@ namespace hex::pl {
|
||||
[this](const std::string &) -> u8 { LogConsole::abortEvaluation("bitfield field size cannot be a string", this); },
|
||||
[this](PatternData *) -> u8 { LogConsole::abortEvaluation("bitfield field size cannot be a custom type", this); },
|
||||
[](auto &&offset) -> u8 { return static_cast<u8>(offset); } },
|
||||
dynamic_cast<ASTNodeLiteral *>(literal)->getValue());
|
||||
dynamic_cast<ASTNodeLiteral *>(literal)->getValue());
|
||||
|
||||
// If a field is named padding, it was created through a padding expression and only advances the bit position
|
||||
if (name != "padding") {
|
||||
@@ -1536,7 +1536,7 @@ namespace hex::pl {
|
||||
|
||||
class ASTNodeParameterPack : public ASTNode {
|
||||
public:
|
||||
explicit ASTNodeParameterPack(std::vector<Token::Literal> values) : m_values(std::move(values)) {}
|
||||
explicit ASTNodeParameterPack(std::vector<Token::Literal> values) : m_values(std::move(values)) { }
|
||||
|
||||
[[nodiscard]] ASTNode *clone() const override {
|
||||
return new ASTNodeParameterPack(*this);
|
||||
@@ -1595,7 +1595,7 @@ namespace hex::pl {
|
||||
} else if (dynamic_cast<PatternDataSigned *>(pattern)) {
|
||||
i128 value = 0;
|
||||
readVariable(evaluator, value, pattern);
|
||||
value = hex::signExtend(pattern->getSize() * 8, value);
|
||||
value = hex::signExtend(pattern->getSize() * 8, value);
|
||||
literal = value;
|
||||
} else if (dynamic_cast<PatternDataFloat *>(pattern)) {
|
||||
if (pattern->getSize() == sizeof(u16)) {
|
||||
@@ -1635,7 +1635,7 @@ namespace hex::pl {
|
||||
readVariable(evaluator, value, assignmentValue);
|
||||
},
|
||||
[&, this](auto &&assignmentValue) { LogConsole::abortEvaluation(hex::format("cannot assign '{}' to string", pattern->getTypeName()), this); } },
|
||||
literal);
|
||||
literal);
|
||||
} else {
|
||||
value.resize(pattern->getSize());
|
||||
evaluator->getProvider()->read(pattern->getOffset(), value.data(), value.size());
|
||||
@@ -1665,7 +1665,7 @@ namespace hex::pl {
|
||||
[[nodiscard]] std::vector<PatternData *> createPatterns(Evaluator *evaluator) const override {
|
||||
std::vector<PatternData *> searchScope;
|
||||
PatternData *currPattern = nullptr;
|
||||
i32 scopeIndex = 0;
|
||||
i32 scopeIndex = 0;
|
||||
|
||||
|
||||
if (!evaluator->isGlobalScope()) {
|
||||
@@ -1690,7 +1690,7 @@ namespace hex::pl {
|
||||
if (-scopeIndex >= evaluator->getScopeCount())
|
||||
LogConsole::abortEvaluation("cannot access parent of global scope", this);
|
||||
|
||||
searchScope = *evaluator->getScope(scopeIndex).scope;
|
||||
searchScope = *evaluator->getScope(scopeIndex).scope;
|
||||
auto currParent = evaluator->getScope(scopeIndex).parent;
|
||||
|
||||
if (currParent == nullptr) {
|
||||
@@ -1717,7 +1717,7 @@ namespace hex::pl {
|
||||
auto newPattern = (*iter)->clone();
|
||||
delete currPattern;
|
||||
currPattern = newPattern;
|
||||
found = true;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1755,7 +1755,7 @@ namespace hex::pl {
|
||||
currPattern = newPattern;
|
||||
}
|
||||
} },
|
||||
index->getValue());
|
||||
index->getValue());
|
||||
}
|
||||
|
||||
if (currPattern == nullptr)
|
||||
@@ -1810,7 +1810,7 @@ namespace hex::pl {
|
||||
},
|
||||
[&](PatternData *assignmentValue) { readVariable(evaluator, value, assignmentValue); },
|
||||
[&](auto &&assignmentValue) { value = assignmentValue; } },
|
||||
literal);
|
||||
literal);
|
||||
} else {
|
||||
if constexpr (isString) {
|
||||
value.resize(variablePattern->getSize());
|
||||
@@ -1893,7 +1893,7 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] std::vector<PatternData *> createPatterns(Evaluator *evaluator) const override {
|
||||
auto &scope = *evaluator->getScope(0).scope;
|
||||
auto &body = evaluateCondition(evaluator) ? this->m_trueBody : this->m_falseBody;
|
||||
auto &body = evaluateCondition(evaluator) ? this->m_trueBody : this->m_falseBody;
|
||||
|
||||
for (auto &node : body) {
|
||||
auto newPatterns = node->createPatterns(evaluator);
|
||||
@@ -1912,7 +1912,7 @@ namespace hex::pl {
|
||||
FunctionResult execute(Evaluator *evaluator) const override {
|
||||
auto &body = evaluateCondition(evaluator) ? this->m_trueBody : this->m_falseBody;
|
||||
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
auto parameterPack = evaluator->getScope(0).parameterPack;
|
||||
|
||||
u32 startVariableCount = variables.size();
|
||||
@@ -1948,7 +1948,7 @@ namespace hex::pl {
|
||||
[](const std::string &value) -> bool { return !value.empty(); },
|
||||
[this](PatternData *const &) -> bool { LogConsole::abortEvaluation("cannot cast custom type to bool", this); },
|
||||
[](auto &&value) -> bool { return value != 0; } },
|
||||
literal->getValue());
|
||||
literal->getValue());
|
||||
}
|
||||
|
||||
ASTNode *m_condition;
|
||||
@@ -2010,7 +2010,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
auto &customFunctions = evaluator->getCustomFunctions();
|
||||
auto functions = ContentRegistry::PatternLanguage::getFunctions();
|
||||
auto functions = ContentRegistry::PatternLanguage::getFunctions();
|
||||
|
||||
for (auto &func : customFunctions)
|
||||
functions.insert(func);
|
||||
@@ -2081,7 +2081,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
ASTNodeTypeOperator(const ASTNodeTypeOperator &other) : ASTNode(other) {
|
||||
this->m_op = other.m_op;
|
||||
this->m_op = other.m_op;
|
||||
this->m_expression = other.m_expression->clone();
|
||||
}
|
||||
|
||||
@@ -2106,12 +2106,12 @@ namespace hex::pl {
|
||||
ON_SCOPE_EXIT { delete pattern; };
|
||||
|
||||
switch (this->getOperator()) {
|
||||
case Token::Operator::AddressOf:
|
||||
return new ASTNodeLiteral(u128(pattern->getOffset()));
|
||||
case Token::Operator::SizeOf:
|
||||
return new ASTNodeLiteral(u128(pattern->getSize()));
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid type operator", this);
|
||||
case Token::Operator::AddressOf:
|
||||
return new ASTNodeLiteral(u128(pattern->getOffset()));
|
||||
case Token::Operator::SizeOf:
|
||||
return new ASTNodeLiteral(u128(pattern->getSize()));
|
||||
default:
|
||||
LogConsole::abortEvaluation("invalid type operator", this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2129,7 +2129,7 @@ namespace hex::pl {
|
||||
|
||||
ASTNodeAssignment(const ASTNodeAssignment &other) : ASTNode(other) {
|
||||
this->m_lvalueName = other.m_lvalueName;
|
||||
this->m_rvalue = other.m_rvalue->clone();
|
||||
this->m_rvalue = other.m_rvalue->clone();
|
||||
}
|
||||
|
||||
[[nodiscard]] ASTNode *clone() const override {
|
||||
@@ -2231,7 +2231,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
ASTNodeFunctionDefinition(const ASTNodeFunctionDefinition &other) : ASTNode(other) {
|
||||
this->m_name = other.m_name;
|
||||
this->m_name = other.m_name;
|
||||
this->m_params = other.m_params;
|
||||
|
||||
for (const auto &[name, type] : other.m_params) {
|
||||
@@ -2304,12 +2304,12 @@ namespace hex::pl {
|
||||
|
||||
if (ctx->getCurrentControlFlowStatement() != ControlFlowStatement::None) {
|
||||
switch (ctx->getCurrentControlFlowStatement()) {
|
||||
case ControlFlowStatement::Break:
|
||||
LogConsole::abortEvaluation("break statement not within a loop", statement);
|
||||
case ControlFlowStatement::Continue:
|
||||
LogConsole::abortEvaluation("continue statement not within a loop", statement);
|
||||
default:
|
||||
break;
|
||||
case ControlFlowStatement::Break:
|
||||
LogConsole::abortEvaluation("break statement not within a loop", statement);
|
||||
case ControlFlowStatement::Continue:
|
||||
LogConsole::abortEvaluation("continue statement not within a loop", statement);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->setCurrentControlFlowStatement(ControlFlowStatement::None);
|
||||
@@ -2379,7 +2379,7 @@ namespace hex::pl {
|
||||
FunctionResult execute(Evaluator *evaluator) const override {
|
||||
FunctionResult result;
|
||||
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
u32 startVariableCount = variables.size();
|
||||
|
||||
if (this->m_newScope) {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace hex::pl {
|
||||
PatternLanguageError(u32 lineNumber, std::string message) : m_lineNumber(lineNumber), m_message(std::move(message)) { }
|
||||
|
||||
[[nodiscard]] const char *what() const noexcept override {
|
||||
return this->m_message.c_str();
|
||||
return this->m_message.c_str();
|
||||
}
|
||||
|
||||
[[nodiscard]] u32 getLineNumber() const {
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace hex::pl {
|
||||
std::map<std::string, Token::Literal> m_inVariables;
|
||||
std::map<std::string, size_t> m_outVariables;
|
||||
|
||||
std::atomic<bool> m_dangerousFunctionCalled = false;
|
||||
std::atomic<bool> m_dangerousFunctionCalled = false;
|
||||
std::atomic<DangerousFunctionPermission> m_allowDangerousFunctions = DangerousFunctionPermission::Ask;
|
||||
ControlFlowStatement m_currControlFlowStatement;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace hex::pl {
|
||||
public:
|
||||
using TokenIter = std::vector<Token>::const_iterator;
|
||||
|
||||
Parser() = default;
|
||||
Parser() = default;
|
||||
~Parser() = default;
|
||||
|
||||
std::optional<std::vector<ASTNode *>> parse(const std::vector<Token> &tokens);
|
||||
@@ -151,7 +151,7 @@ namespace hex::pl {
|
||||
|
||||
enum class Setting { };
|
||||
constexpr static auto Normal = static_cast<Setting>(0);
|
||||
constexpr static auto Not = static_cast<Setting>(1);
|
||||
constexpr static auto Not = static_cast<Setting>(1);
|
||||
|
||||
bool begin() {
|
||||
this->m_originalPosition = this->m_curr;
|
||||
|
||||
@@ -69,15 +69,16 @@ namespace hex::pl {
|
||||
getEvaluator()->patternDestroyed();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
Evaluator* getEvaluator() const {
|
||||
[[nodiscard]] Evaluator *getEvaluator() const {
|
||||
return this->m_evaluator;
|
||||
}
|
||||
|
||||
private:
|
||||
Evaluator *m_evaluator = nullptr;
|
||||
};
|
||||
|
||||
class PatternData : public PatternCreationLimiter, public Cloneable<PatternData> {
|
||||
class PatternData : public PatternCreationLimiter,
|
||||
public Cloneable<PatternData> {
|
||||
public:
|
||||
PatternData(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
|
||||
: PatternCreationLimiter(evaluator), m_offset(offset), m_size(size), m_color(color) {
|
||||
@@ -86,7 +87,7 @@ namespace hex::pl {
|
||||
if (color != 0)
|
||||
return;
|
||||
|
||||
this->m_color = ContentRegistry::PatternLanguage::getNextColor();
|
||||
this->m_color = ContentRegistry::PatternLanguage::getNextColor();
|
||||
this->m_manualColor = false;
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] u32 getColor() const { return this->m_color; }
|
||||
virtual void setColor(u32 color) {
|
||||
this->m_color = color;
|
||||
this->m_color = color;
|
||||
this->m_manualColor = true;
|
||||
}
|
||||
[[nodiscard]] bool hasOverriddenColor() const { return this->m_manualColor; }
|
||||
@@ -131,7 +132,7 @@ namespace hex::pl {
|
||||
[[nodiscard]] const auto &getFormatterFunction() const { return this->m_formatterFunction; }
|
||||
void setFormatterFunction(const ContentRegistry::PatternLanguage::Function &function) { this->m_formatterFunction = function; }
|
||||
|
||||
virtual void createEntry(prv::Provider *&provider) = 0;
|
||||
virtual void createEntry(prv::Provider *&provider) = 0;
|
||||
[[nodiscard]] virtual std::string getFormattedName() const = 0;
|
||||
|
||||
[[nodiscard]] virtual const PatternData *getPattern(u64 offset) const {
|
||||
@@ -298,7 +299,7 @@ namespace hex::pl {
|
||||
bool m_hidden = false;
|
||||
|
||||
private:
|
||||
u64 m_offset = 0x00;
|
||||
u64 m_offset = 0x00;
|
||||
size_t m_size = 0x00;
|
||||
|
||||
u32 m_color = 0x00;
|
||||
@@ -310,7 +311,7 @@ namespace hex::pl {
|
||||
std::optional<ContentRegistry::PatternLanguage::Function> m_formatterFunction;
|
||||
std::optional<ContentRegistry::PatternLanguage::Function> m_transformFunction;
|
||||
|
||||
bool m_local = false;
|
||||
bool m_local = false;
|
||||
bool m_manualColor = false;
|
||||
};
|
||||
|
||||
@@ -318,8 +319,7 @@ namespace hex::pl {
|
||||
public:
|
||||
PatternDataPadding(Evaluator *evaluator, u64 offset, size_t size) : PatternData(evaluator, offset, size, 0xFF000000) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataPadding(*this);
|
||||
}
|
||||
|
||||
@@ -347,8 +347,7 @@ namespace hex::pl {
|
||||
delete this->m_pointedAt;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataPointer(*this);
|
||||
}
|
||||
|
||||
@@ -387,21 +386,21 @@ namespace hex::pl {
|
||||
[[nodiscard]] std::string getFormattedName() const override {
|
||||
std::string result = this->m_pointedAt->getFormattedName() + "* : ";
|
||||
switch (this->getSize()) {
|
||||
case 1:
|
||||
result += "u8";
|
||||
break;
|
||||
case 2:
|
||||
result += "u16";
|
||||
break;
|
||||
case 4:
|
||||
result += "u32";
|
||||
break;
|
||||
case 8:
|
||||
result += "u64";
|
||||
break;
|
||||
case 16:
|
||||
result += "u128";
|
||||
break;
|
||||
case 1:
|
||||
result += "u8";
|
||||
break;
|
||||
case 2:
|
||||
result += "u16";
|
||||
break;
|
||||
case 4:
|
||||
result += "u32";
|
||||
break;
|
||||
case 8:
|
||||
result += "u64";
|
||||
break;
|
||||
case 16:
|
||||
result += "u128";
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -459,7 +458,7 @@ namespace hex::pl {
|
||||
|
||||
private:
|
||||
PatternData *m_pointedAt = nullptr;
|
||||
u64 m_pointedAtAddress = 0;
|
||||
u64 m_pointedAtAddress = 0;
|
||||
|
||||
u64 m_pointerBase = 0;
|
||||
};
|
||||
@@ -469,8 +468,7 @@ namespace hex::pl {
|
||||
PatternDataUnsigned(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
|
||||
: PatternData(evaluator, offset, size, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataUnsigned(*this);
|
||||
}
|
||||
|
||||
@@ -484,18 +482,18 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] std::string getFormattedName() const override {
|
||||
switch (this->getSize()) {
|
||||
case 1:
|
||||
return "u8";
|
||||
case 2:
|
||||
return "u16";
|
||||
case 4:
|
||||
return "u32";
|
||||
case 8:
|
||||
return "u64";
|
||||
case 16:
|
||||
return "u128";
|
||||
default:
|
||||
return "Unsigned data";
|
||||
case 1:
|
||||
return "u8";
|
||||
case 2:
|
||||
return "u16";
|
||||
case 4:
|
||||
return "u32";
|
||||
case 8:
|
||||
return "u64";
|
||||
case 16:
|
||||
return "u128";
|
||||
default:
|
||||
return "Unsigned data";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,8 +505,7 @@ namespace hex::pl {
|
||||
PatternDataSigned(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
|
||||
: PatternData(evaluator, offset, size, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataSigned(*this);
|
||||
}
|
||||
|
||||
@@ -523,18 +520,18 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] std::string getFormattedName() const override {
|
||||
switch (this->getSize()) {
|
||||
case 1:
|
||||
return "s8";
|
||||
case 2:
|
||||
return "s16";
|
||||
case 4:
|
||||
return "s32";
|
||||
case 8:
|
||||
return "s64";
|
||||
case 16:
|
||||
return "s128";
|
||||
default:
|
||||
return "Signed data";
|
||||
case 1:
|
||||
return "s8";
|
||||
case 2:
|
||||
return "s16";
|
||||
case 4:
|
||||
return "s32";
|
||||
case 8:
|
||||
return "s64";
|
||||
case 16:
|
||||
return "s128";
|
||||
default:
|
||||
return "Signed data";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,8 +543,7 @@ namespace hex::pl {
|
||||
PatternDataFloat(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
|
||||
: PatternData(evaluator, offset, size, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataFloat(*this);
|
||||
}
|
||||
|
||||
@@ -569,12 +565,12 @@ namespace hex::pl {
|
||||
|
||||
[[nodiscard]] std::string getFormattedName() const override {
|
||||
switch (this->getSize()) {
|
||||
case 4:
|
||||
return "float";
|
||||
case 8:
|
||||
return "double";
|
||||
default:
|
||||
return "Floating point data";
|
||||
case 4:
|
||||
return "float";
|
||||
case 8:
|
||||
return "double";
|
||||
default:
|
||||
return "Floating point data";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,8 +582,7 @@ namespace hex::pl {
|
||||
explicit PatternDataBoolean(Evaluator *evaluator, u64 offset, u32 color = 0)
|
||||
: PatternData(evaluator, offset, 1, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataBoolean(*this);
|
||||
}
|
||||
|
||||
@@ -615,8 +610,7 @@ namespace hex::pl {
|
||||
explicit PatternDataCharacter(Evaluator *evaluator, u64 offset, u32 color = 0)
|
||||
: PatternData(evaluator, offset, 1, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataCharacter(*this);
|
||||
}
|
||||
|
||||
@@ -639,8 +633,7 @@ namespace hex::pl {
|
||||
explicit PatternDataCharacter16(Evaluator *evaluator, u64 offset, u32 color = 0)
|
||||
: PatternData(evaluator, offset, 2, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataCharacter16(*this);
|
||||
}
|
||||
|
||||
@@ -673,8 +666,7 @@ namespace hex::pl {
|
||||
PatternDataString(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
|
||||
: PatternData(evaluator, offset, size, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataString(*this);
|
||||
}
|
||||
|
||||
@@ -714,8 +706,7 @@ namespace hex::pl {
|
||||
PatternDataString16(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
|
||||
: PatternData(evaluator, offset, size, color) { }
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataString16(*this);
|
||||
}
|
||||
|
||||
@@ -731,9 +722,10 @@ namespace hex::pl {
|
||||
for (auto &c : buffer)
|
||||
c = hex::changeEndianess(c, 2, this->getEndian());
|
||||
|
||||
buffer.erase(std::remove_if(buffer.begin(), buffer.end(), [](auto c){
|
||||
buffer.erase(std::remove_if(buffer.begin(), buffer.end(), [](auto c) {
|
||||
return c == 0x00;
|
||||
}), buffer.end());
|
||||
}),
|
||||
buffer.end());
|
||||
|
||||
auto utf8String = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(buffer);
|
||||
|
||||
@@ -781,8 +773,7 @@ namespace hex::pl {
|
||||
delete entry;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataDynamicArray(*this);
|
||||
}
|
||||
|
||||
@@ -934,8 +925,7 @@ namespace hex::pl {
|
||||
delete this->m_highlightTemplate;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataStaticArray(*this);
|
||||
}
|
||||
|
||||
@@ -1036,9 +1026,9 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
void setEntries(PatternData *templ, size_t count) {
|
||||
this->m_template = templ;
|
||||
this->m_template = templ;
|
||||
this->m_highlightTemplate = this->m_template->clone();
|
||||
this->m_entryCount = count;
|
||||
this->m_entryCount = count;
|
||||
|
||||
if (this->hasOverriddenColor()) this->setColor(this->m_template->getColor());
|
||||
this->m_template->setEndian(templ->getEndian());
|
||||
@@ -1070,10 +1060,10 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
private:
|
||||
PatternData *m_template = nullptr;
|
||||
PatternData *m_template = nullptr;
|
||||
mutable PatternData *m_highlightTemplate = nullptr;
|
||||
size_t m_entryCount = 0;
|
||||
u64 m_displayEnd = 50;
|
||||
size_t m_entryCount = 0;
|
||||
u64 m_displayEnd = 50;
|
||||
};
|
||||
|
||||
class PatternDataStruct : public PatternData,
|
||||
@@ -1094,8 +1084,7 @@ namespace hex::pl {
|
||||
delete member;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataStruct(*this);
|
||||
}
|
||||
|
||||
@@ -1242,8 +1231,7 @@ namespace hex::pl {
|
||||
delete member;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataUnion(*this);
|
||||
}
|
||||
|
||||
@@ -1380,8 +1368,7 @@ namespace hex::pl {
|
||||
: PatternData(evaluator, offset, size, color) {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataEnum(*this);
|
||||
}
|
||||
|
||||
@@ -1404,9 +1391,9 @@ namespace hex::pl {
|
||||
|
||||
return false;
|
||||
},
|
||||
[](std::string&) { return false; },
|
||||
[](std::string &) { return false; },
|
||||
[](PatternData *) { return false; } },
|
||||
entryValueLiteral);
|
||||
entryValueLiteral);
|
||||
if (matches)
|
||||
break;
|
||||
}
|
||||
@@ -1476,8 +1463,7 @@ namespace hex::pl {
|
||||
: PatternData(evaluator, offset, 0, color), m_bitOffset(bitOffset), m_bitSize(bitSize), m_bitField(bitField) {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataBitfieldField(*this);
|
||||
}
|
||||
|
||||
@@ -1556,8 +1542,7 @@ namespace hex::pl {
|
||||
delete field;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
PatternData *clone() const override {
|
||||
[[nodiscard]] PatternData *clone() const override {
|
||||
return new PatternDataBitfield(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace hex::pl {
|
||||
[[nodiscard]] bool hasDangerousFunctionBeenCalled() const;
|
||||
void allowDangerousFunctions(bool allow);
|
||||
|
||||
[[nodiscard]] std::vector<PatternData*> &getPatterns() {
|
||||
[[nodiscard]] std::vector<PatternData *> &getPatterns() {
|
||||
return this->m_patterns;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace hex::pl {
|
||||
|
||||
std::optional<PatternLanguageError> m_currError;
|
||||
|
||||
std::vector<PatternData*> m_patterns;
|
||||
std::vector<PatternData *> m_patterns;
|
||||
|
||||
bool m_running = false;
|
||||
};
|
||||
|
||||
@@ -81,31 +81,31 @@ namespace hex::pl {
|
||||
};
|
||||
|
||||
enum class ValueType {
|
||||
Unsigned8Bit = 0x10,
|
||||
Signed8Bit = 0x11,
|
||||
Unsigned16Bit = 0x20,
|
||||
Signed16Bit = 0x21,
|
||||
Unsigned32Bit = 0x40,
|
||||
Signed32Bit = 0x41,
|
||||
Unsigned64Bit = 0x80,
|
||||
Signed64Bit = 0x81,
|
||||
Unsigned8Bit = 0x10,
|
||||
Signed8Bit = 0x11,
|
||||
Unsigned16Bit = 0x20,
|
||||
Signed16Bit = 0x21,
|
||||
Unsigned32Bit = 0x40,
|
||||
Signed32Bit = 0x41,
|
||||
Unsigned64Bit = 0x80,
|
||||
Signed64Bit = 0x81,
|
||||
Unsigned128Bit = 0x100,
|
||||
Signed128Bit = 0x101,
|
||||
Character = 0x13,
|
||||
Character16 = 0x23,
|
||||
Boolean = 0x14,
|
||||
Float = 0x42,
|
||||
Double = 0x82,
|
||||
String = 0x15,
|
||||
Auto = 0x16,
|
||||
CustomType = 0x00,
|
||||
Padding = 0x1F,
|
||||
Signed128Bit = 0x101,
|
||||
Character = 0x13,
|
||||
Character16 = 0x23,
|
||||
Boolean = 0x14,
|
||||
Float = 0x42,
|
||||
Double = 0x82,
|
||||
String = 0x15,
|
||||
Auto = 0x16,
|
||||
CustomType = 0x00,
|
||||
Padding = 0x1F,
|
||||
|
||||
Unsigned = 0xFF00,
|
||||
Signed = 0xFF01,
|
||||
Unsigned = 0xFF00,
|
||||
Signed = 0xFF01,
|
||||
FloatingPoint = 0xFF02,
|
||||
Integer = 0xFF03,
|
||||
Any = 0xFFFF
|
||||
Integer = 0xFF03,
|
||||
Any = 0xFFFF
|
||||
};
|
||||
|
||||
enum class Separator {
|
||||
@@ -127,13 +127,13 @@ 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;
|
||||
bool operator==(const Identifier &) const = default;
|
||||
|
||||
private:
|
||||
std::string m_identifier;
|
||||
};
|
||||
|
||||
using Literal = std::variant<char, bool, u128, i128, double, std::string, PatternData *>;
|
||||
using Literal = std::variant<char, bool, u128, i128, double, std::string, PatternData *>;
|
||||
using ValueTypes = std::variant<Keyword, Identifier, Operator, Literal, ValueType, Separator>;
|
||||
|
||||
Token(Type type, auto value, u32 lineNumber) : type(type), value(value), lineNumber(lineNumber) {
|
||||
@@ -160,7 +160,7 @@ namespace hex::pl {
|
||||
[](const std::string &) -> u128 { LogConsole::abortEvaluation("expected integral type, got string"); },
|
||||
[](PatternData *) -> u128 { LogConsole::abortEvaluation("expected integral type, got custom type"); },
|
||||
[](auto &&result) -> u128 { return result; } },
|
||||
literal);
|
||||
literal);
|
||||
}
|
||||
|
||||
static i128 literalToSigned(const pl::Token::Literal &literal) {
|
||||
@@ -168,7 +168,7 @@ namespace hex::pl {
|
||||
[](const std::string &) -> i128 { LogConsole::abortEvaluation("expected integral type, got string"); },
|
||||
[](PatternData *) -> i128 { LogConsole::abortEvaluation("expected integral type, got custom type"); },
|
||||
[](auto &&result) -> i128 { return result; } },
|
||||
literal);
|
||||
literal);
|
||||
}
|
||||
|
||||
static double literalToFloatingPoint(const pl::Token::Literal &literal) {
|
||||
@@ -176,7 +176,7 @@ namespace hex::pl {
|
||||
[](const std::string &) -> double { LogConsole::abortEvaluation("expected integral type, got string"); },
|
||||
[](PatternData *) -> double { LogConsole::abortEvaluation("expected integral type, got custom type"); },
|
||||
[](auto &&result) -> double { return result; } },
|
||||
literal);
|
||||
literal);
|
||||
}
|
||||
|
||||
static bool literalToBoolean(const pl::Token::Literal &literal) {
|
||||
@@ -184,7 +184,7 @@ namespace hex::pl {
|
||||
[](const std::string &) -> bool { LogConsole::abortEvaluation("expected integral type, got string"); },
|
||||
[](PatternData *) -> bool { LogConsole::abortEvaluation("expected integral type, got custom type"); },
|
||||
[](auto &&result) -> bool { return result != 0; } },
|
||||
literal);
|
||||
literal);
|
||||
}
|
||||
|
||||
static std::string literalToString(const pl::Token::Literal &literal, bool cast) {
|
||||
@@ -199,45 +199,45 @@ namespace hex::pl {
|
||||
[](char result) -> std::string { return { 1, result }; },
|
||||
[](PatternData *) -> std::string { LogConsole::abortEvaluation("expected integral type, got custom type"); },
|
||||
[](auto &&result) -> std::string { return std::to_string(result); } },
|
||||
literal);
|
||||
literal);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr static auto getTypeName(const pl::Token::ValueType type) {
|
||||
switch (type) {
|
||||
case ValueType::Signed8Bit:
|
||||
return "s8";
|
||||
case ValueType::Signed16Bit:
|
||||
return "s16";
|
||||
case ValueType::Signed32Bit:
|
||||
return "s32";
|
||||
case ValueType::Signed64Bit:
|
||||
return "s64";
|
||||
case ValueType::Signed128Bit:
|
||||
return "s128";
|
||||
case ValueType::Unsigned8Bit:
|
||||
return "u8";
|
||||
case ValueType::Unsigned16Bit:
|
||||
return "u16";
|
||||
case ValueType::Unsigned32Bit:
|
||||
return "u32";
|
||||
case ValueType::Unsigned64Bit:
|
||||
return "u64";
|
||||
case ValueType::Unsigned128Bit:
|
||||
return "u128";
|
||||
case ValueType::Float:
|
||||
return "float";
|
||||
case ValueType::Double:
|
||||
return "double";
|
||||
case ValueType::Character:
|
||||
return "char";
|
||||
case ValueType::Character16:
|
||||
return "char16";
|
||||
case ValueType::Padding:
|
||||
return "padding";
|
||||
case ValueType::String:
|
||||
return "str";
|
||||
default:
|
||||
return "< ??? >";
|
||||
case ValueType::Signed8Bit:
|
||||
return "s8";
|
||||
case ValueType::Signed16Bit:
|
||||
return "s16";
|
||||
case ValueType::Signed32Bit:
|
||||
return "s32";
|
||||
case ValueType::Signed64Bit:
|
||||
return "s64";
|
||||
case ValueType::Signed128Bit:
|
||||
return "s128";
|
||||
case ValueType::Unsigned8Bit:
|
||||
return "u8";
|
||||
case ValueType::Unsigned16Bit:
|
||||
return "u16";
|
||||
case ValueType::Unsigned32Bit:
|
||||
return "u32";
|
||||
case ValueType::Unsigned64Bit:
|
||||
return "u64";
|
||||
case ValueType::Unsigned128Bit:
|
||||
return "u128";
|
||||
case ValueType::Float:
|
||||
return "float";
|
||||
case ValueType::Double:
|
||||
return "double";
|
||||
case ValueType::Character:
|
||||
return "char";
|
||||
case ValueType::Character16:
|
||||
return "char16";
|
||||
case ValueType::Padding:
|
||||
return "padding";
|
||||
case ValueType::String:
|
||||
return "str";
|
||||
default:
|
||||
return "< ??? >";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace hex::pl {
|
||||
return true;
|
||||
else if (this->type == Type::ValueType) {
|
||||
auto otherValueType = std::get_if<ValueType>(&other);
|
||||
auto valueType = std::get_if<ValueType>(&this->value);
|
||||
auto valueType = std::get_if<ValueType>(&this->value);
|
||||
|
||||
if (otherValueType == nullptr) return false;
|
||||
if (valueType == nullptr) return false;
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace hex::prv {
|
||||
virtual ~Provider();
|
||||
|
||||
[[nodiscard]] virtual bool isAvailable() const = 0;
|
||||
[[nodiscard]] virtual bool isReadable() const = 0;
|
||||
[[nodiscard]] virtual bool isWritable() const = 0;
|
||||
[[nodiscard]] virtual bool isReadable() const = 0;
|
||||
[[nodiscard]] virtual bool isWritable() const = 0;
|
||||
[[nodiscard]] virtual bool isResizable() const = 0;
|
||||
[[nodiscard]] virtual bool isSavable() const = 0;
|
||||
[[nodiscard]] virtual bool isSavable() const = 0;
|
||||
|
||||
virtual void read(u64 offset, void *buffer, size_t size, bool overlays = true);
|
||||
virtual void write(u64 offset, const void *buffer, size_t size);
|
||||
@@ -35,9 +35,9 @@ namespace hex::prv {
|
||||
virtual void save();
|
||||
virtual void saveAs(const fs::path &path);
|
||||
|
||||
virtual void readRaw(u64 offset, void *buffer, size_t size) = 0;
|
||||
virtual void readRaw(u64 offset, void *buffer, size_t size) = 0;
|
||||
virtual void writeRaw(u64 offset, const void *buffer, size_t size) = 0;
|
||||
[[nodiscard]] virtual size_t getActualSize() const = 0;
|
||||
[[nodiscard]] virtual size_t getActualSize() const = 0;
|
||||
|
||||
void applyOverlays(u64 offset, void *buffer, size_t size);
|
||||
|
||||
@@ -59,11 +59,11 @@ namespace hex::prv {
|
||||
[[nodiscard]] virtual size_t getSize() const;
|
||||
[[nodiscard]] virtual std::optional<u32> getPageOfAddress(u64 address) const;
|
||||
|
||||
[[nodiscard]] virtual std::string getName() const = 0;
|
||||
[[nodiscard]] virtual std::string getName() const = 0;
|
||||
[[nodiscard]] virtual std::vector<std::pair<std::string, std::string>> getDataInformation() const = 0;
|
||||
|
||||
[[nodiscard]] virtual bool open() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
void addPatch(u64 offset, const void *buffer, size_t size, bool createUndo = false);
|
||||
void createUndoPoint();
|
||||
@@ -79,11 +79,11 @@ namespace hex::prv {
|
||||
virtual void drawLoadInterface();
|
||||
virtual void drawInterface();
|
||||
|
||||
pl::PatternLanguage& getPatternLanguageRuntime() { return this->m_patternLanguageRuntime; }
|
||||
std::string& getPatternLanguageSourceCode() { return this->m_patternLanguageSourceCode; }
|
||||
pl::PatternLanguage &getPatternLanguageRuntime() { return this->m_patternLanguageRuntime; }
|
||||
std::string &getPatternLanguageSourceCode() { return this->m_patternLanguageSourceCode; }
|
||||
|
||||
protected:
|
||||
u32 m_currPage = 0;
|
||||
u32 m_currPage = 0;
|
||||
u64 m_baseAddress = 0;
|
||||
|
||||
u32 m_patchTreeOffset = 0;
|
||||
|
||||
@@ -219,10 +219,8 @@ namespace hex {
|
||||
}
|
||||
|
||||
void ContentRegistry::PatternLanguage::addColorPalette(const std::string &unlocalizedName, const std::vector<u32> &colors) {
|
||||
s_colorPalettes.push_back({
|
||||
unlocalizedName,
|
||||
colors
|
||||
});
|
||||
s_colorPalettes.push_back({ unlocalizedName,
|
||||
colors });
|
||||
}
|
||||
|
||||
void ContentRegistry::PatternLanguage::setSelectedPalette(u32 index) {
|
||||
|
||||
@@ -29,13 +29,15 @@ namespace hex {
|
||||
static std::map<u32, ImHexApi::HexEditor::Highlighting> s_highlights;
|
||||
|
||||
Highlighting::Highlighting(Region region, color_t color, const std::string &tooltip)
|
||||
: m_region(region), m_color(color), m_tooltip(tooltip) {
|
||||
: m_region(region), m_color(color), m_tooltip(tooltip) {
|
||||
}
|
||||
|
||||
u32 addHighlight(const Region ®ion, color_t color, std::string tooltip) {
|
||||
auto id = s_highlights.size();
|
||||
|
||||
s_highlights.insert({ id, Highlighting{ region, color, tooltip } });
|
||||
s_highlights.insert({
|
||||
id, Highlighting {region, color, tooltip}
|
||||
});
|
||||
|
||||
return id;
|
||||
}
|
||||
@@ -67,7 +69,7 @@ namespace hex {
|
||||
namespace ImHexApi::Provider {
|
||||
|
||||
static u32 s_currentProvider;
|
||||
static std::vector<prv::Provider*> s_providers;
|
||||
static std::vector<prv::Provider *> s_providers;
|
||||
|
||||
prv::Provider *get() {
|
||||
if (!ImHexApi::Provider::isValid())
|
||||
@@ -82,7 +84,7 @@ namespace hex {
|
||||
|
||||
void setCurrentProvider(u32 index) {
|
||||
if (index < s_providers.size()) {
|
||||
auto oldProvider = get();
|
||||
auto oldProvider = get();
|
||||
s_currentProvider = index;
|
||||
EventManager::post<EventProviderChanged>(oldProvider, get());
|
||||
}
|
||||
@@ -126,7 +128,7 @@ namespace hex {
|
||||
getDeferredCalls().push_back(function);
|
||||
}
|
||||
|
||||
std::vector<std::function<void()>>& getDeferredCalls() {
|
||||
std::vector<std::function<void()>> &getDeferredCalls() {
|
||||
return s_deferredCalls;
|
||||
}
|
||||
|
||||
@@ -169,8 +171,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
|
||||
|
||||
const ProgramArguments& getProgramArguments() {
|
||||
const ProgramArguments &getProgramArguments() {
|
||||
return impl::s_programArguments;
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ namespace hex {
|
||||
return impl::s_mainDockSpaceId;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string>& getInitArguments() {
|
||||
std::map<std::string, std::string> &getInitArguments() {
|
||||
static std::map<std::string, std::string> initArgs;
|
||||
|
||||
return initArgs;
|
||||
|
||||
@@ -17,35 +17,35 @@ namespace hex {
|
||||
|
||||
auto pluginName = fs::path(path).stem().string();
|
||||
|
||||
this->m_initializePluginFunction = getPluginFunction<InitializePluginFunc>("initializePlugin");
|
||||
this->m_getPluginNameFunction = getPluginFunction<GetPluginNameFunc>("getPluginName");
|
||||
this->m_getPluginAuthorFunction = getPluginFunction<GetPluginAuthorFunc>("getPluginAuthor");
|
||||
this->m_getPluginDescriptionFunction = getPluginFunction<GetPluginDescriptionFunc>("getPluginDescription");
|
||||
this->m_getCompatibleVersionFunction = getPluginFunction<GetCompatibleVersionFunc>("getCompatibleVersion");
|
||||
this->m_setImGuiContextFunction = getPluginFunction<SetImGuiContextFunc>("setImGuiContext");
|
||||
this->m_isBuiltinPluginFunction = getPluginFunction<IsBuiltinPluginFunc>("isBuiltinPlugin");
|
||||
this->m_initializePluginFunction = getPluginFunction<InitializePluginFunc>("initializePlugin");
|
||||
this->m_getPluginNameFunction = getPluginFunction<GetPluginNameFunc>("getPluginName");
|
||||
this->m_getPluginAuthorFunction = getPluginFunction<GetPluginAuthorFunc>("getPluginAuthor");
|
||||
this->m_getPluginDescriptionFunction = getPluginFunction<GetPluginDescriptionFunc>("getPluginDescription");
|
||||
this->m_getCompatibleVersionFunction = getPluginFunction<GetCompatibleVersionFunc>("getCompatibleVersion");
|
||||
this->m_setImGuiContextFunction = getPluginFunction<SetImGuiContextFunc>("setImGuiContext");
|
||||
this->m_isBuiltinPluginFunction = getPluginFunction<IsBuiltinPluginFunc>("isBuiltinPlugin");
|
||||
}
|
||||
|
||||
Plugin::Plugin(Plugin &&other) noexcept {
|
||||
this->m_handle = other.m_handle;
|
||||
this->m_path = std::move(other.m_path);
|
||||
this->m_path = std::move(other.m_path);
|
||||
|
||||
this->m_initializePluginFunction = other.m_initializePluginFunction;
|
||||
this->m_getPluginNameFunction = other.m_getPluginNameFunction;
|
||||
this->m_getPluginAuthorFunction = other.m_getPluginAuthorFunction;
|
||||
this->m_getPluginDescriptionFunction = other.m_getPluginDescriptionFunction;
|
||||
this->m_getCompatibleVersionFunction = other.m_getCompatibleVersionFunction;
|
||||
this->m_setImGuiContextFunction = other.m_setImGuiContextFunction;
|
||||
this->m_isBuiltinPluginFunction = other.m_isBuiltinPluginFunction;
|
||||
this->m_initializePluginFunction = other.m_initializePluginFunction;
|
||||
this->m_getPluginNameFunction = other.m_getPluginNameFunction;
|
||||
this->m_getPluginAuthorFunction = other.m_getPluginAuthorFunction;
|
||||
this->m_getPluginDescriptionFunction = other.m_getPluginDescriptionFunction;
|
||||
this->m_getCompatibleVersionFunction = other.m_getCompatibleVersionFunction;
|
||||
this->m_setImGuiContextFunction = other.m_setImGuiContextFunction;
|
||||
this->m_isBuiltinPluginFunction = other.m_isBuiltinPluginFunction;
|
||||
|
||||
other.m_handle = nullptr;
|
||||
other.m_initializePluginFunction = nullptr;
|
||||
other.m_getPluginNameFunction = nullptr;
|
||||
other.m_getPluginAuthorFunction = nullptr;
|
||||
other.m_getPluginDescriptionFunction = nullptr;
|
||||
other.m_getCompatibleVersionFunction = nullptr;
|
||||
other.m_setImGuiContextFunction = nullptr;
|
||||
other.m_isBuiltinPluginFunction = nullptr;
|
||||
other.m_handle = nullptr;
|
||||
other.m_initializePluginFunction = nullptr;
|
||||
other.m_getPluginNameFunction = nullptr;
|
||||
other.m_getPluginAuthorFunction = nullptr;
|
||||
other.m_getPluginDescriptionFunction = nullptr;
|
||||
other.m_getCompatibleVersionFunction = nullptr;
|
||||
other.m_setImGuiContextFunction = nullptr;
|
||||
other.m_isBuiltinPluginFunction = nullptr;
|
||||
}
|
||||
|
||||
Plugin::~Plugin() {
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace hex::crypt {
|
||||
m_refin(refin),
|
||||
m_refout(refout),
|
||||
table([polynomial, bits]() {
|
||||
auto reflectedpoly = reflect(polynomial & ((0b10ull << (bits - 1)) - 1), bits);
|
||||
auto reflectedpoly = reflect(polynomial & ((0b10ull << (bits - 1)) - 1), bits);
|
||||
std::array<uint64_t, 256> table = { 0 };
|
||||
|
||||
for (uint32_t i = 0; i < 256; i++) {
|
||||
@@ -452,47 +452,47 @@ namespace hex::crypt {
|
||||
|
||||
std::vector<u8> aesDecrypt(AESMode mode, KeyLength keyLength, const std::vector<u8> &key, std::array<u8, 8> nonce, std::array<u8, 8> iv, const std::vector<u8> &input) {
|
||||
switch (keyLength) {
|
||||
case KeyLength::Key128Bits:
|
||||
if (key.size() != 128 / 8) return {};
|
||||
break;
|
||||
case KeyLength::Key192Bits:
|
||||
if (key.size() != 192 / 8) return {};
|
||||
break;
|
||||
case KeyLength::Key256Bits:
|
||||
if (key.size() != 256 / 8) return {};
|
||||
break;
|
||||
default:
|
||||
return {};
|
||||
case KeyLength::Key128Bits:
|
||||
if (key.size() != 128 / 8) return {};
|
||||
break;
|
||||
case KeyLength::Key192Bits:
|
||||
if (key.size() != 192 / 8) return {};
|
||||
break;
|
||||
case KeyLength::Key256Bits:
|
||||
if (key.size() != 256 / 8) return {};
|
||||
break;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
||||
mbedtls_cipher_type_t type;
|
||||
switch (mode) {
|
||||
case AESMode::ECB:
|
||||
type = MBEDTLS_CIPHER_AES_128_ECB;
|
||||
break;
|
||||
case AESMode::CBC:
|
||||
type = MBEDTLS_CIPHER_AES_128_CBC;
|
||||
break;
|
||||
case AESMode::CFB128:
|
||||
type = MBEDTLS_CIPHER_AES_128_CFB128;
|
||||
break;
|
||||
case AESMode::CTR:
|
||||
type = MBEDTLS_CIPHER_AES_128_CTR;
|
||||
break;
|
||||
case AESMode::GCM:
|
||||
type = MBEDTLS_CIPHER_AES_128_GCM;
|
||||
break;
|
||||
case AESMode::CCM:
|
||||
type = MBEDTLS_CIPHER_AES_128_CCM;
|
||||
break;
|
||||
case AESMode::OFB:
|
||||
type = MBEDTLS_CIPHER_AES_128_OFB;
|
||||
break;
|
||||
case AESMode::XTS:
|
||||
type = MBEDTLS_CIPHER_AES_128_XTS;
|
||||
break;
|
||||
default:
|
||||
return {};
|
||||
case AESMode::ECB:
|
||||
type = MBEDTLS_CIPHER_AES_128_ECB;
|
||||
break;
|
||||
case AESMode::CBC:
|
||||
type = MBEDTLS_CIPHER_AES_128_CBC;
|
||||
break;
|
||||
case AESMode::CFB128:
|
||||
type = MBEDTLS_CIPHER_AES_128_CFB128;
|
||||
break;
|
||||
case AESMode::CTR:
|
||||
type = MBEDTLS_CIPHER_AES_128_CTR;
|
||||
break;
|
||||
case AESMode::GCM:
|
||||
type = MBEDTLS_CIPHER_AES_128_GCM;
|
||||
break;
|
||||
case AESMode::CCM:
|
||||
type = MBEDTLS_CIPHER_AES_128_CCM;
|
||||
break;
|
||||
case AESMode::OFB:
|
||||
type = MBEDTLS_CIPHER_AES_128_OFB;
|
||||
break;
|
||||
case AESMode::XTS:
|
||||
type = MBEDTLS_CIPHER_AES_128_XTS;
|
||||
break;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
||||
type = mbedtls_cipher_type_t(type + u8(keyLength));
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace hex {
|
||||
std::ifstream encodingFile(path.c_str());
|
||||
|
||||
switch (type) {
|
||||
case Type::Thingy:
|
||||
parseThingyFile(encodingFile);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case Type::Thingy:
|
||||
parseThingyFile(encodingFile);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
this->m_valid = true;
|
||||
@@ -45,7 +45,7 @@ namespace hex {
|
||||
continue;
|
||||
|
||||
from = line.substr(0, delimiterPos);
|
||||
to = line.substr(delimiterPos + 1);
|
||||
to = line.substr(delimiterPos + 1);
|
||||
|
||||
hex::trim(from);
|
||||
hex::trim(to);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace hex {
|
||||
u64 address;
|
||||
size_t size;
|
||||
|
||||
char *name = nullptr;
|
||||
char *name = nullptr;
|
||||
char *comment = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "K|n|s|s", &address, &size, &name, &comment)) {
|
||||
@@ -213,7 +213,7 @@ namespace hex {
|
||||
|
||||
{
|
||||
auto sysPath = PySys_GetObject("path");
|
||||
auto path = PyUnicode_FromString("lib");
|
||||
auto path = PyUnicode_FromString("lib");
|
||||
|
||||
PyList_Insert(sysPath, 0, path);
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ namespace hex {
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_NOSIGNAL, 1L);
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_NOPROGRESS, 0L);
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_CAINFO, nullptr);
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_CAPATH, nullptr);
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_SSLCERTTYPE, "PEM");
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_SSL_CTX_FUNCTION, sslCtxFunction);
|
||||
#endif
|
||||
#if defined(OS_WINDOWS)
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_CAINFO, nullptr);
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_CAPATH, nullptr);
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_SSLCERTTYPE, "PEM");
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_SSL_CTX_FUNCTION, sslCtxFunction);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<i32> Net::execute() {
|
||||
@@ -127,8 +127,8 @@ namespace hex {
|
||||
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||
|
||||
curl_slist_free_all(this->m_headers);
|
||||
this->m_headers = nullptr;
|
||||
this->m_progress = 0.0F;
|
||||
this->m_headers = nullptr;
|
||||
this->m_progress = 0.0F;
|
||||
this->m_shouldCancel = false;
|
||||
|
||||
if (result != CURLE_OK)
|
||||
@@ -183,7 +183,7 @@ namespace hex {
|
||||
if (!file.isValid())
|
||||
return Response<std::string> { 400, {} };
|
||||
|
||||
curl_mime *mime = curl_mime_init(this->m_ctx);
|
||||
curl_mime *mime = curl_mime_init(this->m_ctx);
|
||||
curl_mimepart *part = curl_mime_addpart(mime);
|
||||
|
||||
auto fileName = filePath.filename().string();
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace hex {
|
||||
if (bytes.size() > 0xFFFF || startAddress > 0xFF'FFFF)
|
||||
return {};
|
||||
|
||||
u32 address = startAddress.value();
|
||||
u32 address = startAddress.value();
|
||||
auto addressBytes = reinterpret_cast<u8 *>(&address);
|
||||
|
||||
result.push_back(addressBytes[2]);
|
||||
@@ -93,7 +93,7 @@ namespace hex {
|
||||
if (bytes.size() > 0xFFFF || startAddress > 0xFFFF'FFFF)
|
||||
return {};
|
||||
|
||||
u32 address = startAddress.value();
|
||||
u32 address = startAddress.value();
|
||||
auto addressBytes = reinterpret_cast<u8 *>(&address);
|
||||
|
||||
result.push_back(addressBytes[3]);
|
||||
@@ -128,7 +128,7 @@ namespace hex {
|
||||
u32 ipsOffset = 5;
|
||||
while (ipsOffset < ipsPatch.size() - (5 + 3)) {
|
||||
u32 offset = ipsPatch[ipsOffset + 2] | (ipsPatch[ipsOffset + 1] << 8) | (ipsPatch[ipsOffset + 0] << 16);
|
||||
u16 size = ipsPatch[ipsOffset + 4] | (ipsPatch[ipsOffset + 3] << 8);
|
||||
u16 size = ipsPatch[ipsOffset + 4] | (ipsPatch[ipsOffset + 3] << 8);
|
||||
|
||||
ipsOffset += 5;
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace hex {
|
||||
u32 ipsOffset = 5;
|
||||
while (ipsOffset < ipsPatch.size() - (5 + 4)) {
|
||||
u32 offset = ipsPatch[ipsOffset + 3] | (ipsPatch[ipsOffset + 2] << 8) | (ipsPatch[ipsOffset + 1] << 16) | (ipsPatch[ipsOffset + 0] << 24);
|
||||
u16 size = ipsPatch[ipsOffset + 5] | (ipsPatch[ipsOffset + 4] << 8);
|
||||
u16 size = ipsPatch[ipsOffset + 5] | (ipsPatch[ipsOffset + 4] << 8);
|
||||
|
||||
ipsOffset += 6;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace hex {
|
||||
std::vector<fs::path> result;
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
const auto exePath = getExecutablePath();
|
||||
const auto exePath = getExecutablePath();
|
||||
const auto parentDir = fs::path(exePath).parent_path();
|
||||
|
||||
fs::path appDataDir;
|
||||
@@ -56,60 +56,60 @@ namespace hex {
|
||||
std::vector<fs::path> paths = { parentDir, appDataDir / "imhex" };
|
||||
|
||||
switch (path) {
|
||||
case ImHexPath::Patterns:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "patterns").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::PatternsInclude:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "includes").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "magic").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "python").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "plugins").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "yara").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
return { (appDataDir / "imhex" / "config").string() };
|
||||
case ImHexPath::Resources:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "resources").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "constants").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Encodings:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "encodings").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Logs:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "logs").string();
|
||||
});
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
case ImHexPath::Patterns:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "patterns").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::PatternsInclude:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "includes").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "magic").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "python").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "plugins").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "yara").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
return { (appDataDir / "imhex" / "config").string() };
|
||||
case ImHexPath::Resources:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "resources").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "constants").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Encodings:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "encodings").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Logs:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "logs").string();
|
||||
});
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
#elif defined(OS_MACOS)
|
||||
// Get path to special directories
|
||||
@@ -119,47 +119,47 @@ namespace hex {
|
||||
std::vector<fs::path> paths = { exePath, applicationSupportDir };
|
||||
|
||||
switch (path) {
|
||||
case ImHexPath::Patterns:
|
||||
result.push_back((applicationSupportDir / "patterns").string());
|
||||
break;
|
||||
case ImHexPath::PatternsInclude:
|
||||
result.push_back((applicationSupportDir / "includes").string());
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
result.push_back((applicationSupportDir / "magic").string());
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
result.push_back((applicationSupportDir / "python").string());
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "plugins").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
result.push_back((applicationSupportDir / "yara").string());
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
result.push_back((applicationSupportDir / "config").string());
|
||||
break;
|
||||
case ImHexPath::Resources:
|
||||
result.push_back((applicationSupportDir / "resources").string());
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
result.push_back((applicationSupportDir / "constants").string());
|
||||
break;
|
||||
case ImHexPath::Encodings:
|
||||
result.push_back((applicationSupportDir / "encodings").string());
|
||||
break;
|
||||
case ImHexPath::Logs:
|
||||
result.push_back((applicationSupportDir / "logs").string());
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
case ImHexPath::Patterns:
|
||||
result.push_back((applicationSupportDir / "patterns").string());
|
||||
break;
|
||||
case ImHexPath::PatternsInclude:
|
||||
result.push_back((applicationSupportDir / "includes").string());
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
result.push_back((applicationSupportDir / "magic").string());
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
result.push_back((applicationSupportDir / "python").string());
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) {
|
||||
return (path / "plugins").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
result.push_back((applicationSupportDir / "yara").string());
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
result.push_back((applicationSupportDir / "config").string());
|
||||
break;
|
||||
case ImHexPath::Resources:
|
||||
result.push_back((applicationSupportDir / "resources").string());
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
result.push_back((applicationSupportDir / "constants").string());
|
||||
break;
|
||||
case ImHexPath::Encodings:
|
||||
result.push_back((applicationSupportDir / "encodings").string());
|
||||
break;
|
||||
case ImHexPath::Logs:
|
||||
result.push_back((applicationSupportDir / "logs").string());
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
#else
|
||||
std::vector<fs::path> configDirs = xdg::ConfigDirs();
|
||||
std::vector<fs::path> dataDirs = xdg::DataDirs();
|
||||
std::vector<fs::path> dataDirs = xdg::DataDirs();
|
||||
|
||||
configDirs.insert(configDirs.begin(), xdg::ConfigHomeDir());
|
||||
dataDirs.insert(dataDirs.begin(), xdg::DataHomeDir());
|
||||
@@ -173,49 +173,49 @@ namespace hex {
|
||||
dataDirs.emplace(dataDirs.begin(), fs::path(exePath.data()).parent_path());
|
||||
|
||||
switch (path) {
|
||||
case ImHexPath::Patterns:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "patterns").string(); });
|
||||
break;
|
||||
case ImHexPath::PatternsInclude:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "includes").string(); });
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "magic").string(); });
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p).string(); });
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "plugins").string(); });
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "yara").string(); });
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
std::transform(configDirs.begin(), configDirs.end(), std::back_inserter(result), [](auto p) { return (p / "imhex").string(); });
|
||||
break;
|
||||
case ImHexPath::Resources:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "resources").string(); });
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "constants").string(); });
|
||||
break;
|
||||
case ImHexPath::Encodings:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "encodings").string(); });
|
||||
break;
|
||||
case ImHexPath::Logs:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "logs").string(); });
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
case ImHexPath::Patterns:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "patterns").string(); });
|
||||
break;
|
||||
case ImHexPath::PatternsInclude:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "includes").string(); });
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "magic").string(); });
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p).string(); });
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "plugins").string(); });
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "yara").string(); });
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
std::transform(configDirs.begin(), configDirs.end(), std::back_inserter(result), [](auto p) { return (p / "imhex").string(); });
|
||||
break;
|
||||
case ImHexPath::Resources:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "resources").string(); });
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "constants").string(); });
|
||||
break;
|
||||
case ImHexPath::Encodings:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "encodings").string(); });
|
||||
break;
|
||||
case ImHexPath::Logs:
|
||||
std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "logs").string(); });
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!listNonExisting) {
|
||||
result.erase(std::remove_if(result.begin(), result.end(), [](const auto &path) {
|
||||
return !fs::is_directory(path);
|
||||
}),
|
||||
result.end());
|
||||
return !fs::is_directory(path);
|
||||
}),
|
||||
result.end());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace hex {
|
||||
std::ifstream projectFile(filePath.c_str());
|
||||
projectFile >> projectFileData;
|
||||
|
||||
ProjectFile::s_filePath = fs::path(projectFileData["filePath"].get<std::string>());
|
||||
ProjectFile::s_pattern = projectFileData["pattern"];
|
||||
ProjectFile::s_patches = projectFileData["patches"].get<Patches>();
|
||||
ProjectFile::s_filePath = fs::path(projectFileData["filePath"].get<std::string>());
|
||||
ProjectFile::s_pattern = projectFileData["pattern"];
|
||||
ProjectFile::s_patches = projectFileData["patches"].get<Patches>();
|
||||
ProjectFile::s_dataProcessorContent = projectFileData["dataProcessor"];
|
||||
|
||||
ProjectFile::s_bookmarks.clear();
|
||||
@@ -89,9 +89,9 @@ namespace hex {
|
||||
filePath = ProjectFile::s_currProjectFilePath;
|
||||
|
||||
try {
|
||||
projectFileData["filePath"] = ProjectFile::s_filePath;
|
||||
projectFileData["pattern"] = ProjectFile::s_pattern;
|
||||
projectFileData["patches"] = ProjectFile::s_patches;
|
||||
projectFileData["filePath"] = ProjectFile::s_filePath;
|
||||
projectFileData["pattern"] = ProjectFile::s_pattern;
|
||||
projectFileData["patches"] = ProjectFile::s_patches;
|
||||
projectFileData["dataProcessor"] = ProjectFile::s_dataProcessorContent;
|
||||
|
||||
for (auto &bookmark : ProjectFile::s_bookmarks) {
|
||||
@@ -106,7 +106,7 @@ namespace hex {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectFile::s_hasUnsavedChanged = false;
|
||||
ProjectFile::s_hasUnsavedChanged = false;
|
||||
ProjectFile::s_currProjectFilePath = filePath;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
Socket::Socket(Socket &&other) {
|
||||
this->m_socket = other.m_socket;
|
||||
this->m_socket = other.m_socket;
|
||||
this->m_connected = other.m_connected;
|
||||
|
||||
other.m_socket = SOCKET_NONE;
|
||||
@@ -78,7 +78,7 @@ namespace hex {
|
||||
sockaddr_in client = { 0 };
|
||||
|
||||
client.sin_family = AF_INET;
|
||||
client.sin_port = htons(port);
|
||||
client.sin_port = htons(port);
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
client.sin_addr.S_un.S_addr = ::inet_addr(address.c_str());
|
||||
|
||||
@@ -83,29 +83,29 @@ namespace hex {
|
||||
std::string result = hex::format("{0:.2f}", value);
|
||||
|
||||
switch (unitIndex) {
|
||||
case 0:
|
||||
result += " Bytes";
|
||||
break;
|
||||
case 1:
|
||||
result += " kB";
|
||||
break;
|
||||
case 2:
|
||||
result += " MB";
|
||||
break;
|
||||
case 3:
|
||||
result += " GB";
|
||||
break;
|
||||
case 4:
|
||||
result += " TB";
|
||||
break;
|
||||
case 5:
|
||||
result += " PB";
|
||||
break;
|
||||
case 6:
|
||||
result += " EB";
|
||||
break;
|
||||
default:
|
||||
result = "A lot!";
|
||||
case 0:
|
||||
result += " Bytes";
|
||||
break;
|
||||
case 1:
|
||||
result += " kB";
|
||||
break;
|
||||
case 2:
|
||||
result += " MB";
|
||||
break;
|
||||
case 3:
|
||||
result += " GB";
|
||||
break;
|
||||
case 4:
|
||||
result += " TB";
|
||||
break;
|
||||
case 5:
|
||||
result += " PB";
|
||||
break;
|
||||
case 6:
|
||||
result += " EB";
|
||||
break;
|
||||
default:
|
||||
result = "A lot!";
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -113,78 +113,78 @@ namespace hex {
|
||||
|
||||
std::string makePrintable(u8 c) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
return "NUL";
|
||||
case 1:
|
||||
return "SOH";
|
||||
case 2:
|
||||
return "STX";
|
||||
case 3:
|
||||
return "ETX";
|
||||
case 4:
|
||||
return "EOT";
|
||||
case 5:
|
||||
return "ENQ";
|
||||
case 6:
|
||||
return "ACK";
|
||||
case 7:
|
||||
return "BEL";
|
||||
case 8:
|
||||
return "BS";
|
||||
case 9:
|
||||
return "TAB";
|
||||
case 10:
|
||||
return "LF";
|
||||
case 11:
|
||||
return "VT";
|
||||
case 12:
|
||||
return "FF";
|
||||
case 13:
|
||||
return "CR";
|
||||
case 14:
|
||||
return "SO";
|
||||
case 15:
|
||||
return "SI";
|
||||
case 16:
|
||||
return "DLE";
|
||||
case 17:
|
||||
return "DC1";
|
||||
case 18:
|
||||
return "DC2";
|
||||
case 19:
|
||||
return "DC3";
|
||||
case 20:
|
||||
return "DC4";
|
||||
case 21:
|
||||
return "NAK";
|
||||
case 22:
|
||||
return "SYN";
|
||||
case 23:
|
||||
return "ETB";
|
||||
case 24:
|
||||
return "CAN";
|
||||
case 25:
|
||||
return "EM";
|
||||
case 26:
|
||||
return "SUB";
|
||||
case 27:
|
||||
return "ESC";
|
||||
case 28:
|
||||
return "FS";
|
||||
case 29:
|
||||
return "GS";
|
||||
case 30:
|
||||
return "RS";
|
||||
case 31:
|
||||
return "US";
|
||||
case 32:
|
||||
return "Space";
|
||||
case 127:
|
||||
return "DEL";
|
||||
case 128 ... 255:
|
||||
return " ";
|
||||
default:
|
||||
return std::string() + static_cast<char>(c);
|
||||
case 0:
|
||||
return "NUL";
|
||||
case 1:
|
||||
return "SOH";
|
||||
case 2:
|
||||
return "STX";
|
||||
case 3:
|
||||
return "ETX";
|
||||
case 4:
|
||||
return "EOT";
|
||||
case 5:
|
||||
return "ENQ";
|
||||
case 6:
|
||||
return "ACK";
|
||||
case 7:
|
||||
return "BEL";
|
||||
case 8:
|
||||
return "BS";
|
||||
case 9:
|
||||
return "TAB";
|
||||
case 10:
|
||||
return "LF";
|
||||
case 11:
|
||||
return "VT";
|
||||
case 12:
|
||||
return "FF";
|
||||
case 13:
|
||||
return "CR";
|
||||
case 14:
|
||||
return "SO";
|
||||
case 15:
|
||||
return "SI";
|
||||
case 16:
|
||||
return "DLE";
|
||||
case 17:
|
||||
return "DC1";
|
||||
case 18:
|
||||
return "DC2";
|
||||
case 19:
|
||||
return "DC3";
|
||||
case 20:
|
||||
return "DC4";
|
||||
case 21:
|
||||
return "NAK";
|
||||
case 22:
|
||||
return "SYN";
|
||||
case 23:
|
||||
return "ETB";
|
||||
case 24:
|
||||
return "CAN";
|
||||
case 25:
|
||||
return "EM";
|
||||
case 26:
|
||||
return "SUB";
|
||||
case 27:
|
||||
return "ESC";
|
||||
case 28:
|
||||
return "FS";
|
||||
case 29:
|
||||
return "GS";
|
||||
case 30:
|
||||
return "RS";
|
||||
case 31:
|
||||
return "US";
|
||||
case 32:
|
||||
return "Space";
|
||||
case 127:
|
||||
return "DEL";
|
||||
case 128 ... 255:
|
||||
return " ";
|
||||
default:
|
||||
return std::string() + static_cast<char>(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,17 +268,17 @@ namespace hex {
|
||||
nfdchar_t *outPath;
|
||||
nfdresult_t result;
|
||||
switch (mode) {
|
||||
case DialogMode::Open:
|
||||
result = NFD::OpenDialog(outPath, validExtensions.data(), validExtensions.size(), defaultPath.c_str());
|
||||
break;
|
||||
case DialogMode::Save:
|
||||
result = NFD::SaveDialog(outPath, validExtensions.data(), validExtensions.size(), defaultPath.c_str());
|
||||
break;
|
||||
case DialogMode::Folder:
|
||||
result = NFD::PickFolder(outPath, defaultPath.c_str());
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
case DialogMode::Open:
|
||||
result = NFD::OpenDialog(outPath, validExtensions.data(), validExtensions.size(), defaultPath.c_str());
|
||||
break;
|
||||
case DialogMode::Save:
|
||||
result = NFD::SaveDialog(outPath, validExtensions.data(), validExtensions.size(), defaultPath.c_str());
|
||||
break;
|
||||
case DialogMode::Folder:
|
||||
result = NFD::PickFolder(outPath, defaultPath.c_str());
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
if (result == NFD_OKAY) {
|
||||
@@ -290,7 +290,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
float float16ToFloat32(u16 float16) {
|
||||
u32 sign = float16 >> 15;
|
||||
u32 sign = float16 >> 15;
|
||||
u32 exponent = (float16 >> 10) & 0x1F;
|
||||
u32 mantissa = float16 & 0x3FF;
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace hex {
|
||||
bool isProcessElevated() {
|
||||
#if defined(OS_WINDOWS)
|
||||
bool elevated = false;
|
||||
HANDLE token = INVALID_HANDLE_VALUE;
|
||||
HANDLE token = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) {
|
||||
TOKEN_ELEVATION elevation;
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace hex::pl {
|
||||
}
|
||||
}
|
||||
|
||||
auto startOffset = this->dataOffset();
|
||||
auto pattern = type == nullptr ? nullptr : type->createPatterns(this).front();
|
||||
auto startOffset = this->dataOffset();
|
||||
auto pattern = type == nullptr ? nullptr : type->createPatterns(this).front();
|
||||
this->dataOffset() = startOffset;
|
||||
|
||||
if (pattern == nullptr) {
|
||||
@@ -123,7 +123,7 @@ namespace hex::pl {
|
||||
else
|
||||
LogConsole::abortEvaluation(hex::format("cannot cast integer literal to type '{}'", pattern->getTypeName()));
|
||||
} },
|
||||
value);
|
||||
value);
|
||||
|
||||
this->getStack()[pattern->getOffset()] = castedLiteral;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace hex::pl {
|
||||
this->m_envVariables.clear();
|
||||
};
|
||||
|
||||
this->dataOffset() = 0x00;
|
||||
this->dataOffset() = 0x00;
|
||||
this->m_currPatternCount = 0;
|
||||
|
||||
for (auto &func : this->m_customFunctionDefinitions)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace hex::pl {
|
||||
|
||||
u8 base;
|
||||
|
||||
auto endPos = getIntegerLiteralLength(string);
|
||||
auto endPos = getIntegerLiteralLength(string);
|
||||
auto numberData = std::string_view(string).substr(0, endPos);
|
||||
|
||||
if (numberData.ends_with('U')) {
|
||||
@@ -56,7 +56,7 @@ namespace hex::pl {
|
||||
|
||||
if (numberData.starts_with("0x")) {
|
||||
numberData = numberData.substr(2);
|
||||
base = 16;
|
||||
base = 16;
|
||||
|
||||
if (Token::isFloatingPoint(type))
|
||||
return std::nullopt;
|
||||
@@ -65,7 +65,7 @@ namespace hex::pl {
|
||||
return std::nullopt;
|
||||
} else if (numberData.starts_with("0b")) {
|
||||
numberData = numberData.substr(2);
|
||||
base = 2;
|
||||
base = 2;
|
||||
|
||||
if (Token::isFloatingPoint(type))
|
||||
return std::nullopt;
|
||||
@@ -111,23 +111,23 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Token::ValueType::Unsigned128Bit:
|
||||
return { u128(integer) };
|
||||
case Token::ValueType::Signed128Bit:
|
||||
return { i128(integer) };
|
||||
default:
|
||||
return std::nullopt;
|
||||
case Token::ValueType::Unsigned128Bit:
|
||||
return { u128(integer) };
|
||||
case Token::ValueType::Signed128Bit:
|
||||
return { i128(integer) };
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
} else if (Token::isFloatingPoint(type)) {
|
||||
double floatingPoint = strtod(numberData.data(), nullptr);
|
||||
|
||||
switch (type) {
|
||||
case Token::ValueType::Float:
|
||||
return { float(floatingPoint) };
|
||||
case Token::ValueType::Double:
|
||||
return { double(floatingPoint) };
|
||||
default:
|
||||
return std::nullopt;
|
||||
case Token::ValueType::Float:
|
||||
return { float(floatingPoint) };
|
||||
case Token::ValueType::Double:
|
||||
return { double(floatingPoint) };
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,46 +147,46 @@ namespace hex::pl {
|
||||
|
||||
// Handle simple escape sequences
|
||||
switch (string[1]) {
|
||||
case 'a':
|
||||
return {
|
||||
{'\a', 2}
|
||||
};
|
||||
case 'b':
|
||||
return {
|
||||
{'\b', 2}
|
||||
};
|
||||
case 'f':
|
||||
return {
|
||||
{'\f', 2}
|
||||
};
|
||||
case 'n':
|
||||
return {
|
||||
{'\n', 2}
|
||||
};
|
||||
case 'r':
|
||||
return {
|
||||
{'\r', 2}
|
||||
};
|
||||
case 't':
|
||||
return {
|
||||
{'\t', 2}
|
||||
};
|
||||
case 'v':
|
||||
return {
|
||||
{'\v', 2}
|
||||
};
|
||||
case '\\':
|
||||
return {
|
||||
{'\\', 2}
|
||||
};
|
||||
case '\'':
|
||||
return {
|
||||
{'\'', 2}
|
||||
};
|
||||
case '\"':
|
||||
return {
|
||||
{'\"', 2}
|
||||
};
|
||||
case 'a':
|
||||
return {
|
||||
{'\a', 2}
|
||||
};
|
||||
case 'b':
|
||||
return {
|
||||
{'\b', 2}
|
||||
};
|
||||
case 'f':
|
||||
return {
|
||||
{'\f', 2}
|
||||
};
|
||||
case 'n':
|
||||
return {
|
||||
{'\n', 2}
|
||||
};
|
||||
case 'r':
|
||||
return {
|
||||
{'\r', 2}
|
||||
};
|
||||
case 't':
|
||||
return {
|
||||
{'\t', 2}
|
||||
};
|
||||
case 'v':
|
||||
return {
|
||||
{'\v', 2}
|
||||
};
|
||||
case '\\':
|
||||
return {
|
||||
{'\\', 2}
|
||||
};
|
||||
case '\'':
|
||||
return {
|
||||
{'\'', 2}
|
||||
};
|
||||
case '\"':
|
||||
return {
|
||||
{'\"', 2}
|
||||
};
|
||||
}
|
||||
|
||||
// Hexadecimal number
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace hex::pl {
|
||||
auto originalPos = this->m_curr;
|
||||
parseNamespaceResolution();
|
||||
bool isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN);
|
||||
this->m_curr = originalPos;
|
||||
this->m_curr = originalPos;
|
||||
|
||||
|
||||
if (isFunction) {
|
||||
@@ -174,7 +174,7 @@ namespace hex::pl {
|
||||
|
||||
ASTNode *Parser::parseCastExpression() {
|
||||
if (peek(KEYWORD_BE) || peek(KEYWORD_LE) || peek(VALUETYPE_ANY)) {
|
||||
auto type = parseType(true);
|
||||
auto type = parseType(true);
|
||||
auto builtinType = dynamic_cast<ASTNodeBuiltinType *>(type->getType());
|
||||
|
||||
if (builtinType == nullptr)
|
||||
@@ -210,7 +210,7 @@ namespace hex::pl {
|
||||
|
||||
while (MATCHES(oneOf(OPERATOR_STAR, OPERATOR_SLASH, OPERATOR_PERCENT))) {
|
||||
auto op = getValue<Token::Operator>(-1);
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseUnaryExpression(), op));
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseUnaryExpression(), op));
|
||||
}
|
||||
|
||||
nodeCleanup.release();
|
||||
@@ -226,7 +226,7 @@ namespace hex::pl {
|
||||
|
||||
while (MATCHES(variant(OPERATOR_PLUS, OPERATOR_MINUS))) {
|
||||
auto op = getValue<Token::Operator>(-1);
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseMultiplicativeExpression(), op));
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseMultiplicativeExpression(), op));
|
||||
}
|
||||
|
||||
nodeCleanup.release();
|
||||
@@ -242,7 +242,7 @@ namespace hex::pl {
|
||||
|
||||
while (MATCHES(variant(OPERATOR_SHIFTLEFT, OPERATOR_SHIFTRIGHT))) {
|
||||
auto op = getValue<Token::Operator>(-1);
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseAdditiveExpression(), op));
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseAdditiveExpression(), op));
|
||||
}
|
||||
|
||||
nodeCleanup.release();
|
||||
@@ -258,7 +258,7 @@ namespace hex::pl {
|
||||
|
||||
while (MATCHES(sequence(OPERATOR_BOOLGREATERTHAN) || sequence(OPERATOR_BOOLLESSTHAN) || sequence(OPERATOR_BOOLGREATERTHANOREQUALS) || sequence(OPERATOR_BOOLLESSTHANOREQUALS))) {
|
||||
auto op = getValue<Token::Operator>(-1);
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseShiftExpression(), op));
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseShiftExpression(), op));
|
||||
}
|
||||
|
||||
nodeCleanup.release();
|
||||
@@ -274,7 +274,7 @@ namespace hex::pl {
|
||||
|
||||
while (MATCHES(sequence(OPERATOR_BOOLEQUALS) || sequence(OPERATOR_BOOLNOTEQUALS))) {
|
||||
auto op = getValue<Token::Operator>(-1);
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseRelationExpression(), op));
|
||||
node = create(new ASTNodeMathematicalExpression(node, this->parseRelationExpression(), op));
|
||||
}
|
||||
|
||||
nodeCleanup.release();
|
||||
@@ -385,7 +385,7 @@ namespace hex::pl {
|
||||
throwParserError("expected ':' in ternary expression");
|
||||
|
||||
auto third = this->parseBooleanOr();
|
||||
node = create(new ASTNodeTernaryExpression(node, second, third, Token::Operator::TernaryConditional));
|
||||
node = create(new ASTNodeTernaryExpression(node, second, third, Token::Operator::TernaryConditional));
|
||||
}
|
||||
|
||||
nodeCleanup.release();
|
||||
@@ -410,7 +410,7 @@ namespace hex::pl {
|
||||
auto attribute = getValue<Token::Identifier>(-1).get();
|
||||
|
||||
if (MATCHES(sequence(SEPARATOR_ROUNDBRACKETOPEN, STRING, SEPARATOR_ROUNDBRACKETCLOSE))) {
|
||||
auto value = getValue<Token::Literal>(-2);
|
||||
auto value = getValue<Token::Literal>(-2);
|
||||
auto string = std::get_if<std::string>(&value);
|
||||
|
||||
if (string == nullptr)
|
||||
@@ -434,7 +434,7 @@ namespace hex::pl {
|
||||
std::optional<std::string> parameterPack;
|
||||
|
||||
// Parse parameter list
|
||||
bool hasParams = !peek(SEPARATOR_ROUNDBRACKETCLOSE);
|
||||
bool hasParams = !peek(SEPARATOR_ROUNDBRACKETCLOSE);
|
||||
u32 unnamedParamCount = 0;
|
||||
while (hasParams) {
|
||||
if (MATCHES(sequence(VALUETYPE_AUTO, SEPARATOR_DOT, SEPARATOR_DOT, SEPARATOR_DOT, IDENTIFIER))) {
|
||||
@@ -488,7 +488,7 @@ namespace hex::pl {
|
||||
|
||||
if (MATCHES(sequence(IDENTIFIER))) {
|
||||
auto identifier = getValue<Token::Identifier>(-1).get();
|
||||
statement = parseMemberVariable(type);
|
||||
statement = parseMemberVariable(type);
|
||||
|
||||
if (MATCHES(sequence(OPERATOR_ASSIGNMENT))) {
|
||||
auto expression = parseMathematicalExpression();
|
||||
@@ -516,13 +516,13 @@ namespace hex::pl {
|
||||
else if (MATCHES(oneOf(KEYWORD_RETURN, KEYWORD_BREAK, KEYWORD_CONTINUE)))
|
||||
statement = parseFunctionControlFlowStatement();
|
||||
else if (MATCHES(sequence(KEYWORD_IF, SEPARATOR_ROUNDBRACKETOPEN))) {
|
||||
statement = parseFunctionConditional();
|
||||
statement = parseFunctionConditional();
|
||||
needsSemicolon = false;
|
||||
} else if (MATCHES(sequence(KEYWORD_WHILE, SEPARATOR_ROUNDBRACKETOPEN))) {
|
||||
statement = parseFunctionWhileLoop();
|
||||
statement = parseFunctionWhileLoop();
|
||||
needsSemicolon = false;
|
||||
} else if (MATCHES(sequence(KEYWORD_FOR, SEPARATOR_ROUNDBRACKETOPEN))) {
|
||||
statement = parseFunctionForLoop();
|
||||
statement = parseFunctionForLoop();
|
||||
needsSemicolon = false;
|
||||
} else if (MATCHES(sequence(IDENTIFIER))) {
|
||||
auto originalPos = this->m_curr;
|
||||
@@ -531,10 +531,10 @@ namespace hex::pl {
|
||||
|
||||
if (isFunction) {
|
||||
this->m_curr = originalPos;
|
||||
statement = parseFunctionCall();
|
||||
statement = parseFunctionCall();
|
||||
} else {
|
||||
this->m_curr = originalPos - 1;
|
||||
statement = parseFunctionVariableDecl();
|
||||
statement = parseFunctionVariableDecl();
|
||||
}
|
||||
} else if (peek(KEYWORD_BE) || peek(KEYWORD_LE) || peek(VALUETYPE_ANY)) {
|
||||
statement = parseFunctionVariableDecl();
|
||||
@@ -651,13 +651,13 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
ASTNode *Parser::parseFunctionForLoop() {
|
||||
auto variable = parseFunctionVariableDecl();
|
||||
auto variable = parseFunctionVariableDecl();
|
||||
auto variableCleanup = SCOPE_GUARD { delete variable; };
|
||||
|
||||
if (!MATCHES(sequence(SEPARATOR_COMMA)))
|
||||
throwParserError("expected ',' after for loop variable declaration");
|
||||
|
||||
auto condition = parseMathematicalExpression();
|
||||
auto condition = parseMathematicalExpression();
|
||||
auto conditionCleanup = SCOPE_GUARD { delete condition; };
|
||||
|
||||
if (!MATCHES(sequence(SEPARATOR_COMMA)))
|
||||
@@ -833,7 +833,7 @@ namespace hex::pl {
|
||||
ASTNode *Parser::parseMemberArrayVariable(ASTNodeTypeDecl *type) {
|
||||
auto name = getValue<Token::Identifier>(-2).get();
|
||||
|
||||
ASTNode *size = nullptr;
|
||||
ASTNode *size = nullptr;
|
||||
auto sizeCleanup = SCOPE_GUARD { delete size; };
|
||||
|
||||
if (!MATCHES(sequence(SEPARATOR_SQUAREBRACKETCLOSE))) {
|
||||
@@ -881,7 +881,7 @@ namespace hex::pl {
|
||||
auto originalPos = this->m_curr;
|
||||
this->m_curr++;
|
||||
parseNamespaceResolution();
|
||||
isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN);
|
||||
isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN);
|
||||
this->m_curr = originalPos;
|
||||
|
||||
if (isFunction) {
|
||||
@@ -938,8 +938,8 @@ namespace hex::pl {
|
||||
const auto &typeName = getValue<Token::Identifier>(-1).get();
|
||||
|
||||
const auto structNode = create(new ASTNodeStruct());
|
||||
const auto typeDecl = addType(typeName, structNode);
|
||||
auto structGuard = SCOPE_GUARD {
|
||||
const auto typeDecl = addType(typeName, structNode);
|
||||
auto structGuard = SCOPE_GUARD {
|
||||
delete structNode;
|
||||
delete typeDecl;
|
||||
};
|
||||
@@ -976,8 +976,8 @@ namespace hex::pl {
|
||||
const auto &typeName = getValue<Token::Identifier>(-2).get();
|
||||
|
||||
const auto unionNode = create(new ASTNodeUnion());
|
||||
const auto typeDecl = addType(typeName, unionNode);
|
||||
auto unionGuard = SCOPE_GUARD {
|
||||
const auto typeDecl = addType(typeName, unionNode);
|
||||
auto unionGuard = SCOPE_GUARD {
|
||||
delete unionNode;
|
||||
delete typeDecl;
|
||||
};
|
||||
@@ -1000,7 +1000,7 @@ namespace hex::pl {
|
||||
|
||||
const auto enumNode = create(new ASTNodeEnum(underlyingType));
|
||||
const auto typeDecl = addType(typeName, enumNode);
|
||||
auto enumGuard = SCOPE_GUARD {
|
||||
auto enumGuard = SCOPE_GUARD {
|
||||
delete enumNode;
|
||||
delete typeDecl;
|
||||
};
|
||||
@@ -1011,7 +1011,7 @@ namespace hex::pl {
|
||||
ASTNode *lastEntry = nullptr;
|
||||
while (!MATCHES(sequence(SEPARATOR_CURLYBRACKETCLOSE))) {
|
||||
if (MATCHES(sequence(IDENTIFIER, OPERATOR_ASSIGNMENT))) {
|
||||
auto name = getValue<Token::Identifier>(-2).get();
|
||||
auto name = getValue<Token::Identifier>(-2).get();
|
||||
auto value = parseMathematicalExpression();
|
||||
|
||||
enumNode->addEntry(name, value);
|
||||
@@ -1048,7 +1048,7 @@ namespace hex::pl {
|
||||
std::string typeName = getValue<Token::Identifier>(-2).get();
|
||||
|
||||
const auto bitfieldNode = create(new ASTNodeBitfield());
|
||||
const auto typeDecl = addType(typeName, bitfieldNode);
|
||||
const auto typeDecl = addType(typeName, bitfieldNode);
|
||||
|
||||
auto enumGuard = SCOPE_GUARD {
|
||||
delete bitfieldNode;
|
||||
@@ -1081,7 +1081,7 @@ namespace hex::pl {
|
||||
|
||||
// (parseType) Identifier @ Integer
|
||||
ASTNode *Parser::parseVariablePlacement(ASTNodeTypeDecl *type) {
|
||||
bool inVariable = false;
|
||||
bool inVariable = false;
|
||||
bool outVariable = false;
|
||||
|
||||
auto name = getValue<Token::Identifier>(-1).get();
|
||||
@@ -1102,7 +1102,7 @@ namespace hex::pl {
|
||||
ASTNode *Parser::parseArrayVariablePlacement(ASTNodeTypeDecl *type) {
|
||||
auto name = getValue<Token::Identifier>(-2).get();
|
||||
|
||||
ASTNode *size = nullptr;
|
||||
ASTNode *size = nullptr;
|
||||
auto sizeCleanup = SCOPE_GUARD { delete size; };
|
||||
|
||||
if (!MATCHES(sequence(SEPARATOR_SQUAREBRACKETCLOSE))) {
|
||||
@@ -1129,7 +1129,7 @@ namespace hex::pl {
|
||||
ASTNode *Parser::parsePointerVariablePlacement(ASTNodeTypeDecl *type) {
|
||||
auto name = getValue<Token::Identifier>(-2).get();
|
||||
|
||||
auto sizeType = parseType();
|
||||
auto sizeType = parseType();
|
||||
auto sizeCleanup = SCOPE_GUARD { delete sizeType; };
|
||||
|
||||
{
|
||||
@@ -1196,7 +1196,7 @@ namespace hex::pl {
|
||||
|
||||
// <(parseUsingDeclaration)|(parseVariablePlacement)|(parseStruct)>
|
||||
std::vector<ASTNode *> Parser::parseStatements() {
|
||||
ASTNode *statement = nullptr;
|
||||
ASTNode *statement = nullptr;
|
||||
auto statementGuard = SCOPE_GUARD {
|
||||
delete statement;
|
||||
};
|
||||
@@ -1208,7 +1208,7 @@ namespace hex::pl {
|
||||
this->m_curr++;
|
||||
parseNamespaceResolution();
|
||||
bool isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN);
|
||||
this->m_curr = originalPos;
|
||||
this->m_curr = originalPos;
|
||||
|
||||
if (isFunction) {
|
||||
this->m_curr++;
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace hex::pl {
|
||||
|
||||
PatternLanguage::PatternLanguage() {
|
||||
this->m_preprocessor = new Preprocessor();
|
||||
this->m_lexer = new Lexer();
|
||||
this->m_parser = new Parser();
|
||||
this->m_validator = new Validator();
|
||||
this->m_evaluator = new Evaluator();
|
||||
this->m_lexer = new Lexer();
|
||||
this->m_parser = new Parser();
|
||||
this->m_validator = new Validator();
|
||||
this->m_evaluator = new Evaluator();
|
||||
|
||||
this->m_preprocessor->addDefaultPragmaHandlers();
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
namespace hex::pl {
|
||||
|
||||
std::optional<std::string> Preprocessor::preprocess(const std::string &code, bool initialRun) {
|
||||
u32 offset = 0;
|
||||
u32 lineNumber = 1;
|
||||
u32 offset = 0;
|
||||
u32 lineNumber = 1;
|
||||
bool isInString = false;
|
||||
|
||||
if (initialRun) {
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace hex::prv {
|
||||
void Provider::applyOverlays(u64 offset, void *buffer, size_t size) {
|
||||
for (auto &overlay : this->m_overlays) {
|
||||
auto overlayOffset = overlay->getAddress();
|
||||
auto overlaySize = overlay->getSize();
|
||||
auto overlaySize = overlay->getSize();
|
||||
|
||||
i128 overlapMin = std::max(offset, overlayOffset);
|
||||
i128 overlapMax = std::min(offset + size, overlayOffset + overlaySize);
|
||||
@@ -156,7 +156,7 @@ namespace hex::prv {
|
||||
createUndoPoint();
|
||||
|
||||
for (u64 i = 0; i < size; i++) {
|
||||
u8 patch = reinterpret_cast<const u8 *>(buffer)[i];
|
||||
u8 patch = reinterpret_cast<const u8 *>(buffer)[i];
|
||||
u8 originalValue = 0x00;
|
||||
this->readRaw(offset + i, &originalValue, sizeof(u8));
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace ImGui {
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
ImVec2 label_size = CalcTextSize(icon, NULL, false);
|
||||
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;
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y);
|
||||
|
||||
const ImRect bb(pos, pos + size);
|
||||
@@ -62,12 +62,12 @@ namespace ImGui {
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y);
|
||||
|
||||
const ImRect bb(pos, pos + size);
|
||||
@@ -95,12 +95,12 @@ namespace ImGui {
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y) + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f);
|
||||
|
||||
const ImRect bb(pos, pos + size);
|
||||
@@ -130,10 +130,10 @@ namespace ImGui {
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 text_size = CalcTextSize((std::string(label) + "\n " + std::string(description)).c_str(), NULL, true);
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 text_size = CalcTextSize((std::string(label) + "\n " + std::string(description)).c_str(), NULL, true);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
@@ -180,7 +180,7 @@ namespace ImGui {
|
||||
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y);
|
||||
|
||||
PushStyleColor(ImGuiCol_Text, ImU32(color));
|
||||
@@ -221,7 +221,7 @@ namespace ImGui {
|
||||
static double lastMoveTime;
|
||||
static ImGuiID lastHoveredID;
|
||||
|
||||
double currTime = ImGui::GetTime();
|
||||
double currTime = ImGui::GetTime();
|
||||
ImGuiID hoveredID = ImGui::GetHoveredID();
|
||||
|
||||
if (IsItemHovered() && (currTime - lastMoveTime) >= 0.5 && hoveredID == lastHoveredID) {
|
||||
@@ -238,14 +238,14 @@ namespace ImGui {
|
||||
|
||||
ImU32 GetCustomColorU32(ImGuiCustomCol idx, float alpha_mul) {
|
||||
auto &customData = *static_cast<ImHexCustomData *>(GImGui->IO.UserData);
|
||||
ImVec4 c = customData.Colors[idx];
|
||||
ImVec4 c = customData.Colors[idx];
|
||||
c.w *= GImGui->Style.Alpha * alpha_mul;
|
||||
return ColorConvertFloat4ToU32(c);
|
||||
}
|
||||
|
||||
ImVec4 GetCustomColorVec4(ImGuiCustomCol idx, float alpha_mul) {
|
||||
auto &customData = *static_cast<ImHexCustomData *>(GImGui->IO.UserData);
|
||||
ImVec4 c = customData.Colors[idx];
|
||||
ImVec4 c = customData.Colors[idx];
|
||||
c.w *= GImGui->Style.Alpha * alpha_mul;
|
||||
return c;
|
||||
}
|
||||
@@ -253,17 +253,17 @@ namespace ImGui {
|
||||
void StyleCustomColorsDark() {
|
||||
auto &colors = static_cast<ImHexCustomData *>(GImGui->IO.UserData)->Colors;
|
||||
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(20, 20, 20);
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(20, 20, 20);
|
||||
colors[ImGuiCustomCol_DescButtonHovered] = ImColor(40, 40, 40);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(60, 60, 60);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(60, 60, 60);
|
||||
|
||||
colors[ImGuiCustomCol_ToolbarGray] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_ToolbarRed] = ImColor(231, 76, 60);
|
||||
colors[ImGuiCustomCol_ToolbarGray] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_ToolbarRed] = ImColor(231, 76, 60);
|
||||
colors[ImGuiCustomCol_ToolbarYellow] = ImColor(241, 196, 15);
|
||||
colors[ImGuiCustomCol_ToolbarGreen] = ImColor(56, 139, 66);
|
||||
colors[ImGuiCustomCol_ToolbarBlue] = ImColor(6, 83, 155);
|
||||
colors[ImGuiCustomCol_ToolbarGreen] = ImColor(56, 139, 66);
|
||||
colors[ImGuiCustomCol_ToolbarBlue] = ImColor(6, 83, 155);
|
||||
colors[ImGuiCustomCol_ToolbarPurple] = ImColor(103, 42, 120);
|
||||
colors[ImGuiCustomCol_ToolbarBrown] = ImColor(219, 179, 119);
|
||||
colors[ImGuiCustomCol_ToolbarBrown] = ImColor(219, 179, 119);
|
||||
|
||||
colors[ImGuiCustomCol_Highlight] = ImColor(77, 198, 155);
|
||||
}
|
||||
@@ -271,17 +271,17 @@ namespace ImGui {
|
||||
void StyleCustomColorsLight() {
|
||||
auto &colors = static_cast<ImHexCustomData *>(GImGui->IO.UserData)->Colors;
|
||||
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_DescButtonHovered] = ImColor(210, 210, 210);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(190, 190, 190);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(190, 190, 190);
|
||||
|
||||
colors[ImGuiCustomCol_ToolbarGray] = ImColor(25, 25, 25);
|
||||
colors[ImGuiCustomCol_ToolbarRed] = ImColor(231, 76, 60);
|
||||
colors[ImGuiCustomCol_ToolbarGray] = ImColor(25, 25, 25);
|
||||
colors[ImGuiCustomCol_ToolbarRed] = ImColor(231, 76, 60);
|
||||
colors[ImGuiCustomCol_ToolbarYellow] = ImColor(241, 196, 15);
|
||||
colors[ImGuiCustomCol_ToolbarGreen] = ImColor(56, 139, 66);
|
||||
colors[ImGuiCustomCol_ToolbarBlue] = ImColor(6, 83, 155);
|
||||
colors[ImGuiCustomCol_ToolbarGreen] = ImColor(56, 139, 66);
|
||||
colors[ImGuiCustomCol_ToolbarBlue] = ImColor(6, 83, 155);
|
||||
colors[ImGuiCustomCol_ToolbarPurple] = ImColor(103, 42, 120);
|
||||
colors[ImGuiCustomCol_ToolbarBrown] = ImColor(219, 179, 119);
|
||||
colors[ImGuiCustomCol_ToolbarBrown] = ImColor(219, 179, 119);
|
||||
|
||||
colors[ImGuiCustomCol_Highlight] = ImColor(41, 151, 112);
|
||||
}
|
||||
@@ -289,23 +289,23 @@ namespace ImGui {
|
||||
void StyleCustomColorsClassic() {
|
||||
auto &colors = static_cast<ImHexCustomData *>(GImGui->IO.UserData)->Colors;
|
||||
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(40, 40, 80);
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(40, 40, 80);
|
||||
colors[ImGuiCustomCol_DescButtonHovered] = ImColor(60, 60, 100);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(80, 80, 120);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(80, 80, 120);
|
||||
|
||||
colors[ImGuiCustomCol_ToolbarGray] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_ToolbarRed] = ImColor(231, 76, 60);
|
||||
colors[ImGuiCustomCol_ToolbarGray] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_ToolbarRed] = ImColor(231, 76, 60);
|
||||
colors[ImGuiCustomCol_ToolbarYellow] = ImColor(241, 196, 15);
|
||||
colors[ImGuiCustomCol_ToolbarGreen] = ImColor(56, 139, 66);
|
||||
colors[ImGuiCustomCol_ToolbarBlue] = ImColor(6, 83, 155);
|
||||
colors[ImGuiCustomCol_ToolbarGreen] = ImColor(56, 139, 66);
|
||||
colors[ImGuiCustomCol_ToolbarBlue] = ImColor(6, 83, 155);
|
||||
colors[ImGuiCustomCol_ToolbarPurple] = ImColor(103, 42, 120);
|
||||
colors[ImGuiCustomCol_ToolbarBrown] = ImColor(219, 179, 119);
|
||||
colors[ImGuiCustomCol_ToolbarBrown] = ImColor(219, 179, 119);
|
||||
|
||||
colors[ImGuiCustomCol_Highlight] = ImColor(77, 198, 155);
|
||||
}
|
||||
|
||||
Texture LoadImageFromPath(const char *path) {
|
||||
int imageWidth = 0;
|
||||
int imageWidth = 0;
|
||||
int imageHeight = 0;
|
||||
|
||||
unsigned char *imageData = stbi_load(path, &imageWidth, &imageHeight, nullptr, 4);
|
||||
@@ -330,7 +330,7 @@ namespace ImGui {
|
||||
}
|
||||
|
||||
Texture LoadImageFromMemory(const ImU8 *buffer, int size) {
|
||||
int imageWidth = 0;
|
||||
int imageWidth = 0;
|
||||
int imageHeight = 0;
|
||||
|
||||
|
||||
@@ -377,9 +377,9 @@ namespace ImGui {
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
@@ -416,9 +416,9 @@ namespace ImGui {
|
||||
|
||||
color.w = 1.0F;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(symbol);
|
||||
const ImGuiID id = window->GetID(symbol);
|
||||
const ImVec2 label_size = CalcTextSize(symbol, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
@@ -459,9 +459,9 @@ namespace ImGui {
|
||||
|
||||
color.w = 1.0F;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(symbol);
|
||||
const ImGuiID id = window->GetID(symbol);
|
||||
const ImVec2 label_size = CalcTextSize(symbol, NULL, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
@@ -500,10 +500,10 @@ namespace ImGui {
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiContext &g = *GImGui;
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos + ImVec2(0, yOffset);
|
||||
ImVec2 pos = window->DC.CursorPos + ImVec2(0, yOffset);
|
||||
ImVec2 size = CalcItemSize(ImVec2(100, 5), 100, g.FontSize + style.FramePadding.y * 2.0f);
|
||||
ImRect bb(pos, pos + size);
|
||||
ItemSize(size, 0);
|
||||
|
||||
@@ -118,10 +118,10 @@ namespace hex {
|
||||
}
|
||||
|
||||
void View::showFileChooserPopup(const std::vector<fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(fs::path)> &callback) {
|
||||
View::s_selectableFileIndex = 0;
|
||||
View::s_selectableFiles = paths;
|
||||
View::s_selectableFileIndex = 0;
|
||||
View::s_selectableFiles = paths;
|
||||
View::s_selectableFilesValidExtensions = validExtensions;
|
||||
View::s_selectableFileOpenCallback = callback;
|
||||
View::s_selectableFileOpenCallback = callback;
|
||||
|
||||
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.common.choose_file"_lang); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user