1
0
mirror of synced 2025-01-10 21:41:53 +01:00

impr: Modernize the disassembler, hashes and yara view

This commit is contained in:
WerWolv 2024-12-24 10:57:09 +01:00
parent aad6f6bcbe
commit 512fcd361b
6 changed files with 63 additions and 42 deletions

View File

@ -512,7 +512,9 @@ namespace ImGuiExt {
PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F);
PushStyleColor(ImGuiCol_Text, iconColor);
ImGui::PushID(text);
Button(icon);
ImGui::PopID();
PopStyleColor();
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {

View File

@ -16,6 +16,7 @@
"hex.disassembler.view.disassembler.bpf.classic": "Classic",
"hex.disassembler.view.disassembler.bpf.extended": "Extended",
"hex.disassembler.view.disassembler.image_base_address": "Image Base Address",
"hex.disassembler.view.disassembler.image_base_address.hint": "This is the start address of the code region in the loaded data. For example the begin of the .text section",
"hex.disassembler.view.disassembler.disassemble": "Disassemble",
"hex.disassembler.view.disassembler.disassembling": "Disassembling...",
"hex.disassembler.view.disassembler.disassembly.address": "Address",
@ -25,6 +26,7 @@
"hex.disassembler.view.disassembler.export": "Export instructions as...",
"hex.disassembler.view.disassembler.export.popup.error": "Failed to export to ASM file!",
"hex.disassembler.view.disassembler.image_load_address": "Image Load Address",
"hex.disassembler.view.disassembler.image_load_address.hint": "This is the address of where the disassembled code is being loaded into memory before it's being executed",
"hex.disassembler.view.disassembler.m680x.6301": "6301",
"hex.disassembler.view.disassembler.m680x.6309": "6309",
"hex.disassembler.view.disassembler.m680x.6800": "6800",

View File

@ -145,11 +145,15 @@ namespace hex::plugin::disasm {
// Draw base address input
ImGuiExt::InputHexadecimal("hex.disassembler.view.disassembler.image_load_address"_lang, &m_imageLoadAddress, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::SameLine();
ImGuiExt::HelpHover("hex.disassembler.view.disassembler.image_load_address.hint"_lang, ICON_VS_INFO);
// Draw code region start address input
ImGui::BeginDisabled(m_range == ui::RegionType::EntireData);
{
ImGuiExt::InputHexadecimal("hex.disassembler.view.disassembler.image_base_address"_lang, &m_imageBaseAddress, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::SameLine();
ImGuiExt::HelpHover("hex.disassembler.view.disassembler.image_base_address.hint"_lang, ICON_VS_INFO);
}
ImGui::EndDisabled();
@ -428,14 +432,14 @@ namespace hex::plugin::disasm {
m_mode = cs_mode(u32(m_mode) | CS_MODE_BIG_ENDIAN);
}
ImGuiExt::EndBox();
}
ImGuiExt::EndBox();
}
// Draw disassemble button
ImGui::BeginDisabled(m_disassemblerTask.isRunning() || m_regionToDisassemble.getStartAddress() < m_imageBaseAddress);
{
if (ImGui::Button("hex.disassembler.view.disassembler.disassemble"_lang))
if (ImGuiExt::DimmedButton("hex.disassembler.view.disassembler.disassemble"_lang))
this->disassemble();
}
ImGui::EndDisabled();

View File

@ -11,7 +11,9 @@
"hex.hashes.view.hashes.hover_info": "Hover over the Hex Editor selection and hold down SHIFT to view the hashes of that region.",
"hex.hashes.view.hashes.name": "Hashes",
"hex.hashes.view.hashes.no_settings": "No settings available",
"hex.hashes.view.hashes.add": "Add hash",
"hex.hashes.view.hashes.remove": "Remove hash",
"hex.hashes.view.hashes.hash_name": "Hash Name",
"hex.hashes.view.hashes.table.name": "Name",
"hex.hashes.view.hashes.table.result": "Result",
"hex.hashes.view.hashes.table.type": "Type",

View File

@ -152,48 +152,56 @@ namespace hex::plugin::hashes {
m_selectedHash = hashes.front().get();
}
if (ImGui::BeginCombo("hex.hashes.view.hashes.function"_lang, m_selectedHash != nullptr ? Lang(m_selectedHash->getUnlocalizedName()) : "")) {
if (ImGuiExt::DimmedButton("hex.hashes.view.hashes.add"_lang)) {
ImGui::OpenPopup("##CreateHash");
}
for (const auto &hash : hashes) {
if (ImGui::Selectable(Lang(hash->getUnlocalizedName()), m_selectedHash == hash.get())) {
m_selectedHash = hash.get();
m_newHashName.clear();
if (ImGui::BeginPopup("##CreateHash")) {
ImGuiExt::InputTextIcon("hex.hashes.view.hashes.hash_name"_lang, ICON_VS_SYMBOL_KEY, m_newHashName);
ImGui::NewLine();
if (ImGui::BeginCombo("hex.hashes.view.hashes.function"_lang, m_selectedHash != nullptr ? Lang(m_selectedHash->getUnlocalizedName()) : "")) {
for (const auto &hash : hashes) {
if (ImGui::Selectable(Lang(hash->getUnlocalizedName()), m_selectedHash == hash.get())) {
m_selectedHash = hash.get();
m_newHashName.clear();
}
}
ImGui::EndCombo();
}
if (m_newHashName.empty() && m_selectedHash != nullptr)
m_newHashName = hex::format("{} {}", Lang(m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.hashes.view.hashes.hash"_lang));
if (ImGuiExt::BeginSubWindow("hex.builtin.common.settings"_lang, nullptr, scaled({ 400, 200 }))) {
if (m_selectedHash != nullptr) {
auto startPos = ImGui::GetCursorPosY();
m_selectedHash->draw();
// Check if no elements have been added
if (startPos == ImGui::GetCursorPosY()) {
ImGuiExt::TextFormattedCentered("hex.hashes.view.hashes.no_settings"_lang);
}
}
}
ImGuiExt::EndSubWindow();
ImGui::EndCombo();
}
if (m_newHashName.empty() && m_selectedHash != nullptr)
m_newHashName = hex::format("{} {}", Lang(m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.hashes.view.hashes.hash"_lang));
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvail().x, 200_scaled), true)) {
if (m_selectedHash != nullptr) {
auto startPos = ImGui::GetCursorPosY();
m_selectedHash->draw();
// Check if no elements have been added
if (startPos == ImGui::GetCursorPosY()) {
ImGuiExt::TextFormattedCentered("hex.hashes.view.hashes.no_settings"_lang);
ImGui::BeginDisabled(m_newHashName.empty() || m_selectedHash == nullptr);
if (ImGuiExt::DimmedButton("hex.hashes.view.hashes.add"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
if (m_selectedHash != nullptr) {
m_hashFunctions->push_back(m_selectedHash->create(m_newHashName));
AchievementManager::unlockAchievement("hex.builtin.achievement.misc", "hex.hashes.achievement.misc.create_hash.name");
ImGui::CloseCurrentPopup();
}
}
ImGui::EndDisabled();
ImGui::EndPopup();
}
ImGui::EndChild();
ImGuiExt::InputTextIcon("##hash_name", ICON_VS_SYMBOL_KEY, m_newHashName);
ImGui::SameLine();
ImGui::BeginDisabled(m_newHashName.empty() || m_selectedHash == nullptr);
if (ImGuiExt::IconButton(ICON_VS_ADD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
if (m_selectedHash != nullptr) {
m_hashFunctions->push_back(m_selectedHash->create(m_newHashName));
AchievementManager::unlockAchievement("hex.builtin.achievement.misc", "hex.hashes.achievement.misc.create_hash.name");
}
}
ImGui::EndDisabled();
ImGui::SameLine();
ImGui::SameLine(0, 10_scaled);
ImGuiExt::HelpHover("hex.hashes.view.hashes.hover_info"_lang, ICON_VS_INFO);
if (ImGui::BeginTable("##hashes", 4, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Borders | ImGuiTableFlags_ScrollY)) {
@ -247,7 +255,7 @@ namespace hex::plugin::hashes {
PopupTextHash::open(function);
}
ImGui::SameLine();
if (ImGuiExt::IconButton(ICON_VS_X, ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_ToolbarRed))) {
if (ImGuiExt::IconButton(ICON_VS_X, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
indexToRemove = i;
}

View File

@ -163,15 +163,18 @@ namespace hex::plugin::yara {
}
ImGui::SameLine();
ImGui::BeginDisabled(*m_selectedRule >= m_rulePaths->size());
if (ImGuiExt::IconButton(ICON_VS_REMOVE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
if (*m_selectedRule < m_rulePaths->size()) {
m_rulePaths->erase(m_rulePaths->begin() + *m_selectedRule);
m_selectedRule = std::min(*m_selectedRule, u32(m_rulePaths->size() - 1));
}
m_rulePaths->erase(m_rulePaths->begin() + *m_selectedRule);
m_selectedRule = std::min(*m_selectedRule, u32(m_rulePaths->size() - 1));
}
ImGui::EndDisabled();
ImGui::NewLine();
if (ImGui::Button("hex.yara_rules.view.yara.match"_lang)) this->applyRules();
ImGui::BeginDisabled(m_rulePaths->empty());
if (ImGuiExt::DimmedButton("hex.yara_rules.view.yara.match"_lang)) this->applyRules();
ImGui::EndDisabled();
if (m_matcherTask.isRunning()) {
ImGui::SameLine();