package bap-std

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Input information.

This module abstracts the input data necessary to create a project.

type t = input
val load : ?target:Bap_core_theory.Theory.Target.t -> ?loader:string -> string -> t

load filename loads the file from the specified path. The file must be regular (i.e., not a pipe) and is expected to have the necessary meta information, i.e., not the raw code (use raw_file to load files that are raw code).

If loader is not specified then all image loaders are used and the information from the is merged, otherwise only the selected loaded is used. See Image.available_backend.

The target could be used to override the target information derived from the input file.

  • since 2.5.0 if [target] is specified then it is used

instead of the derived target, and the derivation itself is not performed.

  • before 2.5.0

    if target is specified and is less specific, then the derived target it will be ignored, if it contradicts the information in the file then the project creation will fail.

  • since 2.2.0
val raw_file : ?base:addr -> Bap_core_theory.Theory.Target.t -> string -> t

raw_file ?base target ~filename creates an input from a binary file that is raw code for the given target, i.e., without any headers or meta information.

  • parameter base

    is an virtual address of the first byte (defaults to 0).

  • since 2.2.0
val from_string : ?base:addr -> Bap_core_theory.Theory.Target.t -> string -> t

create ?base target code creates input from the binary code for the given target.

  • since 2.2.0

create ?base target code creates input from the binary code for the given target.

  • since 2.2.0
val custom : ?finish:(project -> project) -> ?filename:string -> ?code:value memmap -> ?data:value memmap -> Bap_core_theory.Theory.Target.t -> t

custom target creates a custom input.

The target parameter denotes the target system of the input program. The code and data parameters are stored in the Project.memory and code is disassembled and lifted if the specified target has a disassembler and lifter.

The filename is used to communicate with external tools and will be broadcasted via Info.file stream and stored in the filename property of the project, otherwise it is not used when the project is created.

The finish project is the post-constructor that takes the nearly finished project (with code and data and potentially disassembled and lifted code) and constructs the final project.

val register_loader : string -> (string -> t) -> unit

register_loader name load register a loader under provided name. The load function will be called the filename, and it must return the input value.

val available_loaders : unit -> string list

available_loaders () returns a list of names of currently known loaders.

Deprecated Interface

The following functions are deprecated and better alternatives are provided. They might be removed in BAP 3.0.

val binary : ?base:addr -> arch -> filename:string -> t

binary ?base arch ~filename create an input from a binary file that is a pure code without any headers or meta information.

  • parameter base

    is an virtual address of the first byte (defaults to 0).

  • deprecated

    use Input.raw_file instead.

val file : ?loader:string -> filename:string -> t

file ?target ?loader ~filename input data from a file, using the specified loader. If loader is not specified, then some existing loader will be used. If it is specified, then it is first looked up in the available_loaders and if it is not found, then it will be looked up in the Image.available_backends.

  • deprecated

    use Input.load filename

val create : ?finish:(project -> project) -> arch -> string -> code:value memmap -> data:value memmap -> t

create arch filename ~code ~data creates an input from a file, using two memory maps. The code memmap spans the code in the file, and data spans the data. An optional finish function can be used to propagate to the project any additional information that is available to the loader. It defaults to Fn.id.

  • deprecated

    use either Input.custom or Input.from_string and Input.from_bigstring.

OCaml

Innovation. Community. Security.