-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzero_bytes.h
More file actions
76 lines (61 loc) · 2.23 KB
/
zero_bytes.h
File metadata and controls
76 lines (61 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include <entropy/hex_display_feature.h>
namespace entropy {
class ZeroBytesFeature : public HexDisplayFeature {
public:
ZeroBytesFeature() { color = IM_COL32(255, 255, 255, 100); }
std::string getName() const override { return "Zero Bytes Finder"; }
std::string getSlug() const override { return "zeros"; }
std::string getVersion() const override { return "1.0"; }
std::string getAuthor() const override { return "Entropy Visualizer Team"; }
int getPriority() const override { return 1; }
std::vector<Highlight> getHighlights(const std::vector<uint8_t> §orData, size_t sectorIndex) const override {
std::vector<Highlight> highlights;
for (size_t i = 0; i < sectorData.size(); i++) {
if (sectorData[i] == 0) {
highlights.push_back({i, this->color});
}
if (colorFF && sectorData[i] == 0xFF) {
highlights.push_back({i, this->color});
}
}
return highlights;
}
void renderSettingsPanel() const override {
ImGui::PushID(getName().c_str());
// Default Config (color)
HexDisplayFeature::renderSettingsPanel();
bool changed = ImGui::Checkbox("Color FF as well", &colorFF);
if (changed) {
highlightCache.clear();
}
ImGui::PopID();
}
std::vector<std::string> getConfigOptions() const override {
std::vector<std::string> options = HexDisplayFeature::getConfigOptions(); // default options
options.push_back("colorFF");
return options;
}
std::string getConfigValue(const std::string &key) const override {
if (key == "colorFF") {
return colorFF ? "1" : "0";
}
// default options
return HexDisplayFeature::getConfigValue(key);
}
void setConfig(const std::string &key, const std::string &value) override {
if (key == "colorFF") {
colorFF = (value == "1");
highlightCache.clear();
return;
}
// default options
HexDisplayFeature::setConfig(key, value);
}
private:
mutable bool colorFF = false;
};
} // namespace entropy