Class rehex.Document

An open “Document” (file) in the editor.

Methods

rehex.Document:buffer_length () Get the length of the file, in bytes.
rehex.Document:clear_virt_mapping_r (real_offset, length) Clear virtual address mapping by file offset.
rehex.Document:clear_virt_mapping_v (virt_offset, length) Clear virtual address mapping by virtual address.
rehex.Document:get_comments () Get all comments in the document.
rehex.Document:get_filename () Get the filename of the document.
rehex.Document:get_title () Get the title of the document.
rehex.Document:read_data (offset, max_length) Read data from the document.
rehex.Document:real_to_virt_offset (real_offset) Convert a file offset to a virtual address.
rehex.Document:set_comment (offset, length, comment) Set a comment in the document.
rehex.Document:set_data_type (offset, length, type) Set the data type of a range of bytes.
rehex.Document:set_virt_mapping (real_offset, virt_offset, length) Set up a virtual address mapping in the document.
rehex.Document:virt_to_real_offset (virt_offset) Convert a virtual address to a file offset.


Methods

rehex.Document:buffer_length ()
Get the length of the file, in bytes.
rehex.Document:clear_virt_mapping_r (real_offset, length)
Clear virtual address mapping by file offset.

Parameters:

  • real_offset Offset to segment to clear in file.
  • length Length to clear in bytes.

    This method can be used to clear partial of whole segments. Any byte ranges which are not part of a virtual segment will be ignored.

rehex.Document:clear_virt_mapping_v (virt_offset, length)
Clear virtual address mapping by virtual address.

Parameters:

  • virt_offset Address of segment to clear.
  • length Length to clear in bytes.

    This method can be used to clear partial of whole segments. Any byte ranges which are not part of a virtual segment will be ignored.

rehex.Document:get_comments ()
Get all comments in the document.

Returns:

    A table containing each comment as a table.

    {
        {
            offset = 0,
            length = 0,
            text   = "First comment",
        },
        {
            offset = 10,
            length = 8,
            text   = "Second comment",
        },
    }
    
rehex.Document:get_filename ()
Get the filename of the document.
rehex.Document:get_title ()
Get the title of the document.
rehex.Document:read_data (offset, max_length)
Read data from the document.

Parameters:

  • offset File offset to read from, in bytes.
  • max_length Maximum number of bytes to read.

Returns:

    The binary data as a string.
rehex.Document:real_to_virt_offset (real_offset)
Convert a file offset to a virtual address.

Parameters:

  • real_offset
    • File offset.

Returns:

    Virtual address of file offset, negative if offset isn’t part of a virtual segment.
rehex.Document:set_comment (offset, length, comment)
Set a comment in the document.

Parameters:

  • offset File offset in bytes.
  • length Length in bytes.
  • comment rehex.REHex_Document_Comment object.

Returns:

    true on success, false on failure

    Example usage:

    -- Set a comment at the start of the file.
    doc:set_comment(0, 0, rehex.Comment.new("Hello world"))
    

    The length parameter sets how many bytes are encompassed by the comment - if it is zero, the comment will just be inserted at that point in the data, if nonzero, it will visibly nest the data in itself (if the “Nest comments” option is enabled).

    Existing comments with the same offset and length will be replaced.

rehex.Document:set_data_type (offset, length, type)
Set the data type of a range of bytes.

Parameters:

  • offset File offset in bytes
  • length Length in bytes
  • type Data type as a string

Returns:

    true on success, false on failure

    Example data types include:

    "u16le"      - unsigned 16-bit (little endian)
    "f32be"      - 32-bit float (big endian)
    "code:i386"  - Machine code (X86)
    
rehex.Document:set_virt_mapping (real_offset, virt_offset, length)
Set up a virtual address mapping in the document.

Parameters:

  • real_offset Offset to start of segment in file.
  • virt_offset Virtual address of segment.
  • length Length of segment in bytes.

Returns:

    true on success, false on conflict.
rehex.Document:virt_to_real_offset (virt_offset)
Convert a virtual address to a file offset.

Parameters:

  • virt_offset
    • Virtual address.

Returns:

    File offset of virtual address, negative if address isn’t part of a virtual segment.
generated by LDoc 1.4.6 Last updated 2021-05-03 00:07:25