summaryrefslogtreecommitdiff
path: root/rust/examples/minidump/src/lib.rs
blob: 9d8b4054a4f989708d490abae0ca82e84810423d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use binaryninja::binaryview::BinaryView;
use binaryninja::command::{register, Command};
use binaryninja::custombinaryview::register_view_type;
use log::{debug, LevelFilter};

mod command;
mod view;

struct PrintMemoryInformationCommand;

impl Command for PrintMemoryInformationCommand {
    fn action(&self, binary_view: &BinaryView) {
        command::print_memory_information(binary_view);
    }

    fn valid(&self, _binary_view: &BinaryView) -> bool {
        true // TODO: Of course, the command will not always be valid!
    }
}

#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
    binaryninja::logger::init(LevelFilter::Trace).expect("failed to initialize logging");

    debug!("Registering minidump binary view type");
    register_view_type("Minidump", "Minidump", view::MinidumpBinaryViewType::new);

    debug!("Registering minidump plugin commands");
    register(
        "Minidump\\[DEBUG] Print Minidump Memory Information",
        "Print a human-readable description of the contents of the MinidumpMemoryInfoList stream in the loaded minidump",
        PrintMemoryInformationCommand {},
    );

    true
}