dz6 0.8.0

Fast Vim-inspired hex editor for the terminal
use std::collections::HashMap;

use ratatui::widgets::TableState;

#[derive(Debug, Clone)]
pub struct PEImport {
    pub dll: String,
    pub name: String,
    pub offset: usize,
    pub ordinal: u16,
    pub rva: usize,
    pub _size: usize,
}

#[derive(Debug, Clone)]
pub struct PEExport {
    pub name: String,
    pub offset: usize,
    pub rva: usize,
    pub size: usize,
}

#[derive(Debug, Clone)]
pub struct Pe {
    pub dos_header: goblin::pe::header::DosHeader,
    pub coff_header: goblin::pe::header::CoffHeader,
    pub optional_header: Option<goblin::pe::optional_header::OptionalHeader>,
    pub sections: Vec<goblin::pe::section_table::SectionTable>,
    pub imports: Vec<PEImport>,
    pub exports: Vec<PEExport>,
}

#[derive(Debug, Clone)]
pub struct Elf {
    pub header: goblin::elf::Header,
    pub phdrs: goblin::elf::ProgramHeaders,
    pub sections: goblin::elf::SectionHeaders,
    pub dynsymtab: Vec<goblin::elf::Sym>,
    pub dynstrtab: HashMap<usize, String>,
    pub symtab: Vec<goblin::elf::Sym>,
    pub strtab: HashMap<usize, String>,
    // for more detailed relactions, we need goblin::elf::reloc::reloc32::Rel, etc
    // but we need to think about how to show it in Relocations tab
    pub relocs: Vec<goblin::elf::reloc::Reloc>,
}

#[derive(Debug, Default)]
pub struct PeState {
    pub dos_header_table_state: TableState,
    pub coff_header_table_state: TableState,
    pub optional_header_table_state: TableState,
    pub data_dirs_table_state: TableState,
    pub sections_table_state: TableState,
    pub imports_table_sate: TableState,
    pub exports_table_sate: TableState,
    pub overlay_table_sate: TableState,
}

#[derive(Debug, Default)]
pub struct ElfState {
    pub elf_header_table_state: TableState,
    pub program_header_table_state: TableState,
    pub sections_table_state: TableState,
    pub symbols_table_state: TableState,
    pub relocations_table_state: TableState,
}

#[derive(Default, Debug)]
pub struct HeaderView {
    pub pe: Option<Pe>,
    pub elf: Option<Elf>,
    pub elf_state: ElfState,
    pub pe_state: PeState,
    pub tab_index: usize,
}