MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / get_form_input

Method get_form_input

rust/src/interaction.rs:493–537  ·  view source on GitHub ↗

Prompts the user for a set of inputs specified in `fields` with given title. The fields parameter is a list which can contain the following types: This API is flexible and works both in the UI via a pop-up dialog and on the command-line. ```no_run # use binaryninja::interaction::FormInputBuilder; # use binaryninja::interaction::FormResponses; let responses = FormInputBuilder::new() .text_field("

(&mut self, title: &str)

Source from the content-addressed store, hash-verified

491 /// println!("{} {} likes {}", &first_name, &last_name, food);
492 /// ```
493 pub fn get_form_input(&mut self, title: &str) -> Vec<FormResponses> {
494 if unsafe {
495 BNGetFormInput(
496 self.fields.as_mut_ptr(),
497 self.fields.len(),
498 title.into_bytes_with_nul().as_ptr() as *const _,
499 )
500 } {
501 let result = self
502 .fields
503 .iter()
504 .map(|form_field| match form_field.type_ {
505 BNFormInputFieldType::LabelFormField
506 | BNFormInputFieldType::SeparatorFormField => FormResponses::None,
507
508 BNFormInputFieldType::TextLineFormField
509 | BNFormInputFieldType::MultilineTextFormField
510 | BNFormInputFieldType::OpenFileNameFormField
511 | BNFormInputFieldType::SaveFileNameFormField
512 | BNFormInputFieldType::DirectoryNameFormField => {
513 FormResponses::String(unsafe {
514 CStr::from_ptr(form_field.stringResult)
515 .to_str()
516 .unwrap()
517 .to_owned()
518 })
519 }
520
521 BNFormInputFieldType::IntegerFormField => {
522 FormResponses::Integer(form_field.intResult)
523 }
524 BNFormInputFieldType::AddressFormField => {
525 FormResponses::Address(form_field.addressResult)
526 }
527 BNFormInputFieldType::ChoiceFormField => {
528 FormResponses::Index(form_field.indexResult)
529 }
530 })
531 .collect();
532 unsafe { BNFreeFormInputResults(self.fields.as_mut_ptr(), self.fields.len()) };
533 result
534 } else {
535 vec![]
536 }
537 }
538}
539
540impl Default for FormInputBuilder {

Callers

nothing calls this directly

Calls 6

StringClass · 0.85
into_bytes_with_nulMethod · 0.80
mapMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected