├── .cargo
└── config.toml
├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
├── assets
├── iconx256.icns
├── iconx256.ico
├── iconx256.png
├── iconx64.png
├── logo_dark.png
├── logo_light.png
├── logo_text_dark.svg
├── logo_text_light.svg
├── screenshot.png
└── split_source.png
├── binformat
├── Cargo.toml
└── src
│ ├── elf.rs
│ ├── lib.rs
│ ├── macho.rs
│ └── pe.rs
├── build.rs
├── bundle.sh
├── commands
├── Cargo.toml
└── src
│ ├── cli.rs
│ ├── debug.rs
│ ├── gui.rs
│ └── lib.rs
├── config
├── Cargo.toml
└── src
│ └── lib.rs
├── debugvault
├── Cargo.toml
├── bin
│ ├── dsymutil_aarch64
│ └── dsymutil_x86_64
└── src
│ ├── demangler.rs
│ ├── dwarf.rs
│ ├── error.rs
│ ├── intern.rs
│ ├── itanium
│ ├── ast.rs
│ ├── error.rs
│ ├── index_str.rs
│ ├── mod.rs
│ ├── subs.rs
│ └── tests.rs
│ ├── lib.rs
│ ├── msvc
│ ├── context.rs
│ ├── mod.rs
│ └── tests.rs
│ ├── pdb.rs
│ ├── prefix.rs
│ ├── rust
│ ├── mod.rs
│ └── tests.rs
│ └── rust_legacy
│ ├── mod.rs
│ └── tests.rs
├── decoder-arm
├── Cargo.toml
├── src
│ ├── armv7.rs
│ ├── armv7
│ │ └── thumb.rs
│ ├── armv8
│ │ ├── a64.rs
│ │ └── mod.rs
│ └── lib.rs
└── tests
│ ├── armv7
│ ├── mod.rs
│ └── thumb.rs
│ ├── armv8
│ ├── a64.rs
│ └── mod.rs
│ └── test.rs
├── decoder-mips
├── Cargo.toml
└── src
│ ├── lib.rs
│ └── tests.rs
├── decoder-riscv
├── Cargo.toml
└── src
│ ├── lib.rs
│ └── tests.rs
├── decoder-x86_64
├── Cargo.toml
└── src
│ ├── lib.rs
│ ├── long_mode
│ ├── display.rs
│ ├── evex.rs
│ ├── mod.rs
│ ├── tests
│ │ ├── evex_generated.rs
│ │ ├── mod.rs
│ │ ├── opcode.rs
│ │ ├── operand.rs
│ │ └── regspec.rs
│ ├── uarch.rs
│ └── vex.rs
│ ├── protected_mode
│ ├── display.rs
│ ├── evex.rs
│ ├── mod.rs
│ ├── tests
│ │ ├── evex_generated.rs
│ │ ├── mod.rs
│ │ ├── opcode.rs
│ │ ├── operand.rs
│ │ └── regspec.rs
│ ├── uarch.rs
│ └── vex.rs
│ └── safer_unchecked.rs
├── decoder
├── Cargo.toml
└── src
│ └── lib.rs
├── example_config.yaml
├── gui
├── Cargo.toml
├── fonts
│ ├── Hack-Regular.ttf
│ ├── IcoMoon.ttf
│ └── LigaSFMonoNerdFont-Regular.ttf
└── src
│ ├── common.rs
│ ├── fmt.rs
│ ├── icon.rs
│ ├── interp.rs
│ ├── lib.rs
│ ├── panes
│ ├── functions.rs
│ ├── listing.rs
│ ├── mod.rs
│ └── source_code.rs
│ ├── style.rs
│ ├── unix.rs
│ ├── wgpu_backend
│ ├── egui.rs
│ ├── egui.wgsl
│ └── mod.rs
│ ├── widgets
│ ├── donut.rs
│ ├── mod.rs
│ ├── terminal.rs
│ ├── text_edit.rs
│ └── text_select.rs
│ ├── windows.rs
│ └── winit_backend.rs
├── infinite_scroll
├── Cargo.toml
└── src
│ ├── egui_inbox.rs
│ ├── egui_virtual_list.rs
│ └── lib.rs
├── log
├── Cargo.toml
└── src
│ ├── lib.rs
│ └── progress.rs
├── processor
├── Cargo.toml
└── src
│ ├── blocks.rs
│ ├── fmt.rs
│ └── lib.rs
├── processor_shared
├── Cargo.toml
└── src
│ └── lib.rs
├── rustfmt.toml
├── src
├── main.rs
└── wayland.rs
└── tokenizing
├── Cargo.toml
└── src
└── lib.rs
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [target.'cfg(all())']
2 | rustflags = [
3 | "-Aclippy::unusual_byte_groupings",
4 | "-Aclippy::upper_case_acronyms",
5 | "-Aclippy::needless_range_loop",
6 | "-Aclippy::new_without_default",
7 | "-Ctarget-cpu=native",
8 | ]
9 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | - pull_request
4 | - push
5 | env:
6 | CARGO_TERM_COLOR: always
7 | jobs:
8 | build-ubuntu:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: Checking out repo
12 | uses: actions/checkout@v4
13 | - name: Checking out rust toolchain
14 | uses: dtolnay/rust-toolchain@stable
15 | with:
16 | toolchain: stable
17 | components: rustfmt
18 | - name: Caching cargo
19 | uses: Swatinem/rust-cache@v2
20 | - name: Install dependencies
21 | run: sudo apt-get install libgtk-3-dev
22 | - name: Build
23 | run: cargo build --release
24 | - name: Upload binary
25 | uses: actions/upload-artifact@v4
26 | with:
27 | name: Linux build
28 | path: ./target/release/bite
29 | build-macos:
30 | runs-on: macos-latest
31 | steps:
32 | - name: Checking out repo
33 | uses: actions/checkout@v4
34 | - name: Checking out rust toolchain
35 | uses: dtolnay/rust-toolchain@stable
36 | with:
37 | toolchain: stable
38 | components: rustfmt
39 | - name: Caching cargo
40 | uses: Swatinem/rust-cache@v2
41 | - name: Build
42 | run: cargo build --release
43 | - name: Upload binary
44 | uses: actions/upload-artifact@v4
45 | with:
46 | name: MacOS build
47 | path: ./target/release/bite
48 | build-windows:
49 | runs-on: windows-latest
50 | steps:
51 | - name: Checking out repo
52 | uses: actions/checkout@v4
53 | - name: Checking out rust toolchain
54 | uses: dtolnay/rust-toolchain@stable
55 | with:
56 | toolchain: stable
57 | components: rustfmt
58 | - name: Caching cargo
59 | uses: Swatinem/rust-cache@v2
60 | - name: Build
61 | run: cargo build --release
62 | - name: Upload binary
63 | uses: actions/upload-artifact@v4
64 | with:
65 | name: Windows build
66 | path: ./target/release/bite.exe
67 | test-ubuntu:
68 | runs-on: ubuntu-latest
69 | steps:
70 | - name: Checking out repo
71 | uses: actions/checkout@v4
72 | - name: Checking out rust toolchain
73 | uses: dtolnay/rust-toolchain@stable
74 | with:
75 | toolchain: stable
76 | targets: riscv64gc-unknown-none-elf
77 | - name: Caching cargo
78 | uses: Swatinem/rust-cache@v2
79 | - name: Install dependencies
80 | run: sudo apt-get install libgtk-3-dev
81 | - name: Test
82 | run: cargo test --workspace --lib
83 | test-macos:
84 | runs-on: macos-latest
85 | steps:
86 | - name: Checking out repo
87 | uses: actions/checkout@v4
88 | - name: Checking out rust toolchain
89 | uses: dtolnay/rust-toolchain@stable
90 | with:
91 | toolchain: stable
92 | targets: riscv64gc-unknown-none-elf
93 | - name: Caching cargo
94 | uses: Swatinem/rust-cache@v2
95 | - name: Test
96 | run: cargo test --workspace --lib
97 | test-windows:
98 | runs-on: windows-latest
99 | steps:
100 | - name: Checking out repo
101 | uses: actions/checkout@v4
102 | - name: Checking out rust toolchain
103 | uses: dtolnay/rust-toolchain@stable
104 | with:
105 | toolchain: stable
106 | targets: riscv64gc-unknown-none-elf
107 | - name: Caching cargo
108 | uses: Swatinem/rust-cache@v2
109 | - name: Test
110 | run: cargo test --workspace --lib
111 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /.vs
3 | *.swp
4 | *~
5 | .vscode/settings.json
6 | .DS_Store
7 | #Jetbrains IntelliJ/RustRover
8 | .idea/
9 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "bite"
3 | description = "Disassembler"
4 | version = "0.3.0"
5 | edition = "2021"
6 |
7 | [dependencies]
8 | nix = { workspace = true }
9 | object = { workspace = true }
10 | commands = { path = "./commands" }
11 | log = { path = "./log" }
12 | gui = { path = "./gui" }
13 | debugvault = { path = "./debugvault" }
14 |
15 | [profile.release]
16 | lto = 'thin'
17 |
18 | [target.'cfg(windows)'.build-dependencies]
19 | winres = "0.1"
20 |
21 | [workspace]
22 | resolver = "2"
23 | members = [
24 | "log",
25 | "gui",
26 | "commands",
27 | "tokenizing",
28 | "decoder",
29 | "decoder-x86_64",
30 | "decoder-arm",
31 | "decoder-riscv",
32 | "decoder-mips",
33 | "debugvault",
34 | "processor",
35 | "processor_shared",
36 | "infinite_scroll",
37 | "binformat",
38 | "config"
39 | ]
40 |
41 | [workspace.dependencies]
42 | egui = { version = "0.27", features = ["bytemuck"], default-features = false }
43 | rfd = "0.14"
44 | crossbeam-queue = "0.3"
45 | object = "0.32"
46 | gimli = "0.28"
47 | pdb = { git = "https://github.com/WINSDK/pdb-rs" }
48 | once_cell = "1.18"
49 | nix = { git = "https://github.com/mbyzhang/nix" }
50 | memmap2 = "0.9"
51 | dirs = "5"
52 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2023 Nicolas Mazzon
2 |
3 | Permission is hereby granted, free of charge, to any
4 | person obtaining a copy of this software and associated
5 | documentation files (the "Software"), to deal in the
6 | Software without restriction, including without
7 | limitation the rights to use, copy, modify, merge,
8 | publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software
10 | is furnished to do so, subject to the following
11 | conditions:
12 |
13 | The above copyright notice and this permission notice
14 | shall be included in all copies or substantial portions
15 | of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 | DEALINGS IN THE SOFTWARE.
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Ever wanted to inspect every bite of your binary.
13 |
14 | [](https://github.com/WINSDK/bite/actions/workflows/ci.yml)
15 | 
16 |
17 | `BiTE` is a platform-agnostic executable analysis tool. It aims to offer an
18 | environment for inspecting the content of binaries and their debug info. While it is
19 | still in early development, various architectures are supported.
20 |
21 | ## Showcase
22 |
23 | Here is an example of the assembly listing viewing.
24 |
25 | 
26 |
27 | The ability to view a binary's disassembly and the associated source code.
28 |
29 | 
30 |
31 | ## Installation
32 |
33 | Building from source.
34 | ```
35 | cargo install --path .
36 | ```
37 |
38 | ## Features yet to be implemented
39 |
40 | Whenever I have time this year I'll try implementing most of these. \
41 | If you feel like it, submit a pull request and I'll have a look at it!
42 |
43 | - [x] Port GUI to wgpu + winit
44 | - [x] Header with buttons and options
45 | - [x] Assembly listing exploration
46 | - [x] Interactive terminal
47 | - [ ] Assembly instruction byte patching
48 | - [x] Hex binary viewer
49 | - [ ] Debugging front-end's
50 | - [ ] [GDB](https://www.sourceware.org/gdb)
51 | - [ ] [LLDB](https://lldb.llvm.org)
52 | - [ ] [WinDbg](https://windbg.org)
53 | - [x] X86-64 support
54 | - [x] AArch64/Armv7 support
55 | - [x] Riscv64gc/Riscv32gc support
56 | - [x] MIPS-V support
57 | - [x] Demangling support for most targets
58 | - [x] MSVC
59 | - [x] Itanium
60 | - [x] Rust
61 | - [x] Decoding datastructures depending on each section
62 | - [ ] Assembly listing lifting
63 | - [x] Resolving addresses
64 | - [x] Interpreting non-code data
65 | - [ ] Creating labels for relative jumps
66 |
--------------------------------------------------------------------------------
/assets/iconx256.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/iconx256.icns
--------------------------------------------------------------------------------
/assets/iconx256.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/iconx256.ico
--------------------------------------------------------------------------------
/assets/iconx256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/iconx256.png
--------------------------------------------------------------------------------
/assets/iconx64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/iconx64.png
--------------------------------------------------------------------------------
/assets/logo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/logo_dark.png
--------------------------------------------------------------------------------
/assets/logo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/logo_light.png
--------------------------------------------------------------------------------
/assets/logo_text_dark.svg:
--------------------------------------------------------------------------------
1 |
12 |
--------------------------------------------------------------------------------
/assets/logo_text_light.svg:
--------------------------------------------------------------------------------
1 |
12 |
--------------------------------------------------------------------------------
/assets/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/screenshot.png
--------------------------------------------------------------------------------
/assets/split_source.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WINSDK/bite/20b4f68252c7f6c36c831ea925c78fd7819f5c17/assets/split_source.png
--------------------------------------------------------------------------------
/binformat/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "binformat"
3 | version = "0.0.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | processor_shared = { path = "../processor_shared" }
8 | log = { path = "../log" }
9 | object = { workspace = true }
10 |
--------------------------------------------------------------------------------
/binformat/src/lib.rs:
--------------------------------------------------------------------------------
1 | use object::{Object, ObjectSection, ObjectSymbol};
2 | use processor_shared::{AddressMap, Addressed};
3 |
4 | pub mod elf;
5 | pub mod macho;
6 | pub mod pe;
7 |
8 | pub struct RawSymbol<'data> {
9 | pub name: &'data str,
10 | pub module: Option<&'data str>,
11 | }
12 |
13 | fn parse_symbol_table<'data, Obj: Object<'data, 'data>>(
14 | obj: &'data Obj,
15 | ) -> AddressMap> {
16 | let mut syms = AddressMap::default();
17 | for sym in obj.symbols() {
18 | match sym.name() {
19 | Ok(name) => syms.push(Addressed {
20 | addr: sym.address() as usize,
21 | item: RawSymbol { name, module: None },
22 | }),
23 | Err(err) => {
24 | log::complex!(
25 | w "[parse_symbol_table] ",
26 | y err.to_string(),
27 | y "."
28 | );
29 | continue;
30 | }
31 | }
32 | }
33 | syms
34 | }
35 |
36 | fn parse_section_generics<'data, Obj: ObjectSection<'data>>(
37 | section: &'data Obj,
38 | ) -> (String, &'static [u8], usize, usize) {
39 | let name = match section.name() {
40 | Ok(name) => name,
41 | Err(_) => {
42 | log::complex!(
43 | w "[macho::parse_sections] ",
44 | y "Failed to read name.",
45 | );
46 | "unknown"
47 | }
48 | };
49 |
50 | let bytes: &'static [u8] = match section.data() {
51 | // The file is memory mapped so only the bytes are of lifetime &'static [u8].
52 | Ok(data) => unsafe { std::mem::transmute(data) },
53 | Err(..) => {
54 | log::complex!(
55 | w "[macho::parse_sections] ",
56 | y "Failed to read section ",
57 | b name,
58 | y "."
59 | );
60 | &[]
61 | }
62 | };
63 |
64 | let start = section.address() as usize;
65 | let end = start + section.size() as usize;
66 |
67 | (name.to_string(), bytes, start, end)
68 | }
69 |
70 | pub struct Datastructure {
71 | pub ident: &'static str,
72 | pub fields: Vec<(usize, &'static str, &'static str, String)>,
73 | }
74 |
75 | pub trait ToData {
76 | fn to_fields(&self, addr: usize) -> Datastructure;
77 | }
78 |
79 | // FIXME: This assumes little endianness.
80 | #[macro_export]
81 | macro_rules! datastructure {
82 | (
83 | pub struct $name:ident {
84 | $($field:ident: $ftype:ty,)*
85 | }
86 | ) => {
87 | // Apply attributes to the struct
88 | #[repr(C)]
89 | #[derive(Copy, Clone, Debug)]
90 | pub struct $name {
91 | pub $($field: $ftype),*
92 | }
93 |
94 | impl $crate::ToData for $name {
95 | fn to_fields(&self, mut addr: usize) -> $crate::Datastructure {
96 | let mut fields = Vec::new();
97 | $(
98 | fields.push((
99 | addr,
100 | stringify!($field),
101 | stringify!($ftype),
102 | format!("{:#x}", self.$field)
103 | ));
104 | #[allow(unused_assignments)]
105 | { addr += ::std::mem::size_of::<$ftype>(); }
106 | )*
107 | $crate::Datastructure {
108 | ident: stringify!($name),
109 | fields,
110 | }
111 | }
112 | }
113 |
114 | unsafe impl object::Pod for $name {}
115 | };
116 | }
117 |
--------------------------------------------------------------------------------
/binformat/src/pe.rs:
--------------------------------------------------------------------------------
1 | use crate::{datastructure, RawSymbol};
2 | use processor_shared::{AddressMap, Addressed, Section, SectionKind};
3 | use object::pe;
4 | use object::read::pe::{ImageNtHeaders, ImageThunkData, PeFile};
5 | use object::LittleEndian as LE;
6 | use object::Object;
7 | use std::mem::size_of;
8 |
9 | datastructure! {
10 | pub struct ExceptionDirectoryEntry {
11 | begin_addr: u32,
12 | end_addr: u32,
13 | unwind_info: u32,
14 | }
15 | }
16 |
17 | pub struct PeDebugInfo<'data, Pe: ImageNtHeaders> {
18 | /// Parsed PE32/64 header.
19 | obj: &'data PeFile<'data, Pe>,
20 | /// Parsed sections with extra metadata.
21 | pub sections: Vec,
22 | /// Any parsed but not yet relocated symbols.
23 | pub syms: AddressMap>,
24 | }
25 |
26 | impl<'data, Pe: ImageNtHeaders> PeDebugInfo<'data, Pe> {
27 | pub fn parse(obj: &'data PeFile<'data, Pe>) -> Result {
28 | let mut this = Self {
29 | obj,
30 | syms: AddressMap::default(),
31 | sections: Vec::new(),
32 | };
33 | this.sections = parse_sections(obj);
34 | this.parse_symbols();
35 | this.parse_imports()?;
36 | Ok(this)
37 | }
38 |
39 | pub fn parse_imports(&mut self) -> Result<(), object::Error> {
40 | let import_table = match self.obj.import_table()? {
41 | Some(table) => table,
42 | None => return Ok(()),
43 | };
44 |
45 | let mut import_descs = import_table.descriptors()?;
46 | while let Some(import_desc) = import_descs.next()? {
47 | let module = import_table.name(import_desc.name.get(LE))?;
48 | let first_thunk = import_desc.first_thunk.get(LE);
49 | let original_first_thunk = import_desc.original_first_thunk.get(LE);
50 |
51 | let thunk = if first_thunk == 0 {
52 | original_first_thunk
53 | } else {
54 | first_thunk
55 | };
56 |
57 | let mut import_addr_table = import_table.thunks(thunk)?;
58 | let mut func_rva = first_thunk;
59 | while let Some(func) = import_addr_table.next::()? {
60 | if !func.is_ordinal() {
61 | let (hint, name) = match import_table.hint_name(func.address()) {
62 | Ok(val) => val,
63 | Err(..) => {
64 | // skip over an entry
65 | func_rva += size_of::() as u32;
66 | continue;
67 | }
68 | };
69 |
70 | let name = match std::str::from_utf8(name) {
71 | Ok(name) => name,
72 | Err(..) => {
73 | // skip over an entry
74 | func_rva += size_of::() as u32;
75 | continue;
76 | }
77 | };
78 |
79 | // `original_first_thunk` uses a `hint` into the export
80 | // table whilst iterating thourhg regular `thunk`'s is
81 | // a simple offset into the symbol export table
82 | let addr = if thunk == original_first_thunk {
83 | hint as u64 + self.obj.relative_address_base()
84 | } else {
85 | func_rva as u64 + self.obj.relative_address_base()
86 | };
87 |
88 | let module =
89 | std::str::from_utf8(module).ok().and_then(|x| x.strip_suffix(".dll"));
90 | self.syms.push(Addressed {
91 | addr: addr as usize,
92 | item: RawSymbol { name, module },
93 | });
94 | }
95 |
96 | // skip over an entry
97 | func_rva += size_of::() as u32;
98 | }
99 | }
100 |
101 | Ok(())
102 | }
103 |
104 | pub fn parse_symbols(&mut self) {
105 | self.syms.extend(crate::parse_symbol_table(self.obj));
106 | self.syms.push(Addressed {
107 | addr: self.obj.entry() as usize,
108 | item: RawSymbol {
109 | name: "entry",
110 | module: None,
111 | },
112 | });
113 | }
114 | }
115 |
116 | /// Common ELF dwarf section names I've found so far.
117 | const DWARF_SECTIONS: [&str; 20] = [
118 | ".debug_abbrev",
119 | ".debug_addr",
120 | ".debug_aranges",
121 | ".debug_cu_index",
122 | ".debug_frame",
123 | ".debug_info",
124 | ".debug_line",
125 | ".debug_line_str",
126 | ".debug_loc",
127 | ".debug_loclists",
128 | ".debug_macinfo",
129 | ".debug_macro",
130 | ".debug_pubnames",
131 | ".debug_pubtypes",
132 | ".debug_ranges",
133 | ".debug_rnglists",
134 | ".debug_str",
135 | ".debug_str_offsets",
136 | ".debug_tu_index",
137 | ".debug_types",
138 | ];
139 |
140 | fn parse_sections<'data, Pe: ImageNtHeaders>(obj: &'data PeFile<'data, Pe>) -> Vec {
141 | let mut sections = Vec::new();
142 |
143 | // Re-parsing all this data isn't amazing, all this just for getting the section headers.
144 | let data = obj.data();
145 | let dos_header = object::pe::ImageDosHeader::parse(data).unwrap();
146 | let mut offset = dos_header.nt_headers_offset().into();
147 | let (nt_headers, _) = Pe::parse(data, &mut offset).unwrap();
148 | let section_headers = nt_headers.sections(data, offset).unwrap();
149 |
150 | for (header, section) in section_headers.iter().zip(obj.sections()) {
151 | let (name, bytes, start, end) = crate::parse_section_generics(§ion);
152 |
153 | let characteristics = header.characteristics.get(LE);
154 | let (mut kind, ident) = (SectionKind::Raw, "UNKNOWN");
155 |
156 | // Section contains code.
157 | if characteristics & pe::IMAGE_SCN_CNT_CODE != 0 {
158 | kind = SectionKind::Code;
159 | }
160 |
161 | // ExceptionDirectoryEntry's.
162 | if name == ".pdata" {
163 | kind = SectionKind::ExceptionDirEntry;
164 | }
165 |
166 | // Section contains DWARF debug info.
167 | if DWARF_SECTIONS.contains(&name.as_str()) {
168 | kind = SectionKind::Debug;
169 | }
170 |
171 | sections.push(Section::new(
172 | name,
173 | ident,
174 | kind,
175 | bytes,
176 | start,
177 | end
178 | ));
179 | }
180 |
181 | sections
182 | }
183 |
--------------------------------------------------------------------------------
/build.rs:
--------------------------------------------------------------------------------
1 | fn main() {
2 | #[cfg(target_family = "windows")]
3 | winres::WindowsResource::new()
4 | .set_icon("./assets/iconx256.ico")
5 | .compile()
6 | .unwrap();
7 | }
8 |
--------------------------------------------------------------------------------
/bundle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Creates macos bundle in ./target/bite.app.
3 |
4 | set -e
5 | mkdir -p ./target/bite.app/Contents/MacOS
6 | mkdir -p ./target/bite.app/Contents/Resources
7 | cp ./target/release/bite ./target/bite.app/Contents/MacOS/bite
8 | cp ./assets/iconx256.icns ./target/bite.app/Contents/Resources/shortcut.icns
9 | cat > ./target/bite.app/Contents/Info.plist <
11 |
12 |
13 |
14 | CFBundleExecutable
15 | bite
16 | CFBundleIconFile
17 | shortcut.icns
18 | CFBundleInfoDictionaryVersion
19 | 1.0
20 | CFBundlePackageType
21 | APPL
22 | CFBundleSignature
23 | ????
24 | CFBundleVersion
25 | 1.0
26 |
27 |
28 | EOF
29 |
--------------------------------------------------------------------------------
/commands/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "commands"
3 | version = "0.0.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | triple_accel = "0.4"
8 | debugvault = { path = "../debugvault" }
9 | log = { path = "../log" }
10 | dirs = { workspace = true }
11 | once_cell = { workspace = true }
12 | egui = { workspace = true }
13 |
--------------------------------------------------------------------------------
/commands/src/cli.rs:
--------------------------------------------------------------------------------
1 | use std::path::{Path, PathBuf};
2 |
3 | macro_rules! exit {
4 | ($code:expr => $($arg:tt)*) => {{
5 | eprintln!($($arg)*);
6 | std::process::exit($code);
7 | }};
8 | }
9 |
10 | const HELP: &str = "OVERVIEW: Debugger/Decompilation tool
11 |
12 | USAGE: bite [options]