1

I am running my IDA script on many files (batching), and i need to get the file name the script is running on within the script. the problem is i cannot find any API that does that.

the closest things i found was GetIdbDir(), which doesn't include the file name, also there seems to be a get_path function in ida_loader, but it expects a c type pointer, when i gave it a python string it failed.

2
  • You can use get_input_file_path() IDC function and then extract the file name from it. It's also available in IDAPython as ida_nalt.get_input_file_path source.
    – bart1e
    Aug 29, 2020 at 12:33
  • @bart1e yep that worked thanks, you can post the answer so i can select it as the answer.
    – OneAndOnly
    Sep 4, 2020 at 14:50

2 Answers 2

3

You can use get_input_file_path() IDC function and then extract the file name from it.

It's also available in IDAPython as ida_nalt.get_input_file_path (source).

2

There are three functions exposed by ida_nalt and two of those aliased from idc module.

  • idc.get_root_filename = ida_nalt.get_root_filename
    Returns the file name only (no leading path elements; old name idc.GetInputFile)
  • idc.get_input_file_path = ida_nalt.get_input_file_path Returns the full file path (old name idc.GetInputFilePath) ida_nalt.get_input_file_path
  • and separately ida_nalt.dbg_get_input_path

All of them return a str and take no arguments.

PS: didn't want to butcher the original answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.