{"id":27953811,"url":"https://github.com/binaryanalysisplatform/bap-bindings","last_synced_at":"2025-07-25T07:37:05.810Z","repository":{"id":46118811,"uuid":"78047909","full_name":"BinaryAnalysisPlatform/bap-bindings","owner":"BinaryAnalysisPlatform","description":"C Bindings to BAP","archived":false,"fork":false,"pushed_at":"2022-07-13T17:30:29.000Z","size":141,"stargazers_count":15,"open_issues_count":3,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-08T05:44:17.336Z","etag":null,"topics":["bap","binary-analysis","reverse-engineering"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BinaryAnalysisPlatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-04T19:53:25.000Z","updated_at":"2022-05-17T08:05:06.000Z","dependencies_parsed_at":"2022-09-23T06:40:28.490Z","dependency_job_id":null,"html_url":"https://github.com/BinaryAnalysisPlatform/bap-bindings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BinaryAnalysisPlatform/bap-bindings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryAnalysisPlatform%2Fbap-bindings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryAnalysisPlatform%2Fbap-bindings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryAnalysisPlatform%2Fbap-bindings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryAnalysisPlatform%2Fbap-bindings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BinaryAnalysisPlatform","download_url":"https://codeload.github.com/BinaryAnalysisPlatform/bap-bindings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryAnalysisPlatform%2Fbap-bindings/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266974135,"owners_count":24014847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bap","binary-analysis","reverse-engineering"],"created_at":"2025-05-07T17:14:58.114Z","updated_at":"2025-07-25T07:37:05.769Z","avatar_url":"https://github.com/BinaryAnalysisPlatform.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BAP Bindings\n\nThis project provides a C interface to BAP library and other\ncomponents of the infrastructure. The interface is rather complete,\nalthough some functions may be omitted for a reason or accidentaly.\nBy desing, everything that is possible to do in OCaml with the Bap.Std\ninterface should be possible to implement in C, using `bap.h`. If you\nfind any violations of this rule, please don't hesitate to file an\nissue.\n\n\n## Quick start\n\nThe following simple program is a good test that your installation\nworks fine.\n\n```c\nint main(int argc, const char *argv) {\n    bap_init(argc, argv);\n    printf(\"Welcome to BAP %s\", bap_version());\n}\n\n```\n\nThe `examples` folder contains a set of small programs, that can be\nviewed as tutorials to BAP and BAP bindings. The following order is\nsuggested:\n\n1. lift_insn - teaches how to disassemble, lift and print code;\n2. print_reachable - explains how to write simple analysis;\n3. show_image - uncovers low-level details of file parsing.\n\n## Requirements\n\n* BAP 2.x.x\n* OCaml 4.03+ with PIC runtime\n* GCC\n* Patience (it takes some time to generate the bindings)\n\nThe PIC runtime is usually installed with OCaml (at least in OPAM).\n\n\n## Compilation and installation\n\nNothing new here:\n\n```\nautoconf\n./configure\nmake\nmake install\n```\n\nYou can parametrize installation variables, e.g., prefix using the\nconfigure script, see `./configure --help` for more information.\n\nIf the `configure` script is not available (e.g., when you just cloned\nthe repo), then use `autoconf` to generate it.\n\n\n# Documentation\n\nLacks. The long story is the following. There is an official\nsearchable documentation for OCaml library. You should consult it as a\nprimary source of information. Although it is for OCaml, it should be\nunderstandable without a dictionary. We were trying to follow some\nconventions to make it easier to map C functions to their OCaml\ncounterpart.\n\n1. Module namespaces are translated to the underscore delimited\n   prefixes, with exception to Bap.Std that is translated just to\n   `bap`, e.g., `Project.Input.file` is `project_input_file`. So to\n   get the documentation for the `project_input_file` just type\n   `Project.Input.file` in the search window of the OCaml\n   documentation. The same is true for types. A type `Project.t` is\n   defined as an opaque data structure `bap_project_t`. The name is\n   typedefed into from the structure tag namespace to the symbol\n   namespace, so no `struct` word is needed.\n\n2. The order of function parameters is preserved, except that optional\n   parameters (prefixed with `?` in OCaml) are specified after all\n   required parameters. For example,\n   `Project.Input.file ?loader:string -\u003e filename:string -\u003e t`\n   is translated into `project_input_file(char *filename, char *loader)`.\n   The `NULL` value can be passed as an argument to the optional parameter.\n\n3. If there are too many optional parameters, then they are passed\n   using a strcture. Field names of a structure correspond to the\n   names of optional parameters. For example, `bap_project_create` corresponds\n   to `Project.create` function that has the following interface:\n    ```ocaml\n    val create :\n           ?disassembler:string -\u003e\n           ?brancher:brancher source -\u003e\n           ?symbolizer:symbolizer source -\u003e\n           ?rooter:rooter source -\u003e\n           ?reconstructor:reconstructor source -\u003e\n           input -\u003e t Or_error.t\n    ```\n       In C land it corresponds to\n\n    ```c\n    struct bap_project_t* bap_project_create(struct bap_project_input_t* input,\n                                             struct bap_project_parameters_t* params);\n    ```\n\n       Where structure `params` is defined as:\n\n    ```c\n    struct bap_project_parameters_t {\n      bap_rooter_source_t* rooter;\n      bap_brancher_source_t* brancher;\n      bap_symbolizer_source_t* symbolizer;\n      bap_reconstructor_source_t* reconstructor;\n      char* disassember;\n    };\n\n    ```\n   Each individual field of the params data structure can be\n   `NULL`. Moreover, the params itself can be also `NULL`. That will denote\n   that all optional arguments were omitted.\n\n4. Nontotal functions (those that return `t Or_error.t` or `t option`\n   instead of `t`) may return `NULL`. If the OCaml counterpart was\n   returning a value of `t Or_error.t` then the error can be retrieved\n   with `bap_error_get` function.\n\n\n5. If a module `XXX` implements `Printable.S` interface, then the following\n   functions are available:\n   * `bap_XXX_to_string(bap_XXX_t *)` returns a string representation of a value;\n   * `bap_fprint(bap_XXX_t *value, FILE *)` prints value into a stream;\n   * `bap_print(bap_XXX_t *)` prints a value into stdout;\n   * `bap_eprint(bap_XXX_t *)` prints a value into stderr;\n\n6. If a module `XXX` implements `Data.S` interface, then the following\n   functions are available:\n   * `bap_XXX_data_version(void)`;\n   * `bap_XXX_data_size(bap_XXX_t *)`;\n   * `bap_XXX_copy(bap_XXX_t *value, char *data, int len)`;\n   * `bap_XXX_of_bytes(char *data, int len)`;\n   * `bap_XXX_input(const char *filename)`;\n   * `bap_XXX_output(const char *filename)`;\n\n\n6. If a module `XXX` implements `Data.S` interface, (that subsumes\n   `Printable.S` and `Data.S`) then the following functions are\n   also available:\n   * `bap_XXX_hash(bap_XXX_t *)`;\n   * `bap_XXX_equal(bap_XXX_t *x, bap_XXX_t *y)`;\n   * `bap_XXX_compare(bap_XXX_t *x, bap_XXX_t *y)`;\n\n7. Polymorphic operations are provided for certain type in a type-safe\n   maner. A polymorphic operation `OP` defined in module `M`\n   concretized for type `XXX` will be named `bap_XXX_M_OP` for\n   example, `Seq.map` for a sequence of `insn` is named\n   `bap_insn_seq_map`.  Currenlty, all Regular types provide two\n   polymorphic containers: `set` and `seq`. The `set` is implemented\n   using mutable hash table, and `seq` is a generic sequence (that can\n   be even infinte).\n\n8. Truly generic operatons, like `Seq.length` are provided as\n   `bap_seq_length`, wher `bap_seq_t` is base class for all sequences\n   (in the sense, `bap_XXX_seq_t` is an instance of `bap_seq_t` for\n   all `XXX`). The instance relation is checked in runtime, a static\n   cast is required at compile time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinaryanalysisplatform%2Fbap-bindings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinaryanalysisplatform%2Fbap-bindings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinaryanalysisplatform%2Fbap-bindings/lists"}