impr: Split out digram and layered distribution in their own section
This commit is contained in:
parent
4100e48fe2
commit
2f7b949bd1
@ -70,7 +70,7 @@ namespace ImGuiExt {
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
enum class Filter {
|
||||
enum class Filter : int {
|
||||
Linear,
|
||||
Nearest
|
||||
};
|
||||
|
@ -107,7 +107,7 @@ namespace hex {
|
||||
|
||||
class DiagramDigram {
|
||||
public:
|
||||
explicit DiagramDigram(size_t sampleSize = 0x9000) : m_sampleSize(sampleSize) { }
|
||||
explicit DiagramDigram() { }
|
||||
|
||||
void draw(ImVec2 size) {
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImU32(ImColor(0, 0, 0)));
|
||||
@ -131,7 +131,7 @@ namespace hex {
|
||||
pixels[x * 0xFF + y] = ImAlphaBlendColors(pixels[x * 0xFF + y], ImColor(color));
|
||||
}
|
||||
|
||||
m_texture = ImGuiExt::Texture(reinterpret_cast<u8*>(pixels.data()), pixels.size() * 4, ImGuiExt::Texture::Filter::Nearest, 0xFF, 0xFF);
|
||||
m_texture = ImGuiExt::Texture(reinterpret_cast<u8*>(pixels.data()), pixels.size() * 4, m_filter, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
auto pos = ImGui::GetWindowPos() + ImVec2(size.x * 0.025F, size.y * 0.025F);
|
||||
@ -145,14 +145,14 @@ namespace hex {
|
||||
|
||||
void process(prv::Provider *provider, u64 address, size_t size) {
|
||||
m_processing = true;
|
||||
m_buffer = impl::getSampleSelection(provider, address, size, m_sampleSize);
|
||||
m_buffer = impl::getSampleSelection(provider, address, size, m_sampleSize == 0 ? size : m_sampleSize);
|
||||
processImpl();
|
||||
m_processing = false;
|
||||
}
|
||||
|
||||
void process(const std::vector<u8> &buffer) {
|
||||
m_processing = true;
|
||||
m_buffer = impl::getSampleSelection(buffer, m_sampleSize);
|
||||
m_buffer = impl::getSampleSelection(buffer, m_sampleSize == 0 ? buffer.size() : m_sampleSize);
|
||||
processImpl();
|
||||
m_processing = false;
|
||||
}
|
||||
@ -160,7 +160,7 @@ namespace hex {
|
||||
void reset(u64 size) {
|
||||
m_processing = true;
|
||||
m_buffer.clear();
|
||||
m_buffer.reserve(m_sampleSize);
|
||||
m_buffer.reserve(m_sampleSize == 0 ? size : m_sampleSize);
|
||||
m_byteCount = 0;
|
||||
m_fileSize = size;
|
||||
m_texture = ImGuiExt::Texture();
|
||||
@ -169,7 +169,7 @@ namespace hex {
|
||||
void update(u8 byte) {
|
||||
// Check if there is some space left
|
||||
if (m_byteCount < m_fileSize) {
|
||||
if ((m_byteCount % u64(std::ceil(double(m_fileSize) / double(m_sampleSize)))) == 0)
|
||||
if (m_sampleSize == 0 || (m_byteCount % u64(std::ceil(double(m_fileSize) / double(m_sampleSize)))) == 0)
|
||||
m_buffer.push_back(byte);
|
||||
++m_byteCount;
|
||||
if (m_byteCount == m_fileSize) {
|
||||
@ -179,6 +179,17 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
void setFiltering(ImGuiExt::Texture::Filter filter) {
|
||||
m_filter = filter;
|
||||
}
|
||||
|
||||
void setBrightness(float brightness) {
|
||||
m_brightness = brightness;
|
||||
}
|
||||
|
||||
void setSampleSize(size_t sampleSize) {
|
||||
m_sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
private:
|
||||
void processImpl() {
|
||||
@ -195,10 +206,12 @@ namespace hex {
|
||||
m_glowBuffer[i] = std::min<float>(0.2F + (float(heatMap[m_buffer[i] << 8 | m_buffer[i + 1]]) / float(m_highestCount / 1000)), 1.0F);
|
||||
}
|
||||
|
||||
m_opacity = (log10(float(m_sampleSize)) / log10(float(m_highestCount))) / 10.0F;
|
||||
m_opacity = (log10(float(m_sampleSize == 0 ? m_buffer.size() : m_sampleSize)) / log10(float(m_highestCount))) / (100.0F * m_brightness);
|
||||
}
|
||||
|
||||
private:
|
||||
ImGuiExt::Texture::Filter m_filter = ImGuiExt::Texture::Filter::Nearest;
|
||||
float m_brightness = 0.5F;
|
||||
size_t m_sampleSize = 0;
|
||||
|
||||
// The number of bytes processed and the size of
|
||||
@ -215,7 +228,7 @@ namespace hex {
|
||||
|
||||
class DiagramLayeredDistribution {
|
||||
public:
|
||||
explicit DiagramLayeredDistribution(size_t sampleSize = 0x9000) : m_sampleSize(sampleSize) { }
|
||||
explicit DiagramLayeredDistribution() { }
|
||||
|
||||
void draw(ImVec2 size) {
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImU32(ImColor(0, 0, 0)));
|
||||
@ -236,7 +249,7 @@ namespace hex {
|
||||
pixels[x * 0xFF + y] = ImAlphaBlendColors(pixels[x * 0xFF + y], ImColor(color));
|
||||
}
|
||||
|
||||
m_texture = ImGuiExt::Texture(reinterpret_cast<u8*>(pixels.data()), pixels.size() * 4, ImGuiExt::Texture::Filter::Nearest, 0xFF, 0xFF);
|
||||
m_texture = ImGuiExt::Texture(reinterpret_cast<u8*>(pixels.data()), pixels.size() * 4, m_filter, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
const auto pos = ImGui::GetWindowPos() + ImVec2(size.x * 0.025F, size.y * 0.025F);
|
||||
@ -249,14 +262,14 @@ namespace hex {
|
||||
|
||||
void process(prv::Provider *provider, u64 address, size_t size) {
|
||||
m_processing = true;
|
||||
m_buffer = impl::getSampleSelection(provider, address, size, m_sampleSize);
|
||||
m_buffer = impl::getSampleSelection(provider, address, size, m_sampleSize == 0 ? size : m_sampleSize);
|
||||
processImpl();
|
||||
m_processing = false;
|
||||
}
|
||||
|
||||
void process(const std::vector<u8> &buffer) {
|
||||
m_processing = true;
|
||||
m_buffer = impl::getSampleSelection(buffer, m_sampleSize);
|
||||
m_buffer = impl::getSampleSelection(buffer, m_sampleSize == 0 ? buffer.size() : m_sampleSize);
|
||||
processImpl();
|
||||
m_processing = false;
|
||||
}
|
||||
@ -264,7 +277,7 @@ namespace hex {
|
||||
void reset(u64 size) {
|
||||
m_processing = true;
|
||||
m_buffer.clear();
|
||||
m_buffer.reserve(m_sampleSize);
|
||||
m_buffer.reserve(m_sampleSize == 0 ? size : m_sampleSize);
|
||||
m_byteCount = 0;
|
||||
m_fileSize = size;
|
||||
m_texture = ImGuiExt::Texture();
|
||||
@ -273,7 +286,7 @@ namespace hex {
|
||||
void update(u8 byte) {
|
||||
// Check if there is some space left
|
||||
if (m_byteCount < m_fileSize) {
|
||||
if ((m_byteCount % u64(std::ceil(double(m_fileSize) / double(m_sampleSize)))) == 0)
|
||||
if (m_sampleSize == 0 || (m_byteCount % u64(std::ceil(double(m_fileSize) / double(m_sampleSize)))) == 0)
|
||||
m_buffer.push_back(byte);
|
||||
++m_byteCount;
|
||||
if (m_byteCount == m_fileSize) {
|
||||
@ -283,6 +296,18 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
void setFiltering(ImGuiExt::Texture::Filter filter) {
|
||||
m_filter = filter;
|
||||
}
|
||||
|
||||
void setBrightness(float brightness) {
|
||||
m_brightness = brightness;
|
||||
}
|
||||
|
||||
void setSampleSize(size_t sampleSize) {
|
||||
m_sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
private:
|
||||
void processImpl() {
|
||||
m_glowBuffer.resize(m_buffer.size());
|
||||
@ -298,11 +323,14 @@ namespace hex {
|
||||
m_glowBuffer[i] = std::min<float>(0.2F + (float(heatMap[m_buffer[i] << 8 | m_buffer[i + 1]]) / float(m_highestCount / 1000)), 1.0F);
|
||||
}
|
||||
|
||||
m_opacity = (log10(float(m_sampleSize)) / log10(float(m_highestCount))) / 10.0F;
|
||||
m_opacity = (log10(float(m_sampleSize == 0 ? m_buffer.size() : m_sampleSize)) / log10(float(m_highestCount))) / (100.0F * m_brightness);
|
||||
}
|
||||
|
||||
private:
|
||||
ImGuiExt::Texture::Filter m_filter = ImGuiExt::Texture::Filter::Nearest;
|
||||
float m_brightness = 0.5F;
|
||||
size_t m_sampleSize = 0;
|
||||
|
||||
|
||||
// The number of bytes processed and the size of
|
||||
// the file to analyze (useful for iterative analysis)
|
||||
u64 m_byteCount = 0;
|
||||
|
@ -843,7 +843,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "Byte Typen",
|
||||
"hex.builtin.view.information.control": "Einstellungen",
|
||||
"hex.builtin.information_section.magic.description": "Beschreibung",
|
||||
"hex.builtin.information_section.info_analysis.digram": "Diagramm",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "Diagramm",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "Byte Verteilung",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "Diese Daten sind vermutlich verschlüsselt oder komprimiert!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "Entropie",
|
||||
@ -852,7 +852,7 @@
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "Höchste Blockentropie",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "Informationsanalyse",
|
||||
"hex.builtin.information_section.info_analysis": "Schichtverteilung",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "Tiefste Blockentropie",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "Tiefste Blockentropie",
|
||||
"hex.builtin.view.information.error_processing_section": "Auswerten von Informationssektion {0} fehlgeschlagen: '{1}'",
|
||||
"hex.builtin.information_section.magic": "Magic Informationen",
|
||||
"hex.builtin.view.information.magic_db_added": "Magic Datenbank hinzugefügt!",
|
||||
|
@ -833,7 +833,6 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "Byte types",
|
||||
"hex.builtin.view.information.control": "Control",
|
||||
"hex.builtin.information_section.magic.description": "Description",
|
||||
"hex.builtin.information_section.info_analysis.digram": "Digram",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "Byte distribution",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "This data is most likely encrypted or compressed!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "Entropy",
|
||||
@ -842,7 +841,12 @@
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "Highest block entropy",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "Lowest block entropy",
|
||||
"hex.builtin.information_section.info_analysis": "Information analysis",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "Layered distribution",
|
||||
"hex.builtin.information_section.relationship_analysis": "Byte Relationship",
|
||||
"hex.builtin.information_section.relationship_analysis.sample_size": "Sample size",
|
||||
"hex.builtin.information_section.relationship_analysis.brightness": "Brightness",
|
||||
"hex.builtin.information_section.relationship_analysis.filter": "Filter",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "Digram",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "Layered distribution",
|
||||
"hex.builtin.information_section.magic": "Magic Information",
|
||||
"hex.builtin.view.information.error_processing_section": "Failed to process information section {0}: '{1}'",
|
||||
"hex.builtin.view.information.magic_db_added": "Magic database added!",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "Tipos de byte",
|
||||
"hex.builtin.view.information.control": "Ajustes",
|
||||
"hex.builtin.information_section.magic.description": "Descripción",
|
||||
"hex.builtin.information_section.info_analysis.digram": "Digrama",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "Digrama",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "Distribución de bytes",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "¡Estos datos están probablemente encriptados o comprimidos!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "Entropía",
|
||||
@ -848,7 +848,7 @@
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "Entropía del mayor bloque",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "Entropía del menor bloque",
|
||||
"hex.builtin.information_section.info_analysis": "Análisis de información",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "Distribución en capas",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "Distribución en capas",
|
||||
"hex.builtin.information_section.magic": "Información del 'magic'",
|
||||
"hex.builtin.view.information.magic_db_added": "¡Añadida base de datos de 'magic's!",
|
||||
"hex.builtin.information_section.magic.mime": "Tipo MIME",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "",
|
||||
"hex.builtin.view.information.control": "Controllo",
|
||||
"hex.builtin.information_section.magic.description": "Descrizione",
|
||||
"hex.builtin.information_section.info_analysis.digram": "",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "Distribuzione dei Byte",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "Questi dati sono probabilmente codificati o compressi!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "Entropia",
|
||||
@ -847,7 +847,7 @@
|
||||
"hex.builtin.information_section.info_analysis.file_entropy": "",
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "Highest block entropy",
|
||||
"hex.builtin.information_section.info_analysis": "Informazioni dell'analisi",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "",
|
||||
"hex.builtin.information_section.magic": "Informazione Magica",
|
||||
"hex.builtin.view.information.magic_db_added": "Database magico aggiunto!",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "",
|
||||
"hex.builtin.view.information.control": "コントロール",
|
||||
"hex.builtin.information_section.magic.description": "詳細",
|
||||
"hex.builtin.information_section.info_analysis.digram": "",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "バイト分布",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "暗号化や圧縮を経たデータと推測されます。",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "エントロピー",
|
||||
@ -847,7 +847,7 @@
|
||||
"hex.builtin.information_section.info_analysis.file_entropy": "",
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "最大エントロピーブロック",
|
||||
"hex.builtin.information_section.info_analysis": "情報の分析",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "",
|
||||
"hex.builtin.information_section.magic": "Magic情報",
|
||||
"hex.builtin.view.information.magic_db_added": "Magicデータベースが追加されました。",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "바이트 유형",
|
||||
"hex.builtin.view.information.control": "제어",
|
||||
"hex.builtin.information_section.magic.description": "설명",
|
||||
"hex.builtin.information_section.info_analysis.digram": "다이어그램",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "다이어그램",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "바이트 분포",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "이 데이터는 암호화 또는 압축되어 있을 가능성이 높습니다!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "엔트로피",
|
||||
@ -847,7 +847,7 @@
|
||||
"hex.builtin.information_section.info_analysis.file_entropy": "전체 엔트로피",
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "최고 블록 엔트로피",
|
||||
"hex.builtin.information_section.info_analysis": "정보 분석",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "계층화 분포",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "계층화 분포",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "최저 블록 엔트로피",
|
||||
"hex.builtin.information_section.magic": "Magic 정보",
|
||||
"hex.builtin.view.information.magic_db_added": "Magic 데이터베이스 추가됨!",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "",
|
||||
"hex.builtin.view.information.control": "Controle",
|
||||
"hex.builtin.information_section.magic.description": "Descrição",
|
||||
"hex.builtin.information_section.info_analysis.digram": "",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "Byte distribution",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "Esses dados provavelmente estão criptografados ou compactados!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "Entropy",
|
||||
@ -847,7 +847,7 @@
|
||||
"hex.builtin.information_section.info_analysis.file_entropy": "",
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "Highest block entropy",
|
||||
"hex.builtin.information_section.info_analysis": "Análise de Informações",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "",
|
||||
"hex.builtin.information_section.magic": "Informação Mágica",
|
||||
"hex.builtin.view.information.magic_db_added": "Magic database added!",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "字节类型",
|
||||
"hex.builtin.view.information.control": "控制",
|
||||
"hex.builtin.information_section.magic.description": "描述",
|
||||
"hex.builtin.information_section.info_analysis.digram": "图",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "图",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "字节分布",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "此数据似乎经过了加密或压缩!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "熵",
|
||||
@ -847,7 +847,7 @@
|
||||
"hex.builtin.information_section.info_analysis.file_entropy": "整体熵",
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "最高区块熵",
|
||||
"hex.builtin.information_section.info_analysis": "信息分析",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "分层分布",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "分层分布",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "最低区块熵",
|
||||
"hex.builtin.information_section.magic": "LibMagic 信息",
|
||||
"hex.builtin.view.information.magic_db_added": "LibMagic 数据库已添加!",
|
||||
|
@ -839,7 +839,7 @@
|
||||
"hex.builtin.information_section.info_analysis.byte_types": "",
|
||||
"hex.builtin.view.information.control": "控制",
|
||||
"hex.builtin.information_section.magic.description": "說明",
|
||||
"hex.builtin.information_section.info_analysis.digram": "",
|
||||
"hex.builtin.information_section.relationship_analysis.digram": "",
|
||||
"hex.builtin.information_section.info_analysis.distribution": "位元組分佈",
|
||||
"hex.builtin.information_section.info_analysis.encrypted": "此資料很有可能經過加密或壓縮!",
|
||||
"hex.builtin.information_section.info_analysis.entropy": "熵",
|
||||
@ -847,7 +847,7 @@
|
||||
"hex.builtin.information_section.info_analysis.file_entropy": "",
|
||||
"hex.builtin.information_section.info_analysis.highest_entropy": "Highest block entropy",
|
||||
"hex.builtin.information_section.info_analysis": "資訊分析",
|
||||
"hex.builtin.information_section.info_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.relationship_analysis.layered_distribution": "",
|
||||
"hex.builtin.information_section.info_analysis.lowest_entropy": "",
|
||||
"hex.builtin.information_section.magic": "Magic Information",
|
||||
"hex.builtin.view.information.magic_db_added": "Magic database added!",
|
||||
|
@ -160,8 +160,6 @@ namespace hex::plugin::builtin {
|
||||
m_blockSize = std::max<u32>(std::ceil(region.getSize() / 2048.0F), 256);
|
||||
|
||||
m_byteDistribution.reset();
|
||||
m_digram.reset(region.getSize());
|
||||
m_layeredDistribution.reset(region.getSize());
|
||||
m_byteTypesDistribution.reset(region.getStartAddress(), region.getEndAddress(), provider->getBaseAddress(), provider->getActualSize());
|
||||
m_chunkBasedEntropy.reset(m_inputChunkSize, region.getStartAddress(), region.getEndAddress(),
|
||||
provider->getBaseAddress(), provider->getActualSize());
|
||||
@ -177,8 +175,6 @@ namespace hex::plugin::builtin {
|
||||
m_byteDistribution.update(byte);
|
||||
m_byteTypesDistribution.update(byte);
|
||||
m_chunkBasedEntropy.update(byte);
|
||||
m_layeredDistribution.update(byte);
|
||||
m_digram.update(byte);
|
||||
task.update();
|
||||
}
|
||||
|
||||
@ -318,21 +314,6 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
auto availableWidth = ImGui::GetContentRegionAvail().x;
|
||||
ImGui::BeginGroup();
|
||||
{
|
||||
ImGui::TextUnformatted("hex.builtin.information_section.info_analysis.digram"_lang);
|
||||
m_digram.draw({ availableWidth, availableWidth });
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::BeginGroup();
|
||||
{
|
||||
ImGui::TextUnformatted("hex.builtin.information_section.info_analysis.layered_distribution"_lang);
|
||||
m_layeredDistribution.draw({ availableWidth, availableWidth });
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
void load(const nlohmann::json &data) override {
|
||||
@ -360,17 +341,119 @@ namespace hex::plugin::builtin {
|
||||
u64 m_lowestBlockEntropyAddress = 0x00;
|
||||
double m_plainTextCharacterPercentage = -1.0;
|
||||
|
||||
DiagramDigram m_digram;
|
||||
DiagramLayeredDistribution m_layeredDistribution;
|
||||
DiagramByteDistribution m_byteDistribution;
|
||||
DiagramByteTypesDistribution m_byteTypesDistribution;
|
||||
DiagramChunkBasedEntropyAnalysis m_chunkBasedEntropy;
|
||||
};
|
||||
|
||||
class InformationByteRelationshipAnalysis : public ContentRegistry::DataInformation::InformationSection {
|
||||
public:
|
||||
InformationByteRelationshipAnalysis() : InformationSection("hex.builtin.information_section.relationship_analysis", "", true) {
|
||||
|
||||
}
|
||||
~InformationByteRelationshipAnalysis() override {
|
||||
}
|
||||
|
||||
void process(Task &task, prv::Provider *provider, Region region) override {
|
||||
updateSettings();
|
||||
m_digram.reset(region.getSize());
|
||||
m_layeredDistribution.reset(region.getSize());
|
||||
|
||||
// Create a handle to the file
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(region.getStartAddress());
|
||||
reader.setEndAddress(region.getEndAddress());
|
||||
|
||||
// Loop over each byte of the selection and update each analysis
|
||||
// one byte at a time to process the file only once
|
||||
for (u8 byte : reader) {
|
||||
m_layeredDistribution.update(byte);
|
||||
m_digram.update(byte);
|
||||
task.update();
|
||||
}
|
||||
}
|
||||
|
||||
void reset() override {
|
||||
m_digram.reset(0);
|
||||
m_layeredDistribution.reset(0);
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
void drawSettings() override {
|
||||
if (ImGuiExt::InputHexadecimal("hex.builtin.information_section.relationship_analysis.sample_size"_lang, &m_sampleSize)) {
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
if (ImGui::SliderFloat("hex.builtin.information_section.relationship_analysis.brightness"_lang, &m_brightness, 0.0F, 1.0F)) {
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Combo("hex.builtin.information_section.relationship_analysis.filter"_lang, reinterpret_cast<int*>(&m_filter), "Nearest\0Linear\0\0")) {
|
||||
updateSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void drawContent() override {
|
||||
auto availableWidth = ImGui::GetContentRegionAvail().x;
|
||||
ImGui::BeginGroup();
|
||||
{
|
||||
ImGui::TextUnformatted("hex.builtin.information_section.relationship_analysis.digram"_lang);
|
||||
m_digram.draw({ availableWidth, availableWidth });
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::BeginGroup();
|
||||
{
|
||||
ImGui::TextUnformatted("hex.builtin.information_section.relationship_analysis.layered_distribution"_lang);
|
||||
m_layeredDistribution.draw({ availableWidth, availableWidth });
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
void load(const nlohmann::json &data) override {
|
||||
InformationSection::load(data);
|
||||
|
||||
m_filter = data.value("filter", ImGuiExt::Texture::Filter::Nearest);
|
||||
m_sampleSize = data.value("sample_size", 0x9000);
|
||||
m_brightness = data.value("brightness", 0.5F);
|
||||
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
nlohmann::json store() override {
|
||||
auto result = InformationSection::store();
|
||||
result["sample_size"] = m_sampleSize;
|
||||
result["brightness"] = m_brightness;
|
||||
result["filter"] = m_filter;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
void updateSettings() {
|
||||
m_digram.setFiltering(m_filter);
|
||||
m_digram.setSampleSize(m_sampleSize);
|
||||
m_digram.setBrightness(m_brightness);
|
||||
|
||||
m_layeredDistribution.setFiltering(m_filter);
|
||||
m_layeredDistribution.setSampleSize(m_sampleSize);
|
||||
m_layeredDistribution.setBrightness(m_brightness);
|
||||
}
|
||||
|
||||
private:
|
||||
ImGuiExt::Texture::Filter m_filter = ImGuiExt::Texture::Filter::Nearest;
|
||||
u64 m_sampleSize = 0x9000;
|
||||
float m_brightness = 0.5F;
|
||||
|
||||
DiagramDigram m_digram;
|
||||
DiagramLayeredDistribution m_layeredDistribution;
|
||||
};
|
||||
|
||||
void registerDataInformationSections() {
|
||||
ContentRegistry::DataInformation::addInformationSection<InformationProvider>();
|
||||
ContentRegistry::DataInformation::addInformationSection<InformationMagic>();
|
||||
ContentRegistry::DataInformation::addInformationSection<InformationByteAnalysis>();
|
||||
ContentRegistry::DataInformation::addInformationSection<InformationByteRelationshipAnalysis>();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user