filemetadata module

binaryninja.filemetadata.FileMetadata([…])

class FileMetadata represents the file being analyzed by Binary Ninja.

binaryninja.filemetadata.NavigationHandler()

binaryninja.filemetadata.SaveSettings([handle])

class SaveSettings is used to specify actions and options that apply to saving a database (.bndb).

binaryninja.filemetadata.pyNativeStr(arg)

class FileMetadata(filename=None, handle=None)[source]

Bases: object

class FileMetadata represents the file being analyzed by Binary Ninja. It is responsible for opening, closing, creating the database (.bndb) files, and is used to keep track of undoable actions.

begin_undo_actions()[source]

begin_undo_actions start recording actions taken so the can be undone at some point.

Return type

None

Example
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>> bv.begin_undo_actions()
>>> bv.convert_to_nop(0x100012f1)
True
>>> bv.commit_undo_actions()
>>> bv.get_disassembly(0x100012f1)
'nop'
>>> bv.undo()
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>>
close()[source]

Closes the underlying file handle. It is recommended that this is done in a finally clause to avoid handle leaks.

close_project()[source]
commit_undo_actions()[source]

commit_undo_actions commit the actions taken since the last commit to the undo database.

Return type

None

Example
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>> bv.begin_undo_actions()
>>> bv.convert_to_nop(0x100012f1)
True
>>> bv.commit_undo_actions()
>>> bv.get_disassembly(0x100012f1)
'nop'
>>> bv.undo()
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>>
create_database(filename, progress_func=None, settings=None)[source]

create_database writes the current database (.bndb) out to the specified file.

Parameters
  • filename (str) – path and filename to write the bndb to, this string should have “.bndb” appended to it.

  • progress_func (callback) – optional function to be called with the current progress and total count.

  • settings (SaveSettings) – optional argument for special save options.

Returns

true on success, false on failure

Return type

bool

Example
>>> settings = SaveSettings()
>>> bv.file.create_database(f"{bv.file.filename}.bndb", None, settings)
True
get_view_of_type(name)[source]
is_project_open()[source]
merge_user_analysis(path, progress_func=None)[source]
navigate(view, offset)[source]

navigate navigates the UI to the specified virtual address

Note

Despite the confusing name, view in this context is not a BinaryView but rather a string describing the different UI Views. Check view while in different views to see examples such as Linear:ELF, Graph:PE.

Parameters
  • view (str) – virtual address to read from.

  • offset (int) – address to navigate to

Returns

whether or not navigation succeeded

Return type

bool

Example
>>> import random
>>> bv.navigate(bv.view, random.choice(bv.functions).start)
True
open_database_for_configuration(filename)[source]
open_existing_database(filename, progress_func=None)[source]
open_project()[source]
redo()[source]

redo redo the last committed action in the undo database.

Return type

None

Example
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>> bv.begin_undo_actions()
>>> bv.convert_to_nop(0x100012f1)
True
>>> bv.commit_undo_actions()
>>> bv.get_disassembly(0x100012f1)
'nop'
>>> bv.undo()
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>> bv.redo()
>>> bv.get_disassembly(0x100012f1)
'nop'
>>>
save_auto_snapshot(progress_func=None, settings=None)[source]
classmethod set_default_session_data(name, value)[source]
undo()[source]

undo undo the last committed action in the undo database.

Return type

None

Example
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>> bv.begin_undo_actions()
>>> bv.convert_to_nop(0x100012f1)
True
>>> bv.commit_undo_actions()
>>> bv.get_disassembly(0x100012f1)
'nop'
>>> bv.undo()
>>> bv.get_disassembly(0x100012f1)
'xor     eax, eax'
>>> bv.redo()
>>> bv.get_disassembly(0x100012f1)
'nop'
>>>
property analysis_changed

Boolean result of whether the auto-analysis results have changed (read-only)

property existing_views
property filename

The name of the open bndb or binary filename (read/write)

property has_database

Whether the FileMetadata is backed by a database, or if specified, a specific BinaryViewType (read-only)

property modified

Boolean result of whether the file is modified (Inverse of ‘saved’ property) (read/write)

property nav
property navigation

Alias for nav

property offset

The current offset into the file (read/write)

property original_filename

The original name of the binary opened if a bndb, otherwise reads or sets the current filename (read/write)

property raw

Gets the “Raw” BinaryView of the file

property saved

Boolean result of whether the file has been saved (Inverse of ‘modified’ property) (read/write)

property session_data

Dictionary object where plugins can store arbitrary data associated with the file

property snapshot_data_applied_without_error
property view
class NavigationHandler[source]

Bases: object

class SaveSettings(handle=None)[source]

Bases: object

class SaveSettings is used to specify actions and options that apply to saving a database (.bndb).

is_option_set(option)[source]
set_option(option, state=True)[source]

Set a SaveOption in this instance.

Parameters
  • option (SaveOption) – Option to set.

  • state (bool) – State to assign. Defaults to True.

Example
>>> settings = SaveSettings()
>>> settings.set_option(SaveOption.TrimSnapshots)