Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions plugins/ida/bap_ida_service.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open Core_kernel.Std
open Bap_ida.Std
open Bap.Std

type ida_kind = [ `idal | `idal64 | `idaq | `idaq64 ] [@@deriving sexp]

Expand Down Expand Up @@ -73,19 +74,22 @@ let setup_headless_env path =
with Not_found -> "", lib in
Unix.putenv var new_path;
fun () ->
FileUtil.rm ~recurse:true [lib];
if old_path <> "" then Unix.putenv var old_path
try
FileUtil.rm ~recurse:true [lib];
if old_path <> "" then Unix.putenv var old_path
with _ -> ()

(* ida works fine only if everything is in the same folder *)
let run (t:ida) cmd =
let cwd = Unix.getcwd () in
let clean = match t.curses with
| Some path -> setup_headless_env path
| None -> fun () -> () in
let cleanup () = clean (); Sys.chdir cwd in
Sys.chdir (Filename.dirname t.exe);
cmd ();
clean ();
Sys.chdir cwd
try cmd (); cleanup ()
with exn -> cleanup (); raise exn


let check_path path = match Bap_ida_check.check_path path with
| Ok () -> ()
Expand Down
6 changes: 3 additions & 3 deletions plugins/ida/ida_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let extract path arch =
| None -> match Ida.(with_file path get_symbols) with
| [] ->
warning "didn't find any symbols";
info "this plugin doesn't work with IDA Free";
info "note: this plugin doesn't work with IDA Free";
[]
| syms -> Symbols.Cache.save id syms; syms in
let size = Arch.addr_size arch in
Expand All @@ -57,15 +57,15 @@ let extract path arch =
let register_source (module T : Target) =
let source =
let open Project.Info in
let extract file arch = Or_error.try_with (fun () ->
let extract file arch = Or_error.try_with ~backtrace:true (fun () ->
extract file arch |> T.of_blocks) in
Stream.merge file arch ~f:extract in
T.Factory.register name source


type perm = [`code | `data] [@@deriving sexp]
type section = string * perm * int * (int64 * int)
[@@deriving sexp]
[@@deriving sexp]

type image = string * addr_size * section list [@@deriving sexp]

Expand Down