2021-12-07 22:47:41 +01:00
|
|
|
#include "content/views/view_information.hpp"
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/providers/provider.hpp>
|
2022-07-31 16:57:35 +02:00
|
|
|
#include <hex/providers/buffered_reader.hpp>
|
2022-08-17 16:15:36 +02:00
|
|
|
|
2022-03-04 11:36:37 +01:00
|
|
|
#include <hex/helpers/fs.hpp>
|
2022-08-17 16:15:36 +02:00
|
|
|
#include <hex/helpers/magic.hpp>
|
2020-11-12 09:38:52 +01:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cmath>
|
2020-11-12 21:21:11 +01:00
|
|
|
#include <filesystem>
|
|
|
|
#include <span>
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2021-03-02 13:49:45 +01:00
|
|
|
#include <implot.h>
|
2021-02-22 13:08:06 +01:00
|
|
|
|
2021-12-07 22:47:41 +01:00
|
|
|
namespace hex::plugin::builtin {
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2021-09-06 16:15:05 +02:00
|
|
|
using namespace hex::literals;
|
|
|
|
|
2021-12-07 22:47:41 +01:00
|
|
|
ViewInformation::ViewInformation() : View("hex.builtin.view.information.name") {
|
2021-03-27 11:36:36 +01:00
|
|
|
EventManager::subscribe<EventDataChanged>(this, [this]() {
|
2022-07-31 16:57:35 +02:00
|
|
|
this->m_dataValid = false;
|
2022-12-28 23:06:49 +01:00
|
|
|
this->m_plainTextCharacterPercentage = -1.0;
|
|
|
|
this->m_averageEntropy = -1.0;
|
|
|
|
this->m_highestBlockEntropy = -1.0;
|
2022-07-31 16:57:35 +02:00
|
|
|
this->m_blockSize = 0;
|
|
|
|
this->m_dataMimeType.clear();
|
|
|
|
this->m_dataDescription.clear();
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_analyzedRegion = { 0, 0 };
|
2020-11-12 09:38:52 +01:00
|
|
|
});
|
2021-04-12 22:20:05 +02:00
|
|
|
|
|
|
|
EventManager::subscribe<EventRegionSelected>(this, [this](Region region) {
|
2023-03-10 16:06:18 +01:00
|
|
|
// Set the position of the diagram relative to the place where
|
|
|
|
// the user clicked inside the hex editor view
|
|
|
|
if (this->m_blockSize != 0) {
|
|
|
|
this->m_byteTypesDistribution.setHandlePosition(region.getStartAddress());
|
|
|
|
this->m_chunkBasedEntropy.setHandlePosition(region.getStartAddress());
|
|
|
|
}
|
2021-04-12 22:20:05 +02:00
|
|
|
});
|
2021-12-05 22:09:43 +01:00
|
|
|
|
2022-07-30 22:01:49 +02:00
|
|
|
EventManager::subscribe<EventProviderDeleted>(this, [this](const auto*) {
|
2021-12-05 22:09:43 +01:00
|
|
|
this->m_dataValid = false;
|
|
|
|
});
|
2022-01-13 14:34:19 +01:00
|
|
|
|
|
|
|
ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) {
|
2022-03-04 11:36:37 +01:00
|
|
|
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Magic)) {
|
2023-03-12 18:27:29 +01:00
|
|
|
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
2022-07-02 17:53:13 +02:00
|
|
|
View::showInfoPopup("hex.builtin.view.information.magic_db_added"_lang);
|
2022-01-13 14:34:19 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2020-11-12 09:38:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ViewInformation::~ViewInformation() {
|
2021-03-27 11:36:36 +01:00
|
|
|
EventManager::unsubscribe<EventDataChanged>(this);
|
2021-04-12 22:20:05 +02:00
|
|
|
EventManager::unsubscribe<EventRegionSelected>(this);
|
2022-07-30 22:01:49 +02:00
|
|
|
EventManager::unsubscribe<EventProviderDeleted>(this);
|
2020-11-12 09:38:52 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 13:08:06 +01:00
|
|
|
void ViewInformation::analyze() {
|
2022-08-17 16:15:36 +02:00
|
|
|
this->m_analyzerTask = TaskManager::createTask("hex.builtin.view.information.analyzing", 0, [this](auto &task) {
|
2021-09-21 02:29:54 +02:00
|
|
|
auto provider = ImHexApi::Provider::get();
|
2020-12-27 15:39:06 +01:00
|
|
|
|
2023-03-17 17:07:39 +01:00
|
|
|
if ((this->m_inputChunkSize <= 0)
|
2023-03-10 16:06:18 +01:00
|
|
|
|| (this->m_inputStartAddress >= this->m_inputEndAddress)
|
2023-03-17 17:07:39 +01:00
|
|
|
|| ((size_t) this->m_inputEndAddress > provider->getActualSize())) {
|
2023-03-10 16:06:18 +01:00
|
|
|
// Invalid parameters, set default one
|
|
|
|
this->m_inputChunkSize = 256;
|
|
|
|
this->m_inputStartAddress = 0;
|
2023-03-17 17:07:39 +01:00
|
|
|
this->m_inputEndAddress = provider->getActualSize();
|
2023-03-10 16:06:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
task.setMaxValue(this->m_inputEndAddress - this->m_inputStartAddress);
|
2021-12-16 23:48:52 +01:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Modify the analyzed region
|
|
|
|
this->m_analyzedRegion = {
|
|
|
|
provider->getBaseAddress() + this->m_inputStartAddress,
|
|
|
|
size_t(this->m_inputEndAddress - this->m_inputStartAddress)
|
|
|
|
};
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2021-12-16 23:48:52 +01:00
|
|
|
{
|
|
|
|
magic::compile();
|
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
this->m_dataDescription = magic::getDescription(provider);
|
|
|
|
this->m_dataMimeType = magic::getMIMEType(provider);
|
2021-12-16 23:48:52 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 13:08:06 +01:00
|
|
|
{
|
2023-03-18 10:52:50 +01:00
|
|
|
this->m_blockSize = std::max<u32>(std::ceil(provider->getActualSize() / 2048.0F), 256);
|
2022-07-31 16:57:35 +02:00
|
|
|
|
2022-12-28 23:06:49 +01:00
|
|
|
this->m_averageEntropy = -1.0;
|
|
|
|
this->m_highestBlockEntropy = -1.0;
|
|
|
|
this->m_plainTextCharacterPercentage = -1.0;
|
2022-12-27 22:50:37 +01:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Setup / start each analysis
|
|
|
|
|
|
|
|
this->m_byteDistribution.reset();
|
|
|
|
this->m_digram.reset(this->m_inputEndAddress - this->m_inputStartAddress);
|
|
|
|
this->m_layeredDistribution.reset(this->m_inputEndAddress - this->m_inputStartAddress);
|
|
|
|
this->m_byteTypesDistribution.reset(this->m_inputStartAddress, this->m_inputEndAddress,
|
2023-03-18 10:52:50 +01:00
|
|
|
provider->getBaseAddress(), provider->getActualSize());
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_chunkBasedEntropy.reset(this->m_inputChunkSize, this->m_inputStartAddress, this->m_inputEndAddress,
|
2023-03-18 10:52:50 +01:00
|
|
|
provider->getBaseAddress(), provider->getActualSize());
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Create a handle to the file
|
2023-03-12 18:27:29 +01:00
|
|
|
auto reader = prv::ProviderReader(provider);
|
2023-03-10 16:06:18 +01:00
|
|
|
reader.seek(provider->getBaseAddress() + this->m_inputStartAddress);
|
|
|
|
reader.setEndAddress(provider->getBaseAddress() + this->m_inputEndAddress);
|
2020-11-12 21:21:11 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
u64 count = 0;
|
2022-12-28 23:06:49 +01:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Loop over each byte of the [part of the] file and update each analysis
|
|
|
|
// one byte at the time in order to process the file only once
|
2022-07-31 16:57:35 +02:00
|
|
|
for (u8 byte : reader) {
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_byteDistribution.update(byte);
|
|
|
|
this->m_byteTypesDistribution.update(byte);
|
|
|
|
this->m_chunkBasedEntropy.update(byte);
|
|
|
|
this->m_layeredDistribution.update(byte);
|
|
|
|
this->m_digram.update(byte);
|
|
|
|
++count;
|
|
|
|
task.update(count);
|
2021-02-22 13:08:06 +01:00
|
|
|
}
|
2020-11-12 21:21:11 +01:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_averageEntropy = this->m_chunkBasedEntropy.calculateEntropy(this->m_byteDistribution.get(), this->m_inputEndAddress - this->m_inputStartAddress);
|
2023-03-17 17:07:39 +01:00
|
|
|
this->m_highestBlockEntropy = this->m_chunkBasedEntropy.getHighestEntropyBlockValue();
|
|
|
|
this->m_highestBlockEntropyAddress = this->m_chunkBasedEntropy.getHighestEntropyBlockAddress();
|
|
|
|
this->m_lowestBlockEntropy = this->m_chunkBasedEntropy.getLowestEntropyBlockValue();
|
|
|
|
this->m_lowestBlockEntropyAddress = this->m_chunkBasedEntropy.getLowestEntropyBlockAddress();
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_plainTextCharacterPercentage = this->m_byteTypesDistribution.getPlainTextCharacterPercentage();
|
2021-02-22 13:08:06 +01:00
|
|
|
}
|
2023-03-10 16:06:18 +01:00
|
|
|
|
|
|
|
this->m_dataValid = true;
|
2022-08-17 16:15:36 +02:00
|
|
|
});
|
2023-03-10 16:06:18 +01:00
|
|
|
}
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2021-02-22 13:08:06 +01:00
|
|
|
void ViewInformation::drawContent() {
|
2021-12-07 22:47:41 +01:00
|
|
|
if (ImGui::Begin(View::toWindowName("hex.builtin.view.information.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
2021-08-28 14:22:02 +02:00
|
|
|
if (ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav)) {
|
2020-11-15 16:06:10 +01:00
|
|
|
|
2021-09-21 02:29:54 +02:00
|
|
|
auto provider = ImHexApi::Provider::get();
|
|
|
|
if (ImHexApi::Provider::isValid() && provider->isReadable()) {
|
2022-08-17 16:15:36 +02:00
|
|
|
ImGui::BeginDisabled(this->m_analyzerTask.isRunning());
|
2022-05-27 20:42:07 +02:00
|
|
|
{
|
2023-03-17 17:07:39 +01:00
|
|
|
ImGui::Header("hex.builtin.common.settings"_lang, true);
|
2023-03-10 16:06:18 +01:00
|
|
|
|
2023-03-17 17:07:39 +01:00
|
|
|
const u64 min = 0;
|
|
|
|
const u64 max = provider->getActualSize();
|
|
|
|
ImGui::SliderScalar("hex.builtin.common.begin"_lang, ImGuiDataType_U64, &this->m_inputStartAddress, &min, &max, "0x%02llX", ImGuiSliderFlags_AlwaysClamp);
|
|
|
|
ImGui::SliderScalar("hex.builtin.common.end"_lang, ImGuiDataType_U64, &this->m_inputEndAddress, &min, &max, "0x%02llX", ImGuiSliderFlags_AlwaysClamp);
|
|
|
|
|
|
|
|
ImGui::NewLine();
|
2023-03-10 16:06:18 +01:00
|
|
|
|
2023-03-17 17:07:39 +01:00
|
|
|
ImGui::InputInt("hex.builtin.view.information.block_size"_lang, &this->m_inputChunkSize, ImGuiInputTextFlags_CharsDecimal);
|
2023-03-10 16:06:18 +01:00
|
|
|
|
2022-08-03 23:32:34 +02:00
|
|
|
if (ImGui::Button("hex.builtin.view.information.analyze"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0)))
|
2021-08-28 14:22:02 +02:00
|
|
|
this->analyze();
|
2022-05-27 20:42:07 +02:00
|
|
|
}
|
|
|
|
ImGui::EndDisabled();
|
2020-11-22 19:43:35 +01:00
|
|
|
|
2022-08-17 16:15:36 +02:00
|
|
|
if (this->m_analyzerTask.isRunning()) {
|
2021-12-07 22:47:41 +01:00
|
|
|
ImGui::TextSpinner("hex.builtin.view.information.analyzing"_lang);
|
2021-12-12 00:41:44 +01:00
|
|
|
} else {
|
|
|
|
ImGui::NewLine();
|
2021-08-28 14:22:02 +02:00
|
|
|
}
|
2020-11-15 16:06:10 +01:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
if (!this->m_analyzerTask.isRunning() && this->m_dataValid) {
|
2020-11-15 16:06:10 +01:00
|
|
|
|
2023-03-17 17:07:39 +01:00
|
|
|
// Provider information
|
|
|
|
ImGui::Header("hex.builtin.view.information.provider_information"_lang, true);
|
2021-02-22 13:08:06 +01:00
|
|
|
|
2022-12-25 15:45:49 +01:00
|
|
|
if (ImGui::BeginTable("information", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoKeepColumnsVisible)) {
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableSetupColumn("type");
|
|
|
|
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
2020-11-15 16:06:10 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableNextRow();
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2023-01-24 09:07:11 +01:00
|
|
|
for (auto &[name, value] : provider->getDataDescription()) {
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", name);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormattedWrapped("{}", value);
|
|
|
|
}
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", "hex.builtin.view.information.region"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("0x{:X} - 0x{:X}", this->m_analyzedRegion.getStartAddress(), this->m_analyzedRegion.getEndAddress());
|
2021-03-02 13:49:45 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::EndTable();
|
2021-08-28 14:22:02 +02:00
|
|
|
}
|
2021-03-02 13:49:45 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
// Magic information
|
|
|
|
if (!(this->m_dataDescription.empty() && this->m_dataMimeType.empty())) {
|
|
|
|
ImGui::Header("hex.builtin.view.information.magic"_lang);
|
2021-04-12 22:20:05 +02:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
if (ImGui::BeginTable("magic", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg)) {
|
|
|
|
ImGui::TableSetupColumn("type");
|
|
|
|
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableNextRow();
|
2020-11-12 09:38:52 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
if (!this->m_dataDescription.empty()) {
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.description"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormattedWrapped("{}", this->m_dataDescription.c_str());
|
|
|
|
}
|
2021-03-02 13:49:45 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
if (!this->m_dataMimeType.empty()) {
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.mime"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormattedWrapped("{}", this->m_dataMimeType.c_str());
|
|
|
|
}
|
2021-03-02 13:49:45 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
2021-04-12 22:20:05 +02:00
|
|
|
}
|
2021-03-02 13:49:45 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
// Information analysis
|
|
|
|
{
|
|
|
|
|
|
|
|
ImGui::Header("hex.builtin.view.information.info_analysis"_lang);
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetColorU32(ImGuiCol_WindowBg));
|
|
|
|
ImPlot::PushStyleColor(ImPlotCol_FrameBg, ImGui::GetColorU32(ImGuiCol_WindowBg));
|
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Display byte distribution analysis
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.distribution"_lang);
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_byteDistribution.draw(
|
|
|
|
ImVec2(-1, 0),
|
|
|
|
ImPlotFlags_NoChild | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect
|
|
|
|
);
|
2022-07-31 16:57:35 +02:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Display byte types distribution analysis
|
2022-12-25 15:45:49 +01:00
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.byte_types"_lang);
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_byteTypesDistribution.draw(
|
|
|
|
ImVec2(-1, 0),
|
|
|
|
ImPlotFlags_NoChild | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_AntiAliased,
|
|
|
|
true
|
|
|
|
);
|
2022-07-31 16:57:35 +02:00
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
// Display chunk based entropy analysis
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.entropy"_lang);
|
2023-03-10 16:06:18 +01:00
|
|
|
this->m_chunkBasedEntropy.draw(
|
|
|
|
ImVec2(-1, 0),
|
|
|
|
ImPlotFlags_NoChild | ImPlotFlags_CanvasOnly | ImPlotFlags_AntiAliased,
|
|
|
|
true
|
|
|
|
);
|
2021-08-28 14:22:02 +02:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImPlot::PopStyleColor();
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
|
|
|
|
ImGui::NewLine();
|
2021-08-28 14:22:02 +02:00
|
|
|
}
|
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
// Entropy information
|
2022-12-28 23:06:49 +01:00
|
|
|
if (ImGui::BeginTable("entropy_info", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg)) {
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableSetupColumn("type");
|
|
|
|
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
2020-11-22 19:43:35 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableNextRow();
|
2020-11-22 19:43:35 +01:00
|
|
|
|
2022-07-31 16:57:35 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", "hex.builtin.view.information.block_size"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
2023-03-10 16:06:18 +01:00
|
|
|
ImGui::TextFormatted("hex.builtin.view.information.block_size.desc"_lang, this->m_chunkBasedEntropy.getSize(), this->m_chunkBasedEntropy.getChunkSize());
|
2022-07-31 16:57:35 +02:00
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", "hex.builtin.view.information.file_entropy"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
2022-12-28 23:06:49 +01:00
|
|
|
if (this->m_averageEntropy < 0) ImGui::TextUnformatted("???");
|
2023-03-17 17:07:39 +01:00
|
|
|
else ImGui::TextFormatted("{:.5f}", this->m_averageEntropy);
|
2022-07-31 16:57:35 +02:00
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", "hex.builtin.view.information.highest_entropy"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
2023-03-17 17:07:39 +01:00
|
|
|
ImGui::TextFormatted("{:.5f} @ 0x{:02X}", this->m_highestBlockEntropy, this->m_highestBlockEntropyAddress);
|
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", "hex.builtin.view.information.lowest_entropy"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{:.5f} @ 0x{:02X}", this->m_lowestBlockEntropy, this->m_lowestBlockEntropyAddress);
|
2022-12-28 23:06:49 +01:00
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormatted("{}", "hex.builtin.view.information.plain_text_percentage"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
if (this->m_plainTextCharacterPercentage < 0) ImGui::TextUnformatted("???");
|
2023-03-17 17:07:39 +01:00
|
|
|
else ImGui::TextFormatted("{:.2f}%", this->m_plainTextCharacterPercentage);
|
2022-07-31 16:57:35 +02:00
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
2021-08-28 14:22:02 +02:00
|
|
|
|
2022-12-28 23:06:49 +01:00
|
|
|
ImGui::NewLine();
|
|
|
|
|
|
|
|
// General information
|
|
|
|
if (ImGui::BeginTable("info", 1, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg)) {
|
|
|
|
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
if (this->m_averageEntropy > 0.83 && this->m_highestBlockEntropy > 0.9) {
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormattedColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "{}", "hex.builtin.view.information.encrypted"_lang);
|
|
|
|
}
|
|
|
|
|
2023-03-17 17:07:39 +01:00
|
|
|
if (this->m_plainTextCharacterPercentage > 95) {
|
2022-12-28 23:06:49 +01:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextFormattedColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "{}", "hex.builtin.view.information.plain_text"_lang);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
2021-08-28 14:22:02 +02:00
|
|
|
}
|
2022-12-27 22:50:37 +01:00
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
{
|
2022-12-28 23:06:49 +01:00
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.digram"_lang);
|
2023-03-17 21:18:28 +01:00
|
|
|
this->m_digram.draw(scaled(ImVec2(300, 300)));
|
2022-12-27 22:50:37 +01:00
|
|
|
}
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
{
|
2022-12-28 23:06:49 +01:00
|
|
|
ImGui::TextUnformatted("hex.builtin.view.information.layered_distribution"_lang);
|
2023-03-17 21:18:28 +01:00
|
|
|
this->m_layeredDistribution.draw(scaled(ImVec2(300, 300)));
|
2022-12-27 22:50:37 +01:00
|
|
|
}
|
2022-12-28 23:06:49 +01:00
|
|
|
ImGui::EndGroup();
|
|
|
|
}
|
2020-11-12 12:01:13 +01:00
|
|
|
}
|
2020-11-12 09:38:52 +01:00
|
|
|
}
|
2021-08-28 16:02:53 +02:00
|
|
|
ImGui::EndChild();
|
2020-11-12 09:38:52 +01:00
|
|
|
}
|
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
|
2023-03-10 16:06:18 +01:00
|
|
|
}
|