data
Raw binary representation of the active file. This object can be accessed or modified using standard
Python []
operator (slices are supported). See below for a description of the methods
supported by the data object.
exe
Like the data
object, but instead represents the in memory view of an executable. If the
file is not an executable, this object is the same as data
. This object can also be
accessed or modified using the standard Python []
operator. See below for a description
of the methods supported by the data object.
view
Active view container object. Most functionality is exposed by the APIs listed below.
data.read(address, size)
Reads the given number of bytes at the given address, and returns the result as a string object.
data.write(address, value)
Writes the given value at the given address. The given value should be a string object containing the data to be written. The write is an in-place overwrite that is the same length as the string object given. The function returns the number of bytes written.
data.insert(address, value)
Inserts the given value at the given address. The existing contents at the given address will be moved to be directly after the inserted data. The given value should be a string object containing the data to be written. Some data types may not support insertion, and will return zero from this function. The function returns the number of bytes inserted.
data.remove(address, size)
Removes the given number of bytes at the given address. Some data types may not support removal of bytes, and will return zero from this function. The function returns the number of bytes removed.
data.add_callback(object)
Registers an object to receive callbacks when this data object is updated. The following methods will be invoked when the data is updated:
callback.notify_data_write(data, address, value)
: Data was written with data.write
.callback.notify_data_insert(data, address, value)
: Data was inserted with data.insert
.callback.notify_data_remove(data, address, size)
: Data was removed with data.remove
.data.remove_callback(object)
Unregisters an object that was receiving callbacks.
data.save(filename)
Saves the current file contents to disk with the given filename.
data.start()
Gets the starting address of the data. For raw data, this will be zero. For executables, this will be the base address of the module.
data.is_modified()
Determines if the data has been modified since the last time it was written to disk.
data.find(regex, address)
Find the first occurence of the given regular expression starting at the given address. Returns the address of the first match.
data.architecture()
Returns the target CPU architecture of the file. For raw data, this will default to 32-bit X86.
data.entry()
Gets the entry point of an executable. This method will not exist on raw data objects.
current_view()
Get the currently active view.
change_view(view_type)
Changes the current view to the type passed. The type should be the class object of the desired view
type (for example, DisassemblerView.DisassemblerView
).
navigate(action_type, address)
Navigates to the given address with the given action type string. The following action types are currently defined in the default install:
disassembler
: Navigate to address in disassembly view.make_proc
: Make new function at address in disassembly view.hex
: Navigate to address in raw hex view.exe
: Navigate to address in executable hex view.create_file(data)
Creates a new unnamed file with the given contents. The initial view type is chosen based on the content in the same manner as opening a file through the user interface.
cursor()
Gets the address of the current cursor position.
set_cursor(pos)
Sets the cursor position to the given address. After this function call there will be no active selection.
selection_range()
Gets the address range of the current selection as a tuple. The first element is the start of the selection and the second element is the end of the selection. If there is no selection, the function returns the current cursor position in both of the elements. The second element minus the first element is the length of the selection.
set_selection_range(start, end)
Sets the current selection to the range given.
selection()
Returns the currently selected bytes as a string object. If there is no selection, this function returns the empty string.
replace_selection(value)
Replaces the selected bytes with the given value. The value should be a string object containing the new data. If there is no active selection, this function will insert the bytes at the cursor position.
write_at_cursor(value)
Overwrites the bytes at the cursor position with the given value. The value should be a string object containing the new data. This is an in-place overwrite and will perform a write of the same length as the string object passed to this function.
undo()
Undo the last action(s) performed since the last undo buffer commit.
redo()
Redo the actions that were last undone.
commit()
Commit the actions pending in the undo buffer. Each undo action will go to the previous buffer commit. Undo buffer commits should be performed after each logical action (i.e. replace, rebase image, create symbol, etc.). If an undo buffer commit is not performed, undo will still function, but may cause more actions to be undone than desired for a single step.
copy(value)
Copies the given value to the clipboard. The value should be a string object containing the data to be copied.
paste()
Paste the contents of the clipboard into the current view. This performs the same function as the paste menu item.
clipboard()
Get the current clipboard contents as a string object.