Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ rust/examples/*/target/
rust/examples/dwarf/*/target/
# Allow the test binaries
!/rust/fixtures/bin/**
!/rust/src/types

# Debugger docs
docs/img/debugger
Expand Down
3 changes: 1 addition & 2 deletions rust/examples/bndb_to_type_library.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Usage: cargo run --example bndb_to_type_library <bndb_path> <type_library_path>

use binaryninja::binary_view::BinaryViewExt;
use binaryninja::type_library::TypeLibrary;
use binaryninja::types::QualifiedName;
use binaryninja::types::{QualifiedName, TypeLibrary};

fn main() {
let bndb_path_str = std::env::args().nth(1).expect("No header provided");
Expand Down
3 changes: 1 addition & 2 deletions rust/examples/create_type_library.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Usage: cargo run --example create_type_library <header_file_path> <platform> <type_library_path>

use binaryninja::platform::Platform;
use binaryninja::type_library::TypeLibrary;
use binaryninja::type_parser::{CoreTypeParser, TypeParser};
use binaryninja::types::{CoreTypeParser, TypeLibrary, TypeParser};

fn main() {
let header_path_str = std::env::args().nth(1).expect("No header provided");
Expand Down
4 changes: 2 additions & 2 deletions rust/examples/dump_type_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use binaryninja::binary_view::BinaryView;
use binaryninja::file_metadata::FileMetadata;
use binaryninja::type_library::TypeLibrary;
use binaryninja::type_printer::{CoreTypePrinter, TokenEscapingType};
use binaryninja::types::library::TypeLibrary;
use binaryninja::types::printer::{CoreTypePrinter, TokenEscapingType};

fn main() {
let type_lib_str = std::env::args().nth(1).expect("No type library provided");
Expand Down
2 changes: 1 addition & 1 deletion rust/examples/type_printer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use binaryninja::type_printer::{CoreTypePrinter, TokenEscapingType};
use binaryninja::types::printer::{CoreTypePrinter, TokenEscapingType};
use binaryninja::types::{MemberAccess, MemberScope, Structure, StructureMember, Type};

fn main() {
Expand Down
11 changes: 4 additions & 7 deletions rust/src/binary_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ pub use crate::workflow::AnalysisContext;
use crate::architecture::{Architecture, CoreArchitecture};
use crate::base_detection::BaseAddressDetection;
use crate::basic_block::BasicBlock;
use crate::binary_view::search::SearchQuery;
use crate::component::Component;
use crate::confidence::Conf;
use crate::data_buffer::DataBuffer;
use crate::debuginfo::DebugInfo;
use crate::disassembly::DisassemblySettings;
use crate::external_library::{ExternalLibrary, ExternalLocation};
use crate::file_accessor::{Accessor, FileAccessor};
use crate::file_metadata::FileMetadata;
Expand All @@ -53,12 +55,12 @@ use crate::settings::Settings;
use crate::string::*;
use crate::symbol::{Symbol, SymbolType};
use crate::tags::{Tag, TagType};
use crate::type_container::TypeContainer;
use crate::type_library::TypeLibrary;
use crate::types::{
NamedTypeReference, QualifiedName, QualifiedNameAndType, QualifiedNameTypeAndId, Type,
TypeArchive, TypeArchiveId, TypeContainer, TypeLibrary,
};
use crate::variable::DataVariable;
use crate::workflow::Workflow;
use crate::{Endianness, BN_FULL_CONFIDENCE};
use std::collections::HashMap;
use std::ffi::{c_char, c_void, CString};
Expand All @@ -67,17 +69,12 @@ use std::ops::Range;
use std::path::{Path, PathBuf};
use std::ptr::NonNull;
use std::{result, slice};
// TODO : general reorg of modules related to bv

pub mod memory_map;
pub mod reader;
pub mod search;
pub mod writer;

use crate::binary_view::search::SearchQuery;
use crate::disassembly::DisassemblySettings;
use crate::type_archive::{TypeArchive, TypeArchiveId};
use crate::workflow::Workflow;
pub use memory_map::MemoryMap;
pub use reader::BinaryReader;
pub use writer::BinaryWriter;
Expand Down
2 changes: 1 addition & 1 deletion rust/src/collaboration/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::progress::{NoProgressCallback, ProgressCallback};
use crate::project::file::ProjectFile;
use crate::rc::Ref;
use crate::string::{raw_to_string, BnString, IntoCStr};
use crate::type_archive::{TypeArchive, TypeArchiveMergeConflict};
use crate::types::archive::{TypeArchive, TypeArchiveMergeConflict};

/// Get the default directory path for a remote Project. This is based off the Setting for
/// collaboration.directory, the project's id, and the project's remote's id.
Expand Down
23 changes: 22 additions & 1 deletion rust/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::binary_view::{BinaryView, BinaryViewExt};
use crate::function::Function;
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable};
use crate::string::{BnString, IntoCStr};
use crate::types::ComponentReferencedType;
use crate::types::Type;
use std::ffi::c_char;
use std::fmt::Debug;
use std::ptr::NonNull;
Expand Down Expand Up @@ -304,3 +304,24 @@ unsafe impl CoreArrayProviderInner for Component {
Guard::new(Self::from_raw(raw_ptr), context)
}
}

// TODO: Remove this struct, or make it not a ZST with a terrible array provider.
/// ZST used only for `Array<ComponentReferencedType>`.
pub struct ComponentReferencedType;

impl CoreArrayProvider for ComponentReferencedType {
type Raw = *mut BNType;
type Context = ();
type Wrapped<'a> = &'a Type;
}

unsafe impl CoreArrayProviderInner for ComponentReferencedType {
unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) {
BNComponentFreeReferencedTypes(raw, count)
}

unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> {
// SAFETY: &*mut BNType == &Type (*mut BNType == Type)
std::mem::transmute(raw)
}
}
3 changes: 1 addition & 2 deletions rust/src/data_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::section::Section;
use crate::segment::Segment;
use crate::symbol::Symbol;
use crate::tags::{TagReference, TagType};
use crate::type_archive::TypeArchive;
use crate::types::{QualifiedName, Type};
use crate::types::{QualifiedName, Type, TypeArchive};
use crate::variable::DataVariable;

macro_rules! trait_handler {
Expand Down
3 changes: 1 addition & 2 deletions rust/src/language_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use crate::high_level_il::{HighLevelExpressionIndex, HighLevelILFunction};
use crate::line_formatter::CoreLineFormatter;
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Ref, RefCountable};
use crate::string::{BnString, IntoCStr};
use crate::type_parser::CoreTypeParser;
use crate::type_printer::CoreTypePrinter;
use crate::types::{CoreTypeParser, CoreTypePrinter};

pub type InstructionTextTokenContext = BNInstructionTextTokenContext;
pub type ScopeType = BNScopeType;
Expand Down
6 changes: 1 addition & 5 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub mod metadata;
pub mod platform;
pub mod progress;
pub mod project;
pub mod qualified_name;
pub mod rc;
pub mod references;
pub mod relocation;
Expand All @@ -81,11 +82,6 @@ pub mod string;
pub mod symbol;
pub mod tags;
pub mod template_simplifier;
pub mod type_archive;
pub mod type_container;
pub mod type_library;
pub mod type_parser;
pub mod type_printer;
pub mod types;
pub mod update;
pub mod variable;
Expand Down
8 changes: 4 additions & 4 deletions rust/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

//! Contains all information related to the execution environment of the binary, mainly the calling conventions used

use crate::type_container::TypeContainer;
use crate::type_parser::{TypeParserError, TypeParserErrorSeverity, TypeParserResult};
use crate::{
architecture::{Architecture, CoreArchitecture},
calling_convention::CoreCallingConvention,
rc::*,
string::*,
type_library::TypeLibrary,
types::QualifiedNameAndType,
types::{
QualifiedNameAndType, TypeContainer, TypeLibrary, TypeParserError, TypeParserErrorSeverity,
TypeParserResult,
},
};
use binaryninjacore_sys::*;
use std::fmt::Debug;
Expand Down
Loading
Loading