Struct binaryninja::project::Project
source · #[repr(C)]pub struct Project { /* private fields */ }
Implementations§
source§impl Project
impl Project
pub fn all_open() -> Array<Project>
sourcepub fn create<P: BnStrCompatible, S: BnStrCompatible>(path: P, name: S) -> Self
pub fn create<P: BnStrCompatible, S: BnStrCompatible>(path: P, name: S) -> Self
Create a new project
path
- Path to the project directory (.bnpr)name
- Name of the new project
sourcepub fn open_project<P: BnStrCompatible>(path: P) -> Self
pub fn open_project<P: BnStrCompatible>(path: P) -> Self
Open an existing project
path
- Path to the project directory (.bnpr) or project metadata file (.bnpm)
sourcepub fn set_name<S: BnStrCompatible>(&self, value: S)
pub fn set_name<S: BnStrCompatible>(&self, value: S)
Set the name of the project
sourcepub fn description(&self) -> BnString
pub fn description(&self) -> BnString
Get the description of the project
sourcepub fn set_description<S: BnStrCompatible>(&self, value: S)
pub fn set_description<S: BnStrCompatible>(&self, value: S)
Set the description of the project
sourcepub fn query_metadata<S: BnStrCompatible>(&self, key: S) -> Ref<Metadata>
pub fn query_metadata<S: BnStrCompatible>(&self, key: S) -> Ref<Metadata>
Retrieves metadata stored under a key from the project
sourcepub fn store_metadata<S: BnStrCompatible>(
&self,
key: S,
value: &Metadata
) -> bool
pub fn store_metadata<S: BnStrCompatible>( &self, key: S, value: &Metadata ) -> bool
Stores metadata within the project,
key
- Key under which to store the Metadata objectvalue
- Object to store
sourcepub fn remove_metadata<S: BnStrCompatible>(&self, key: S)
pub fn remove_metadata<S: BnStrCompatible>(&self, key: S)
Removes the metadata associated with this key
from the project
pub fn push_folder(&self, file: &ProjectFolder)
sourcepub fn create_folder_from_path<P, D>(
&self,
path: P,
parent: Option<&ProjectFolder>,
description: D
) -> Result<ProjectFolder, ()>where
P: BnStrCompatible,
D: BnStrCompatible,
pub fn create_folder_from_path<P, D>(
&self,
path: P,
parent: Option<&ProjectFolder>,
description: D
) -> Result<ProjectFolder, ()>where
P: BnStrCompatible,
D: BnStrCompatible,
Recursively create files and folders in the project from a path on disk
path
- Path to folder on diskparent
- Parent folder in the project that will contain the new contentsdescription
- Description for created root folder
sourcepub fn create_folder_from_path_with_progress<P, D, F>(
&self,
path: P,
parent: Option<&ProjectFolder>,
description: D,
progress_func: F
) -> Result<ProjectFolder, ()>
pub fn create_folder_from_path_with_progress<P, D, F>( &self, path: P, parent: Option<&ProjectFolder>, description: D, progress_func: F ) -> Result<ProjectFolder, ()>
Recursively create files and folders in the project from a path on disk
path
- Path to folder on diskparent
- Parent folder in the project that will contain the new contentsdescription
- Description for created root folderprogress_func
- Progress function that will be called
sourcepub fn create_folder<N, D>(
&self,
parent: Option<&ProjectFolder>,
name: N,
description: D
) -> Result<ProjectFolder, ()>where
N: BnStrCompatible,
D: BnStrCompatible,
pub fn create_folder<N, D>(
&self,
parent: Option<&ProjectFolder>,
name: N,
description: D
) -> Result<ProjectFolder, ()>where
N: BnStrCompatible,
D: BnStrCompatible,
Recursively create files and folders in the project from a path on disk
parent
- Parent folder in the project that will contain the new foldername
- Name for the created folderdescription
- Description for created folder
sourcepub unsafe fn create_folder_unsafe<N, D, I>(
&self,
parent: Option<&ProjectFolder>,
name: N,
description: D,
id: I
) -> Result<ProjectFolder, ()>
pub unsafe fn create_folder_unsafe<N, D, I>( &self, parent: Option<&ProjectFolder>, name: N, description: D, id: I ) -> Result<ProjectFolder, ()>
Recursively create files and folders in the project from a path on disk
parent
- Parent folder in the project that will contain the new foldername
- Name for the created folderdescription
- Description for created folderid
- id unique ID
sourcepub fn folder_by_id<S: BnStrCompatible>(&self, id: S) -> Option<ProjectFolder>
pub fn folder_by_id<S: BnStrCompatible>(&self, id: S) -> Option<ProjectFolder>
Retrieve a folder in the project by unique folder id
sourcepub fn delete_folder(&self, folder: &ProjectFolder) -> Result<(), ()>
pub fn delete_folder(&self, folder: &ProjectFolder) -> Result<(), ()>
Recursively delete a folder from the project
folder
- Folder to delete recursively
sourcepub fn delete_folder_with_progress<F>(
&self,
folder: &ProjectFolder,
progress_func: F
) -> Result<(), ()>
pub fn delete_folder_with_progress<F>( &self, folder: &ProjectFolder, progress_func: F ) -> Result<(), ()>
Recursively delete a folder from the project
folder
- Folder to delete recursivelyprogress_func
- Progress function that will be called as objects get deleted
pub fn push_file(&self, file: &ProjectFile)
sourcepub fn create_file_from_path<P, N, D>(
&self,
path: P,
folder: Option<&ProjectFolder>,
name: N,
description: D
) -> Result<ProjectFile, ()>
pub fn create_file_from_path<P, N, D>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D ) -> Result<ProjectFile, ()>
Create a file in the project from a path on disk
path
- Path on diskfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created file
sourcepub fn create_file_from_path_with_progress<P, N, D, F>(
&self,
path: P,
folder: Option<&ProjectFolder>,
name: N,
description: D,
progress_func: F
) -> Result<ProjectFile, ()>
pub fn create_file_from_path_with_progress<P, N, D, F>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D, progress_func: F ) -> Result<ProjectFile, ()>
Create a file in the project from a path on disk
path
- Path on diskfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created fileprogress_func
- Progress function that will be called as the file is being added
sourcepub unsafe fn create_file_from_path_unsafe<P, N, D, I>(
&self,
path: P,
folder: Option<&ProjectFolder>,
name: N,
description: D,
id: I,
creation_time: SystemTime
) -> Result<ProjectFile, ()>
pub unsafe fn create_file_from_path_unsafe<P, N, D, I>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime ) -> Result<ProjectFile, ()>
Create a file in the project from a path on disk
path
- Path on diskfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created fileid
- id unique IDcreation_time
- Creation time of the file
sourcepub unsafe fn create_file_from_path_with_progress_unsafe<P, N, D, I, F>(
&self,
path: P,
folder: Option<&ProjectFolder>,
name: N,
description: D,
id: I,
creation_time: SystemTime,
progress_func: F
) -> Result<ProjectFile, ()>where
P: BnStrCompatible,
N: BnStrCompatible,
D: BnStrCompatible,
I: BnStrCompatible,
F: FnMut(usize, usize) -> bool,
pub unsafe fn create_file_from_path_with_progress_unsafe<P, N, D, I, F>(
&self,
path: P,
folder: Option<&ProjectFolder>,
name: N,
description: D,
id: I,
creation_time: SystemTime,
progress_func: F
) -> Result<ProjectFile, ()>where
P: BnStrCompatible,
N: BnStrCompatible,
D: BnStrCompatible,
I: BnStrCompatible,
F: FnMut(usize, usize) -> bool,
Create a file in the project from a path on disk
path
- Path on diskfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created fileid
- id unique IDcreation_time
- Creation time of the fileprogress_func
- Progress function that will be called as the file is being added
sourcepub fn create_file<N, D>(
&self,
contents: &[u8],
folder: Option<&ProjectFolder>,
name: N,
description: D
) -> Result<ProjectFile, ()>where
N: BnStrCompatible,
D: BnStrCompatible,
pub fn create_file<N, D>(
&self,
contents: &[u8],
folder: Option<&ProjectFolder>,
name: N,
description: D
) -> Result<ProjectFile, ()>where
N: BnStrCompatible,
D: BnStrCompatible,
Create a file in the project
contents
- Bytes of the file that will be createdfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created file
sourcepub fn create_file_with_progress<N, D, F>(
&self,
contents: &[u8],
folder: Option<&ProjectFolder>,
name: N,
description: D,
progress_func: F
) -> Result<ProjectFile, ()>
pub fn create_file_with_progress<N, D, F>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D, progress_func: F ) -> Result<ProjectFile, ()>
Create a file in the project
contents
- Bytes of the file that will be createdfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created fileprogress_func
- Progress function that will be called as the file is being added
sourcepub unsafe fn create_file_unsafe<N, D, I>(
&self,
contents: &[u8],
folder: Option<&ProjectFolder>,
name: N,
description: D,
id: I,
creation_time: SystemTime
) -> Result<ProjectFile, ()>
pub unsafe fn create_file_unsafe<N, D, I>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime ) -> Result<ProjectFile, ()>
Create a file in the project
contents
- Bytes of the file that will be createdfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created fileid
- id unique IDcreation_time
- Creation time of the file
sourcepub unsafe fn create_file_with_progress_unsafe<N, D, I, F>(
&self,
contents: &[u8],
folder: Option<&ProjectFolder>,
name: N,
description: D,
id: I,
creation_time: SystemTime,
progress_func: F
) -> Result<ProjectFile, ()>
pub unsafe fn create_file_with_progress_unsafe<N, D, I, F>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime, progress_func: F ) -> Result<ProjectFile, ()>
Create a file in the project
contents
- Bytes of the file that will be createdfolder
- Folder to place the created file inname
- Name to assign to the created filedescription
- Description to assign to the created fileid
- id unique IDcreation_time
- Creation time of the fileprogress_func
- Progress function that will be called as the file is being added
sourcepub fn file_by_id<S: BnStrCompatible>(&self, id: S) -> Option<ProjectFile>
pub fn file_by_id<S: BnStrCompatible>(&self, id: S) -> Option<ProjectFile>
Retrieve a file in the project by unique id
sourcepub fn file_by_path<S: BnStrCompatible>(&self, path: S) -> Option<ProjectFile>
pub fn file_by_path<S: BnStrCompatible>(&self, path: S) -> Option<ProjectFile>
Retrieve a file in the project by the path
on disk
sourcepub fn delete_file(&self, file: &ProjectFile) -> bool
pub fn delete_file(&self, file: &ProjectFile) -> bool
Delete a file from the project
sourcepub fn bulk_operation(&mut self) -> Result<ProjectBulkOperationLock<'_>, ()>
pub fn bulk_operation(&mut self) -> Result<ProjectBulkOperationLock<'_>, ()>
A context manager to speed up bulk project operations. Project modifications are synced to disk in chunks, and the project on disk vs in memory may not agree on state if an exception occurs while a bulk operation is happening.
if let Ok(bulk) = project.bulk_operation() {
for file in std::fs::read_dir("/bin/").unwrap().into_iter() {
let file = file.unwrap();
let file_type = file.file_type().unwrap();
if file_type.is_file() && !file_type.is_symlink() {
bulk.create_file_from_path(
"/bin/",
None,
&file.file_name().to_string_lossy(),
"",
).unwrap();
}
}
}