Skip to content

Commit fe633e8

Browse files
committed
impl rust custom interactive handler
1 parent 4e77062 commit fe633e8

File tree

5 files changed

+1725
-391
lines changed

5 files changed

+1725
-391
lines changed

plugins/dwarf/dwarf_export/src/lib.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -628,14 +628,14 @@ fn present_form(bv_arch: &str) -> Vec<FormResponses> {
628628
"Wasm32",
629629
"Xtensa",
630630
];
631-
interaction::FormInputBuilder::new()
632-
.save_file_field(
631+
let mut form = [
632+
interaction::FormInput::save_file_field::<_, _, &str, &str>(
633633
"Save Location",
634634
Some("Debug Files (*.dwo *.debug);;All Files (*)"),
635635
None,
636636
None,
637-
)
638-
.choice_field(
637+
),
638+
interaction::FormInput::choice_field(
639639
"Architecture",
640640
&archs,
641641
archs
@@ -646,14 +646,15 @@ fn present_form(bv_arch: &str) -> Vec<FormResponses> {
646646
.cmp(&edit_distance::distance(bv_arch, arch_name_2))
647647
})
648648
.map(|(index, _)| index),
649-
)
649+
),
650650
// Add actual / better support for formats other than elf?
651-
// .choice_field(
652-
// "Container Format",
653-
// &["Coff", "Elf", "MachO", "Pe", "Wasm", "Xcoff"],
654-
// None,
655-
// )
656-
.get_form_input("Export as DWARF")
651+
//interaction::FormInput::choice_field(
652+
// "Container Format",
653+
// &["Coff", "Elf", "MachO", "Pe", "Wasm", "Xcoff"],
654+
// None,
655+
//),
656+
];
657+
interaction::get_form_input("Export as DWARF", &mut form)
657658
}
658659

659660
fn write_dwarf<T: gimli::Endianity>(

rust/src/binary_view.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,60 @@ pub trait BinaryViewExt: BinaryViewBase {
11091109
unsafe { BNApplyDebugInfo(self.as_ref().handle, debug_info.handle) }
11101110
}
11111111

1112+
fn show_plaintext_report<S1: BnStrCompatible, S2: BnStrCompatible>(
1113+
&self,
1114+
title: S1,
1115+
plaintext: S2,
1116+
) {
1117+
let title = title.into_bytes_with_nul();
1118+
let plaintext = plaintext.into_bytes_with_nul();
1119+
unsafe {
1120+
BNShowPlainTextReport(
1121+
self.as_ref().handle,
1122+
title.as_ref().as_ptr() as *mut _,
1123+
plaintext.as_ref().as_ptr() as *mut _,
1124+
)
1125+
}
1126+
}
1127+
1128+
fn show_markdown_report<S1: BnStrCompatible, S2: BnStrCompatible, S3: BnStrCompatible>(
1129+
&self,
1130+
title: S1,
1131+
contents: S2,
1132+
plaintext: S3,
1133+
) {
1134+
let title = title.into_bytes_with_nul();
1135+
let contents = contents.into_bytes_with_nul();
1136+
let plaintext = plaintext.into_bytes_with_nul();
1137+
unsafe {
1138+
BNShowMarkdownReport(
1139+
self.as_ref().handle,
1140+
title.as_ref().as_ptr() as *mut _,
1141+
contents.as_ref().as_ptr() as *mut _,
1142+
plaintext.as_ref().as_ptr() as *mut _,
1143+
)
1144+
}
1145+
}
1146+
1147+
fn show_html_report<S1: BnStrCompatible, S2: BnStrCompatible, S3: BnStrCompatible>(
1148+
&self,
1149+
title: S1,
1150+
contents: S2,
1151+
plaintext: S3,
1152+
) {
1153+
let title = title.into_bytes_with_nul();
1154+
let contents = contents.into_bytes_with_nul();
1155+
let plaintext = plaintext.into_bytes_with_nul();
1156+
unsafe {
1157+
BNShowHTMLReport(
1158+
self.as_ref().handle,
1159+
title.as_ref().as_ptr() as *mut _,
1160+
contents.as_ref().as_ptr() as *mut _,
1161+
plaintext.as_ref().as_ptr() as *mut _,
1162+
)
1163+
}
1164+
}
1165+
11121166
fn show_graph_report<S: BnStrCompatible>(&self, raw_name: S, graph: &FlowGraph) {
11131167
let raw_name = raw_name.into_bytes_with_nul();
11141168
unsafe {

0 commit comments

Comments
 (0)