summaryrefslogtreecommitdiff
path: root/rust/examples/minidump/src/lib.rs
diff options
context:
space:
mode:
authorCindy Xiao <git@cxiao.net>2023-02-11 11:25:38 -0800
committerKyle Martin <krm504@nyu.edu>2023-02-20 10:45:04 -0500
commit56996b0617c499178b463eb27973e7b12a056ffc (patch)
tree9035cee98b515fa2946d5d115a9eac3768f9d8bc /rust/examples/minidump/src/lib.rs
parent9993345001464331697167349803235498218652 (diff)
Rust API : Add minidump example
Squashed commit message history: Initial commit chore: Add files from cargo new, Binary Ninja Rust API template chore: Add README feat: Add basic plugin registration code feat: Add command to print memory information from minidump I can't believe this actually worked the first time feat: Set up registration of Minidump BinaryView type Also set architecture based on contents of MinidumpSystemInfo stream in the minidump. feat: Perform basic segment mapping from MinidumpMemoryList, MinidumpMemory64List feat: Read and apply memory segment protection info from MinidumpMemoryInfoList feat: Log action to add segments at info level docs: Update readme with build instructions, screenshot style: Minor cleanup of types refactor: Remove use of unwrap when parsing raw BaseRVA docs: Add doc comments to view module feat: More logging in print_memory_information command, remove unwrap refactor: Add struct for representing memory protection flags fix: Correct information about difference between MinidumpMemoryList, MinidumpMemory64List MinidumpMemory64List is always used for "full dumps", i.e. dumps which include the full process memory. It does not have to do with 64-bit segments specifically. docs: Clarify Windows-only support for now in README fix: First try to find full dump memory in MinidumpMemory64List before looking for partial dump memory in MinidumpMemoryList docs: Update README with examples of how to generate minidumps feat: Parse module information in MinidumpModuleList, and add modules as sections docs: Add information about unsupported features docs: Update README with screenshots, explanation of memory map docs: Update TODOs in BinaryViewBase impl Rust Minidump example : Clippy appeasements; remove network dependency
Diffstat (limited to 'rust/examples/minidump/src/lib.rs')
-rw-r--r--rust/examples/minidump/src/lib.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/rust/examples/minidump/src/lib.rs b/rust/examples/minidump/src/lib.rs
new file mode 100644
index 00000000..9d8b4054
--- /dev/null
+++ b/rust/examples/minidump/src/lib.rs
@@ -0,0 +1,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
+}