Skip to content

Commit 434a794

Browse files
committed
[BNTL] Misc improvements
1 parent f67d8c2 commit 434a794

7 files changed

Lines changed: 21 additions & 13 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/bntl_utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ walkdir = "2.5"
2323
dashmap = "6.1"
2424

2525
# For TBD parsing
26-
serde-saphyr = { version = "0.0.18", default-features = false, features = [] }
26+
serde-saphyr = { version = "0.0.19", default-features = false, features = [] }
2727

2828
# For reports
2929
minijinja = "2.10.2"

plugins/bntl_utils/cli/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Examples:
3434
- Downloads and processes all files in the project, placing potentially multiple `.bntl` files in the `output` directory.
3535
- `./bntl_cli create sqlite3.dll "windows-x86_64" ./winmd/ ./output/`
3636
- `winmd` files are also supported as input, they will be processed together. You also probably want to provide some apiset schema files as well.
37+
- `./bntl_cli create sqlite3.dll "windows-x86_64" ./headers/ ./output/ --include-directories ./system_headers/`
38+
- You can also specify additional include directories to search for referenced headers.
3739

3840
#### Dump
3941

@@ -45,7 +47,7 @@ Examples:
4547

4648
#### Diff
4749

48-
Compare two type libraries and generate a .diff file containing a similarity ratio.
50+
Compare two type libraries and generate a .diff file.
4951

5052
Examples:
5153

plugins/bntl_utils/cli/src/create.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub struct CreateArgs {
1414
pub platform: String,
1515
pub input: Input,
1616
pub output_directory: Option<PathBuf>,
17+
/// A list of directories to use for include paths when parsing C header files.
18+
#[clap(long)]
19+
pub include_directories: Vec<PathBuf>,
1720
#[clap(long)]
1821
pub dry_run: bool,
1922
}
@@ -37,7 +40,8 @@ impl CreateArgs {
3740
}
3841
std::fs::create_dir_all(&output_path).expect("Failed to create output directory");
3942

40-
let processor = TypeLibProcessor::new(&self.name, &self.platform);
43+
let processor = TypeLibProcessor::new(&self.name, &self.platform)
44+
.with_include_directories(self.include_directories.clone());
4145
// TODO: Need progress indicator here, when downloading files.
4246
let resolved_input = self.input.resolve().expect("Failed to resolve input");
4347

plugins/bntl_utils/src/command/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::command::{InputDirectoryField, OutputDirectoryField};
22
use crate::helper::path_to_type_libraries;
33
use crate::validate::TypeLibValidater;
4-
use binaryninja::binary_view::{BinaryView, BinaryViewExt};
4+
use binaryninja::binary_view::BinaryView;
55
use binaryninja::command::Command;
66
use binaryninja::interaction::Form;
77
use binaryninja::platform::Platform;

plugins/bntl_utils/src/process.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,12 @@ impl ProcessedData {
354354
(QualifiedName, CoreArchitecture),
355355
Vec<Ref<TypeLibrary>>,
356356
> = HashMap::new();
357-
for merged_type_library in &self.type_libraries {
358-
for named_type in &merged_type_library.named_types() {
357+
for tl in &self.type_libraries {
358+
for named_type in &tl.named_types() {
359359
mapped_named_types
360-
.entry((named_type.name.clone(), merged_type_library.arch()))
360+
.entry((named_type.name.clone(), tl.arch()))
361361
.or_default()
362-
.push(merged_type_library.clone());
362+
.push(tl.clone());
363363
}
364364
}
365365

@@ -1093,13 +1093,13 @@ pub fn is_parsable(path: &Path) -> bool {
10931093
if path.extension() == Some(OsStr::new("pdb")) {
10941094
return false;
10951095
}
1096-
let mut metadata = FileMetadata::with_file_path(path);
1097-
let Ok(view) = BinaryView::from_path(&metadata, path) else {
1096+
let metadata = FileMetadata::with_file_path(path);
1097+
let Ok(view) = BinaryView::from_metadata(&metadata) else {
10981098
return false;
10991099
};
11001100
// If any view type parses this file, consider it for this source.
11011101
// All files will have a "Raw" file type, so we account for that.
1102-
BinaryViewType::list_valid_types_for(&view).len() > 1
1102+
BinaryViewType::valid_types_for_data(&view).len() > 1
11031103
}
11041104

11051105
#[cfg(test)]

plugins/bntl_utils/src/tbd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Parse Apples TBD file format, which gives information about where source symbols are located.
2+
13
use binaryninja::architecture::CoreArchitecture;
24
use binaryninja::platform::Platform;
35
use binaryninja::rc::Ref;

0 commit comments

Comments
 (0)