mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
Select region when clicking on string, disassembly or pattern data item
This commit is contained in:
@@ -59,6 +59,7 @@ namespace hex {
|
||||
Disassembly disassembly = { 0 };
|
||||
disassembly.address = instructions[instr].address;
|
||||
disassembly.offset = this->m_codeOffset + address + usedBytes;
|
||||
disassembly.size = instructions[instr].size;
|
||||
disassembly.opcodeString = instructions[instr].mnemonic + " "s + instructions[instr].op_str;
|
||||
|
||||
for (u8 i = 0; i < instructions[instr].size; i++)
|
||||
@@ -120,6 +121,9 @@ namespace hex {
|
||||
this->m_micoMode = false;
|
||||
this->m_sparcV9Mode = false;
|
||||
|
||||
if (this->m_modeBasicARM == cs_mode(0))
|
||||
this->m_modeBasicARM = CS_MODE_ARM;
|
||||
|
||||
if (ImGui::RadioButton("ARM mode", this->m_modeBasicARM == CS_MODE_ARM))
|
||||
this->m_modeBasicARM = CS_MODE_ARM;
|
||||
ImGui::SameLine();
|
||||
@@ -142,6 +146,9 @@ namespace hex {
|
||||
this->m_modeBasicPPC = cs_mode(0);
|
||||
this->m_sparcV9Mode = false;
|
||||
|
||||
if (this->m_modeBasicMIPS == cs_mode(0))
|
||||
this->m_modeBasicMIPS = CS_MODE_MIPS32;
|
||||
|
||||
if (ImGui::RadioButton("MIPS32 mode", this->m_modeBasicMIPS == CS_MODE_MIPS32))
|
||||
this->m_modeBasicMIPS = CS_MODE_MIPS32;
|
||||
ImGui::SameLine();
|
||||
@@ -161,6 +168,9 @@ namespace hex {
|
||||
this->m_micoMode = false;
|
||||
this->m_sparcV9Mode = false;
|
||||
|
||||
if (this->m_modeBasicX86 == cs_mode(0))
|
||||
this->m_modeBasicX86 = CS_MODE_16;
|
||||
|
||||
if (ImGui::RadioButton("16-bit mode", this->m_modeBasicX86 == CS_MODE_16))
|
||||
this->m_modeBasicX86 = CS_MODE_16;
|
||||
ImGui::SameLine();
|
||||
@@ -178,6 +188,9 @@ namespace hex {
|
||||
this->m_micoMode = false;
|
||||
this->m_sparcV9Mode = false;
|
||||
|
||||
if (m_modeBasicPPC == cs_mode(0))
|
||||
this->m_modeBasicPPC = CS_MODE_32;
|
||||
|
||||
if (ImGui::RadioButton("32-bit mode", this->m_modeBasicPPC == CS_MODE_32))
|
||||
this->m_modeBasicPPC = CS_MODE_32;
|
||||
ImGui::SameLine();
|
||||
@@ -236,6 +249,11 @@ namespace hex {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(("##DisassemblyLine"s + std::to_string(i)).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
Region selectRegion = { this->m_disassembly[i].offset, this->m_disassembly[i].size };
|
||||
View::postEvent(Events::SelectionChangeRequest, &selectRegion);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("0x%llx", this->m_disassembly[i].address);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x%llx", this->m_disassembly[i].offset);
|
||||
|
||||
@@ -56,6 +56,19 @@ namespace hex {
|
||||
if (filePath != nullptr)
|
||||
this->openFile(filePath);
|
||||
});
|
||||
|
||||
View::subscribeEvent(Events::SelectionChangeRequest, [this](const void *userData) {
|
||||
const Region ®ion = *reinterpret_cast<const Region*>(userData);
|
||||
|
||||
auto page = this->m_dataProvider->getPageOfAddress(region.address);
|
||||
if (!page.has_value())
|
||||
return;
|
||||
|
||||
this->m_dataProvider->setCurrentPage(page.value());
|
||||
this->m_memoryEditor.GotoAddr = region.address;
|
||||
this->m_memoryEditor.DataPreviewAddr = region.address;
|
||||
this->m_memoryEditor.DataPreviewAddrEnd = region.address + region.size - 1;
|
||||
});
|
||||
}
|
||||
|
||||
ViewHexEditor::~ViewHexEditor() {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "views/view_strings.hpp"
|
||||
|
||||
#include "providers/provider.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
namespace hex {
|
||||
|
||||
ViewStrings::ViewStrings(prv::Provider* &dataProvider) : View(), m_dataProvider(dataProvider) {
|
||||
@@ -122,6 +125,11 @@ namespace hex {
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(("##StringLine"s + std::to_string(i)).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
Region selectRegion = { foundString.offset, foundString.size };
|
||||
View::postEvent(Events::SelectionChangeRequest, &selectRegion);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("0x%08lx : 0x%08lx", foundString.offset, foundString.offset + foundString.size);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x%04lx", foundString.size);
|
||||
|
||||
Reference in New Issue
Block a user