sys: Reformat all

This commit is contained in:
WerWolv
2022-02-01 22:09:44 +01:00
parent 1991afb87b
commit ce59226909
99 changed files with 2304 additions and 2314 deletions

View File

@@ -93,7 +93,7 @@ namespace hex::plugin::builtin {
if (col == (offset >> 4) && i < (offset & 0xF) || col == (end >> 4) && i > (end & 0xF))
result += " ";
else {
u8 c = buffer[((col << 4) - offset) + i];
u8 c = buffer[((col << 4) - offset) + i];
char displayChar = (c < 32 || c >= 128) ? '.' : c;
result += hex::format("{0}", displayChar);
}
@@ -145,7 +145,7 @@ namespace hex::plugin::builtin {
if (col == (offset >> 4) && i < (offset & 0xF) || col == (end >> 4) && i > (end & 0xF))
result += "&nbsp";
else {
u8 c = buffer[((col << 4) - offset) + i];
u8 c = buffer[((col << 4) - offset) + i];
char displayChar = (c < 32 || c >= 128) ? '.' : c;
result += hex::format("{0}", displayChar);
}

View File

@@ -49,9 +49,9 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.i8", sizeof(i8), [](auto buffer, auto endian, auto style) {
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:02X}" : "{0}0o{1:03o}");
auto number = hex::changeEndianess(*reinterpret_cast<i8 *>(buffer.data()), endian);
auto number = hex::changeEndianess(*reinterpret_cast<i8 *>(buffer.data()), endian);
bool negative = number < 0;
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
});
@@ -67,9 +67,9 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.i16", sizeof(i16), [](auto buffer, auto endian, auto style) {
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:04X}" : "{0}0o{1:06o}");
auto number = hex::changeEndianess(*reinterpret_cast<i16 *>(buffer.data()), endian);
auto number = hex::changeEndianess(*reinterpret_cast<i16 *>(buffer.data()), endian);
bool negative = number < 0;
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
});
@@ -85,9 +85,9 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.i32", sizeof(i32), [](auto buffer, auto endian, auto style) {
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:08X}" : "{0}0o{1:011o}");
auto number = hex::changeEndianess(*reinterpret_cast<i32 *>(buffer.data()), endian);
auto number = hex::changeEndianess(*reinterpret_cast<i32 *>(buffer.data()), endian);
bool negative = number < 0;
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
});
@@ -103,9 +103,9 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.i64", sizeof(i64), [](auto buffer, auto endian, auto style) {
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:016X}" : "{0}0o{1:022o}");
auto number = hex::changeEndianess(*reinterpret_cast<i64 *>(buffer.data()), endian);
auto number = hex::changeEndianess(*reinterpret_cast<i64 *>(buffer.data()), endian);
bool negative = number < 0;
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
});
@@ -143,17 +143,17 @@ namespace hex::plugin::builtin {
});
ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) {
char utf8Buffer[5] = { 0 };
char utf8Buffer[5] = { 0 };
char codepointString[5] = { 0 };
u32 codepoint = 0;
u32 codepoint = 0;
std::memcpy(utf8Buffer, reinterpret_cast<char8_t *>(buffer.data()), 4);
u8 codepointSize = ImTextCharFromUtf8(&codepoint, utf8Buffer, utf8Buffer + 4);
std::memcpy(codepointString, utf8Buffer, std::min(codepointSize, u8(4)));
auto value = hex::format("'{0}' (U+0x{1:04X})",
codepoint == 0xFFFD ? "Invalid" : (codepointSize == 1 ? makePrintable(codepointString[0]) : codepointString),
codepoint);
codepoint == 0xFFFD ? "Invalid" : (codepointSize == 1 ? makePrintable(codepointString[0]) : codepointString),
codepoint);
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
});
@@ -228,18 +228,18 @@ namespace hex::plugin::builtin {
GUID guid;
std::memcpy(&guid, buffer.data(), sizeof(GUID));
auto value = hex::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
(hex::changeEndianess(guid.data3, endian) >> 12) <= 5 && ((guid.data4[0] >> 4) >= 8 || (guid.data4[0] >> 4) == 0) ? "" : "Invalid ",
hex::changeEndianess(guid.data1, endian),
hex::changeEndianess(guid.data2, endian),
hex::changeEndianess(guid.data3, endian),
guid.data4[0],
guid.data4[1],
guid.data4[2],
guid.data4[3],
guid.data4[4],
guid.data4[5],
guid.data4[6],
guid.data4[7]);
(hex::changeEndianess(guid.data3, endian) >> 12) <= 5 && ((guid.data4[0] >> 4) >= 8 || (guid.data4[0] >> 4) == 0) ? "" : "Invalid ",
hex::changeEndianess(guid.data1, endian),
hex::changeEndianess(guid.data2, endian),
hex::changeEndianess(guid.data3, endian),
guid.data4[0],
guid.data4[1],
guid.data4[2],
guid.data4[3],
guid.data4[4],
guid.data4[5],
guid.data4[6],
guid.data4[7]);
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
});

View File

@@ -52,7 +52,7 @@ namespace hex::plugin::builtin {
}
void load(nlohmann::json &j) override {
this->m_size = j["size"];
this->m_size = j["size"];
this->m_buffer = j["data"].get<std::vector<u8>>();
}
@@ -162,10 +162,10 @@ namespace hex::plugin::builtin {
class NodeRGBA8 : public dp::Node {
public:
NodeRGBA8() : Node("hex.builtin.nodes.constants.rgba8.header",
{ dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.r"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.g"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.a") }) { }
{ dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.r"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.g"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.a") }) { }
void drawNode() override {
ImGui::PushItemWidth(200);
@@ -183,7 +183,7 @@ namespace hex::plugin::builtin {
void store(nlohmann::json &j) override {
j = nlohmann::json::object();
j["data"] = nlohmann::json::object();
j["data"] = nlohmann::json::object();
j["data"]["r"] = this->m_color.Value.x;
j["data"]["g"] = this->m_color.Value.y;
j["data"]["b"] = this->m_color.Value.z;
@@ -347,7 +347,7 @@ namespace hex::plugin::builtin {
void process() override {
auto address = this->getIntegerOnInput(0);
auto size = this->getIntegerOnInput(1);
auto size = this->getIntegerOnInput(1);
std::vector<u8> data;
data.resize(size);
@@ -364,7 +364,7 @@ namespace hex::plugin::builtin {
void process() override {
auto address = this->getIntegerOnInput(0);
auto data = this->getBufferOnInput(1);
auto data = this->getBufferOnInput(1);
this->setOverlayData(address, data);
}
@@ -506,8 +506,8 @@ namespace hex::plugin::builtin {
void process() override {
auto input = this->getBufferOnInput(0);
auto from = this->getIntegerOnInput(1);
auto to = this->getIntegerOnInput(2);
auto from = this->getIntegerOnInput(1);
auto to = this->getIntegerOnInput(2);
if (from < 0 || from >= input.size())
throwNodeError("'from' input out of range");
@@ -526,7 +526,7 @@ namespace hex::plugin::builtin {
void process() override {
auto buffer = this->getBufferOnInput(0);
auto count = this->getIntegerOnInput(1);
auto count = this->getIntegerOnInput(1);
std::vector<u8> output;
output.resize(buffer.size() * count);
@@ -541,14 +541,14 @@ namespace hex::plugin::builtin {
class NodeIf : public dp::Node {
public:
NodeIf() : Node("ex.builtin.nodes.control_flow.if.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.if.condition"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.true"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.false"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.if.condition"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.true"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.false"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.output") }) { }
void process() override {
auto cond = this->getIntegerOnInput(0);
auto trueData = this->getBufferOnInput(1);
auto cond = this->getIntegerOnInput(0);
auto trueData = this->getBufferOnInput(1);
auto falseData = this->getBufferOnInput(2);
if (cond != 0)
@@ -561,9 +561,9 @@ namespace hex::plugin::builtin {
class NodeEquals : public dp::Node {
public:
NodeEquals() : Node("hex.builtin.nodes.control_flow.equals.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.output") }) { }
void process() override {
auto inputA = this->getIntegerOnInput(0);
@@ -576,8 +576,8 @@ namespace hex::plugin::builtin {
class NodeNot : public dp::Node {
public:
NodeNot() : Node("hex.builtin.nodes.control_flow.not.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.input"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.input"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.output") }) { }
void process() override {
auto input = this->getIntegerOnInput(0);
@@ -589,9 +589,9 @@ namespace hex::plugin::builtin {
class NodeGreaterThan : public dp::Node {
public:
NodeGreaterThan() : Node("hex.builtin.nodes.control_flow.gt.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.output") }) { }
void process() override {
auto inputA = this->getIntegerOnInput(0);
@@ -604,9 +604,9 @@ namespace hex::plugin::builtin {
class NodeLessThan : public dp::Node {
public:
NodeLessThan() : Node("hex.builtin.nodes.control_flow.lt.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.output") }) { }
void process() override {
auto inputA = this->getIntegerOnInput(0);
@@ -619,9 +619,9 @@ namespace hex::plugin::builtin {
class NodeBoolAND : public dp::Node {
public:
NodeBoolAND() : Node("hex.builtin.nodes.control_flow.and.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.output") }) { }
void process() override {
auto inputA = this->getIntegerOnInput(0);
@@ -634,9 +634,9 @@ namespace hex::plugin::builtin {
class NodeBoolOR : public dp::Node {
public:
NodeBoolOR() : Node("hex.builtin.nodes.control_flow.or.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.a"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.output") }) { }
void process() override {
auto inputA = this->getIntegerOnInput(0);
@@ -649,11 +649,11 @@ namespace hex::plugin::builtin {
class NodeCryptoAESDecrypt : public dp::Node {
public:
NodeCryptoAESDecrypt() : Node("hex.builtin.nodes.crypto.aes.header",
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.key"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.iv"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.nonce"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.input"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.output") }) { }
{ dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.key"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.iv"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.nonce"),
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.input"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.output") }) { }
void drawNode() override {
ImGui::PushItemWidth(100);
@@ -663,8 +663,8 @@ namespace hex::plugin::builtin {
}
void process() override {
auto key = this->getBufferOnInput(0);
auto iv = this->getBufferOnInput(1);
auto key = this->getBufferOnInput(0);
auto iv = this->getBufferOnInput(1);
auto nonce = this->getBufferOnInput(2);
auto input = this->getBufferOnInput(3);
@@ -687,18 +687,18 @@ namespace hex::plugin::builtin {
void store(nlohmann::json &j) override {
j = nlohmann::json::object();
j["data"] = nlohmann::json::object();
j["data"]["mode"] = this->m_mode;
j["data"] = nlohmann::json::object();
j["data"]["mode"] = this->m_mode;
j["data"]["key_length"] = this->m_keyLength;
}
void load(nlohmann::json &j) override {
this->m_mode = j["data"]["mode"];
this->m_mode = j["data"]["mode"];
this->m_keyLength = j["data"]["key_length"];
}
private:
int m_mode = 0;
int m_mode = 0;
int m_keyLength = 0;
};

View File

@@ -16,10 +16,10 @@ namespace hex::plugin::builtin {
void registerLayouts() {
ContentRegistry::Interface::addLayout("hex.builtin.layouts.default", [](ImGuiID dockMain) {
ImGuiID hexEditor = ImGui::DockBuilderSplitNode(dockMain, ImGuiDir_Left, 0.7F, nullptr, &dockMain);
ImGuiID utils = ImGui::DockBuilderSplitNode(dockMain, ImGuiDir_Right, 0.8F, nullptr, &dockMain);
ImGuiID hexEditor = ImGui::DockBuilderSplitNode(dockMain, ImGuiDir_Left, 0.7F, nullptr, &dockMain);
ImGuiID utils = ImGui::DockBuilderSplitNode(dockMain, ImGuiDir_Right, 0.8F, nullptr, &dockMain);
ImGuiID patternData = ImGui::DockBuilderSplitNode(hexEditor, ImGuiDir_Down, 0.3F, nullptr, &hexEditor);
ImGuiID inspector = ImGui::DockBuilderSplitNode(hexEditor, ImGuiDir_Right, 0.3F, nullptr, &hexEditor);
ImGuiID inspector = ImGui::DockBuilderSplitNode(hexEditor, ImGuiDir_Right, 0.3F, nullptr, &hexEditor);
openViewAndDockTo("hex.builtin.view.hexeditor.name", hexEditor);
openViewAndDockTo("hex.builtin.view.data_inspector.name", inspector);

View File

@@ -31,7 +31,7 @@ namespace hex::plugin::builtin {
[&](auto &&value) {
formatArgs.push_back(value);
} },
param);
param);
}
try {
@@ -80,14 +80,14 @@ namespace hex::plugin::builtin {
/* error(message) */
ContentRegistry::PatternLanguage::addFunction(nsStd, "error", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
LogConsole::abortEvaluation(Token::literalToString(params[0], true));
LogConsole::abortEvaluation(Token::literalToString(params[0], true));
return std::nullopt;
});
/* warning(message) */
ContentRegistry::PatternLanguage::addFunction(nsStd, "warning", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
ctx->getConsole().log(LogConsole::Level::Warning, Token::literalToString(params[0], true));
ctx->getConsole().log(LogConsole::Level::Warning, Token::literalToString(params[0], true));
return std::nullopt;
});
@@ -141,7 +141,7 @@ namespace hex::plugin::builtin {
/* read_unsigned(address, size) */
ContentRegistry::PatternLanguage::addFunction(nsStdMem, "read_unsigned", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto address = Token::literalToUnsigned(params[0]);
auto size = Token::literalToUnsigned(params[1]);
auto size = Token::literalToUnsigned(params[1]);
if (size > 16)
LogConsole::abortEvaluation("read size out of range");
@@ -155,7 +155,7 @@ namespace hex::plugin::builtin {
/* read_signed(address, size) */
ContentRegistry::PatternLanguage::addFunction(nsStdMem, "read_signed", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto address = Token::literalToUnsigned(params[0]);
auto size = Token::literalToUnsigned(params[1]);
auto size = Token::literalToUnsigned(params[1]);
if (size > 16)
LogConsole::abortEvaluation("read size out of range");
@@ -168,7 +168,7 @@ namespace hex::plugin::builtin {
/* read_string(address, size) */
ContentRegistry::PatternLanguage::addFunction(nsStdMem, "read_string", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto address = Token::literalToUnsigned(params[0]);
auto size = Token::literalToUnsigned(params[1]);
auto size = Token::literalToUnsigned(params[1]);
std::string result(size, '\x00');
ctx->getProvider()->read(address, result.data(), size);
@@ -189,11 +189,11 @@ namespace hex::plugin::builtin {
/* at(string, index) */
ContentRegistry::PatternLanguage::addFunction(nsStdString, "at", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto string = Token::literalToString(params[0], false);
auto index = Token::literalToSigned(params[1]);
auto index = Token::literalToSigned(params[1]);
#if defined(OS_MACOS)
const auto signIndex = index >> (sizeof(index) * 8 - 1);
const auto absIndex = (index ^ signIndex) - signIndex;
const auto absIndex = (index ^ signIndex) - signIndex;
#else
const auto absIndex = std::abs(index);
#endif
@@ -210,8 +210,8 @@ namespace hex::plugin::builtin {
/* substr(string, pos, count) */
ContentRegistry::PatternLanguage::addFunction(nsStdString, "substr", 3, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto string = Token::literalToString(params[0], false);
auto pos = Token::literalToUnsigned(params[1]);
auto size = Token::literalToUnsigned(params[2]);
auto pos = Token::literalToUnsigned(params[1]);
auto size = Token::literalToUnsigned(params[2]);
if (pos > string.length())
LogConsole::abortEvaluation("character index out of range");
@@ -222,7 +222,7 @@ namespace hex::plugin::builtin {
/* parse_int(string, base) */
ContentRegistry::PatternLanguage::addFunction(nsStdString, "parse_int", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto string = Token::literalToString(params[0], false);
auto base = Token::literalToUnsigned(params[1]);
auto base = Token::literalToUnsigned(params[1]);
return i128(std::strtoll(string.c_str(), nullptr, base));
});
@@ -255,22 +255,22 @@ namespace hex::plugin::builtin {
/* open(path, mode) */
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "open", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
const auto path = Token::literalToString(params[0], false);
const auto path = Token::literalToString(params[0], false);
const auto modeEnum = Token::literalToUnsigned(params[1]);
File::Mode mode;
switch (modeEnum) {
case 1:
mode = File::Mode::Read;
break;
case 2:
mode = File::Mode::Write;
break;
case 3:
mode = File::Mode::Create;
break;
default:
LogConsole::abortEvaluation("invalid file open mode");
case 1:
mode = File::Mode::Read;
break;
case 2:
mode = File::Mode::Write;
break;
case 3:
mode = File::Mode::Create;
break;
default:
LogConsole::abortEvaluation("invalid file open mode");
}
auto file = File(path, mode);
@@ -322,7 +322,7 @@ namespace hex::plugin::builtin {
/* seek(file, offset) */
ContentRegistry::PatternLanguage::addDangerousFunction(nsStdFile, "seek", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
const auto file = Token::literalToUnsigned(params[0]);
const auto file = Token::literalToUnsigned(params[0]);
const auto offset = Token::literalToUnsigned(params[1]);
if (!openFiles.contains(file))
@@ -507,7 +507,6 @@ namespace hex::plugin::builtin {
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atanh", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
return std::atanh(Token::literalToFloatingPoint(params[0]));
});
}
}

View File

@@ -73,7 +73,7 @@ namespace hex::plugin::builtin::prv {
this->m_diskHandle = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (this->m_diskHandle == INVALID_HANDLE_VALUE) {
this->m_diskHandle = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_writable = false;
this->m_writable = false;
if (this->m_diskHandle == INVALID_HANDLE_VALUE)
return false;
@@ -81,7 +81,7 @@ namespace hex::plugin::builtin::prv {
{
DISK_GEOMETRY_EX diskGeometry = { 0 };
DWORD bytesRead = 0;
DWORD bytesRead = 0;
if (DeviceIoControl(
this->m_diskHandle,
IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
@@ -91,14 +91,14 @@ namespace hex::plugin::builtin::prv {
sizeof(DISK_GEOMETRY_EX),
&bytesRead,
nullptr)) {
this->m_diskSize = diskGeometry.DiskSize.QuadPart;
this->m_diskSize = diskGeometry.DiskSize.QuadPart;
this->m_sectorSize = diskGeometry.Geometry.BytesPerSector;
this->m_sectorBuffer.resize(this->m_sectorSize);
}
}
if (this->m_diskHandle == nullptr || this->m_diskHandle == INVALID_HANDLE_VALUE) {
this->m_readable = false;
this->m_readable = false;
this->m_diskHandle = nullptr;
CloseHandle(this->m_diskHandle);
@@ -112,13 +112,13 @@ namespace hex::plugin::builtin::prv {
struct stat driveStat;
::stat(path.c_str(), &driveStat) == 0;
this->m_diskSize = driveStat.st_size;
this->m_diskSize = driveStat.st_size;
this->m_sectorSize = 0;
this->m_diskHandle = ::open(path.c_str(), O_RDWR);
if (this->m_diskHandle == -1) {
this->m_diskHandle = ::open(path.c_str(), O_RDONLY);
this->m_writable = false;
this->m_writable = false;
}
if (this->m_diskHandle == -1) {
@@ -153,7 +153,7 @@ namespace hex::plugin::builtin::prv {
while (size > 0) {
LARGE_INTEGER seekPosition;
seekPosition.LowPart = (offset & 0xFFFF'FFFF) - (offset % this->m_sectorSize);
seekPosition.LowPart = (offset & 0xFFFF'FFFF) - (offset % this->m_sectorSize);
seekPosition.HighPart = offset >> 32;
if (this->m_sectorBufferAddress != seekPosition.QuadPart) {
@@ -168,7 +168,7 @@ namespace hex::plugin::builtin::prv {
offset += this->m_sectorSize;
}
#else
u64 startOffset = offset;
u64 startOffset = offset;
while (size > 0) {
u64 seekPosition = offset - (offset % this->m_sectorSize);
@@ -197,14 +197,14 @@ namespace hex::plugin::builtin::prv {
modifiedSectorBuffer.resize(this->m_sectorSize);
while (size > 0) {
u64 sectorBase = offset - (offset % this->m_sectorSize);
u64 sectorBase = offset - (offset % this->m_sectorSize);
size_t currSize = std::min(size, this->m_sectorSize);
this->readRaw(sectorBase, modifiedSectorBuffer.data(), modifiedSectorBuffer.size());
std::memcpy(modifiedSectorBuffer.data() + ((offset - sectorBase) % this->m_sectorSize), reinterpret_cast<const u8 *>(buffer) + (startOffset - offset), currSize);
LARGE_INTEGER seekPosition;
seekPosition.LowPart = (offset & 0xFFFF'FFFF) - (offset % this->m_sectorSize);
seekPosition.LowPart = (offset & 0xFFFF'FFFF) - (offset % this->m_sectorSize);
seekPosition.HighPart = offset >> 32;
::SetFilePointer(this->m_diskHandle, seekPosition.LowPart, &seekPosition.HighPart, FILE_BEGIN);
@@ -222,7 +222,7 @@ namespace hex::plugin::builtin::prv {
modifiedSectorBuffer.resize(this->m_sectorSize);
while (size > 0) {
u64 sectorBase = offset - (offset % this->m_sectorSize);
u64 sectorBase = offset - (offset % this->m_sectorSize);
size_t currSize = std::min(size, this->m_sectorSize);
this->readRaw(sectorBase, modifiedSectorBuffer.data(), modifiedSectorBuffer.size());
@@ -271,8 +271,8 @@ namespace hex::plugin::builtin::prv {
if (handle == INVALID_HANDLE_VALUE) continue;
VOLUME_DISK_EXTENTS diskExtents = { 0 };
DWORD bytesRead = 0;
auto result = ::DeviceIoControl(
DWORD bytesRead = 0;
auto result = ::DeviceIoControl(
handle,
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
nullptr,

View File

@@ -173,7 +173,7 @@ namespace hex::plugin::builtin::prv {
const auto &path = this->m_path.native();
LARGE_INTEGER fileSize = { 0 };
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
GetFileSizeEx(this->m_file, &fileSize);
this->m_fileSize = fileSize.QuadPart;
@@ -181,7 +181,7 @@ namespace hex::plugin::builtin::prv {
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (this->m_file == nullptr || this->m_file == INVALID_HANDLE_VALUE) {
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_writable = false;
}
@@ -189,7 +189,7 @@ namespace hex::plugin::builtin::prv {
CloseHandle(this->m_file);
this->m_readable = false;
this->m_file = nullptr;
this->m_file = nullptr;
};
if (this->m_file == nullptr || this->m_file == INVALID_HANDLE_VALUE) {
@@ -209,7 +209,7 @@ namespace hex::plugin::builtin::prv {
auto mappingCleanup = SCOPE_GUARD {
CloseHandle(this->m_mapping);
this->m_mapping = nullptr;
this->m_mapping = nullptr;
this->m_readable = false;
};
@@ -241,7 +241,7 @@ namespace hex::plugin::builtin::prv {
this->m_file = ::open(path.c_str(), O_RDWR);
if (this->m_file == -1) {
this->m_file = ::open(path.c_str(), O_RDONLY);
this->m_file = ::open(path.c_str(), O_RDONLY);
this->m_writable = false;
}

View File

@@ -42,7 +42,7 @@ namespace hex::plugin::builtin::prv {
if (packet[packet.length() - 3] != '#')
return std::nullopt;
std::string data = packet.substr(1, packet.length() - 4);
std::string data = packet.substr(1, packet.length() - 4);
std::string checksum = packet.substr(packet.length() - 2, 2);
if (checksum.length() != 2 || crypt::decode16(checksum)[0] != calculateChecksum(data))
@@ -229,10 +229,10 @@ namespace hex::plugin::builtin::prv {
if (!this->isConnected()) {
address = "-";
port = "-";
port = "-";
} else {
address = this->m_ipAddress;
port = std::to_string(this->m_port);
port = std::to_string(this->m_port);
}
return hex::format("hex.builtin.provider.gdb.name"_lang, address, port);

View File

@@ -101,10 +101,10 @@ namespace hex::plugin::builtin {
}
void drawRegexReplacer() {
static auto regexInput = [] { std::string s; s.reserve(0xFFF); return s; }();
static auto regexPattern = [] { std::string s; s.reserve(0xFFF); return s; }();
static auto regexInput = [] { std::string s; s.reserve(0xFFF); return s; }();
static auto regexPattern = [] { std::string s; s.reserve(0xFFF); return s; }();
static auto replacePattern = [] { std::string s; s.reserve(0xFFF); return s; }();
static auto regexOutput = [] { std::string s; s.reserve(0xFFF); return s; }();
static auto regexOutput = [] { std::string s; s.reserve(0xFFF); return s; }();
bool changed1 = ImGui::InputText("hex.builtin.tools.regex_replacer.pattern"_lang, regexPattern.data(), regexPattern.capacity(), ImGuiInputTextFlags_CallbackEdit, ImGui::UpdateStringSizeCallback, &regexPattern);
bool changed2 = ImGui::InputText("hex.builtin.tools.regex_replacer.replace"_lang, replacePattern.data(), replacePattern.capacity(), ImGuiInputTextFlags_CallbackEdit, ImGui::UpdateStringSizeCallback, &replacePattern);
@@ -243,32 +243,32 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
ImGui::NewLine();
switch (mathDisplayType) {
case MathDisplayType::Standard:
case MathDisplayType::Scientific:
case MathDisplayType::Engineering:
if (ImGui::Button("", buttonSize)) mathInput += "** 2";
ImGui::SameLine();
if (ImGui::Button("1/x", buttonSize)) mathInput += "1/";
ImGui::SameLine();
if (ImGui::Button("|x|", buttonSize)) mathInput += "abs";
ImGui::SameLine();
if (ImGui::Button("exp", buttonSize)) mathInput += "e ** ";
ImGui::SameLine();
if (ImGui::Button("%", buttonSize)) mathInput += "%";
ImGui::SameLine();
break;
case MathDisplayType::Programmer:
if (ImGui::Button("<<", buttonSize)) mathInput += "<<";
ImGui::SameLine();
if (ImGui::Button(">>", buttonSize)) mathInput += ">>";
ImGui::SameLine();
if (ImGui::Button("&", buttonSize)) mathInput += "&";
ImGui::SameLine();
if (ImGui::Button("|", buttonSize)) mathInput += "|";
ImGui::SameLine();
if (ImGui::Button("^", buttonSize)) mathInput += "^";
ImGui::SameLine();
break;
case MathDisplayType::Standard:
case MathDisplayType::Scientific:
case MathDisplayType::Engineering:
if (ImGui::Button("", buttonSize)) mathInput += "** 2";
ImGui::SameLine();
if (ImGui::Button("1/x", buttonSize)) mathInput += "1/";
ImGui::SameLine();
if (ImGui::Button("|x|", buttonSize)) mathInput += "abs";
ImGui::SameLine();
if (ImGui::Button("exp", buttonSize)) mathInput += "e ** ";
ImGui::SameLine();
if (ImGui::Button("%", buttonSize)) mathInput += "%";
ImGui::SameLine();
break;
case MathDisplayType::Programmer:
if (ImGui::Button("<<", buttonSize)) mathInput += "<<";
ImGui::SameLine();
if (ImGui::Button(">>", buttonSize)) mathInput += ">>";
ImGui::SameLine();
if (ImGui::Button("&", buttonSize)) mathInput += "&";
ImGui::SameLine();
if (ImGui::Button("|", buttonSize)) mathInput += "|";
ImGui::SameLine();
if (ImGui::Button("^", buttonSize)) mathInput += "^";
ImGui::SameLine();
break;
}
ImGui::NewLine();
if (ImGui::Button("sqrt", buttonSize)) mathInput += "sqrt";
@@ -352,20 +352,20 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
switch (mathDisplayType) {
case MathDisplayType::Standard:
ImGui::TextFormatted("{0:.3Lf}", mathHistory[(mathHistory.size() - 1) - i]);
break;
case MathDisplayType::Scientific:
ImGui::TextFormatted("{0:.6Le}", mathHistory[(mathHistory.size() - 1) - i]);
break;
case MathDisplayType::Engineering:
ImGui::TextFormatted("{0}", hex::toEngineeringString(mathHistory[(mathHistory.size() - 1) - i]).c_str());
break;
case MathDisplayType::Programmer:
ImGui::TextFormatted("0x{0:X} ({1})",
u64(mathHistory[(mathHistory.size() - 1) - i]),
u64(mathHistory[(mathHistory.size() - 1) - i]));
break;
case MathDisplayType::Standard:
ImGui::TextFormatted("{0:.3Lf}", mathHistory[(mathHistory.size() - 1) - i]);
break;
case MathDisplayType::Scientific:
ImGui::TextFormatted("{0:.6Le}", mathHistory[(mathHistory.size() - 1) - i]);
break;
case MathDisplayType::Engineering:
ImGui::TextFormatted("{0}", hex::toEngineeringString(mathHistory[(mathHistory.size() - 1) - i]).c_str());
break;
case MathDisplayType::Programmer:
ImGui::TextFormatted("0x{0:X} ({1})",
u64(mathHistory[(mathHistory.size() - 1) - i]),
u64(mathHistory[(mathHistory.size() - 1) - i]));
break;
}
if (i == 0)
@@ -392,18 +392,18 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
switch (mathDisplayType) {
case MathDisplayType::Standard:
ImGui::TextFormatted("{0:.3Lf}", value);
break;
case MathDisplayType::Scientific:
ImGui::TextFormatted("{0:.6Le}", value);
break;
case MathDisplayType::Engineering:
ImGui::TextFormatted("{}", hex::toEngineeringString(value));
break;
case MathDisplayType::Programmer:
ImGui::TextFormatted("0x{0:X} ({1})", u64(value), u64(value));
break;
case MathDisplayType::Standard:
ImGui::TextFormatted("{0:.3Lf}", value);
break;
case MathDisplayType::Scientific:
ImGui::TextFormatted("{0:.6Le}", value);
break;
case MathDisplayType::Engineering:
ImGui::TextFormatted("{}", hex::toEngineeringString(value));
break;
case MathDisplayType::Programmer:
ImGui::TextFormatted("0x{0:X} ({1})", u64(value), u64(value));
break;
}
}
@@ -447,16 +447,16 @@ namespace hex::plugin::builtin {
static auto CharFilter = [](ImGuiInputTextCallbackData *data) -> int {
switch (*static_cast<u32 *>(data->UserData)) {
case 16:
return std::isxdigit(data->EventChar);
case 10:
return std::isdigit(data->EventChar);
case 8:
return std::isdigit(data->EventChar) && data->EventChar < '8';
case 2:
return data->EventChar == '0' || data->EventChar == '1';
default:
return false;
case 16:
return std::isxdigit(data->EventChar);
case 10:
return std::isdigit(data->EventChar);
case 8:
return std::isdigit(data->EventChar) && data->EventChar < '8';
case 2:
return data->EventChar == '0' || data->EventChar == '1';
default:
return false;
}
};
@@ -465,26 +465,26 @@ namespace hex::plugin::builtin {
errno = 0;
switch (base) {
case 16:
number = std::strtoull(buffer[1], nullptr, base);
break;
case 10:
number = std::strtoull(buffer[0], nullptr, base);
break;
case 8:
number = std::strtoull(buffer[2], nullptr, base);
break;
case 2:
number = std::strtoull(buffer[3], nullptr, base);
break;
default:
return;
case 16:
number = std::strtoull(buffer[1], nullptr, base);
break;
case 10:
number = std::strtoull(buffer[0], nullptr, base);
break;
case 8:
number = std::strtoull(buffer[2], nullptr, base);
break;
case 2:
number = std::strtoull(buffer[3], nullptr, base);
break;
default:
return;
}
auto base10String = std::to_string(number);
auto base16String = hex::format("0x{0:X}", number);
auto base8String = hex::format("{0:#o}", number);
auto base2String = hex::toBinaryString(number);
auto base8String = hex::format("{0:#o}", number);
auto base2String = hex::toBinaryString(number);
std::strncpy(buffer[0], base10String.c_str(), sizeof(buffer[0]));
std::strncpy(buffer[1], base16String.c_str(), sizeof(buffer[1]));
@@ -552,10 +552,10 @@ namespace hex::plugin::builtin {
ImGui::Separator();
auto result = hex::format("{}{}{}{}",
(setuid << 2) | (setgid << 1) | (sticky << 0),
(r[0] << 2) | (w[0] << 1) | (x[0] << 0),
(r[1] << 2) | (w[1] << 1) | (x[1] << 0),
(r[2] << 2) | (w[2] << 1) | (x[2] << 0));
(setuid << 2) | (setgid << 1) | (sticky << 0),
(r[0] << 2) | (w[0] << 1) | (x[0] << 0),
(r[1] << 2) | (w[1] << 1) | (x[1] << 0),
(r[2] << 2) | (w[2] << 1) | (x[2] << 0));
ImGui::InputText("##permissions_absolute", result.data(), result.size(), ImGuiInputTextFlags_ReadOnly);
ImGui::NewLine();
@@ -586,7 +586,7 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.tools.file_uploader.upload"_lang)) {
hex::openFileBrowser("hex.builtin.tools.file_uploader.done"_lang, DialogMode::Open, {}, [&](auto path) {
uploadProcess = net.uploadFile("https://api.anonfiles.com/upload", path);
currFile = path;
currFile = path;
});
}
} else {
@@ -645,8 +645,8 @@ namespace hex::plugin::builtin {
try {
auto json = nlohmann::json::parse(response.body);
links.push_back({ currFile.filename().string(),
json["data"]["file"]["url"]["short"],
json["data"]["file"]["metadata"]["size"]["readable"] });
json["data"]["file"]["url"]["short"],
json["data"]["file"]["metadata"]["size"]["readable"] });
} catch (...) {
View::showErrorPopup("hex.builtin.tools.file_uploader.invalid_response"_lang);
}
@@ -708,12 +708,12 @@ namespace hex::plugin::builtin {
auto json = nlohmann::json::parse(response.body);
resultTitle = json["query"]["pages"][0]["title"];
resultTitle = json["query"]["pages"][0]["title"];
resultExtract = json["query"]["pages"][0]["extract"];
if (!extendedSearch && resultExtract.ends_with(':')) {
extendedSearch = true;
searchProcess = net.getString(WikipediaApiUrl + "&titles="s + net.encode(searchString));
searchProcess = net.getString(WikipediaApiUrl + "&titles="s + net.encode(searchString));
resultTitle.clear();
resultExtract.clear();
} else {
@@ -724,9 +724,9 @@ namespace hex::plugin::builtin {
resultTitle.clear();
resultExtract.clear();
extendedSearch = false;
searchProcess = {};
searchProcess = {};
resultTitle = "???";
resultTitle = "???";
resultExtract = "hex.builtin.tools.wiki_explain.invalid_response"_lang.get();
}
}
@@ -734,9 +734,9 @@ namespace hex::plugin::builtin {
void drawFileToolShredder() {
static bool shredding = false;
static bool shredding = false;
static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }();
static bool fastMode = false;
static bool fastMode = false;
ImGui::TextUnformatted("hex.builtin.tools.file_tools.shredder.warning"_lang);
ImGui::NewLine();
@@ -879,11 +879,11 @@ namespace hex::plugin::builtin {
1
};
static bool splitting = false;
static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }();
static bool splitting = false;
static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }();
static auto baseOutputPath = [] { std::string s; s.reserve(0x1000); return s; }();
static u64 splitSize = sizes[0];
static int selectedItem = 0;
static u64 splitSize = sizes[0];
static int selectedItem = 0;
if (ImGui::BeginChild("split_settings", { 0, ImGui::GetTextLineHeightWithSpacing() * 7 }, true, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
ImGui::BeginDisabled(splitting);
@@ -1095,7 +1095,7 @@ namespace hex::plugin::builtin {
}
constexpr auto BufferSize = 0xFF'FFFF;
auto inputSize = input.getSize();
auto inputSize = input.getSize();
for (u64 inputOffset = 0; inputOffset < inputSize; inputOffset += BufferSize) {
output.write(input.readBytes(std::min<u64>(BufferSize, inputSize - inputOffset)));
output.flush();

View File

@@ -33,7 +33,7 @@ namespace hex::plugin::builtin {
});
ContentRegistry::Interface::addFooterItem([] {
size_t taskCount = 0;
size_t taskCount = 0;
double taskProgress = 0.0;
std::string taskName;
@@ -43,8 +43,8 @@ namespace hex::plugin::builtin {
taskCount = Task::getRunningTasks().size();
if (taskCount > 0) {
auto frontTask = Task::getRunningTasks().front();
taskProgress = frontTask->getProgress();
taskName = frontTask->getName();
taskProgress = frontTask->getProgress();
taskName = frontTask->getName();
}
}
@@ -71,14 +71,14 @@ namespace hex::plugin::builtin {
if (ImGui::ToolBarButton(ICON_VS_DISCARD, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue)))
provider->undo();
},
!ImHexApi::Provider::isValid() || !provider->canUndo());
!ImHexApi::Provider::isValid() || !provider->canUndo());
// Redo
ImGui::Disabled([&provider] {
if (ImGui::ToolBarButton(ICON_VS_REDO, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue)))
provider->redo();
},
!ImHexApi::Provider::isValid() || !provider->canRedo());
!ImHexApi::Provider::isValid() || !provider->canRedo());
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
@@ -99,7 +99,7 @@ namespace hex::plugin::builtin {
if (ImGui::ToolBarButton(ICON_VS_SAVE, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue)))
provider->save();
},
!ImHexApi::Provider::isValid() || !provider->isWritable() || !provider->isSavable());
!ImHexApi::Provider::isValid() || !provider->isWritable() || !provider->isSavable());
// Save file as
ImGui::Disabled([&provider] {
@@ -108,7 +108,7 @@ namespace hex::plugin::builtin {
provider->saveAs(path);
});
},
!ImHexApi::Provider::isValid() || !provider->isSavable());
!ImHexApi::Provider::isValid() || !provider->isSavable());
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
@@ -123,7 +123,7 @@ namespace hex::plugin::builtin {
ImHexApi::Bookmarks::add(region.address, region.size, {}, {});
}
},
!ImHexApi::Provider::isValid() || !provider->isReadable());
!ImHexApi::Provider::isValid() || !provider->isReadable());
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
@@ -149,7 +149,7 @@ namespace hex::plugin::builtin {
ImGui::EndCombo();
}
},
!ImHexApi::Provider::isValid());
!ImHexApi::Provider::isValid());
});
}

View File

@@ -19,15 +19,13 @@ namespace hex::plugin::builtin {
color = ImGui::GetColorU32(ImGuiCol_Header);
this->m_bookmarks.push_back({
region,
this->m_bookmarks.push_back({ region,
name,
std::move(comment),
color,
false,
ImHexApi::HexEditor::addHighlight(region, color, name)
});
ImHexApi::HexEditor::addHighlight(region, color, name) });
ProjectFile::markDirty();
});
@@ -62,13 +60,13 @@ namespace hex::plugin::builtin {
ImGui::TextFormattedCentered("hex.builtin.view.bookmarks.no_bookmarks"_lang);
}
u32 id = 1;
u32 id = 1;
auto bookmarkToRemove = this->m_bookmarks.end();
for (auto iter = this->m_bookmarks.begin(); iter != this->m_bookmarks.end(); iter++) {
auto &[region, name, comment, color, locked, highlight] = *iter;
auto headerColor = ImColor(color);
auto hoverColor = ImColor(color);
auto hoverColor = ImColor(color);
hoverColor.Value.w *= 1.3F;
ImGui::PushID(id);
@@ -95,7 +93,7 @@ namespace hex::plugin::builtin {
// First line
{
std::array<u8, 0x10> bytes = { 0 };
size_t byteCount = std::min<size_t>(0x10 - offset, region.size);
size_t byteCount = std::min<size_t>(0x10 - offset, region.size);
ImHexApi::Provider::get()->read(region.address, bytes.data() + offset, byteCount);
for (size_t byte = 0; byte < 0x10; byte++) {

View File

@@ -12,7 +12,7 @@ namespace hex::plugin::builtin {
ShortcutManager::addGlobalShortcut(CTRL + SHIFT + Keys::P, [this] {
EventManager::post<RequestOpenPopup>("hex.builtin.view.command_palette.name"_lang);
this->m_commandPaletteOpen = true;
this->m_justOpened = true;
this->m_justOpened = true;
});
}
@@ -23,7 +23,7 @@ namespace hex::plugin::builtin {
if (!this->m_commandPaletteOpen) return;
auto windowPos = ImHexApi::System::getMainWindowPosition();
auto windowPos = ImHexApi::System::getMainWindowPosition();
auto windowSize = ImHexApi::System::getMainWindowSize();
ImGui::SetNextWindowPos(ImVec2(windowPos.x + windowSize.x * 0.5F, windowPos.y), ImGuiCond_Always, ImVec2(0.5F, 0.0F));
@@ -34,7 +34,7 @@ namespace hex::plugin::builtin {
ImGui::PushItemWidth(-1);
if (ImGui::InputText(
"##command_input", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue, [](ImGuiInputTextCallbackData *callbackData) -> int {
auto _this = static_cast<ViewCommandPalette *>(callbackData->UserData);
auto _this = static_cast<ViewCommandPalette *>(callbackData->UserData);
_this->m_lastResults = _this->getCommandResults(callbackData->Buf);
return 0;

View File

@@ -37,7 +37,7 @@ namespace hex::plugin::builtin {
for (auto value : content["values"]) {
Constant constant;
constant.category = content["name"];
constant.name = value["name"];
constant.name = value["name"];
if (value.contains("desc"))
constant.description = value["desc"];
constant.value = value["value"];

View File

@@ -17,7 +17,7 @@ namespace hex::plugin::builtin {
if (!ImHexApi::Provider::isValid() || region.address == (size_t)-1) {
this->m_validBytes = 0;
} else {
this->m_validBytes = u64(provider->getSize() - region.address);
this->m_validBytes = u64(provider->getSize() - region.address);
this->m_startAddress = region.address;
}
@@ -83,32 +83,32 @@ namespace hex::plugin::builtin {
ImGui::NewLine();
if (ImGui::RadioButton("hex.common.little_endian"_lang, this->m_endian == std::endian::little)) {
this->m_endian = std::endian::little;
this->m_endian = std::endian::little;
this->m_shouldInvalidate = true;
}
ImGui::SameLine();
if (ImGui::RadioButton("hex.common.big_endian"_lang, this->m_endian == std::endian::big)) {
this->m_endian = std::endian::big;
this->m_endian = std::endian::big;
this->m_shouldInvalidate = true;
}
if (ImGui::RadioButton("hex.common.decimal"_lang, this->m_numberDisplayStyle == NumberDisplayStyle::Decimal)) {
this->m_numberDisplayStyle = NumberDisplayStyle::Decimal;
this->m_shouldInvalidate = true;
this->m_shouldInvalidate = true;
}
ImGui::SameLine();
if (ImGui::RadioButton("hex.common.hexadecimal"_lang, this->m_numberDisplayStyle == NumberDisplayStyle::Hexadecimal)) {
this->m_numberDisplayStyle = NumberDisplayStyle::Hexadecimal;
this->m_shouldInvalidate = true;
this->m_shouldInvalidate = true;
}
ImGui::SameLine();
if (ImGui::RadioButton("hex.common.octal"_lang, this->m_numberDisplayStyle == NumberDisplayStyle::Octal)) {
this->m_numberDisplayStyle = NumberDisplayStyle::Octal;
this->m_shouldInvalidate = true;
this->m_shouldInvalidate = true;
}
} else {
std::string text = "hex.builtin.view.data_inspector.no_data"_lang;
auto textSize = ImGui::CalcTextSize(text.c_str());
std::string text = "hex.builtin.view.data_inspector.no_data"_lang;
auto textSize = ImGui::CalcTextSize(text.c_str());
auto availableSpace = ImGui::GetContentRegionAvail();
ImGui::SetCursorPos((availableSpace - textSize) / 2.0F);

View File

@@ -15,16 +15,16 @@ namespace hex::plugin::builtin {
ViewDataProcessor::ViewDataProcessor() : View("hex.builtin.view.data_processor.name") {
EventManager::subscribe<RequestChangeTheme>(this, [](u32 theme) {
switch (theme) {
default:
case 1: /* Dark theme */
ImNodes::StyleColorsDark();
break;
case 2: /* Light theme */
ImNodes::StyleColorsLight();
break;
case 3: /* Classic theme */
ImNodes::StyleColorsClassic();
break;
default:
case 1: /* Dark theme */
ImNodes::StyleColorsDark();
break;
case 2: /* Light theme */
ImNodes::StyleColorsLight();
break;
case 3: /* Classic theme */
ImNodes::StyleColorsClassic();
break;
}
ImNodes::GetStyle().Flags = ImNodesStyleFlags_NodeOutline | ImNodesStyleFlags_GridLines;
@@ -53,22 +53,22 @@ namespace hex::plugin::builtin {
hex::openFileBrowser("hex.builtin.view.data_processor.menu.file.load_processor"_lang, DialogMode::Open, {
{"hex.builtin.view.data_processor.name"_lang, "hexnode"}
},
[this](const fs::path &path) {
File file(path, File::Mode::Read);
if (file.isValid())
this->loadNodes(file.readString());
});
[this](const fs::path &path) {
File file(path, File::Mode::Read);
if (file.isValid())
this->loadNodes(file.readString());
});
}
if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.save_processor"_lang, nullptr, false, !this->m_nodes.empty())) {
hex::openFileBrowser("hex.builtin.view.data_processor.menu.file.save_processor"_lang, DialogMode::Save, {
{"hex.builtin.view.data_processor.name"_lang, "hexnode"}
},
[this](const fs::path &path) {
File file(path, File::Mode::Create);
if (file.isValid())
file.write(this->saveNodes());
});
[this](const fs::path &path) {
File file(path, File::Mode::Create);
if (file.isValid())
file.write(this->saveNodes());
});
}
});
}
@@ -228,7 +228,7 @@ namespace hex::plugin::builtin {
this->m_nodes.push_back(node);
bool hasOutput = false;
bool hasInput = false;
bool hasInput = false;
for (auto &attr : node->getAttributes()) {
if (attr.getIOType() == dp::Attribute::IOType::Out)
hasOutput = true;
@@ -291,15 +291,15 @@ namespace hex::plugin::builtin {
ImNodesPinShape pinShape;
switch (attribute.getType()) {
case dp::Attribute::Type::Integer:
pinShape = ImNodesPinShape_Circle;
break;
case dp::Attribute::Type::Float:
pinShape = ImNodesPinShape_Triangle;
break;
case dp::Attribute::Type::Buffer:
pinShape = ImNodesPinShape_Quad;
break;
case dp::Attribute::Type::Integer:
pinShape = ImNodesPinShape_Circle;
break;
case dp::Attribute::Type::Float:
pinShape = ImNodesPinShape_Triangle;
break;
case dp::Attribute::Type::Buffer:
pinShape = ImNodesPinShape_Quad;
break;
}
if (attribute.getIOType() == dp::Attribute::IOType::In) {
@@ -403,17 +403,17 @@ namespace hex::plugin::builtin {
output["nodes"] = json::object();
for (auto &node : this->m_nodes) {
auto id = node->getId();
auto id = node->getId();
auto &currNodeOutput = output["nodes"][std::to_string(id)];
auto pos = ImNodes::GetNodeGridSpacePos(id);
auto pos = ImNodes::GetNodeGridSpacePos(id);
currNodeOutput["type"] = node->getUnlocalizedName();
currNodeOutput["pos"] = {
currNodeOutput["pos"] = {
{"x", pos.x},
{ "y", pos.y}
};
currNodeOutput["attrs"] = json::array();
currNodeOutput["id"] = id;
currNodeOutput["id"] = id;
json nodeData;
node->store(nodeData);
@@ -428,12 +428,12 @@ namespace hex::plugin::builtin {
output["links"] = json::object();
for (auto &link : this->m_links) {
auto id = link.getId();
auto id = link.getId();
auto &currOutput = output["links"][std::to_string(id)];
currOutput["id"] = id;
currOutput["id"] = id;
currOutput["from"] = link.getFromId();
currOutput["to"] = link.getToId();
currOutput["to"] = link.getToId();
}
return output.dump();
@@ -467,13 +467,13 @@ namespace hex::plugin::builtin {
continue;
u32 nodeId = node["id"];
maxNodeId = std::max(nodeId, maxNodeId);
maxNodeId = std::max(nodeId, maxNodeId);
newNode->setId(nodeId);
bool hasOutput = false;
bool hasInput = false;
u32 attrIndex = 0;
bool hasInput = false;
u32 attrIndex = 0;
for (auto &attr : newNode->getAttributes()) {
if (attr.getIOType() == dp::Attribute::IOType::Out)
hasOutput = true;
@@ -482,7 +482,7 @@ namespace hex::plugin::builtin {
hasInput = true;
u32 attrId = node["attrs"][attrIndex];
maxAttrId = std::max(attrId, maxAttrId);
maxAttrId = std::max(attrId, maxAttrId);
attr.setId(attrId);
attrIndex++;
@@ -502,7 +502,7 @@ namespace hex::plugin::builtin {
dp::Link newLink(link["from"], link["to"]);
u32 linkId = link["id"];
maxLinkId = std::max(linkId, maxLinkId);
maxLinkId = std::max(linkId, maxLinkId);
newLink.setID(linkId);
this->m_links.push_back(newLink);

View File

@@ -113,7 +113,7 @@ namespace hex::plugin::builtin {
ImDrawList *drawList = ImGui::GetWindowDrawList();
auto glyphWidth = ImGui::CalcTextSize("0").x + 1;
auto glyphWidth = ImGui::CalcTextSize("0").x + 1;
static auto highlightSize = ImGui::CalcTextSize("00");
auto startY = ImGui::GetCursorPosY();
@@ -122,7 +122,7 @@ namespace hex::plugin::builtin {
ImGui::SetCursorPosY(startY);
ImGui::TableNextColumn();
const ImColor colorText = ImGui::GetColorU32(ImGuiCol_Text);
const ImColor colorText = ImGui::GetColorU32(ImGuiCol_Text);
const ImColor colorDisabled = this->m_greyedOutZeros ? ImGui::GetColorU32(ImGuiCol_TextDisabled) : static_cast<u32>(colorText);
@@ -137,19 +137,19 @@ namespace hex::plugin::builtin {
// Diff bytes
std::optional<u32> highlightColor;
switch (diffBytes(col, lineInfo[curr], lineInfo[other])) {
default:
case DiffResult::Same:
/* No highlight */
break;
case DiffResult::Changed:
highlightColor = getDiffColor(ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarYellow));
break;
case DiffResult::Added:
highlightColor = getDiffColor(ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarGreen));
break;
case DiffResult::Removed:
highlightColor = getDiffColor(ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarRed));
break;
default:
case DiffResult::Same:
/* No highlight */
break;
case DiffResult::Changed:
highlightColor = getDiffColor(ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarYellow));
break;
case DiffResult::Added:
highlightColor = getDiffColor(ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarGreen));
break;
case DiffResult::Removed:
highlightColor = getDiffColor(ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarRed));
break;
}
// Draw byte

View File

@@ -70,13 +70,13 @@ namespace hex::plugin::builtin {
u64 usedBytes = 0;
for (u32 i = 0; i < instructionCount; i++) {
const auto &instr = instructions[i];
const auto &instr = instructions[i];
Disassembly disassembly = { 0 };
disassembly.address = instr.address;
disassembly.offset = this->m_codeRegion[0] + address + usedBytes;
disassembly.size = instr.size;
disassembly.mnemonic = instr.mnemonic;
disassembly.operators = instr.op_str;
disassembly.address = instr.address;
disassembly.offset = this->m_codeRegion[0] + address + usedBytes;
disassembly.size = instr.size;
disassembly.mnemonic = instr.mnemonic;
disassembly.operators = instr.op_str;
for (u16 j = 0; j < instr.size; j++)
disassembly.bytes += hex::format("{0:02X} ", instr.bytes[j]);
@@ -136,178 +136,188 @@ namespace hex::plugin::builtin {
ImGui::NewLine();
switch (this->m_architecture) {
case Architecture::ARM: {
static int mode = CS_MODE_ARM;
ImGui::RadioButton("hex.builtin.view.disassembler.arm.arm"_lang, &mode, CS_MODE_ARM);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.arm.thumb"_lang, &mode, CS_MODE_THUMB);
case Architecture::ARM:
{
static int mode = CS_MODE_ARM;
ImGui::RadioButton("hex.builtin.view.disassembler.arm.arm"_lang, &mode, CS_MODE_ARM);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.arm.thumb"_lang, &mode, CS_MODE_THUMB);
static int extraMode = 0;
ImGui::RadioButton("hex.builtin.view.disassembler.arm.default"_lang, &extraMode, 0);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.arm.cortex_m"_lang, &extraMode, CS_MODE_MCLASS);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.arm.armv8"_lang, &extraMode, CS_MODE_V8);
static int extraMode = 0;
ImGui::RadioButton("hex.builtin.view.disassembler.arm.default"_lang, &extraMode, 0);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.arm.cortex_m"_lang, &extraMode, CS_MODE_MCLASS);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.arm.armv8"_lang, &extraMode, CS_MODE_V8);
this->m_mode = cs_mode(mode | extraMode);
}
break;
case Architecture::MIPS: {
static int mode = CS_MODE_MIPS32;
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips32"_lang, &mode, CS_MODE_MIPS32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips64"_lang, &mode, CS_MODE_MIPS64);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips32R6"_lang, &mode, CS_MODE_MIPS32R6);
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips2"_lang, &mode, CS_MODE_MIPS2);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips3"_lang, &mode, CS_MODE_MIPS3);
static bool microMode;
ImGui::Checkbox("hex.builtin.view.disassembler.mips.micro"_lang, &microMode);
this->m_mode = cs_mode(mode | (microMode ? CS_MODE_MICRO : 0));
}
break;
case Architecture::X86: {
static int mode = CS_MODE_32;
ImGui::RadioButton("hex.builtin.view.disassembler.16bit"_lang, &mode, CS_MODE_16);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.64bit"_lang, &mode, CS_MODE_64);
this->m_mode = cs_mode(mode);
}
break;
case Architecture::PPC: {
static int mode = CS_MODE_32;
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.64bit"_lang, &mode, CS_MODE_64);
static bool qpx = false;
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.qpx"_lang, &qpx);
static bool spe = false;
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.spe"_lang, &spe);
static bool booke = false;
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.booke"_lang, &booke);
this->m_mode = cs_mode(mode | (qpx ? CS_MODE_QPX : 0) | (spe ? CS_MODE_SPE : 0) | (booke ? CS_MODE_BOOKE : 0));
}
break;
case Architecture::SPARC: {
static bool v9Mode = false;
ImGui::Checkbox("hex.builtin.view.disassembler.sparc.v9"_lang, &v9Mode);
this->m_mode = cs_mode(v9Mode ? CS_MODE_V9 : 0);
}
break;
case Architecture::RISCV: {
static int mode = CS_MODE_RISCV32;
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_RISCV32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.64bit"_lang, &mode, CS_MODE_RISCV64);
static bool compressed = false;
ImGui::Checkbox("hex.builtin.view.disassembler.riscv.compressed"_lang, &compressed);
this->m_mode = cs_mode(mode | (compressed ? CS_MODE_RISCVC : 0));
}
break;
case Architecture::M68K: {
static int selectedMode = 0;
std::pair<const char*, cs_mode> modes[] = {
{ "hex.builtin.view.disassembler.m68k.000"_lang, CS_MODE_M68K_000 },
{ "hex.builtin.view.disassembler.m68k.010"_lang, CS_MODE_M68K_010 },
{ "hex.builtin.view.disassembler.m68k.020"_lang, CS_MODE_M68K_020 },
{ "hex.builtin.view.disassembler.m68k.030"_lang, CS_MODE_M68K_030 },
{ "hex.builtin.view.disassembler.m68k.040"_lang, CS_MODE_M68K_040 },
{ "hex.builtin.view.disassembler.m68k.060"_lang, CS_MODE_M68K_060 },
};
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
for (u32 i = 0; i < IM_ARRAYSIZE(modes); i++) {
if (ImGui::Selectable(modes[i].first))
selectedMode = i;
}
ImGui::EndCombo();
this->m_mode = cs_mode(mode | extraMode);
}
break;
case Architecture::MIPS:
{
static int mode = CS_MODE_MIPS32;
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips32"_lang, &mode, CS_MODE_MIPS32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips64"_lang, &mode, CS_MODE_MIPS64);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips32R6"_lang, &mode, CS_MODE_MIPS32R6);
this->m_mode = cs_mode(modes[selectedMode].second);
}
break;
case Architecture::M680X: {
static int selectedMode = 0;
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips2"_lang, &mode, CS_MODE_MIPS2);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips3"_lang, &mode, CS_MODE_MIPS3);
std::pair<const char*, cs_mode> modes[] = {
{ "hex.builtin.view.disassembler.m680x.6301"_lang, CS_MODE_M680X_6301 },
{ "hex.builtin.view.disassembler.m680x.6309"_lang, CS_MODE_M680X_6309 },
{ "hex.builtin.view.disassembler.m680x.6800"_lang, CS_MODE_M680X_6800 },
{ "hex.builtin.view.disassembler.m680x.6801"_lang, CS_MODE_M680X_6801 },
{ "hex.builtin.view.disassembler.m680x.6805"_lang, CS_MODE_M680X_6805 },
{ "hex.builtin.view.disassembler.m680x.6808"_lang, CS_MODE_M680X_6808 },
{ "hex.builtin.view.disassembler.m680x.6809"_lang, CS_MODE_M680X_6809 },
{ "hex.builtin.view.disassembler.m680x.6811"_lang, CS_MODE_M680X_6811 },
{ "hex.builtin.view.disassembler.m680x.cpu12"_lang, CS_MODE_M680X_CPU12 },
{ "hex.builtin.view.disassembler.m680x.hcs08"_lang, CS_MODE_M680X_HCS08 },
};
static bool microMode;
ImGui::Checkbox("hex.builtin.view.disassembler.mips.micro"_lang, &microMode);
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
for (u32 i = 0; i < IM_ARRAYSIZE(modes); i++) {
if (ImGui::Selectable(modes[i].first))
selectedMode = i;
}
ImGui::EndCombo();
this->m_mode = cs_mode(mode | (microMode ? CS_MODE_MICRO : 0));
}
break;
case Architecture::X86:
{
static int mode = CS_MODE_32;
ImGui::RadioButton("hex.builtin.view.disassembler.16bit"_lang, &mode, CS_MODE_16);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.64bit"_lang, &mode, CS_MODE_64);
this->m_mode = cs_mode(modes[selectedMode].second);
}
break;
case Architecture::MOS65XX: {
static int selectedMode = 0;
std::pair<const char*, cs_mode> modes[] = {
{ "hex.builtin.view.disassembler.mos65xx.6502"_lang, CS_MODE_MOS65XX_6502 },
{ "hex.builtin.view.disassembler.mos65xx.65c02"_lang, CS_MODE_MOS65XX_65C02 },
{ "hex.builtin.view.disassembler.mos65xx.w65c02"_lang, CS_MODE_MOS65XX_W65C02 },
{ "hex.builtin.view.disassembler.mos65xx.65816"_lang, CS_MODE_MOS65XX_65816 },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_m"_lang, CS_MODE_MOS65XX_65816_LONG_M },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_x"_lang, CS_MODE_MOS65XX_65816_LONG_X },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_mx"_lang, CS_MODE_MOS65XX_65816_LONG_MX },
};
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
for (u32 i = 0; i < IM_ARRAYSIZE(modes); i++) {
if (ImGui::Selectable(modes[i].first))
selectedMode = i;
}
ImGui::EndCombo();
this->m_mode = cs_mode(mode);
}
break;
case Architecture::PPC:
{
static int mode = CS_MODE_32;
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.64bit"_lang, &mode, CS_MODE_64);
this->m_mode = cs_mode(modes[selectedMode].second);
}
break;
case Architecture::BPF: {
static int mode = CS_MODE_BPF_CLASSIC;
ImGui::RadioButton("hex.builtin.view.disassembler.bpf.classic"_lang, &mode, CS_MODE_BPF_CLASSIC);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.bpf.extended"_lang, &mode, CS_MODE_BPF_EXTENDED);
static bool qpx = false;
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.qpx"_lang, &qpx);
static bool spe = false;
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.spe"_lang, &spe);
static bool booke = false;
ImGui::Checkbox("hex.builtin.view.disassembler.ppc.booke"_lang, &booke);
this->m_mode = cs_mode(mode);
}
break;
case Architecture::EVM:
case Architecture::TMS320C64X:
case Architecture::ARM64:
case Architecture::SYSZ:
case Architecture::XCORE:
case Architecture::WASM:
case Architecture::MAX:
this->m_mode = cs_mode(0);
break;
this->m_mode = cs_mode(mode | (qpx ? CS_MODE_QPX : 0) | (spe ? CS_MODE_SPE : 0) | (booke ? CS_MODE_BOOKE : 0));
}
break;
case Architecture::SPARC:
{
static bool v9Mode = false;
ImGui::Checkbox("hex.builtin.view.disassembler.sparc.v9"_lang, &v9Mode);
this->m_mode = cs_mode(v9Mode ? CS_MODE_V9 : 0);
}
break;
case Architecture::RISCV:
{
static int mode = CS_MODE_RISCV32;
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_RISCV32);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.64bit"_lang, &mode, CS_MODE_RISCV64);
static bool compressed = false;
ImGui::Checkbox("hex.builtin.view.disassembler.riscv.compressed"_lang, &compressed);
this->m_mode = cs_mode(mode | (compressed ? CS_MODE_RISCVC : 0));
}
break;
case Architecture::M68K:
{
static int selectedMode = 0;
std::pair<const char *, cs_mode> modes[] = {
{"hex.builtin.view.disassembler.m68k.000"_lang, CS_MODE_M68K_000},
{ "hex.builtin.view.disassembler.m68k.010"_lang, CS_MODE_M68K_010},
{ "hex.builtin.view.disassembler.m68k.020"_lang, CS_MODE_M68K_020},
{ "hex.builtin.view.disassembler.m68k.030"_lang, CS_MODE_M68K_030},
{ "hex.builtin.view.disassembler.m68k.040"_lang, CS_MODE_M68K_040},
{ "hex.builtin.view.disassembler.m68k.060"_lang, CS_MODE_M68K_060},
};
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
for (u32 i = 0; i < IM_ARRAYSIZE(modes); i++) {
if (ImGui::Selectable(modes[i].first))
selectedMode = i;
}
ImGui::EndCombo();
}
this->m_mode = cs_mode(modes[selectedMode].second);
}
break;
case Architecture::M680X:
{
static int selectedMode = 0;
std::pair<const char *, cs_mode> modes[] = {
{"hex.builtin.view.disassembler.m680x.6301"_lang, CS_MODE_M680X_6301 },
{ "hex.builtin.view.disassembler.m680x.6309"_lang, CS_MODE_M680X_6309 },
{ "hex.builtin.view.disassembler.m680x.6800"_lang, CS_MODE_M680X_6800 },
{ "hex.builtin.view.disassembler.m680x.6801"_lang, CS_MODE_M680X_6801 },
{ "hex.builtin.view.disassembler.m680x.6805"_lang, CS_MODE_M680X_6805 },
{ "hex.builtin.view.disassembler.m680x.6808"_lang, CS_MODE_M680X_6808 },
{ "hex.builtin.view.disassembler.m680x.6809"_lang, CS_MODE_M680X_6809 },
{ "hex.builtin.view.disassembler.m680x.6811"_lang, CS_MODE_M680X_6811 },
{ "hex.builtin.view.disassembler.m680x.cpu12"_lang, CS_MODE_M680X_CPU12},
{ "hex.builtin.view.disassembler.m680x.hcs08"_lang, CS_MODE_M680X_HCS08},
};
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
for (u32 i = 0; i < IM_ARRAYSIZE(modes); i++) {
if (ImGui::Selectable(modes[i].first))
selectedMode = i;
}
ImGui::EndCombo();
}
this->m_mode = cs_mode(modes[selectedMode].second);
}
break;
case Architecture::MOS65XX:
{
static int selectedMode = 0;
std::pair<const char *, cs_mode> modes[] = {
{"hex.builtin.view.disassembler.mos65xx.6502"_lang, CS_MODE_MOS65XX_6502 },
{ "hex.builtin.view.disassembler.mos65xx.65c02"_lang, CS_MODE_MOS65XX_65C02 },
{ "hex.builtin.view.disassembler.mos65xx.w65c02"_lang, CS_MODE_MOS65XX_W65C02 },
{ "hex.builtin.view.disassembler.mos65xx.65816"_lang, CS_MODE_MOS65XX_65816 },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_m"_lang, CS_MODE_MOS65XX_65816_LONG_M },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_x"_lang, CS_MODE_MOS65XX_65816_LONG_X },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_mx"_lang, CS_MODE_MOS65XX_65816_LONG_MX},
};
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
for (u32 i = 0; i < IM_ARRAYSIZE(modes); i++) {
if (ImGui::Selectable(modes[i].first))
selectedMode = i;
}
ImGui::EndCombo();
}
this->m_mode = cs_mode(modes[selectedMode].second);
}
break;
case Architecture::BPF:
{
static int mode = CS_MODE_BPF_CLASSIC;
ImGui::RadioButton("hex.builtin.view.disassembler.bpf.classic"_lang, &mode, CS_MODE_BPF_CLASSIC);
ImGui::SameLine();
ImGui::RadioButton("hex.builtin.view.disassembler.bpf.extended"_lang, &mode, CS_MODE_BPF_EXTENDED);
this->m_mode = cs_mode(mode);
}
break;
case Architecture::EVM:
case Architecture::TMS320C64X:
case Architecture::ARM64:
case Architecture::SYSZ:
case Architecture::XCORE:
case Architecture::WASM:
case Architecture::MAX:
this->m_mode = cs_mode(0);
break;
}
}
ImGui::EndChild();
@@ -316,7 +326,7 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.view.disassembler.disassemble"_lang))
this->disassemble();
},
this->m_disassembling);
this->m_disassembling);
if (this->m_disassembling) {
ImGui::SameLine();

View File

@@ -81,208 +81,208 @@ namespace hex::plugin::builtin {
switch (hashFunctionNames[this->m_currHashFunction].first) {
case HashFunctions::Crc8:
{
static int polynomial = 0x07, init = 0x0000, xorout = 0x0000;
static bool reflectIn = false, reflectOut = false;
case HashFunctions::Crc8:
{
static int polynomial = 0x07, init = 0x0000, xorout = 0x0000;
static bool reflectIn = false, reflectOut = false;
ImGui::InputInt("hex.builtin.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.xorout"_lang, &xorout, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.xorout"_lang, &xorout, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectIn"_lang, &reflectIn);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectIn"_lang, &reflectIn);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectOut"_lang, &reflectOut);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectOut"_lang, &reflectOut);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::NewLine();
ImGui::NewLine();
static u8 result = 0;
static u8 result = 0;
if (this->m_shouldInvalidate)
result = crypt::crc8(provider, this->m_hashRegion[0], this->m_hashRegion[1], polynomial, init, xorout, reflectIn, reflectOut);
if (this->m_shouldInvalidate)
result = crypt::crc8(provider, this->m_hashRegion[0], this->m_hashRegion[1], polynomial, init, xorout, reflectIn, reflectOut);
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%02X", result);
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%02X", result);
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Crc16:
{
static int polynomial = 0x8005, init = 0x0000, xorout = 0x0000;
static bool reflectIn = false, reflectOut = false;
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Crc16:
{
static int polynomial = 0x8005, init = 0x0000, xorout = 0x0000;
static bool reflectIn = false, reflectOut = false;
ImGui::InputInt("hex.builtin.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.xorout"_lang, &xorout, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.xorout"_lang, &xorout, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectIn"_lang, &reflectIn);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectIn"_lang, &reflectIn);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectOut"_lang, &reflectOut);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectOut"_lang, &reflectOut);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::NewLine();
ImGui::NewLine();
static u16 result = 0;
static u16 result = 0;
if (this->m_shouldInvalidate)
result = crypt::crc16(provider, this->m_hashRegion[0], this->m_hashRegion[1], polynomial, init, xorout, reflectIn, reflectOut);
if (this->m_shouldInvalidate)
result = crypt::crc16(provider, this->m_hashRegion[0], this->m_hashRegion[1], polynomial, init, xorout, reflectIn, reflectOut);
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%04X", result);
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%04X", result);
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Crc32:
{
static int polynomial = 0x04C11DB7, init = 0xFFFFFFFF, xorout = 0xFFFFFFFF;
static bool reflectIn = true, reflectOut = true;
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Crc32:
{
static int polynomial = 0x04C11DB7, init = 0xFFFFFFFF, xorout = 0xFFFFFFFF;
static bool reflectIn = true, reflectOut = true;
ImGui::InputInt("hex.builtin.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.xorout"_lang, &xorout, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.xorout"_lang, &xorout, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectIn"_lang, &reflectIn);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectIn"_lang, &reflectIn);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectOut"_lang, &reflectOut);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("hex.common.reflectOut"_lang, &reflectOut);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("hex.builtin.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::NewLine();
ImGui::NewLine();
static u32 result = 0;
static u32 result = 0;
if (this->m_shouldInvalidate)
result = crypt::crc32(provider, this->m_hashRegion[0], this->m_hashRegion[1], polynomial, init, xorout, reflectIn, reflectOut);
if (this->m_shouldInvalidate)
result = crypt::crc32(provider, this->m_hashRegion[0], this->m_hashRegion[1], polynomial, init, xorout, reflectIn, reflectOut);
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%08X", result);
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%08X", result);
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Md5:
{
static std::array<u8, 16> result = { 0 };
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Md5:
{
static std::array<u8, 16> result = { 0 };
if (this->m_shouldInvalidate)
result = crypt::md5(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
if (this->m_shouldInvalidate)
result = crypt::md5(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha1:
{
static std::array<u8, 20> result = { 0 };
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha1:
{
static std::array<u8, 20> result = { 0 };
if (this->m_shouldInvalidate)
result = crypt::sha1(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
if (this->m_shouldInvalidate)
result = crypt::sha1(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha224:
{
static std::array<u8, 28> result = { 0 };
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha224:
{
static std::array<u8, 28> result = { 0 };
if (this->m_shouldInvalidate)
result = crypt::sha224(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
if (this->m_shouldInvalidate)
result = crypt::sha224(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha256:
{
static std::array<u8, 32> result;
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha256:
{
static std::array<u8, 32> result;
if (this->m_shouldInvalidate)
result = crypt::sha256(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
if (this->m_shouldInvalidate)
result = crypt::sha256(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha384:
{
static std::array<u8, 48> result;
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha384:
{
static std::array<u8, 48> result;
if (this->m_shouldInvalidate)
result = crypt::sha384(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
if (this->m_shouldInvalidate)
result = crypt::sha384(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha512:
{
static std::array<u8, 64> result;
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
case HashFunctions::Sha512:
{
static std::array<u8, 64> result;
if (this->m_shouldInvalidate)
result = crypt::sha512(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
if (this->m_shouldInvalidate)
result = crypt::sha512(provider, this->m_hashRegion[0], this->m_hashRegion[1]);
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
char buffer[sizeof(result) * 2 + 1];
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
break;
}
}

View File

@@ -16,7 +16,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.help", 1000, [&, this] {
if (ImGui::MenuItem("hex.builtin.view.help.about.name"_lang, "")) {
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.help.about.name").c_str()); });
this->m_aboutWindowOpen = true;
this->m_aboutWindowOpen = true;
this->getWindowOpenState() = true;
}
@@ -41,7 +41,7 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
if (!this->m_logoTexture.valid()) {
auto logo = romfs::get("logo.png");
auto logo = romfs::get("logo.png");
this->m_logoTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(logo.data()), logo.size());
}

View File

@@ -59,7 +59,7 @@ namespace hex::plugin::builtin {
};
this->m_memoryEditor.HighlightFn = [](const ImU8 *data, size_t off, bool next) -> bool {
auto _this = (ViewHexEditor*)(data);
auto _this = (ViewHexEditor *)(data);
std::optional<u32> currColor, prevColor;
@@ -71,7 +71,7 @@ namespace hex::plugin::builtin {
for (const auto &[id, highlight] : ImHexApi::HexEditor::getHighlights()) {
auto &region = highlight.getRegion();
auto &color = highlight.getColor();
auto &color = highlight.getColor();
if (off >= region.address && off < (region.address + region.size))
currColor = (color & 0x00FFFFFF) | alpha;
@@ -85,7 +85,7 @@ namespace hex::plugin::builtin {
auto child = pattern->getPattern(off);
if (child != nullptr) {
auto color = (child->getColor() & 0x00FFFFFF) | alpha;
currColor = currColor.has_value() ? ImAlphaBlendColors(color, currColor.value()) : color;
currColor = currColor.has_value() ? ImAlphaBlendColors(color, currColor.value()) : color;
break;
}
}
@@ -94,7 +94,7 @@ namespace hex::plugin::builtin {
auto child = pattern->getPattern(off - 1);
if (child != nullptr) {
auto color = (child->getColor() & 0x00FFFFFF) | alpha;
prevColor = prevColor.has_value() ? ImAlphaBlendColors(color, currColor.value()) : color;
prevColor = prevColor.has_value() ? ImAlphaBlendColors(color, currColor.value()) : color;
break;
}
}
@@ -119,8 +119,8 @@ namespace hex::plugin::builtin {
off += ImHexApi::Provider::get()->getBaseAddress();
for (const auto &[id, highlight] : ImHexApi::HexEditor::getHighlights()) {
auto &region = highlight.getRegion();
auto &color = highlight.getColor();
auto &region = highlight.getRegion();
auto &color = highlight.getColor();
auto &tooltip = highlight.getTooltip();
if (off >= region.address && off < (region.address + region.size)) {
@@ -145,7 +145,7 @@ namespace hex::plugin::builtin {
return { ".", 1, 0xFFFF8000 };
auto provider = ImHexApi::Provider::get();
size_t size = std::min<size_t>(_this->m_currEncodingFile.getLongestSequence(), provider->getActualSize() - addr);
size_t size = std::min<size_t>(_this->m_currEncodingFile.getLongestSequence(), provider->getActualSize() - addr);
std::vector<u8> buffer(size);
provider->read(addr + provider->getBaseAddress() + provider->getCurrentPageAddress(), buffer.data(), size);
@@ -270,9 +270,9 @@ namespace hex::plugin::builtin {
hex::openFileBrowser("hex.builtin.view.hexeditor.script.script.title"_lang, DialogMode::Open, {
{"Python Script", "py"}
},
[this](const auto &path) {
this->m_loaderScriptScriptPath = path.string();
});
[this](const auto &path) {
this->m_loaderScriptScriptPath = path.string();
});
}
ImGui::InputText("##nolabel", this->m_loaderScriptFilePath.data(), this->m_loaderScriptFilePath.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
@@ -394,7 +394,7 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get();
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t copySize = (end - start) + 1;
@@ -413,14 +413,14 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get();
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
std::string clipboard = ImGui::GetClipboardText();
// Check for non-hex characters
bool isValidHexString = std::find_if(clipboard.begin(), clipboard.end(), [](char c) {
return !std::isxdigit(c) && !std::isspace(c);
}) == clipboard.end();
return !std::isxdigit(c) && !std::isspace(c);
}) == clipboard.end();
if (!isValidHexString) return;
@@ -455,7 +455,7 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get();
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t copySize = (end - start) + 1;
@@ -534,11 +534,11 @@ namespace hex::plugin::builtin {
void ViewHexEditor::drawSearchPopup() {
static auto InputCallback = [](ImGuiInputTextCallbackData *data) -> int {
auto _this = static_cast<ViewHexEditor *>(data->UserData);
auto _this = static_cast<ViewHexEditor *>(data->UserData);
auto provider = ImHexApi::Provider::get();
*_this->m_lastSearchBuffer = _this->m_searchFunction(provider, data->Buf);
_this->m_lastSearchIndex = 0;
_this->m_lastSearchIndex = 0;
if (!_this->m_lastSearchBuffer->empty())
_this->m_memoryEditor.GotoAddrAndSelect((*_this->m_lastSearchBuffer)[0].first, (*_this->m_lastSearchBuffer)[0].second);
@@ -550,7 +550,7 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get();
*this->m_lastSearchBuffer = this->m_searchFunction(provider, buffer);
this->m_lastSearchIndex = 0;
this->m_lastSearchIndex = 0;
if (!this->m_lastSearchBuffer->empty())
this->m_memoryEditor.GotoAddrAndSelect((*this->m_lastSearchBuffer)[0].first, (*this->m_lastSearchBuffer)[0].second);
@@ -560,7 +560,7 @@ namespace hex::plugin::builtin {
if (!this->m_lastSearchBuffer->empty()) {
++this->m_lastSearchIndex %= this->m_lastSearchBuffer->size();
this->m_memoryEditor.GotoAddrAndSelect((*this->m_lastSearchBuffer)[this->m_lastSearchIndex].first,
(*this->m_lastSearchBuffer)[this->m_lastSearchIndex].second);
(*this->m_lastSearchBuffer)[this->m_lastSearchIndex].second);
}
};
@@ -574,7 +574,7 @@ namespace hex::plugin::builtin {
this->m_lastSearchIndex %= this->m_lastSearchBuffer->size();
this->m_memoryEditor.GotoAddrAndSelect((*this->m_lastSearchBuffer)[this->m_lastSearchIndex].first,
(*this->m_lastSearchBuffer)[this->m_lastSearchIndex].second);
(*this->m_lastSearchBuffer)[this->m_lastSearchIndex].second);
}
};
@@ -584,9 +584,9 @@ namespace hex::plugin::builtin {
if (ImGui::BeginTabBar("searchTabs")) {
std::vector<char> *currBuffer = nullptr;
if (ImGui::BeginTabItem("hex.builtin.view.hexeditor.search.string"_lang)) {
this->m_searchFunction = findString;
this->m_searchFunction = findString;
this->m_lastSearchBuffer = &this->m_lastStringSearch;
currBuffer = &this->m_searchStringBuffer;
currBuffer = &this->m_searchStringBuffer;
ImGui::SetKeyboardFocusHere();
if (ImGui::InputText("##nolabel", currBuffer->data(), currBuffer->size(), ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_EnterReturnsTrue, InputCallback, this)) {
@@ -599,9 +599,9 @@ namespace hex::plugin::builtin {
}
if (ImGui::BeginTabItem("hex.builtin.view.hexeditor.search.hex"_lang)) {
this->m_searchFunction = findHex;
this->m_searchFunction = findHex;
this->m_lastSearchBuffer = &this->m_lastHexSearch;
currBuffer = &this->m_searchHexBuffer;
currBuffer = &this->m_searchHexBuffer;
ImGui::SetKeyboardFocusHere();
if (ImGui::InputText("##nolabel", currBuffer->data(), currBuffer->size(), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_EnterReturnsTrue, InputCallback, this)) {
@@ -636,9 +636,9 @@ namespace hex::plugin::builtin {
}
void ViewHexEditor::drawGotoPopup() {
auto provider = ImHexApi::Provider::get();
auto provider = ImHexApi::Provider::get();
auto baseAddress = provider->getBaseAddress();
auto dataSize = provider->getActualSize();
auto dataSize = provider->getActualSize();
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin() - ImGui::GetStyle().WindowPadding);
if (ImGui::BeginPopup("hex.builtin.view.hexeditor.menu.file.goto"_lang)) {
@@ -708,7 +708,7 @@ namespace hex::plugin::builtin {
}
void ViewHexEditor::drawEditPopup() {
auto provider = ImHexApi::Provider::get();
auto provider = ImHexApi::Provider::get();
bool providerValid = ImHexApi::Provider::isValid();
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.edit.undo"_lang, "CTRL + Z", false, providerValid))
provider->undo();
@@ -731,7 +731,7 @@ namespace hex::plugin::builtin {
for (const auto &[unlocalizedName, callback] : ContentRegistry::DataFormatter::getEntries()) {
if (ImGui::MenuItem(LangEntry(unlocalizedName))) {
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t copySize = (end - start) + 1;
@@ -754,7 +754,7 @@ namespace hex::plugin::builtin {
auto base = ImHexApi::Provider::get()->getBaseAddress();
size_t start = base + std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = base + std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = base + std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
ImHexApi::Bookmarks::add(start, end - start + 1, {}, {});
}
@@ -787,7 +787,7 @@ namespace hex::plugin::builtin {
EventManager::subscribe<RequestSelectionChange>(this, [this](Region region) {
auto provider = ImHexApi::Provider::get();
auto page = provider->getPageOfAddress(region.address);
auto page = provider->getPageOfAddress(region.address);
if (!page.has_value())
return;
@@ -836,10 +836,10 @@ namespace hex::plugin::builtin {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_project"_lang, DialogMode::Open, {
{"Project File", "hexproj"}
},
[this](const auto &path) {
ProjectFile::load(path);
this->getWindowOpenState() = true;
});
[this](const auto &path) {
ProjectFile::load(path);
this->getWindowOpenState() = true;
});
}
});
@@ -968,11 +968,10 @@ namespace hex::plugin::builtin {
/* Basic operations */
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1100, [&] {
auto provider = ImHexApi::Provider::get();
auto provider = ImHexApi::Provider::get();
bool providerValid = ImHexApi::Provider::isValid();
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save"_lang, "CTRL + S", false, providerValid && provider->isWritable())) {
save();
}
@@ -995,16 +994,16 @@ namespace hex::plugin::builtin {
/* Metadata save/load */
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1200, [&, this] {
auto provider = ImHexApi::Provider::get();
auto provider = ImHexApi::Provider::get();
bool providerValid = ImHexApi::Provider::isValid();
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_project"_lang, "")) {
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.open_project"_lang, DialogMode::Open, {
{"Project File", "hexproj"}
},
[](const auto &path) {
ProjectFile::load(path);
});
[](const auto &path) {
ProjectFile::load(path);
});
}
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save_project"_lang, "", false, providerValid && provider->isWritable())) {
@@ -1012,13 +1011,13 @@ namespace hex::plugin::builtin {
hex::openFileBrowser("hex.builtin.view.hexeditor.save_project"_lang, DialogMode::Save, {
{"Project File", "hexproj"}
},
[](const auto &path) {
if (path.extension() == ".hexproj") {
ProjectFile::store(path);
} else {
ProjectFile::store(path.string() + ".hexproj");
}
});
[](const auto &path) {
if (path.extension() == ".hexproj") {
ProjectFile::store(path);
} else {
ProjectFile::store(path.string() + ".hexproj");
}
});
} else
ProjectFile::store();
}
@@ -1036,16 +1035,16 @@ namespace hex::plugin::builtin {
View::showFileChooserPopup(paths, {
{"Thingy Table File", "tbl"}
},
[this](const auto &path) {
this->m_currEncodingFile = EncodingFile(EncodingFile::Type::Thingy, path);
});
[this](const auto &path) {
this->m_currEncodingFile = EncodingFile(EncodingFile::Type::Thingy, path);
});
}
});
/* Import / Export */
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1300, [&, this] {
auto provider = ImHexApi::Provider::get();
auto provider = ImHexApi::Provider::get();
bool providerValid = ImHexApi::Provider::isValid();
/* Import */
@@ -1083,7 +1082,7 @@ namespace hex::plugin::builtin {
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
auto patchData = File(path, File::Mode::Read).readBytes();
auto patch = hex::loadIPSPatch(patchData);
auto patch = hex::loadIPSPatch(patchData);
task.setMaxValue(patch.size());
@@ -1111,7 +1110,7 @@ namespace hex::plugin::builtin {
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
auto patchData = File(path, File::Mode::Read).readBytes();
auto patch = hex::loadIPS32Patch(patchData);
auto patch = hex::loadIPS32Patch(patchData);
task.setMaxValue(patch.size());
@@ -1156,7 +1155,7 @@ namespace hex::plugin::builtin {
std::thread([this, patches] {
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
this->m_dataToSave = generateIPSPatch(patches);
this->m_dataToSave = generateIPSPatch(patches);
this->m_processingImportExport = false;
ImHexApi::Tasks::doLater([this] {
@@ -1185,7 +1184,7 @@ namespace hex::plugin::builtin {
std::thread([this, patches] {
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
this->m_dataToSave = generateIPS32Patch(patches);
this->m_dataToSave = generateIPS32Patch(patches);
this->m_processingImportExport = false;
ImHexApi::Tasks::doLater([this] {

View File

@@ -25,15 +25,15 @@ namespace hex::plugin::builtin {
ViewInformation::ViewInformation() : View("hex.builtin.view.information.name") {
EventManager::subscribe<EventDataChanged>(this, [this]() {
this->m_dataValid = false;
this->m_dataValid = false;
this->m_highestBlockEntropy = 0;
this->m_blockEntropy.clear();
this->m_averageEntropy = 0;
this->m_blockSize = 0;
this->m_blockSize = 0;
this->m_valueCounts.fill(0x00);
this->m_mimeType = "";
this->m_mimeType = "";
this->m_fileDescription = "";
this->m_analyzedRegion = { 0, 0 };
this->m_analyzedRegion = { 0, 0 };
});
EventManager::subscribe<EventRegionSelected>(this, [this](Region region) {
@@ -92,7 +92,7 @@ namespace hex::plugin::builtin {
magic::compile();
this->m_fileDescription = magic::getDescription(provider);
this->m_mimeType = magic::getMIMEType(provider);
this->m_mimeType = magic::getMIMEType(provider);
}
this->m_dataValid = true;
@@ -117,7 +117,7 @@ namespace hex::plugin::builtin {
task.update(i);
}
this->m_averageEntropy = calculateEntropy(this->m_valueCounts, provider->getSize());
this->m_averageEntropy = calculateEntropy(this->m_valueCounts, provider->getSize());
this->m_highestBlockEntropy = *std::max_element(this->m_blockEntropy.begin(), this->m_blockEntropy.end());
}
@@ -139,7 +139,7 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.view.information.analyze"_lang))
this->analyze();
},
this->m_analyzing);
this->m_analyzing);
if (this->m_analyzing) {
ImGui::TextSpinner("hex.builtin.view.information.analyzing"_lang);
@@ -208,7 +208,7 @@ namespace hex::plugin::builtin {
if (ImPlot::DragLineX("Position", &this->m_entropyHandlePosition, false)) {
u64 address = u64(this->m_entropyHandlePosition * this->m_blockSize) + provider->getBaseAddress();
address = std::min(address, provider->getBaseAddress() + provider->getSize() - 1);
address = std::min(address, provider->getBaseAddress() + provider->getSize() - 1);
EventManager::post<RequestSelectionChange>(Region { address, 1 });
}

View File

@@ -44,7 +44,7 @@ namespace hex::plugin::builtin {
ImGui::TableHeadersRow();
auto &patches = provider->getPatches();
u32 index = 0;
u32 index = 0;
ImGuiListClipper clipper(patches.size());

View File

@@ -41,8 +41,8 @@ namespace hex::plugin::builtin {
inBegin++;
if (inBegin == inEnd) {
outBegin = inEnd;
outEnd = inEnd;
outBegin = inEnd;
outEnd = inEnd;
paletteIndex = TextEditor::PaletteIndex::Default;
} else if (TokenizeCStyleIdentifier(inBegin, inEnd, outBegin, outEnd)) {
paletteIndex = TextEditor::PaletteIndex::Identifier;
@@ -56,13 +56,13 @@ namespace hex::plugin::builtin {
return paletteIndex != TextEditor::PaletteIndex::Max;
};
langDef.mCommentStart = "/*";
langDef.mCommentEnd = "*/";
langDef.mCommentStart = "/*";
langDef.mCommentEnd = "*/";
langDef.mSingleLineComment = "//";
langDef.mCaseSensitive = true;
langDef.mCaseSensitive = true;
langDef.mAutoIndentation = true;
langDef.mPreprocChar = '#';
langDef.mPreprocChar = '#';
langDef.mName = "Pattern Language";
@@ -164,16 +164,16 @@ namespace hex::plugin::builtin {
EventManager::subscribe<RequestChangeTheme>(this, [this](u32 theme) {
switch (theme) {
default:
case 1: /* Dark theme */
this->m_textEditor.SetPalette(TextEditor::GetDarkPalette());
break;
case 2: /* Light theme */
this->m_textEditor.SetPalette(TextEditor::GetLightPalette());
break;
case 3: /* Classic theme */
this->m_textEditor.SetPalette(TextEditor::GetRetroBluePalette());
break;
default:
case 1: /* Dark theme */
this->m_textEditor.SetPalette(TextEditor::GetDarkPalette());
break;
case 2: /* Light theme */
this->m_textEditor.SetPalette(TextEditor::GetLightPalette());
break;
case 3: /* Classic theme */
this->m_textEditor.SetPalette(TextEditor::GetRetroBluePalette());
break;
}
});
}
@@ -207,20 +207,20 @@ namespace hex::plugin::builtin {
View::showFileChooserPopup(paths, {
{"Pattern File", "hexpat"}
},
[this](const fs::path &path) {
this->loadPatternFile(path);
});
[this](const fs::path &path) {
this->loadPatternFile(path);
});
}
if (ImGui::MenuItem("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang)) {
hex::openFileBrowser("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, DialogMode::Save, {
{"Pattern", "hexpat"}
},
[this](const auto &path) {
File file(path, File::Mode::Create);
[this](const auto &path) {
File file(path, File::Mode::Create);
file.write(this->m_textEditor.GetText());
});
file.write(this->m_textEditor.GetText());
});
}
});
}
@@ -294,8 +294,8 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
ImGui::TextFormatted("{} / {}",
provider->getPatternLanguageRuntime().getCreatedPatternCount(),
provider->getPatternLanguageRuntime().getMaximumPatternCount());
provider->getPatternLanguageRuntime().getCreatedPatternCount(),
provider->getPatternLanguageRuntime().getMaximumPatternCount());
}
if (this->m_textEditor.IsTextChanged()) {
@@ -323,15 +323,11 @@ namespace hex::plugin::builtin {
ImGui::NewLine();
View::confirmButtons(
"hex.common.yes"_lang, "hex.common.no"_lang,
[] {
"hex.common.yes"_lang, "hex.common.no"_lang, [] {
ImHexApi::Provider::get()->getPatternLanguageRuntime().allowDangerousFunctions(true);
ImGui::CloseCurrentPopup();
},
[] {
ImGui::CloseCurrentPopup(); }, [] {
ImHexApi::Provider::get()->getPatternLanguageRuntime().allowDangerousFunctions(false);
ImGui::CloseCurrentPopup();
});
ImGui::CloseCurrentPopup(); });
ImGui::EndPopup();
}
@@ -350,20 +346,20 @@ namespace hex::plugin::builtin {
const auto &[level, message] = this->m_console[i];
switch (level) {
case pl::LogConsole::Level::Debug:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Comment)]);
break;
case pl::LogConsole::Level::Info:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Default)]);
break;
case pl::LogConsole::Level::Warning:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Preprocessor)]);
break;
case pl::LogConsole::Level::Error:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::ErrorMarker)]);
break;
default:
continue;
case pl::LogConsole::Level::Debug:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Comment)]);
break;
case pl::LogConsole::Level::Info:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Default)]);
break;
case pl::LogConsole::Level::Warning:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Preprocessor)]);
break;
case pl::LogConsole::Level::Error:
ImGui::PushStyleColor(ImGuiCol_Text, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::ErrorMarker)]);
break;
default:
continue;
}
if (ImGui::Selectable(message.c_str()))
@@ -416,34 +412,34 @@ namespace hex::plugin::builtin {
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
switch (type) {
case EnvVarType::Integer:
{
i64 displayValue = hex::get_or<i128>(value, 0);
ImGui::InputScalar("###value", ImGuiDataType_S64, &displayValue);
value = i128(displayValue);
break;
}
case EnvVarType::Float:
{
auto displayValue = hex::get_or<double>(value, 0.0);
ImGui::InputDouble("###value", &displayValue);
value = displayValue;
break;
}
case EnvVarType::Bool:
{
auto displayValue = hex::get_or<bool>(value, false);
ImGui::Checkbox("###value", &displayValue);
value = displayValue;
break;
}
case EnvVarType::String:
{
auto displayValue = hex::get_or<std::string>(value, "");
ImGui::InputText("###value", displayValue.data(), displayValue.capacity(), ImGuiInputTextFlags_CallbackResize, ImGui::UpdateStringSizeCallback, &displayValue);
value = displayValue;
break;
}
case EnvVarType::Integer:
{
i64 displayValue = hex::get_or<i128>(value, 0);
ImGui::InputScalar("###value", ImGuiDataType_S64, &displayValue);
value = i128(displayValue);
break;
}
case EnvVarType::Float:
{
auto displayValue = hex::get_or<double>(value, 0.0);
ImGui::InputDouble("###value", &displayValue);
value = displayValue;
break;
}
case EnvVarType::Bool:
{
auto displayValue = hex::get_or<bool>(value, false);
ImGui::Checkbox("###value", &displayValue);
value = displayValue;
break;
}
case EnvVarType::String:
{
auto displayValue = hex::get_or<std::string>(value, "");
ImGui::InputText("###value", displayValue.data(), displayValue.capacity(), ImGuiInputTextFlags_CallbackResize, ImGui::UpdateStringSizeCallback, &displayValue);
value = displayValue;
break;
}
}
ImGui::PopItemWidth();
@@ -604,9 +600,9 @@ namespace hex::plugin::builtin {
if (builtinType == nullptr) continue;
PatternVariable variable = {
.inVariable = variableDecl->isInVariable(),
.inVariable = variableDecl->isInVariable(),
.outVariable = variableDecl->isOutVariable(),
.type = builtinType->getType()
.type = builtinType->getType()
};
if (variable.inVariable || variable.outVariable) {
@@ -651,7 +647,9 @@ namespace hex::plugin::builtin {
if (!result) {
auto error = runtime.getError();
if (error) {
TextEditor::ErrorMarkers errorMarkers = { { error->getLineNumber(), error->what() } };
TextEditor::ErrorMarkers errorMarkers = {
{error->getLineNumber(), error->what()}
};
this->m_textEditor.SetErrorMarkers(errorMarkers);
}
}

View File

@@ -240,9 +240,9 @@ namespace hex::plugin::builtin {
for (const auto &path : hex::getPath(pathType)) {
auto fullPath = path / fs::path(fileName);
if (!update || fs::exists(fullPath)) {
downloading = true;
downloading = true;
this->m_downloadPath = fullPath;
this->m_download = this->m_net.downloadFile(url, fullPath);
this->m_download = this->m_net.downloadFile(url, fullPath);
break;
}
}
@@ -258,7 +258,7 @@ namespace hex::plugin::builtin {
bool ViewStore::remove(ImHexPath pathType, const std::string &fileName) {
bool removed = false;
for (const auto &path : hex::getPath(pathType)) {
bool removedFile = fs::remove(path / fs::path(fileName));
bool removedFile = fs::remove(path / fs::path(fileName));
bool removedFolder = fs::remove(path / fs::path(fileName).stem());
removed = removedFile || removedFolder;

View File

@@ -65,7 +65,7 @@ namespace hex::plugin::builtin {
std::thread([this] {
auto provider = ImHexApi::Provider::get();
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.strings.searching", provider->getActualSize());
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.strings.searching", provider->getActualSize());
std::vector<u8> buffer(1024, 0x00);
u32 foundCharacters = 0;
@@ -118,7 +118,7 @@ namespace hex::plugin::builtin {
std::regex pattern;
if (view.m_regex) {
try {
pattern = std::regex(data->Buf);
pattern = std::regex(data->Buf);
view.m_pattern_parsed = true;
} catch (std::regex_error &e) {
view.m_pattern_parsed = false;
@@ -142,7 +142,7 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.view.strings.extract"_lang))
this->searchStrings();
},
this->m_searching);
this->m_searching);
if (this->m_searching) {
ImGui::SameLine();
@@ -197,7 +197,7 @@ namespace hex::plugin::builtin {
while (clipper.Step()) {
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
auto &foundString = this->m_foundStrings[this->m_filterIndices[i]];
auto string = readString(foundString);
auto string = readString(foundString);
ImGui::TableNextRow();
ImGui::TableNextColumn();

View File

@@ -70,7 +70,7 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.view.yara.reload"_lang)) this->reloadRules();
if (ImGui::Button("hex.builtin.view.yara.match"_lang)) this->applyRules();
},
this->m_matching);
this->m_matching);
if (this->m_matching) {
ImGui::SameLine();
@@ -155,7 +155,7 @@ namespace hex::plugin::builtin {
if (!ImHexApi::Provider::isValid()) return;
auto provider = ImHexApi::Provider::get();
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.yara.matching", provider->getActualSize());
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.yara.matching", provider->getActualSize());
YR_COMPILER *compiler = nullptr;
yr_compiler_create(&compiler);
@@ -173,7 +173,7 @@ namespace hex::plugin::builtin {
if (!file.isValid())
return nullptr;
auto size = file.getSize();
auto size = file.getSize();
char *buffer = new char[size + 1];
file.readBuffer(reinterpret_cast<u8 *>(buffer), size);
buffer[size] = 0x00;
@@ -210,8 +210,8 @@ namespace hex::plugin::builtin {
};
ScanContext context;
context.task = &task;
context.currBlock.base = 0;
context.task = &task;
context.currBlock.base = 0;
context.currBlock.fetch_data = [](auto *block) -> const u8 * {
auto &context = *static_cast<ScanContext *>(block->context);
@@ -232,7 +232,7 @@ namespace hex::plugin::builtin {
};
iterator.context = &context;
iterator.first = [](YR_MEMORY_BLOCK_ITERATOR *iterator) -> YR_MEMORY_BLOCK * {
iterator.first = [](YR_MEMORY_BLOCK_ITERATOR *iterator) -> YR_MEMORY_BLOCK *{
auto &context = *static_cast<ScanContext *>(iterator->context);
context.currBlock.base = 0;
@@ -247,9 +247,9 @@ namespace hex::plugin::builtin {
u64 address = context.currBlock.base + context.currBlock.size;
iterator->last_error = ERROR_SUCCESS;
context.currBlock.base = address;
context.currBlock.size = ImHexApi::Provider::get()->getActualSize() - address;
iterator->last_error = ERROR_SUCCESS;
context.currBlock.base = address;
context.currBlock.size = ImHexApi::Provider::get()->getActualSize() - address;
context.currBlock.context = &context;
context.task->update(address);
@@ -263,7 +263,7 @@ namespace hex::plugin::builtin {
rules, &iterator, 0, [](YR_SCAN_CONTEXT *context, int message, void *data, void *userData) -> int {
if (message == CALLBACK_MSG_RULE_MATCHING) {
auto &newMatches = *static_cast<std::vector<YaraMatch> *>(userData);
auto rule = static_cast<YR_RULE *>(data);
auto rule = static_cast<YR_RULE *>(data);
YR_STRING *string;
YR_MATCH *match;

View File

@@ -309,43 +309,43 @@ namespace hex::plugin::builtin {
switch (theme) {
default:
case 1: /* Dark theme */
{
ImGui::StyleColorsDark();
ImGui::StyleCustomColorsDark();
ImPlot::StyleColorsDark();
{
ImGui::StyleColorsDark();
ImGui::StyleCustomColorsDark();
ImPlot::StyleColorsDark();
auto banner = romfs::get("banner_dark.png");
s_bannerTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(banner.data()), banner.size());
auto banner = romfs::get("banner_dark.png");
s_bannerTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(banner.data()), banner.size());
break;
}
break;
}
case 2: /* Light theme */
{
ImGui::StyleColorsLight();
ImGui::StyleCustomColorsLight();
ImPlot::StyleColorsLight();
{
ImGui::StyleColorsLight();
ImGui::StyleCustomColorsLight();
ImPlot::StyleColorsLight();
auto banner = romfs::get("banner_light.png");
s_bannerTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(banner.data()), banner.size());
auto banner = romfs::get("banner_light.png");
s_bannerTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(banner.data()), banner.size());
break;
}
break;
}
case 3: /* Classic theme */
{
ImGui::StyleColorsClassic();
ImGui::StyleCustomColorsClassic();
ImPlot::StyleColorsClassic();
{
ImGui::StyleColorsClassic();
ImGui::StyleCustomColorsClassic();
ImPlot::StyleColorsClassic();
auto banner = romfs::get("banner_dark.png");
s_bannerTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(banner.data()), banner.size());
auto banner = romfs::get("banner_dark.png");
s_bannerTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(banner.data()), banner.size());
break;
}
break;
}
}
ImGui::GetStyle().Colors[ImGuiCol_DockingEmptyBg] = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
ImGui::GetStyle().Colors[ImGuiCol_TitleBg] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
ImGui::GetStyle().Colors[ImGuiCol_TitleBgActive] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
ImGui::GetStyle().Colors[ImGuiCol_DockingEmptyBg] = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
ImGui::GetStyle().Colors[ImGuiCol_TitleBg] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
ImGui::GetStyle().Colors[ImGuiCol_TitleBgActive] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
ImGui::GetStyle().Colors[ImGuiCol_TitleBgCollapsed] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
if (!s_bannerTexture.valid()) {
@@ -387,10 +387,9 @@ namespace hex::plugin::builtin {
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1050, [&] {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, {},
[](const auto &path) {
EventManager::post<RequestOpenFile>(path);
});
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, {}, [](const auto &path) {
EventManager::post<RequestOpenFile>(path);
});
}
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.open_recent"_lang, !s_recentFilePaths.empty())) {
@@ -404,9 +403,9 @@ namespace hex::plugin::builtin {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.clear_recent"_lang)) {
s_recentFilePaths.clear();
ContentRegistry::Settings::write(
"hex.builtin.setting.imhex",
"hex.builtin.setting.imhex.recent_files",
std::vector<std::string>{});
"hex.builtin.setting.imhex",
"hex.builtin.setting.imhex.recent_files",
std::vector<std::string> {});
}
ImGui::EndMenu();
@@ -422,7 +421,6 @@ namespace hex::plugin::builtin {
ImGui::EndMenu();
}
});

View File

@@ -116,9 +116,9 @@ namespace hex {
else if (expression == "")
break;
auto inputQueue = parseInput(expression.c_str());
auto inputQueue = parseInput(expression.c_str());
auto postfixTokens = toPostfix(inputQueue);
auto result = evaluate(postfixTokens);
auto result = evaluate(postfixTokens);
if (!result.has_value())
throw std::invalid_argument("Invalid argument for function!");
@@ -220,78 +220,78 @@ namespace hex {
long double result = std::numeric_limits<long double>::quiet_NaN();
switch (front.op) {
default:
case Operator::Invalid:
throw std::invalid_argument("Invalid operator!");
case Operator::And:
result = static_cast<i64>(leftOperand) && static_cast<i64>(rightOperand);
break;
case Operator::Or:
result = static_cast<i64>(leftOperand) && static_cast<i64>(rightOperand);
break;
case Operator::Xor:
result = (static_cast<i64>(leftOperand) ^ static_cast<i64>(rightOperand)) > 0;
break;
case Operator::GreaterThan:
result = leftOperand > rightOperand;
break;
case Operator::LessThan:
result = leftOperand < rightOperand;
break;
case Operator::GreaterThanOrEquals:
result = leftOperand >= rightOperand;
break;
case Operator::LessThanOrEquals:
result = leftOperand <= rightOperand;
break;
case Operator::Equals:
result = leftOperand == rightOperand;
break;
case Operator::NotEquals:
result = leftOperand != rightOperand;
break;
case Operator::Not:
result = !static_cast<i64>(rightOperand);
break;
case Operator::BitwiseOr:
result = static_cast<i64>(leftOperand) | static_cast<i64>(rightOperand);
break;
case Operator::BitwiseXor:
result = static_cast<i64>(leftOperand) ^ static_cast<i64>(rightOperand);
break;
case Operator::BitwiseAnd:
result = static_cast<i64>(leftOperand) & static_cast<i64>(rightOperand);
break;
case Operator::BitwiseNot:
result = ~static_cast<i64>(rightOperand);
break;
case Operator::ShiftLeft:
result = static_cast<i64>(leftOperand) << static_cast<i64>(rightOperand);
break;
case Operator::ShiftRight:
result = static_cast<i64>(leftOperand) >> static_cast<i64>(rightOperand);
break;
case Operator::Addition:
result = leftOperand + rightOperand;
break;
case Operator::Subtraction:
result = leftOperand - rightOperand;
break;
case Operator::Multiplication:
result = leftOperand * rightOperand;
break;
case Operator::Division:
result = leftOperand / rightOperand;
break;
case Operator::Modulus:
result = std::fmod(leftOperand, rightOperand);
break;
case Operator::Exponentiation:
result = std::pow(leftOperand, rightOperand);
break;
case Operator::Combine:
result = (static_cast<u64>(leftOperand) << (64 - __builtin_clzll(static_cast<u64>(rightOperand)))) | static_cast<u64>(rightOperand);
break;
default:
case Operator::Invalid:
throw std::invalid_argument("Invalid operator!");
case Operator::And:
result = static_cast<i64>(leftOperand) && static_cast<i64>(rightOperand);
break;
case Operator::Or:
result = static_cast<i64>(leftOperand) && static_cast<i64>(rightOperand);
break;
case Operator::Xor:
result = (static_cast<i64>(leftOperand) ^ static_cast<i64>(rightOperand)) > 0;
break;
case Operator::GreaterThan:
result = leftOperand > rightOperand;
break;
case Operator::LessThan:
result = leftOperand < rightOperand;
break;
case Operator::GreaterThanOrEquals:
result = leftOperand >= rightOperand;
break;
case Operator::LessThanOrEquals:
result = leftOperand <= rightOperand;
break;
case Operator::Equals:
result = leftOperand == rightOperand;
break;
case Operator::NotEquals:
result = leftOperand != rightOperand;
break;
case Operator::Not:
result = !static_cast<i64>(rightOperand);
break;
case Operator::BitwiseOr:
result = static_cast<i64>(leftOperand) | static_cast<i64>(rightOperand);
break;
case Operator::BitwiseXor:
result = static_cast<i64>(leftOperand) ^ static_cast<i64>(rightOperand);
break;
case Operator::BitwiseAnd:
result = static_cast<i64>(leftOperand) & static_cast<i64>(rightOperand);
break;
case Operator::BitwiseNot:
result = ~static_cast<i64>(rightOperand);
break;
case Operator::ShiftLeft:
result = static_cast<i64>(leftOperand) << static_cast<i64>(rightOperand);
break;
case Operator::ShiftRight:
result = static_cast<i64>(leftOperand) >> static_cast<i64>(rightOperand);
break;
case Operator::Addition:
result = leftOperand + rightOperand;
break;
case Operator::Subtraction:
result = leftOperand - rightOperand;
break;
case Operator::Multiplication:
result = leftOperand * rightOperand;
break;
case Operator::Division:
result = leftOperand / rightOperand;
break;
case Operator::Modulus:
result = std::fmod(leftOperand, rightOperand);
break;
case Operator::Exponentiation:
result = std::pow(leftOperand, rightOperand);
break;
case Operator::Combine:
result = (static_cast<u64>(leftOperand) << (64 - __builtin_clzll(static_cast<u64>(rightOperand)))) | static_cast<u64>(rightOperand);
break;
}
evaluationStack.push(result);