Skip to content

Commit a79dec8

Browse files
committed
improve aewf detector
1 parent 3987a30 commit a79dec8

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

include/entropy/hexdisplay/aewf_detector.h

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <entropy/hex_display_feature.h>
88

9+
#include <iostream>
10+
911
namespace entropy {
1012

1113
class AEWFDetector : public HexDisplayFeature {
@@ -19,12 +21,32 @@ class AEWFDetector : public HexDisplayFeature {
1921

2022
std::vector<Highlight> getHighlights(const std::vector<uint8_t> &sectorData, size_t sectorIndex) const override {
2123
std::vector<Highlight> highlights;
22-
// Scan for a AEWF signature at sector start (0-3)
23-
// Signature: EVF 0x09 0x0d 0x0a 0xff 0x00
24-
if (sectorData.size() >= 13 && sectorData[0] == 0x45 && sectorData[1] == 0x56 && sectorData[2] == 0x46 && sectorData[3] == 0x09 &&
25-
sectorData[4] == 0x0d && sectorData[5] == 0x0a && sectorData[6] == 0xff && sectorData[7] == 0x00) {
26-
for (size_t i = 0; i < 8; i++) {
27-
highlights.push_back({i, this->color});
24+
25+
// .E01 file
26+
// Signature: EVF 0x09 0x0d 0x0a 0xff 0x00
27+
const char aewf_signature[] = {'E', 'V', 'F', 0x09, 0x0d, 0x0a, (char)0xff, 0x00};
28+
29+
// check if sectorData contains the signature
30+
for (size_t i = 0; i + sizeof(aewf_signature) <= sectorData.size(); i++) {
31+
if (memcmp(&sectorData[i], aewf_signature, sizeof(aewf_signature)) == 0) {
32+
for (size_t j = 0; j < sizeof(aewf_signature); j++) {
33+
highlights.push_back({i + j, this->color});
34+
}
35+
return highlights;
36+
}
37+
}
38+
39+
// .AD1 file
40+
// Signature: ADSEGMENTEDFILE\0
41+
const char ad1_signature[] = {'A', 'D', 'S', 'E', 'G', 'M', 'E', 'N', 'T', 'E', 'D', 'F', 'I', 'L', 'E', 0x00};
42+
43+
for (size_t i = 0; i + sizeof(ad1_signature) <= sectorData.size(); i++) {
44+
if (memcmp(&sectorData[i], ad1_signature, sizeof(ad1_signature)) == 0) {
45+
// Found AD1 signature
46+
for (size_t j = 0; j < sizeof(ad1_signature); j++) {
47+
highlights.push_back({i + j, this->color});
48+
}
49+
return highlights;
2850
}
2951
}
3052

src/ui.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ void renderVisualization(ImDrawList *draw_list, GLuint tex, const std::vector<ui
266266
loadHexData(sector_index);
267267
uiState.showHexView = true;
268268
}
269+
270+
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left) && !ImGui::GetIO().WantCaptureMouse) {
271+
size_t sector_index = current_block * block_size + idx;
272+
uiState.highlighted_sector = sector_index;
273+
loadHexData(sector_index);
274+
uiState.showHexView = true;
275+
}
269276
}
270277
}
271278

0 commit comments

Comments
 (0)