Skip to content

Commit 011f533

Browse files
committed
Bump
1 parent 81d4b29 commit 011f533

File tree

5 files changed

+66
-15
lines changed

5 files changed

+66
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/warp/api/warp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using namespace Warp;
55

6-
std::string UUID::ToString() const
6+
std::string WarpUUID::ToString() const
77
{
88
char *str = BNWARPUUIDGetString(&uuid);
99
std::string result = str;

plugins/warp/api/warp.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,23 @@ namespace Warp {
224224
}
225225
};
226226

227-
class UUID
227+
class WarpUUID
228228
{
229229
BNWARPUUID uuid;
230230

231231
public:
232-
UUID() = default;
232+
WarpUUID() = default;
233233

234-
UUID(BNWARPUUID uuid) : uuid(uuid) {}
234+
WarpUUID(BNWARPUUID uuid) : uuid(uuid) {}
235235

236236
std::string ToString() const;
237237

238-
bool operator==(const UUID &other) const
238+
bool operator==(const WarpUUID &other) const
239239
{
240240
return BNWARPUUIDEqual(&uuid, &other.uuid);
241241
}
242242

243-
bool operator!=(const UUID &other) const
243+
bool operator!=(const WarpUUID &other) const
244244
{
245245
return !(*this == other);
246246
}
@@ -256,11 +256,11 @@ namespace Warp {
256256
}
257257
};
258258

259-
typedef UUID Source;
260-
typedef UUID BasicBlockGUID;
261-
typedef UUID FunctionGUID;
262-
typedef UUID ConstraintGUID;
263-
typedef UUID TypeGUID;
259+
typedef WarpUUID Source;
260+
typedef WarpUUID BasicBlockGUID;
261+
typedef WarpUUID FunctionGUID;
262+
typedef WarpUUID ConstraintGUID;
263+
typedef WarpUUID TypeGUID;
264264

265265
class Target : public WarpRefCountObject<BNWARPTarget, BNWARPNewTargetReference,
266266
BNWARPFreeTargetReference>

plugins/warp/src/convert.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use warp::signature::comment::FunctionComment;
1111
use warp::target::Target;
1212

1313
pub fn bn_comment_to_comment(func: &BNFunction, bn_comment: BNComment) -> FunctionComment {
14-
// TODO: Warp offset needs to be i64 lol.
15-
let offset = bn_comment.addr - func.start();
14+
let offset = (bn_comment.addr as i64) - (func.start() as i64);
1615
FunctionComment {
1716
offset,
1817
text: bn_comment.comment,
@@ -21,7 +20,10 @@ pub fn bn_comment_to_comment(func: &BNFunction, bn_comment: BNComment) -> Functi
2120

2221
pub fn comment_to_bn_comment(func: &BNFunction, comment: FunctionComment) -> BNComment {
2322
BNComment {
24-
addr: func.start() + comment.offset,
23+
addr: comment
24+
.offset
25+
.checked_add_unsigned(func.start())
26+
.unwrap_or_default() as u64,
2527
comment: comment.text,
2628
}
2729
}

plugins/warp/src/plugin/ffi/function.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,33 @@ use crate::convert::{to_bn_symbol_at_address, to_bn_type};
44
use crate::plugin::ffi::{BNWARPFunction, BNWARPFunctionGUID, BNWarpConstraint};
55
use binaryninja::function::Function;
66
use binaryninja::rc::Ref;
7+
use binaryninja::string::BnString;
78
use binaryninjacore_sys::{BNFunction, BNSymbol, BNType};
9+
use std::ffi::c_char;
810
use std::mem::ManuallyDrop;
911
use std::sync::Arc;
12+
use warp::signature::comment::FunctionComment;
13+
14+
#[repr(C)]
15+
pub struct BNWarpFunctionComment {
16+
pub text: *mut c_char,
17+
pub offset: i64,
18+
}
19+
20+
impl BNWarpFunctionComment {
21+
/// Leaks the text string to be freed with BNWARPFreeFunctionComment
22+
pub fn from_owned(value: &FunctionComment) -> Self {
23+
let text = BnString::into_raw(BnString::new(&value.text));
24+
Self {
25+
text,
26+
offset: value.offset,
27+
}
28+
}
29+
30+
pub fn free_raw(value: &Self) {
31+
unsafe { BnString::free_raw(value.text) }
32+
}
33+
}
1034

1135
#[no_mangle]
1236
pub unsafe extern "C" fn BNWARPGetFunction(
@@ -119,6 +143,23 @@ pub unsafe extern "C" fn BNWARPFunctionGetConstraints(
119143
raw_constraints_ptr as *mut *mut BNWarpConstraint
120144
}
121145

146+
#[no_mangle]
147+
pub unsafe extern "C" fn BNWARPFunctionGetComments(
148+
function: *mut BNWARPFunction,
149+
count: *mut usize,
150+
) -> *mut BNWarpFunctionComment {
151+
// We do not own function so we should not drop.
152+
let function = ManuallyDrop::new(Arc::from_raw(function));
153+
let raw_comments: Box<[_]> = function
154+
.comments
155+
.iter()
156+
.map(BNWarpFunctionComment::from_owned)
157+
.collect();
158+
*count = raw_comments.len();
159+
let raw_comments_ptr = Box::into_raw(raw_comments);
160+
raw_comments_ptr as *mut BNWarpFunctionComment
161+
}
162+
122163
#[no_mangle]
123164
pub unsafe extern "C" fn BNWARPFunctionsEqual(
124165
function_a: *mut BNWARPFunction,
@@ -156,3 +197,11 @@ pub unsafe extern "C" fn BNWARPFreeFunctionList(functions: *mut *mut BNWARPFunct
156197
BNWARPFreeFunctionReference(function);
157198
}
158199
}
200+
201+
#[no_mangle]
202+
pub unsafe extern "C" fn BNWARPFreeFunctionComment(comment: *mut BNWarpFunctionComment) {
203+
if comment.is_null() {
204+
return;
205+
}
206+
BNWarpFunctionComment::free_raw(&*comment);
207+
}

0 commit comments

Comments
 (0)