1
0
mirror of synced 2024-11-24 15:50:16 +01:00

feat: Added ASCII count minimap visualizer

This commit is contained in:
WerWolv 2024-01-30 00:00:51 +01:00
parent ba6373daa4
commit 3ea32212d7
2 changed files with 15 additions and 3 deletions

View File

@ -173,6 +173,7 @@
"hex.builtin.menu.view.fps": "Display FPS",
"hex.builtin.minimap_visualizer.entropy": "Local Entropy",
"hex.builtin.minimap_visualizer.zeros": "Zeros Count",
"hex.builtin.minimap_visualizer.ascii": "ASCII Count",
"hex.builtin.nodes.arithmetic": "Arithmetic",
"hex.builtin.nodes.arithmetic.add": "Addition",
"hex.builtin.nodes.arithmetic.add.header": "Add",

View File

@ -13,9 +13,9 @@ namespace hex::plugin::builtin {
namespace {
ImColor entropyMiniMapVisualizer(const std::vector<u8> &data) {
std::array<u32, 256> frequencies = { 0 };
std::array<u8, 256> frequencies = { 0 };
for (u8 byte : data)
frequencies[byte]++;
frequencies[byte] += 1;
double entropy = 0.0;
for (u32 frequency : frequencies) {
@ -41,17 +41,28 @@ namespace hex::plugin::builtin {
u32 zerosCount = 0;
for (u8 byte : data) {
if (byte == 0x00)
zerosCount++;
zerosCount += 1;
}
return ImColor::HSV(0.0F, 0.0F, 1.0F - (double(zerosCount) / data.size()));
}
ImColor byteTypeMiniMapVisualizer(const std::vector<u8> &data) {
u8 asciiCount = 0;
for (u8 byte : data) {
if (std::isprint(byte))
asciiCount += 1;
}
return ImColor::HSV(0.5F, 0.5F, (double(asciiCount) / data.size()));
}
}
void registerMiniMapVisualizers() {
ContentRegistry::HexEditor::addMiniMapVisualizer("hex.builtin.minimap_visualizer.entropy", entropyMiniMapVisualizer);
ContentRegistry::HexEditor::addMiniMapVisualizer("hex.builtin.minimap_visualizer.zeros", zerosMiniMapVisualizer);
ContentRegistry::HexEditor::addMiniMapVisualizer("hex.builtin.minimap_visualizer.ascii", byteTypeMiniMapVisualizer);
}
}