This class represents the disassembled document. A document is a set of segments.
Creates and returns a new empty document.
getCurrentDocument()
[static]
Returns the current document.
getAllDocuments()
[static]
Returns a list of all currently opened documents.
Open a window containing a text field, and wait for the user to give a string value. Returns the string, or returns None if the Cancel button is hit.
askFile(msg,path,save)
[static]
Open a file dialog with a specified title, in order to select a file. The 'save' parameter allows you to choose between on 'open' or a 'save' dialog.
askDirectory(msg,path)
[static]
Open a file dialog with a specified title, in order to select a directory.
message(msg,buttons)
[static]
Open a window containing a text field and a set of buttons. The 'Buttons' parameter is a list of strings. The function returns the index of the clicked button.
closeDocument()
Close the document.
loadDocumentAt(path)
Load a document at a given path.
saveDocument()
Save the document.
saveDocumentAt(path)
Save the document at a given path.
getDocumentName()
Returns the document display name.
setDocumentName(name)
Set the document display name.
backgroundProcessActive()
Returns True if the background analysis is still running.
requestBackgroundProcessStop()
Request the background analysis to stop as soon as possible, and wait for its termination.
waitForBackgroundProcessToEnd()
Wait until the background analysis is ended.
assemble(instr,address,syntax)
Assemble an instruction, and returns the bytes as an array. The instruction is NOT injected in the document: the address given to the function is used to encode the instruction. You wan use the writeByte method to inject an assembled instruction. The first argument is the instruction to be assembled. The second is the address of the instruction. The last parameter is the syntax variant index. For the Intel processor, syntax = 0 for Intel syntax, and 1 for AT&T syntax.
getDatabaseFilePath()
Returns the path of the current Hopper database for this document (the HOP file).
getExecutableFilePath()
Returns the path of the executable being analyzed.
setExecutableFilePath(path)
Set the path of the executable being analyzed.
log(msg)
Display a string message into the log window of the document.
newSegment(start_address,length)
Create a new segment of 'length' bytes starting at 'start_address'.
deleteSegment(seg_index)
Delete the segment at a given index. Return True if succeeded.
renameSegment(seg_index,name)
Rename the segment at a given index. Return True if succeeded.
getSegmentCount()
Returns the number of segment the document contains.
getSegment(index)
Returns a segment by index. The returned object is an instance of the Segment class. If the index of not in the range [0;count[, the function returns None.
getSegmentByName(name)
Returns a segment by name. Return None if no segment with this name was found. If multiple segments have this name, the first one is returned.
getSectionByName(name)
Returns a section by name. Return None if no segment with this name was found. If multiple sections have this name, the first one is returned.
getSegmentsList()
Returns a list containing all the segments.
getSegmentIndexAtAddress(addr)
Returns the segment index for a particular address.
getSegmentAtAddress(addr)
Returns the segment for a particular address.
getSectionAtAddress(addr)
Returns the section for a particular address.
getCurrentSegmentIndex()
Returns the segment index where the cursor is. Returns -1 if the current segment cannot be located.
getCurrentSegment()
Returns the segment where the cursor is. Returns None if the current segment cannot be located.
getCurrentSection()
Returns the section where the cursor is. Returns None if the current section cannot be located.
getCurrentProcedure()
Returns the Procedure object where the cursor is. Returns None if there is no procedure there.
getCurrentAddress()
Returns the address where the cursor currently is.
setCurrentAddress(addr)
Set the address where the cursor currently is.
getSelectionAddressRange()
Returns a list, containing two addresses. Those address represents the range of bytes covered by the selection.
moveCursorAtAddress(addr)
Move the cursor at a given address.
selectAddressRange(addrRange)
Select a range of byte. The awaited argument is a list containing exactly two address.
getFileOffsetFromAddress(addr)
Returns the file offset corresponding to the given address.
getAddressFromFileOffset(offset)
Returns the address corresponding to the given file offset.
is64Bits()
Returns True if the disassembled document is interpreted as a 64 bits binary.
getEntryPoint()
Returns the entry point of the document.
moveCursorAtEntryPoint()
Move the cursor at the entry point.
getHighlightedWord()
Returns the word that is currently highlighted in the assembly view.
setNameAtAddress(addr,name)
Set the label name at a given address.
getNameAtAddress(addr)
Get the label name at a given address.
getAddressForName(name)
Get the address associated to a given name.
refreshView()
Force the assembly view to be refresh.
moveCursorOneLineDown()
Move the current line down, and remove the multiselection if needed. Returns True if cursor moved.
moveCursorOneLineUp()
Move the current line up, and remove the multiselection if needed. Returns True if cursor moved.
getRawSelectedLines()
Returns a list of strings corresponding to the current selection.
addTagAtAddress(tag,addr)
Add a tag at a particular address.
removeTagAtAddress(tag,addr)
Remove the tag at a particular address.
hasTagAtAddress(tag,addr)
Returns True if the tag is present at this address.
getTagCountAtAddress(addr)
Returns the number of tags at a given address.
getTagAtAddressByIndex(addr,index)
Returns the Nth tag present at a given address.
tagIteratorAtAddress(addr)
Iterates over all tags present at a given address.
getTagListAtAddress(addr)
Returns the list of all tags present at a given address
getTagCount()
Returns the total number of tags available.
getTagAtIndex(index)
Returns a Tag object, or None if the index does not exists.
tagIterator()
Iterate over all the tags.
getTagList()
Returns a list of all tags.
buildTag(name)
Build a tag with a given name. If a tag with the same name already exists, it return the existing tag.
getTagWithName(name)
Returns a Tag object if a tag with this name already exists, or None.
destroyTag(tag)
Remove the tag from every location, and delete it.
hasColorAtAddress(addr)
Returns True if a color has been defined at the given address.
setColorAtAddress(color,addr)
Sets the color at a given address. The color is a 32bits integer representing the hexadecimal color in the form #AARRGGBB.
getColorAtAddress(addr)
Returns the color at a given address. The color is a 32bits integer representing the hexadecimal color in the form #AARRGGBB.
removeColorAtAddress(addr)
Remove the color at a given address.
readBytes(addr,length)
Read bytes from a mapped segment, and return a string. Returns False if no segments was found for this range.
readByte(addr)
Read a byte from a mapped segment. Returns False if no segments was found for this address.
readUInt16LE(addr)
Read a 16 bits little endian integer from a mapped segment. Returns False if no segments was found for this address.
readUInt32LE(addr)
Read a 32 bits little endian integer from a mapped segment. Returns False if no segments was found for this address.
readUInt64LE(addr)
Read a 64 bits little endian integer from a mapped segment. Returns False if no segments was found for this address.
readUInt16BE(addr)
Read a 16 bits big endian integer from a mapped segment. Returns False if no segments was found for this address.
readUInt32BE(addr)
Read a 32 bits big endian integer from a mapped segment. Returns False if no segments was found for this address.
readUInt64BE(addr)
Read a 64 bits bif endian integer from a mapped segment. Returns False if no segments was found for this address.
writeBytes(addr,byteStr)
Write bytes to a mapped segment. Bytes are given as a string. Returns False if no segments was found for this range.
writeByte(addr,value)
Write a byte to a mapped segment. Returns True if succeeded.
writeUInt16LE(addr,value)
Write a 16 bits little endian integer to a mapped segment. Returns True if succeeded.
writeUInt32LE(addr,value)
Write a 32 bits little endian integer to a mapped segment. Returns True if succeeded.
writeUInt64LE(addr,value)
Write a 64 bits little endian integer to a mapped segment. Returns True if succeeded.
writeUInt16BE(addr,value)
Write a 16 bits big endian integer to a mapped segment. Returns True if succeeded.
writeUInt32BE(addr,value)
Write a 32 bits big endian integer to a mapped segment. Returns True if succeeded.
writeUInt64BE(addr,value)
Write a 64 bits big endian integer to a mapped segment. Returns True if succeeded.
getOperandFormat(addr,index)
Returns the format requested by the user for a given intruction operand.
getOperandFormatRelativeTo(addr,index)
Returns the address to which the format is relative. Usually used for FORMAT_ADDRESS_DIFF format.
setOperandFormat(addr,index,fmt)
Set the format of a given intruction operand.
setOperandRelativeFormat(addr,relto,index,fmt)
Set the relative format of a given intruction operand. This version allows one to provide an address used for the relative formats, like FORMAT_ADDRESS_DIFF.
getInstructionStart(address)
Returns the lowest address value of the instruction found at a particular address. If the given address is in the middle of an instruction, Hopper will look back to find the first byte of this instruction.
getObjectLength(address)
Returns the length in bytes of the object at this address. The object can be an instruction, a data, etc.
generateObjectiveCHeader()
Returns a bytearray object containing the generated Objective-C header extracted from the file's metadata.
produceNewExecutable(remove_sig=False)
Produce a new executable including all the modifications. The optional argument is a boolean indicating if the signature is to be removed in the case of a Mach-O file. Returns a string containing the produced executable.