-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
529 additions
and
3,693 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"fbcg_rust", | ||
"sigem", | ||
"signaturebuild", | ||
"sigview", | ||
"symbolbuild", | ||
"typebuild", | ||
"warp_binja" | ||
] | ||
[package] | ||
name = "warp" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
|
||
[workspace.dependencies] | ||
#binaryninja = { path = "../../binaryninja/api/rust", features = ["rayon"] } | ||
# NOTE: You must update the revision manually when making changes in the `binaryninja` crate. | ||
binaryninja = { git = "https://github.com/Vector35/binaryninja-api.git", rev = "bca07d7", features = ["rayon"] } | ||
[lib] | ||
path = "rust/lib.rs" | ||
|
||
[dependencies] | ||
flatbuffers = "24.3.25" | ||
bon = "2.3.0" | ||
uuid = { version = "1.11.0", features = ["v5"]} | ||
rand = "0.8.5" | ||
|
||
[dev-dependencies] | ||
criterion = "0.5.1" | ||
|
||
[build-dependencies] | ||
flatbuffers-build = { git = "https://github.com/emesare/flatbuffers-build" } | ||
|
||
[profile.release] | ||
panic = "abort" | ||
lto = true | ||
debug = "full" | ||
debug = "full" | ||
|
||
[[example]] | ||
name = "simple" | ||
path = "rust/examples/simple.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2020-2024 Vector 35 Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
signaturebuild/src/basic_block.rs → rust/signature/basic_block.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
signaturebuild/src/function/constraints.rs → rust/signature/function/constraints.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
pub mod class; | ||
|
||
use crate::fb_symbol as fb; | ||
use crate::symbol::class::SymbolClass; | ||
use flatbuffers::{FlatBufferBuilder, WIPOffset}; | ||
|
||
pub use fb::SymbolModifiers; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Hash)] | ||
pub struct Symbol { | ||
pub name: String, | ||
pub modifiers: SymbolModifiers, | ||
pub class: SymbolClass, | ||
} | ||
|
||
impl Symbol { | ||
pub fn new(name: impl Into<String>, class: SymbolClass, modifiers: SymbolModifiers) -> Self { | ||
Self { | ||
name: name.into(), | ||
modifiers, | ||
class, | ||
} | ||
} | ||
|
||
pub(crate) fn create<'a>( | ||
&self, | ||
builder: &mut FlatBufferBuilder<'a>, | ||
) -> WIPOffset<fb::Symbol<'a>> { | ||
let name = builder.create_string(&self.name); | ||
let class_type = self.class.ty(); | ||
let class = self.class.create(builder); | ||
|
||
fb::Symbol::create( | ||
builder, | ||
&fb::SymbolArgs { | ||
name: Some(name), | ||
modifiers: self.modifiers, | ||
class_type, | ||
class: Some(class), | ||
}, | ||
) | ||
} | ||
} | ||
|
||
impl From<fb::Symbol<'_>> for Symbol { | ||
fn from(value: fb::Symbol<'_>) -> Self { | ||
let name = value.name().unwrap().to_string(); | ||
// TODO: I would like this conversion to be on `SymbolClass` instead. | ||
let class = match value.class_type() { | ||
fb::SymbolClass::FunctionSymbolClass => { | ||
SymbolClass::from(value.class_as_function_symbol_class().unwrap()) | ||
} | ||
fb::SymbolClass::DataSymbolClass => { | ||
SymbolClass::from(value.class_as_data_symbol_class().unwrap()) | ||
} | ||
_ => unreachable!(), | ||
}; | ||
|
||
Self { | ||
name, | ||
modifiers: value.modifiers(), | ||
class, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use flatbuffers::FlatBufferBuilder; | ||
|
||
#[test] | ||
fn it_works() { | ||
let mut builder = FlatBufferBuilder::with_capacity(100); | ||
let symbol = Symbol { | ||
name: "".to_string(), | ||
modifiers: SymbolModifiers::empty(), | ||
class: SymbolClass::Data, | ||
}; | ||
let created_symbol = symbol.create(&mut builder); | ||
// TODO: Add actual tests. | ||
} | ||
} |
Oops, something went wrong.