-class insn_t;
-
-/*! \file bytes.hpp
-
- \brief Contains functions that deal with individual byte characteristics.
-
- Each byte of the disassembled program is represented by a 32-bit
- value. We will call this value 'flags'. The structure of the flags is
- here.
-
- You are not allowed to inspect individual bits of flags and modify them directly.
- Use special functions to inspect and/or modify flags.
-
- Flags are kept in a virtual array file (*.id1).
- Addresses (ea) are all 32-bit (or 64-bit) quantities.
-*/
-
-//--------------------------------------------------------------------------
-/// Allocate flags for address range.
-/// This function does not change the storage type of existing ranges.
-/// Exit with an error message if not enough disk space.
-/// \param start_ea should be lower than end_ea.
-/// \param end_ea does not belong to the range.
-/// \param stt ::storage_type_t
-/// \return 0 if ok, otherwise an error code
-
-idaman error_t ida_export enable_flags(ea_t start_ea, ea_t end_ea, storage_type_t stt);
-
-
-/// Deallocate flags for address range.
-/// Exit with an error message if not enough disk space (this may occur too).
-/// \param start_ea should be lower than end_ea.
-/// \param end_ea does not belong to the range.
-/// \return 0 if ok, otherwise return error code
-
-idaman error_t ida_export disable_flags(ea_t start_ea, ea_t end_ea);
-
-
-/// Change flag storage type for address range.
-/// \param start_ea should be lower than end_ea.
-/// \param end_ea does not belong to the range.
-/// \param stt ::storage_type_t
-/// \return error code
-
-idaman error_t ida_export change_storage_type(ea_t start_ea, ea_t end_ea, storage_type_t stt);
-
-
-/// Get next address in the program (i.e. next address which has flags).
-/// \return #BADADDR if no such address exist.
-
-idaman ea_t ida_export next_addr(ea_t ea);
-
-
-/// Get previous address in the program.
-/// \return #BADADDR if no such address exist.
-
-idaman ea_t ida_export prev_addr(ea_t ea);
-
-
-/// Get the first address of next contiguous chunk in the program.
-/// \return #BADADDR if next chunk doesn't exist.
-
-idaman ea_t ida_export next_chunk(ea_t ea);
-
-
-/// Get the last address of previous contiguous chunk in the program.
-/// \return #BADADDR if previous chunk doesn't exist.
-
-idaman ea_t ida_export prev_chunk(ea_t ea);
-
-
-/// Get start of the contiguous address block containing 'ea'.
-/// \return #BADADDR if 'ea' doesn't belong to the program.
-
-idaman ea_t ida_export chunk_start(ea_t ea);
-
-
-/// Get size of the contiguous address block containing 'ea'.
-/// \return 0 if 'ea' doesn't belong to the program.
-
-idaman asize_t ida_export chunk_size(ea_t ea);
-
-
-/// Search for a hole in the addressing space of the program.
-/// \param bottom address to start searching
-/// \param size size of desired block
-/// \param step bit mask for the start of hole (0xF would align hole to a paragraph).
-/// if 'step' is negative, the bottom address with be aligned.
-/// otherwise the kernel will try to use it as is and align it
-/// only when the hole is too small.
-/// \return start of the hole or #BADADDR
-
-idaman ea_t ida_export free_chunk(ea_t bottom, asize_t size, int32 step);
-
-
-/// Flag tester - see next_that(), prev_that()
-typedef bool idaapi testf_t(flags_t flags, void *ud);
-
-
-/// Find next address with a flag satisfying the function 'testf'.
-/// \note do not pass is_unknown() to this function to find unexplored bytes.
-/// It will fail under the debugger. To find unexplored bytes, use next_unknown().
-/// \param ea start searching at this address + 1
-/// \param maxea not included in the search range.
-/// \param testf test function to find next address
-/// \param ud user data - may point to anything. it will be passed to testf.
-/// \return the found address or #BADADDR.
-
-idaman ea_t ida_export next_that(
- ea_t ea,
- ea_t maxea,
- testf_t *testf,
- void *ud=nullptr);
-
-
-/// Similar to next_that(), but will find the next address that is unexplored
-
-inline ea_t idaapi next_unknown(ea_t ea, ea_t maxea)
-{
- return next_that(ea, maxea, nullptr);
-}
-
-
-/// Find previous address with a flag satisfying the function 'testf'.
-/// \note do not pass is_unknown() to this function to find unexplored bytes
-/// It will fail under the debugger. To find unexplored bytes, use prev_unknown().
-/// \param ea start searching from this address - 1.
-/// \param minea included in the search range.
-/// \param testf test function to find previous address
-/// \param ud user data - may point to anything. it will be passed to testf.
-/// \return the found address or #BADADDR.
-
-idaman ea_t ida_export prev_that(
- ea_t ea,
- ea_t minea,
- testf_t *testf,
- void *ud=nullptr);
-
-
-/// Similar to prev_that(), but will find the previous address that is unexplored
-
-inline ea_t idaapi prev_unknown(ea_t ea, ea_t minea)
-{
- return prev_that(ea, minea, nullptr);
-}
-
-
-/// Get start of previous defined item.
-/// \param ea begin search at this address
-/// \param minea included in the search range
-/// \return #BADADDR if none exists.
-
-idaman ea_t ida_export prev_head(ea_t ea, ea_t minea);
-
-
-/// Get start of next defined item.
-/// \param ea begin search at this address
-/// \param maxea not included in the search range
-/// \return #BADADDR if none exists.
-
-idaman ea_t ida_export next_head(ea_t ea, ea_t maxea);
-
-
-/// Get address of previous non-tail byte.
-/// \return #BADADDR if none exists.
-
-idaman ea_t ida_export prev_not_tail(ea_t ea);
-
-
-/// Get address of next non-tail byte.
-/// \return #BADADDR if none exists.
-
-idaman ea_t ida_export next_not_tail(ea_t ea);
-
-
-/// Adjust the address and get the nearest visible address.
-/// (i.e. an address which will appear in the disassembly)
-/// \return #BADADDR only if no addresses are valid
-
-ea_t adjust_visea(ea_t ea);
-
-
-/// Get previous visible address.
-/// \return #BADADDR if none exists.
-
-idaman ea_t ida_export prev_visea(ea_t ea);
-
-
-/// Get next visible address.
-/// \return #BADADDR if none exists.
-
-idaman ea_t ida_export next_visea(ea_t ea);
-
-
-/// Is an address the first visible address?
-
-bool is_first_visea(ea_t ea);
-
-
-/// Is an address the last visible address?
-
-bool is_last_visea(ea_t ea);
-
-
-/// Is the address visible on the screen (not hidden)?
-
-bool is_visible_finally(ea_t ea); // do we need to show anything
- // at this address?
-
-
-
-/// Get the start address of the item at 'ea'.
-/// If there is no current item, then 'ea' will be returned
-/// (see definition at the end of bytes.hpp source)
-
-inline ea_t idaapi get_item_head(ea_t ea);
-
-
-/// Get the end address of the item at 'ea'. The returned address
-/// doesn't belong to the current item. Unexplored bytes are counted as
-/// 1 byte entities.
-
-idaman ea_t ida_export get_item_end(ea_t ea);
-
-
-/// Calculate maximal reasonable end address of a new item.
-/// This function will limit the item with the current segment bounds.
-/// \param ea linear address
-/// \param how when to stop the search. A combination of \ref ITEM_END_
-/// \return end of new item. If it is not possible to create an item,
-/// it will return 'ea'.
-
-idaman ea_t ida_export calc_max_item_end(ea_t ea, int how=15);
-/// \defgroup ITEM_END_ Item end search flags
-/// passed as 'how' parameter to calc_max_item_end()
-//@{
-#define ITEM_END_FIXUP 0x0001 ///< stop at the first fixup
-#define ITEM_END_INITED 0x0002 ///< stop when initialization changes
- ///< i.e.
- ///< - if is_loaded(ea): stop if uninitialized byte is encountered
- ///< - if !is_loaded(ea): stop if initialized byte is encountered
-#define ITEM_END_NAME 0x0004 ///< stop at the first named location
-#define ITEM_END_XREF 0x0008 ///< stop at the first referenced location
-//@}
-
-
-/// Get size of item (instruction/data) in bytes.
-/// Unexplored bytes have length of 1 byte. This function never returns 0.
-
-inline asize_t get_item_size(ea_t ea) { return get_item_end(ea) - ea; }
-
-
-
-
-/// Is the specified address 'ea' present in the program?
-
-idaman bool ida_export is_mapped(ea_t ea);
-
-
-/// Get flags for the specified address, extended form
-
-idaman flags_t ida_export get_flags_ex(ea_t ea, int how);
-
-#define GFE_VALUE 0x0001 ///< get flags with #FF_IVL & #MS_VAL.
- ///< It is much slower under remote debugging
- ///< because the kernel needs to read
- ///< the process memory.
-
-/// \copydoc GFE_VALUE
-inline flags_t idaapi get_flags(ea_t ea) { return get_flags_ex(ea, 0); }
-
-
-/// Get flags value for address 'ea'.
-/// \return 0 if address is not present in the program
-
-inline flags_t idaapi get_full_flags(ea_t ea) { return get_flags_ex(ea, GFE_VALUE); }
-
-
-/// Get flag of the item at 'ea' even if it is a tail byte of some
-/// array or structure. This function is used to get flags of structure members
-/// or array elements.
-/// \param from linear address of the instruction which refers to 'ea'
-/// \param n number of operand which refers to 'ea'
-/// \param ea the referenced address
-/// \param appzero append a struct field name if the field offset is zero?
-/// meaningful only if the name refers to a structure.
-/// \return flags or 0 (if failed)
-
-idaman flags_t ida_export get_item_flag(ea_t from, int n, ea_t ea, bool appzero);
-
-
-//--------------------------------------------------------------------------
-/// \defgroup FF_ Flags structure
-/// Here we define the organization of ::flags_t values.
-/// Low 8 bits contain value of corresponding byte of the program.
-/// The next bit is set if the byte is initialized.
-//@{
-#define MS_VAL 0x000000FFLU ///< Mask for byte value
-#define FF_IVL 0x00000100LU ///< Byte has value ?
-//@}
-
-/// Do flags contain byte value?
-
-inline THREAD_SAFE bool idaapi has_value(flags_t F) { return (F & FF_IVL) != 0; }
-
-
-/// Delete byte value from flags. The corresponding byte becomes
-/// uninitialized.
-
-idaman void ida_export del_value(ea_t ea);
-
-
-/// Does the specified address have a byte value (is initialized?)
-
-idaman bool ida_export is_loaded(ea_t ea);
-
-
-/// Get number of bits in a byte at the given address.
-/// \return \ph{dnbits()} if the address doesn't
-/// belong to a segment, otherwise the result depends on the
-/// segment type
-
-idaman int ida_export nbits(ea_t ea);
-
-
-/// Get number of bytes required to store a byte at the given address
-
-inline int bytesize(ea_t ea)
- { return (nbits(ea)+7)/8; }
-
-
-/// Get one byte (8-bit) of the program at 'ea'.
-/// This function works only for 8bit byte processors.
-
-idaman uchar ida_export get_byte(ea_t ea);
-
-
-/// Get one byte (8-bit) of the program at 'ea' from the database.
-/// Works even if the debugger is active.
-/// See also get_dbg_byte() to read the process memory directly.
-/// This function works only for 8bit byte processors.
-
-idaman uchar ida_export get_db_byte(ea_t ea);
-
-
-/// Get one word (16-bit) of the program at 'ea'.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// This function works only for 8bit byte processors.
-
-idaman ushort ida_export get_word(ea_t ea);
-
-
-/// Get one dword (32-bit) of the program at 'ea'.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// This function works only for 8bit byte processors.
-
-idaman uint32 ida_export get_dword(ea_t ea);
-
-
-/// Get one qword (64-bit) of the program at 'ea'.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// This function works only for 8bit byte processors.
-
-idaman uint64 ida_export get_qword(ea_t ea);
-
-
-/// Get one wide byte of the program at 'ea'.
-/// Some processors may access more than 8bit quantity at an address.
-/// These processors have 32-bit byte organization from the IDA's point of view.
-
-idaman uint64 ida_export get_wide_byte(ea_t ea);
-
-
-/// Get one wide word (2 'byte') of the program at 'ea'.
-/// Some processors may access more than 8bit quantity at an address.
-/// These processors have 32-bit byte organization from the IDA's point of view.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-
-idaman uint64 ida_export get_wide_word(ea_t ea);
-
-
-/// Get two wide words (4 'bytes') of the program at 'ea'.
-/// Some processors may access more than 8bit quantity at an address.
-/// These processors have 32-bit byte organization from the IDA's point of view.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \note this function works incorrectly if \ph{nbits} > 16
-
-idaman uint64 ida_export get_wide_dword(ea_t ea);
-
-
-/// Get 8 bits of the program at 'ea'.
-/// The main usage of this function is to iterate range of bytes.
-/// Here is an example:
-/// \code
-/// uint64 v;
-/// int nbit = 0;
-/// for ( ... ) {
-/// uchar byte = get_octet(&ea, &v, &nbit);
-/// ...
-/// }
-/// \endcode
-/// 'ea' is incremented each time when a new byte is read.
-/// In the above example, it will be incremented in the first loop iteration.
-
-idaman uchar ida_export get_octet(ea_t *ea, uint64 *v, int *nbit);
-
-
-
-/// Get 16bits of the program at 'ea'.
-/// \return 1 byte (getFullByte()) if the current processor has 16-bit byte,
-/// otherwise return get_word()
-
-idaman uint32 ida_export get_16bit(ea_t ea);
-
-
-/// Get not more than 32bits of the program at 'ea'.
-/// \return 32 bit value, depending on \ph{nbits}:
-/// - if ( nbits <= 8 ) return get_dword(ea);
-/// - if ( nbits <= 16) return get_wide_word(ea);
-/// - return get_wide_byte(ea);
-
-idaman uint32 ida_export get_32bit(ea_t ea);
-
-
-/// Get not more than 64bits of the program at 'ea'.
-/// \return 64 bit value, depending on \ph{nbits}:
-/// - if ( nbits <= 8 ) return get_qword(ea);
-/// - if ( nbits <= 16) return get_wide_dword(ea);
-/// - return get_wide_byte(ea);
-
-idaman uint64 ida_export get_64bit(ea_t ea);
-
-
-/// Get the value at of the item at 'ea'.
-/// This function works with entities up to sizeof(ea_t)
-/// (bytes, word, etc)
-/// \param v pointer to the result. may be nullptr
-/// \param ea linear address
-/// \param size size of data to read. If 0, then the item
-/// type at 'ea' will be used
-/// \return success
-
-idaman bool ida_export get_data_value(uval_t *v, ea_t ea, asize_t size);
-
-
-/// Visit all the patched bytes one byte at a time.
-/// \param ea1 start linear address
-/// \param ea2 end linear address
-/// \param cb callback called for each found byte.
-/// if the callback returns non-zero then that value will be
-/// returned to the caller and the enumeration will be interrupted.
-/// \param ud user data passed to the callback
-/// \return the return value returned by the callback (if any) or zero
-/// if the enumeration was completed.
-
-idaman int ida_export visit_patched_bytes(
- ea_t ea1,
- ea_t ea2,
- int (idaapi *cb)(ea_t ea, qoff64_t fpos, uint64 o, uint64 v, void *ud),
- void *ud = nullptr);
-
-
-/// Get original byte value (that was before patching).
-/// This function works for wide byte processors too.
-
-idaman uint64 ida_export get_original_byte(ea_t ea);
-
-
-/// Get original word value (that was before patching).
-/// This function works for wide byte processors too.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-
-idaman uint64 ida_export get_original_word(ea_t ea);
-
-
-/// Get original dword (that was before patching)
-/// This function works for wide byte processors too.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-
-idaman uint64 ida_export get_original_dword(ea_t ea);
-
-
-/// Get original qword value (that was before patching)
-/// This function DOESN'T work for wide byte processors too.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-
-idaman uint64 ida_export get_original_qword(ea_t ea);
-
-
-/// Set value of one byte of the program.
-/// This function modifies the database. If the debugger is active
-/// then the debugged process memory is patched too.
-/// \note The original value of the byte is completely lost and can't
-/// be recovered by the get_original_byte() function.
-/// See also put_dbg_byte() to write to the process memory directly when
-/// the debugger is active.
-/// This function can handle wide byte processors.
-/// \param ea linear address
-/// \param x byte value
-/// \return true if the database has been modified
-
-idaman bool ida_export put_byte(ea_t ea, uint64 x);
-
-
-/// Set value of one word of the program.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// This function works for wide byte processors too.
-/// \note The original value of the word is completely lost and can't
-/// be recovered by the get_original_word() function.
-/// ea - linear address
-/// x - word value
-
-idaman void ida_export put_word(ea_t ea, uint64 x);
-
-
-/// Set value of one dword of the program.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// This function works for wide byte processors too.
-/// \param ea linear address
-/// \param x dword value
-/// \note the original value of the dword is completely lost and can't
-/// be recovered by the get_original_dword() function.
-
-idaman void ida_export put_dword(ea_t ea, uint64 x);
-
-
-/// Set value of one qword (8 bytes) of the program.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// This function DOESN'T works for wide byte processors.
-/// \param ea linear address
-/// \param x qword value
-
-idaman void ida_export put_qword(ea_t ea, uint64 x);
-
-
-/// Patch a byte of the program. The original value of the byte is saved
-/// and can be obtained by get_original_byte().
-/// This function works for wide byte processors too.
-/// \retval true the database has been modified,
-/// \retval false the debugger is running and the process' memory
-/// has value 'x' at address 'ea', or
-/// the debugger is not running, and the IDB
-/// has value 'x' at address 'ea already.
-
-idaman bool ida_export patch_byte(ea_t ea, uint64 x);
-
-
-/// Patch a word of the program. The original value of the word is saved
-/// and can be obtained by get_original_word().
-/// This function works for wide byte processors too.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \retval true the database has been modified,
-/// \retval false the debugger is running and the process' memory
-/// has value 'x' at address 'ea', or
-/// the debugger is not running, and the IDB
-/// has value 'x' at address 'ea already.
-
-idaman bool ida_export patch_word(ea_t ea, uint64 x);
-
-
-/// Patch a dword of the program. The original value of the dword is saved
-/// and can be obtained by get_original_dword().
-/// This function DOESN'T work for wide byte processors.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \retval true the database has been modified,
-/// \retval false the debugger is running and the process' memory
-/// has value 'x' at address 'ea', or
-/// the debugger is not running, and the IDB
-/// has value 'x' at address 'ea already.
-
-idaman bool ida_export patch_dword(ea_t ea, uint64 x);
-
-
-/// Patch a qword of the program. The original value of the qword is saved
-/// and can be obtained by get_original_qword().
-/// This function DOESN'T work for wide byte processors.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \retval true the database has been modified,
-/// \retval false the debugger is running and the process' memory
-/// has value 'x' at address 'ea', or
-/// the debugger is not running, and the IDB
-/// has value 'x' at address 'ea already.
-
-idaman bool ida_export patch_qword(ea_t ea, uint64 x);
-
-
-/// Revert patched byte
-/// \retval true byte was patched before and reverted now
-
-idaman bool ida_export revert_byte(ea_t ea);
-
-
-/// Add a value to one byte of the program.
-/// This function works for wide byte processors too.
-/// \param ea linear address
-/// \param value byte value
-
-idaman void ida_export add_byte(ea_t ea, uint32 value);
-
-
-/// Add a value to one word of the program.
-/// This function works for wide byte processors too.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \param ea linear address
-/// \param value byte value
-
-idaman void ida_export add_word(ea_t ea, uint64 value);
-
-
-/// Add a value to one dword of the program.
-/// This function works for wide byte processors too.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \note this function works incorrectly if \ph{nbits} > 16
-/// \param ea linear address
-/// \param value byte value
-
-idaman void ida_export add_dword(ea_t ea, uint64 value);
-
-
-/// Add a value to one qword of the program.
-/// This function does not work for wide byte processors.
-/// This function takes into account order of bytes specified in \inf{is_be()}
-/// \param ea linear address
-/// \param value byte value
-
-idaman void ida_export add_qword(ea_t ea, uint64 value);
-
-
-/// Return set of ranges with zero initialized bytes.
-/// The returned set includes only big zero initialized ranges (at least >1KB).
-/// Some zero initialized byte ranges may be not included.
-/// Only zero bytes that use the sparse storage method (STT_MM) are reported.
-/// \param zranges pointer to the return value. cannot be nullptr
-/// \param range the range of addresses to verify. can be nullptr - means all ranges
-/// \return true if the result is a non-empty set
-
-idaman bool ida_export get_zero_ranges(rangeset_t *zranges, const range_t *range);
-
-
-/// Get the specified number of bytes of the program into the buffer.
-/// If mask was specified it will contain a bitmap of initialized / uninitialized
-/// database bytes.
-/// \param ea linear address
-/// \param buf buffer to hold bytes
-/// \param size size of buffer in normal 8-bit bytes (sizeof(buf))
-/// \param gmb_flags combination of \ref GMB_ bits
-/// \param mask bitmap of initialize/uninitialized bytes
-/// (may be nullptr; must be at least (size+7)/8)
-/// \return if the user cancelled, return -1; otherwise number of read bytes.
-
-idaman ssize_t ida_export get_bytes(
- void *buf,
- ssize_t size,
- ea_t ea,
- int gmb_flags=0,
- void *mask=nullptr);
-
-/// \defgroup GMB_ flags for get_bytes()
-//@{
-#define GMB_READALL 0x01 ///< try to read all bytes
- ///< if this bit is not set, fail at first uninited byte
-#define GMB_WAITBOX 0x02 ///< show wait box (may return -1 in this case)
-///@}
-
-
-/// Modify the specified number of bytes of the program.
-/// This function does not save the original values of bytes.
-/// See also patch_bytes().
-/// \param ea linear address
-/// \param buf buffer with new values of bytes
-/// \param size size of buffer in normal 8-bit bytes (sizeof(buf))
-
-idaman void ida_export put_bytes(ea_t ea, const void *buf, size_t size);
-
-
-/// Patch the specified number of bytes of the program.
-/// Original values of bytes are saved and are available with get_original...()
-/// functions.
-/// See also put_bytes().
-/// \param ea linear address
-/// \param buf buffer with new values of bytes
-/// \param size size of buffer in normal 8-bit bytes (sizeof(buf))
-
-idaman void ida_export patch_bytes(ea_t ea, const void *buf, size_t size);
-
-//-------------------------------------------------------------------------
-/// \defgroup FF_states States
-/// \ingroup FF_
-/// Represent general characteristics of a byte in the program.
-///
-/// Each byte of the program may be in one of four states.
-/// - unexplored
-/// - start of instruction
-/// - start of data
-/// - second, third (tail) byte of instruction or data.
-///
-/// Initially, all bytes of the program are unexplored.
-/// IDA modifies flags and doing so converts bytes to instructions
-/// and data.
-//@{
-
-/// \defgroup FF_statebits Bits: byte states
-//@{
-#define MS_CLS 0x00000600LU ///< Mask for typing
-#define FF_CODE 0x00000600LU ///< Code ?
-#define FF_DATA 0x00000400LU ///< Data ?
-#define FF_TAIL 0x00000200LU ///< Tail ?
-#define FF_UNK 0x00000000LU ///< Unknown ?
-//@}
-
-/// \defgroup FF_statefuncs Functions: examine byte states
-//@{
-
-/// Does flag denote start of an instruction?
-
-inline THREAD_SAFE bool idaapi is_code(flags_t F) { return (F & MS_CLS) == FF_CODE; }
-inline THREAD_SAFE bool idaapi f_is_code(flags_t F, void *) { return is_code(F); } ///< \copydoc is_code()
-
-
-/// Does flag denote start of data?
-
-inline THREAD_SAFE bool idaapi is_data(flags_t F) { return (F & MS_CLS) == FF_DATA; }
-inline THREAD_SAFE bool idaapi f_is_data(flags_t F, void *) { return is_data(F); } ///< \copydoc is_data()
-
-
-/// Does flag denote tail byte?
-
-inline THREAD_SAFE bool idaapi is_tail(flags_t F) { return (F & MS_CLS) == FF_TAIL; }
-inline THREAD_SAFE bool idaapi f_is_tail(flags_t F, void *) { return is_tail(F); } ///< \copydoc is_tail()
-inline THREAD_SAFE bool idaapi is_not_tail(flags_t F) { return !is_tail(F); } ///< \copydoc is_tail()
-inline THREAD_SAFE bool idaapi f_is_not_tail(flags_t F, void *) { return is_not_tail(F); } ///< \copydoc is_tail()
-
-
-/// Does flag denote unexplored byte?
-
-inline THREAD_SAFE bool idaapi is_unknown(flags_t F) { return (F & MS_CLS) == FF_UNK; }
-
-
-/// Does flag denote start of instruction OR data?
-
-inline THREAD_SAFE bool idaapi is_head(flags_t F) { return (F & FF_DATA) != 0; }
-inline THREAD_SAFE bool idaapi f_is_head(flags_t F, void *) { return is_head(F); } ///< \copydoc is_head()
-
-//@} FF_statefuncs
-//@} FF_states
-
-/// del_items' callback function
-typedef bool idaapi may_destroy_cb_t(ea_t);
-
-/// Convert item (instruction/data) to unexplored bytes.
-/// The whole item (including the head and tail bytes) will be destroyed.
-/// It is allowed to pass any address in the item to this function
-/// \param ea any address within the first item to delete
-/// \param flags combination of \ref DELIT_
-/// \param nbytes number of bytes in the range to be undefined
-/// \param may_destroy optional routine invoked before deleting a head
-/// item. If callback returns false then item has not to
-/// be deleted and operation fails
-/// \return true on sucessful operation, otherwise false
-
-idaman bool ida_export del_items(
- ea_t ea,
- int flags=0,
- asize_t nbytes=1,
- may_destroy_cb_t *may_destroy=nullptr);
-
-/// \defgroup DELIT_ Unexplored byte conversion flags
-/// passed as 'flags' parameter to del_items()
-//@{
-#define DELIT_SIMPLE 0x0000 ///< simply undefine the specified item(s)
-#define DELIT_EXPAND 0x0001 ///< propagate undefined items; for example
- ///< if removing an instruction removes all
- ///< references to the next instruction, then
- ///< plan to convert to unexplored the next
- ///< instruction too.
-#define DELIT_DELNAMES 0x0002 ///< delete any names at the specified
- ///< address range (except for the starting
- ///< address). this bit is valid if nbytes > 1
-#define DELIT_NOTRUNC 0x0004 ///< don't truncate the current function
- ///< even if #AF_TRFUNC is set
-#define DELIT_NOUNAME 0x0008 ///< reject to delete if a user name is
- ///< in address range (except for the starting
- ///< address). this bit is valid if nbytes > 1
-#define DELIT_NOCMT 0x0010 ///< reject to delete if a comment is
- ///< in address range (except for the starting
- ///< address). this bit is valid if nbytes > 1
-#define DELIT_KEEPFUNC 0x0020 ///< do not undefine the function start.
- ///< Just delete xrefs, ops e.t.c.
-//@}
-
-
-//-------------------------------------------------------------------------
-// Manual instructions (they are used to completely override an automatically
-// generated instruction by a user specified string).
-
-/// Is the instruction overridden?
-/// \param ea linear address of the instruction or data item
-
-idaman bool ida_export is_manual_insn(ea_t ea); // Is the instruction overridden?
-
-
-/// Retrieve the user-specified string for the manual instruction.
-/// \param buf output buffer
-/// \param ea linear address of the instruction or data item
-/// \return size of manual instruction or -1
-
-idaman ssize_t ida_export get_manual_insn(qstring *buf, ea_t ea);
-
-
-/// Set manual instruction string.
-/// \param ea linear address of the instruction or data item
-/// \param manual_insn "" - delete manual string.
-/// nullptr - do nothing
-
-idaman void ida_export set_manual_insn(ea_t ea, const char *manual_insn); // Set user-specified string
-
-
-//-------------------------------------------------------------------------
-/*! \defgroup FF_statespecb Bits: specific state information
- \ingroup FF_states
- Flags keep information common to all four states of bytes.
- This information will not be automatically discarded during
- transitions between different states.
-*/
-//@{
-#define MS_COMM 0x000FF800 ///< Mask of common bits
-#define FF_COMM 0x00000800 ///< Has comment ?
-#define FF_REF 0x00001000 ///< has references
-#define FF_LINE 0x00002000 ///< Has next or prev lines ?
-#define FF_NAME 0x00004000 ///< Has name ?
-#define FF_LABL 0x00008000 ///< Has dummy name?
-#define FF_FLOW 0x00010000 ///< Exec flow from prev instruction
-#define FF_SIGN 0x00020000 ///< Inverted sign of operands
-#define FF_BNOT 0x00040000 ///< Bitwise negation of operands
-#define FF_UNUSED 0x00080000 ///< unused bit (was used for variable bytes)
-//@}
-
-/// \defgroup FF_statespecf Functions: examine specific state information
-/// \ingroup FF_states
-//@{
-
-/// Does the previous instruction exist and pass execution flow to the current byte?
-
-inline THREAD_SAFE bool idaapi is_flow(flags_t F) { return (F & FF_FLOW) != 0; }
-
-
-/// Does the current byte have additional anterior or posterior lines?
-
-inline THREAD_SAFE bool idaapi has_extra_cmts(flags_t F) { return (F & FF_LINE) != 0; }
-inline THREAD_SAFE bool idaapi f_has_extra_cmts(flags_t f, void *) { return has_extra_cmts(f); }
-
-/// Does the current byte have an indented comment?
-
-inline THREAD_SAFE bool idaapi has_cmt(flags_t F) { return (F & FF_COMM) != 0; }
-inline THREAD_SAFE bool idaapi f_has_cmt(flags_t f, void *) { return has_cmt(f); }
-
-/// Does the current byte have cross-references to it?
-
-inline THREAD_SAFE bool idaapi has_xref(flags_t F) { return (F & FF_REF) != 0; }
-inline THREAD_SAFE bool idaapi f_has_xref(flags_t f, void *) { return has_xref(f); } ///< \copydoc has_xref()
-
-
-/// Does the current byte have non-trivial (non-dummy) name?
-
-inline THREAD_SAFE bool idaapi has_name(flags_t F) { return (F & FF_NAME) != 0; }
-inline THREAD_SAFE bool idaapi f_has_name(flags_t f, void *) { return has_name(f); } ///< \copydoc has_name()
-
-
-
-#define FF_ANYNAME (FF_LABL|FF_NAME)
-
-/// Does the current byte have dummy (auto-generated, with special prefix) name?
-
-inline THREAD_SAFE bool idaapi has_dummy_name(flags_t F) { return (F & FF_ANYNAME) == FF_LABL; }
-inline THREAD_SAFE bool idaapi f_has_dummy_name(flags_t f, void *) { return has_dummy_name(f); } ///< \copydoc has_dummy_name()
-
-
-/// Does the current byte have auto-generated (no special prefix) name?
-
-inline THREAD_SAFE bool idaapi has_auto_name(flags_t F) { return (F & FF_ANYNAME) == FF_ANYNAME; }
-
-
-/// Does the current byte have any name?
-
-inline THREAD_SAFE bool idaapi has_any_name(flags_t F) { return (F & FF_ANYNAME) != 0; }
-
-
-/// Does the current byte have user-specified name?
-
-inline THREAD_SAFE bool idaapi has_user_name(flags_t F) { return (F & FF_ANYNAME) == FF_NAME; }
-inline THREAD_SAFE bool idaapi f_has_user_name(flags_t F, void *) { return has_user_name(F); } ///< \copydoc has_user_name()
-
-// signness deals with the form of operands of the current instruction/data.
-// inverted sign means the following:
-// if the bit is clear |then when the bit is set
-// and the output is |the output should be:
-// ------------ |----------
-// unsigned |signed
-// signed |unsigned
-//
-
-/// Should sign of n-th operand inverted during output?.
-/// allowed values of n: 0-first operand, 1-other operands
-
-idaman bool ida_export is_invsign(ea_t ea, flags_t F, int n);
-
-
-/// Toggle sign of n-th operand.
-/// allowed values of n: 0-first operand, 1-other operands
-
-idaman bool ida_export toggle_sign(ea_t ea, int n);
-
-
-/// Should we negate the operand?.
-/// \ash{a_bnot} should be defined in the idp module in order to work
-/// with this function
-
-idaman bool ida_export is_bnot(ea_t ea, flags_t F, int n);
-idaman bool ida_export toggle_bnot(ea_t ea, int n); ///< Toggle binary negation of operand. also see is_bnot()
-
-
-/// Display leading zeroes in operands.
-/// The global switch for the leading zeroes is in \inf{s_genflags}
-/// The leading zeroes doesn't work if the octal numbers start with 0
-
-idaman bool ida_export is_lzero(ea_t ea, int n); ///< Display leading zeroes?
- ///< (takes into account \inf{s_genflags})
-idaman bool ida_export set_lzero(ea_t ea, int n); ///< Set toggle lzero bit
-idaman bool ida_export clr_lzero(ea_t ea, int n); ///< Clear lzero bit
-inline bool idaapi toggle_lzero(ea_t ea, int n) ///< Toggle lzero bit
-{
- return (is_lzero(ea, n) ? clr_lzero : set_lzero)(ea, n);
-}
-
-//@} FF_statespecf
-
-
-/// Check if leading zeroes are important
-
-idaman bool ida_export leading_zero_important(ea_t ea, int n);
-
-
-//-------------------------------------------------------------------------
-/// \defgroup FF_op Instruction/Data operands
-/// \ingroup FF_
-/// Represent instruction/data operands.
-///
-/// IDA keeps 2 bitmasks:
-/// - representation of the first operand
-/// - representation of other operands (we will call this
-/// 'representation of second operand'
-/// although it is also applied to third, fourth, etc operands too)
-///
-/// For data bytes, only the first bitmask is used (i.e. all elements of
-/// an array have the same type).
-//@{
-
-/// \defgroup FF_opbits Bits: instruction operand types
-//@{
-#define MS_0TYPE 0x00F00000LU ///< Mask for 1st arg typing
-#define FF_0VOID 0x00000000LU ///< Void (unknown)?
-#define FF_0NUMH 0x00100000LU ///< Hexadecimal number?
-#define FF_0NUMD 0x00200000LU ///< Decimal number?
-#define FF_0CHAR 0x00300000LU ///< Char ('x')?
-#define FF_0SEG 0x00400000LU ///< Segment?
-#define FF_0OFF 0x00500000LU ///< Offset?
-#define FF_0NUMB 0x00600000LU ///< Binary number?
-#define FF_0NUMO 0x00700000LU ///< Octal number?
-#define FF_0ENUM 0x00800000LU ///< Enumeration?
-#define FF_0FOP 0x00900000LU ///< Forced operand?
-#define FF_0STRO 0x00A00000LU ///< Struct offset?
-#define FF_0STK 0x00B00000LU ///< Stack variable?
-#define FF_0FLT 0x00C00000LU ///< Floating point number?
-#define FF_0CUST 0x00D00000LU ///< Custom representation?
-
-#define MS_1TYPE 0x0F000000LU ///< Mask for the type of other operands
-#define FF_1VOID 0x00000000LU ///< Void (unknown)?
-#define FF_1NUMH 0x01000000LU ///< Hexadecimal number?
-#define FF_1NUMD 0x02000000LU ///< Decimal number?
-#define FF_1CHAR 0x03000000LU ///< Char ('x')?
-#define FF_1SEG 0x04000000LU ///< Segment?
-#define FF_1OFF 0x05000000LU ///< Offset?
-#define FF_1NUMB 0x06000000LU ///< Binary number?
-#define FF_1NUMO 0x07000000LU ///< Octal number?
-#define FF_1ENUM 0x08000000LU ///< Enumeration?
-#define FF_1FOP 0x09000000LU ///< Forced operand?
-#define FF_1STRO 0x0A000000LU ///< Struct offset?
-#define FF_1STK 0x0B000000LU ///< Stack variable?
-#define FF_1FLT 0x0C000000LU ///< Floating point number?
-#define FF_1CUST 0x0D000000LU ///< Custom representation?
-//@}
-
-/// \defgroup FF_opfuncs1 Functions: examine operand flags (specific operands)
-//@{
-
-/// Is the first operand defined? Initially operand has no defined representation
-
-inline THREAD_SAFE bool idaapi is_defarg0(flags_t F) { return (F & MS_0TYPE) != FF_0VOID; }
-
-
-/// Is the second operand defined? Initially operand has no defined representation
-
-inline THREAD_SAFE bool idaapi is_defarg1(flags_t F) { return (F & MS_1TYPE) != FF_1VOID; }
-
-
-/// Is the first operand offset? (example: push offset xxx)
-
-inline THREAD_SAFE bool idaapi is_off0(flags_t F) { return (F & MS_0TYPE) == FF_0OFF; }
-
-
-/// Is the second operand offset? (example: mov ax, offset xxx)
-
-inline THREAD_SAFE bool idaapi is_off1(flags_t F) { return (F & MS_1TYPE) == FF_1OFF; }
-
-
-/// Is the first operand character constant? (example: push 'a')
-
-inline THREAD_SAFE bool idaapi is_char0(flags_t F) { return (F & MS_0TYPE) == FF_0CHAR; }
-
-
-/// Is the second operand character constant? (example: mov al, 'a')
-
-inline THREAD_SAFE bool idaapi is_char1(flags_t F) { return (F & MS_1TYPE) == FF_1CHAR; }
-
-
-/// Is the first operand segment selector? (example: push seg seg001)
-
-inline THREAD_SAFE bool idaapi is_seg0(flags_t F) { return (F & MS_0TYPE) == FF_0SEG; }
-
-
-/// Is the second operand segment selector? (example: mov dx, seg dseg)
-
-inline THREAD_SAFE bool idaapi is_seg1(flags_t F) { return (F & MS_1TYPE) == FF_1SEG; }
-
-
-/// Is the first operand a symbolic constant (enum member)?
-
-inline THREAD_SAFE bool idaapi is_enum0(flags_t F) { return (F & MS_0TYPE) == FF_0ENUM; }
-
-
-/// Is the second operand a symbolic constant (enum member)?
-
-inline THREAD_SAFE bool idaapi is_enum1(flags_t F) { return (F & MS_1TYPE) == FF_1ENUM; }
-
-
-/// Is the first operand an offset within a struct?
-
-inline THREAD_SAFE bool idaapi is_stroff0(flags_t F) { return (F & MS_0TYPE) == FF_0STRO; }
-
-
-/// Is the second operand an offset within a struct?
-
-inline THREAD_SAFE bool idaapi is_stroff1(flags_t F) { return (F & MS_1TYPE) == FF_1STRO; }
-
-
-/// Is the first operand a stack variable?
-
-inline THREAD_SAFE bool idaapi is_stkvar0(flags_t F) { return (F & MS_0TYPE) == FF_0STK; }
-
-
-/// Is the second operand a stack variable?
-
-inline THREAD_SAFE bool idaapi is_stkvar1(flags_t F) { return (F & MS_1TYPE) == FF_1STK; }
-
-
-/// Is the first operand a floating point number?
-
-inline THREAD_SAFE bool idaapi is_float0(flags_t F) { return (F & MS_0TYPE) == FF_0FLT; }
-
-
-/// Is the second operand a floating point number?
-
-inline THREAD_SAFE bool idaapi is_float1(flags_t F) { return (F & MS_1TYPE) == FF_1FLT; }
-
-
-/// Does the first operand use a custom data representation?
-
-inline THREAD_SAFE bool idaapi is_custfmt0(flags_t F) { return (F & MS_0TYPE) == FF_0CUST; }
-
-
-/// Does the second operand use a custom data representation?
-
-inline THREAD_SAFE bool idaapi is_custfmt1(flags_t F) { return (F & MS_1TYPE) == FF_1CUST; }
-
-
-/// Is the first operand a number (i.e. binary, octal, decimal or hex?)
-
-idaman bool ida_export is_numop0(flags_t F);
-
-
-/// Is the second operand a number (i.e. binary, octal, decimal or hex?)
-
-idaman bool ida_export is_numop1(flags_t F);
-
-
-/// Get flags for first operand
-
-inline THREAD_SAFE flags_t get_optype_flags0(flags_t F) { return F & MS_0TYPE; }
-
-
-/// Get flags for second operand
-
-inline THREAD_SAFE flags_t get_optype_flags1(flags_t F) { return F & MS_1TYPE; }
-
-//@} FF_opfuncs1
-
-//-------------------------------------------------------------------------
-//
-// The following 2 masks are used with operand numbers
-//
-#define OPND_OUTER 0x80 ///< outer offset base (combined with operand number).
- ///< used only in set, get, del_offset() functions
-#define OPND_MASK 0x0F ///< mask for operand number
-#define OPND_ALL OPND_MASK ///< all operands
-
-/*! \defgroup FF_opfuncs2 Functions: examine operand flags (arbitrary operand)
- For the following functions, 'n' may be:
- - 0 : first operand
- - 1 : second operand
- - #OPND_ALL : both operands - function returns 1 if the first
- OR the second operand satisfies the condition
-*/
-//@{
-idaman bool ida_export is_defarg(flags_t F, int n); ///< is defined?
-idaman bool ida_export is_off(flags_t F, int n); ///< is offset?
-idaman bool ida_export is_char(flags_t F, int n); ///< is character constant?
-idaman bool ida_export is_seg(flags_t F, int n); ///< is segment?
-idaman bool ida_export is_enum(flags_t F, int n); ///< is enum?
-idaman bool ida_export is_manual(flags_t F, int n); ///< is forced operand? (use is_forced_operand())
-idaman bool ida_export is_stroff(flags_t F, int n); ///< is struct offset?
-idaman bool ida_export is_stkvar(flags_t F, int n); ///< is stack variable?
-idaman bool ida_export is_fltnum(flags_t F, int n); ///< is floating point number?
-idaman bool ida_export is_custfmt(flags_t F, int n); ///< is custom data format?
-idaman bool ida_export is_numop(flags_t F, int n); ///< is number (bin, oct, dec, hex)?
-idaman bool ida_export is_suspop(ea_t ea, flags_t F, int n); ///< is suspicious operand?
-//@}
-
-/// Should processor module create xrefs from the operand?.
-/// Currently 'offset' and 'structure offset' operands create xrefs
-
-idaman bool ida_export op_adds_xrefs(flags_t F, int n);
-
-
-/// (internal function) change representation of operand(s).
-/// \param ea linear address
-/// \param type new flag value (should be obtained from char_flag(), num_flag() and
-/// similar functions)
-/// \param n number of operand (0, 1, -1)
-/// \retval 1 ok
-/// \retval 0 failed (applied to a tail byte)
-
-idaman bool ida_export set_op_type(ea_t ea, flags_t type, int n);
-
-
-/// Set operand representation to be 'segment'.
-/// If applied to unexplored bytes, converts them to 16/32bit word data
-/// \param ea linear address
-/// \param n number of operand (0, 1, -1)
-/// \return success
-
-idaman bool ida_export op_seg(ea_t ea, int n);
-
-
-/// Set operand representation to be 'enum_t'.
-/// If applied to unexplored bytes, converts them to 16/32bit word data
-/// \param ea linear address
-/// \param n number of operand (0, 1, -1)
-/// \param id id of enum
-/// \param serial the serial number of the constant in the enumeration,
-/// usually 0. the serial numbers are used if the enumeration
-/// contains several constants with the same value
-/// \return success
-
-idaman bool ida_export op_enum(ea_t ea, int n, enum_t id, uchar serial);
-
-
-/// Get enum id of 'enum' operand.
-/// \param ea linear address
-/// \param n number of operand (0, 1, -1)
-/// \param serial pointer to variable to hold the serial number of the
-/// constant in the enumeration
-/// \return id of enum or #BADNODE
-
-idaman enum_t ida_export get_enum_id(uchar *serial, ea_t ea, int n);
-
-
-/// Set operand representation to be 'struct offset'.
-/// If applied to unexplored bytes, converts them to 16/32bit word data
-/// \param insn the instruction
-/// \param n number of operand (0, 1, -1)
-/// \param path structure path (strpath). see nalt.hpp for more info.
-/// \param path_len length of the structure path
-/// \param delta struct offset delta. usually 0. denotes the difference
-/// between the structure base and the pointer into the structure.
-/// \return success
-
-idaman bool ida_export op_stroff(
- const insn_t &insn,
- int n,
- const tid_t *path,
- int path_len,
- adiff_t delta);
-
-
-/// Get struct path of operand.
-/// \param path buffer for structure path (strpath). see nalt.hpp for more info.
-/// \param delta struct offset delta
-/// \param ea linear address
-/// \param n number of operand (0, 1, -1)
-/// \return length of strpath
-
-idaman int ida_export get_stroff_path(tid_t *path, adiff_t *delta, ea_t ea, int n);
-
-/// Set operand representation to be 'stack variable'.
-/// Should be applied to an instruction within a function.
-/// Should be applied after creating a stack var using
-/// insn_t::create_stkvar().
-/// \param ea linear address
-/// \param n number of operand (0, 1, -1)
-/// \return success
-
-idaman bool ida_export op_stkvar(ea_t ea, int n);
-
-
-/// Set forced operand.
-/// \param ea linear address
-/// \param n number of operand (0, 1, 2)
-/// \param op text of operand
-/// - nullptr: do nothing (return 0)
-/// - "" : delete forced operand
-/// \return success
-
-idaman bool ida_export set_forced_operand(ea_t ea, int n, const char *op);
-
-
-/// Get forced operand.
-/// \param buf output buffer, may be nullptr
-/// \param ea linear address
-/// \param n number of operand (0, 1, 2)
-/// \return size of forced operand or -1
-
-idaman ssize_t ida_export get_forced_operand(qstring *buf, ea_t ea, int n);
-
-
-/// Is operand manually defined?.
-/// \param ea linear address
-/// \param n number of operand (0, 1, 2)
-
-idaman bool ida_export is_forced_operand(ea_t ea, int n);
-
-
-//-------------------------------------------------------------------------
-/*! \defgroup FF_opfuncs3 Functions: get type information bits for flags
- Values of these functions are used as input to set_op_type() function
-*/
-//@{
-inline constexpr flags_t idaapi char_flag(void) { return FF_1CHAR|FF_0CHAR; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi off_flag(void) { return FF_1OFF |FF_0OFF; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi enum_flag(void) { return FF_1ENUM|FF_0ENUM; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi stroff_flag(void) { return FF_1STRO|FF_0STRO; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi stkvar_flag(void) { return FF_1STK |FF_0STK; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi flt_flag(void) { return FF_1FLT |FF_0FLT; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi custfmt_flag(void) { return FF_1CUST|FF_0CUST; } ///< see \ref FF_opbits
-inline constexpr flags_t idaapi seg_flag(void) { return FF_1SEG |FF_0SEG; } ///< see \ref FF_opbits
-
-idaman flags_t ida_export num_flag(void); ///< Get number of default base (bin, oct, dec, hex)
-/// Get number flag of the base, regardless of current processor - better to use num_flag()
-inline constexpr flags_t idaapi hex_flag(void) { return FF_1NUMH|FF_0NUMH; }
-inline constexpr flags_t idaapi dec_flag(void) { return FF_1NUMD|FF_0NUMD; } ///< \copydoc hex_flag()
-inline constexpr flags_t idaapi oct_flag(void) { return FF_1NUMO|FF_0NUMO; } ///< \copydoc hex_flag()
-inline constexpr flags_t idaapi bin_flag(void) { return FF_1NUMB|FF_0NUMB; } ///< \copydoc hex_flag()
-//@}
-
-/*! \defgroup FF_opfuncs4 Functions: set operand representation
- The following functions set operand representation.
- If they are applied to unexplored bytes, they convert them.
- - no segment : fail
- - 16bit segment : to 16bit word data
- - 32bit segment : to dword
- \param ea linear address
- \param n number of operand (0, 1, -1)
- \return success
-*/
-//@{
-inline bool idaapi op_chr(ea_t ea, int n) { return set_op_type(ea, char_flag(), n); } ///< set op type to char_flag()
-inline bool idaapi op_num(ea_t ea, int n) { return set_op_type(ea, num_flag(), n); } ///< set op type to num_flag()
-inline bool idaapi op_hex(ea_t ea, int n) { return set_op_type(ea, hex_flag(), n); } ///< set op type to hex_flag()
-inline bool idaapi op_dec(ea_t ea, int n) { return set_op_type(ea, dec_flag(), n); } ///< set op type to dec_flag()
-inline bool idaapi op_oct(ea_t ea, int n) { return set_op_type(ea, oct_flag(), n); } ///< set op type to oct_flag()
-inline bool idaapi op_bin(ea_t ea, int n) { return set_op_type(ea, bin_flag(), n); } ///< set op type to bin_flag()
-inline bool idaapi op_flt(ea_t ea, int n) { return set_op_type(ea, flt_flag(), n); } ///< set op type to flt_flag()
-//@}
-
-/// Set custom data format for operand (fid-custom data format id)
-
-idaman bool ida_export op_custfmt(ea_t ea, int n, int fid);
-
-
-/// Remove operand representation information.
-/// (set operand representation to be 'undefined')
-/// \param ea linear address
-/// \param n number of operand (0, 1, -1)
-/// \return success
-
-idaman bool ida_export clr_op_type(ea_t ea, int n);
-
-
-/// Get default base of number for the current processor.
-/// \return 2, 8, 10, 16
-
-idaman int ida_export get_default_radix(void);
-
-
-/// Get radix of the operand, in: flags.
-/// If the operand is not a number, returns get_default_radix()
-/// \param F flags
-/// \param n number of operand (0, 1, -1)
-/// \return 2, 8, 10, 16
-
-idaman int ida_export get_radix(flags_t F, int n);
-
-
-//-------------------------------------------------------------------------
-/// \defgroup FF_databits Bits: data bytes
-//@{
-#define DT_TYPE 0xF0000000 ///< Mask for DATA typing
-
-#define FF_BYTE 0x00000000 ///< byte
-#define FF_WORD 0x10000000 ///< word
-#define FF_DWORD 0x20000000 ///< double word
-#define FF_QWORD 0x30000000 ///< quadro word
-#define FF_TBYTE 0x40000000 ///< tbyte
-#define FF_STRLIT 0x50000000 ///< string literal
-#define FF_STRUCT 0x60000000 ///< struct variable
-#define FF_OWORD 0x70000000 ///< octaword/xmm word (16 bytes/128 bits)
-#define FF_FLOAT 0x80000000 ///< float
-#define FF_DOUBLE 0x90000000 ///< double
-#define FF_PACKREAL 0xA0000000 ///< packed decimal real
-#define FF_ALIGN 0xB0000000 ///< alignment directive
-// 0xC0000000 ///< reserved
-#define FF_CUSTOM 0xD0000000 ///< custom data type
-#define FF_YWORD 0xE0000000 ///< ymm word (32 bytes/256 bits)
-#define FF_ZWORD 0xF0000000 ///< zmm word (64 bytes/512 bits)
-//@}
-
-/// \defgroup FF_datafuncs1 Functions: examine data bits
-//@{
-inline constexpr flags_t idaapi code_flag(void) { return FF_CODE; } ///< #FF_CODE
-inline constexpr flags_t idaapi byte_flag(void) { return FF_DATA|FF_BYTE; } ///< Get a flags_t representing a byte
-inline constexpr flags_t idaapi word_flag(void) { return FF_DATA|FF_WORD; } ///< Get a flags_t representing a word
-inline constexpr flags_t idaapi dword_flag(void) { return FF_DATA|FF_DWORD; } ///< Get a flags_t representing a double word
-inline constexpr flags_t idaapi qword_flag(void) { return FF_DATA|FF_QWORD; } ///< Get a flags_t representing a quad word
-inline constexpr flags_t idaapi oword_flag(void) { return FF_DATA|FF_OWORD; } ///< Get a flags_t representing a octaword
-inline constexpr flags_t idaapi yword_flag(void) { return FF_DATA|FF_YWORD; } ///< Get a flags_t representing a ymm word
-inline constexpr flags_t idaapi zword_flag(void) { return FF_DATA|FF_ZWORD; } ///< Get a flags_t representing a zmm word
-inline constexpr flags_t idaapi tbyte_flag(void) { return FF_DATA|FF_TBYTE; } ///< Get a flags_t representing a tbyte
-inline constexpr flags_t idaapi strlit_flag(void) { return FF_DATA|FF_STRLIT; } ///< Get a flags_t representing a string literal
-inline constexpr flags_t idaapi stru_flag(void) { return FF_DATA|FF_STRUCT; } ///< Get a flags_t representing a struct
-inline constexpr flags_t idaapi cust_flag(void) { return FF_DATA|FF_CUSTOM; } ///< Get a flags_t representing custom type data
-inline constexpr flags_t idaapi align_flag(void) { return FF_DATA|FF_ALIGN; } ///< Get a flags_t representing an alignment directive
-inline constexpr flags_t idaapi float_flag(void) { return FF_DATA|FF_FLOAT; } ///< Get a flags_t representing a float
-inline constexpr flags_t idaapi double_flag(void) { return FF_DATA|FF_DOUBLE; } ///< Get a flags_t representing a double
-inline constexpr flags_t idaapi packreal_flag(void) { return FF_DATA|FF_PACKREAL; } ///< Get a flags_t representing a packed decimal real
-
-inline THREAD_SAFE bool idaapi is_byte(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_BYTE; } ///< #FF_BYTE
-inline THREAD_SAFE bool idaapi is_word(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_WORD; } ///< #FF_WORD
-inline THREAD_SAFE bool idaapi is_dword(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_DWORD; } ///< #FF_DWORD
-inline THREAD_SAFE bool idaapi is_qword(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_QWORD; } ///< #FF_QWORD
-inline THREAD_SAFE bool idaapi is_oword(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_OWORD; } ///< #FF_OWORD
-inline THREAD_SAFE bool idaapi is_yword(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_YWORD; } ///< #FF_YWORD
-inline THREAD_SAFE bool idaapi is_zword(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_ZWORD; } ///< #FF_ZWORD
-inline THREAD_SAFE bool idaapi is_tbyte(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_TBYTE; } ///< #FF_TBYTE
-inline THREAD_SAFE bool idaapi is_float(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_FLOAT; } ///< #FF_FLOAT
-inline THREAD_SAFE bool idaapi is_double(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_DOUBLE; } ///< #FF_DOUBLE
-inline THREAD_SAFE bool idaapi is_pack_real(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_PACKREAL; } ///< #FF_PACKREAL
-inline THREAD_SAFE bool idaapi is_strlit(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_STRLIT; } ///< #FF_STRLIT
-inline THREAD_SAFE bool idaapi is_struct(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_STRUCT; } ///< #FF_STRUCT
-inline THREAD_SAFE bool idaapi is_align(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_ALIGN; } ///< #FF_ALIGN
-inline THREAD_SAFE bool idaapi is_custom(flags_t F) { return is_data(F) && (F & DT_TYPE) == FF_CUSTOM; } ///< #FF_CUSTOM
-
-inline THREAD_SAFE bool idaapi f_is_byte(flags_t F, void *) { return is_byte(F); } ///< See is_byte()
-inline THREAD_SAFE bool idaapi f_is_word(flags_t F, void *) { return is_word(F); } ///< See is_word()
-inline THREAD_SAFE bool idaapi f_is_dword(flags_t F, void *) { return is_dword(F); } ///< See is_dword()
-inline THREAD_SAFE bool idaapi f_is_qword(flags_t F, void *) { return is_qword(F); } ///< See is_qword()
-inline THREAD_SAFE bool idaapi f_is_oword(flags_t F, void *) { return is_oword(F); } ///< See is_oword()
-inline THREAD_SAFE bool idaapi f_is_yword(flags_t F, void *) { return is_yword(F); } ///< See is_yword()
-inline THREAD_SAFE bool idaapi f_is_tbyte(flags_t F, void *) { return is_tbyte(F); } ///< See is_tbyte()
-inline THREAD_SAFE bool idaapi f_is_float(flags_t F, void *) { return is_float(F); } ///< See is_float()
-inline THREAD_SAFE bool idaapi f_is_double(flags_t F, void *) { return is_double(F); } ///< See is_double()
-inline THREAD_SAFE bool idaapi f_is_pack_real(flags_t F, void *) { return is_pack_real(F); } ///< See is_pack_real()
-inline THREAD_SAFE bool idaapi f_is_strlit(flags_t F, void *) { return is_strlit(F); } ///< See is_strlit()
-inline THREAD_SAFE bool idaapi f_is_struct(flags_t F, void *) { return is_struct(F); } ///< See is_struct()
-inline THREAD_SAFE bool idaapi f_is_align(flags_t F, void *) { return is_align(F); } ///< See is_align()
-inline THREAD_SAFE bool idaapi f_is_custom(flags_t F, void *) { return is_custom(F); } ///< See is_custom()
-
-
-/// Do the given flags specify the same data type?
-
-inline THREAD_SAFE bool idaapi is_same_data_type(flags_t F1, flags_t F2) { return ((F1 ^ F2) & DT_TYPE) == 0; }
-
-
-/// Get flags from size (in bytes).
-/// Supported sizes: 1, 2, 4, 8, 16, 32.
-/// For other sizes returns 0
-
-idaman flags_t ida_export get_flags_by_size(size_t size);
-//@} FF_datafuncs1
-
-
-/// \defgroup FF_datafuncs2 Functions: manipulate data bits
-/// \param ea linear address
-/// \param length size of array in bytes. should be divisible by the size of
-/// one item of the specified type.
-/// \return success
-//@{
-
-/// Convert to data (byte, word, dword, etc).
-/// This function may be used to create arrays.
-/// \param ea linear address
-/// \param dataflag type of data. Value of function byte_flag(), word_flag(), etc.
-/// \param size size of array in bytes. should be divisible by the size of
-/// one item of the specified type. for variable sized items
-/// it can be specified as 0, and the kernel will try to calculate the size.
-/// \param tid type id. If the specified type is a structure,
-/// then tid is structure id. Otherwise should be #BADNODE.
-/// \return success
-
-idaman bool ida_export create_data(
- ea_t ea,
- flags_t dataflag,
- asize_t size,
- tid_t tid);
-
-
-inline THREAD_SAFE flags_t idaapi calc_dflags(flags_t f, bool force) { return f | (force ? FF_COMM : 0); }
-/// Convert to byte
-inline bool idaapi create_byte(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_BYTE, force), length, BADNODE);
-}
-/// Convert to word
-inline bool idaapi create_word(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_WORD, force), length, BADNODE);
-}
-/// Convert to dword
-inline bool idaapi create_dword(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_DWORD, force), length, BADNODE);
-}
-/// Convert to quadword
-inline bool idaapi create_qword(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_QWORD, force), length, BADNODE);
-}
-/// Convert to octaword/xmm word
-inline bool idaapi create_oword(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_OWORD, force), length, BADNODE);
-}
-/// Convert to ymm word
-inline bool idaapi create_yword(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_YWORD, force), length, BADNODE);
-}
-/// Convert to zmm word
-inline bool idaapi create_zword(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_ZWORD, force), length, BADNODE);
-}
-/// Convert to tbyte
-inline bool idaapi create_tbyte(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_TBYTE, force), length, BADNODE);
-}
-/// Convert to float
-inline bool idaapi create_float(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_FLOAT, force), length, BADNODE);
-}
-/// Convert to double
-inline bool idaapi create_double(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_DOUBLE, force), length, BADNODE);
-}
-/// Convert to packed decimal real
-inline bool idaapi create_packed_real(ea_t ea, asize_t length, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_PACKREAL, force), length, BADNODE);
-}
-/// Convert to struct
-inline bool idaapi create_struct(ea_t ea, asize_t length, tid_t tid, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_STRUCT, force), length, tid);
-}
-/// Convert to custom data type
-inline bool idaapi create_custdata(ea_t ea, asize_t length, int dtid, int fid, bool force=false)
-{
- return create_data(ea, calc_dflags(FF_CUSTOM, force), length, dtid|(fid<<16));
-}
-
-
-/// Alignment: 0 or 2..32. If it is 0, is will be calculated
-idaman bool ida_export create_align(ea_t ea, asize_t length, int alignment);
-idaman int ida_export calc_min_align(asize_t length); ///< Returns: 1..32
-idaman int ida_export calc_max_align(ea_t endea); ///< Returns: 0..32
-idaman int ida_export calc_def_align(ea_t ea, int mina, int maxa); ///< Calculate default alignment
-idaman bool ida_export create_16bit_data(ea_t ea, asize_t length); ///< Convert to 16-bit quantity (take byte size into account)
-idaman bool ida_export create_32bit_data(ea_t ea, asize_t length); ///< Convert to 32-bit quantity (take byte size into account)
-//@} FF_datafuncs2
-
-//@} FF_op
-
-/// \defgroup ALOPT_ string literal length options
-/// passed as 'options' parameter to get_max_strlit_length()
-//@{
-#define ALOPT_IGNHEADS 0x01 ///< don't stop if another data item is encountered.
- ///< only the byte values will be used to determine
- ///< the string length.
- ///< if not set, a defined data item or instruction
- ///< will truncate the string
-#define ALOPT_IGNPRINT 0x02 ///< if set, don't stop at non-printable codepoints,
- ///< but only at the terminating character (or not
- ///< unicode-mapped character (e.g., 0x8f in CP1252))
-#define ALOPT_IGNCLT 0x04 ///< if set, don't stop at codepoints that are not
- ///< part of the current 'culture'; accept all
- ///< those that are graphical (this is typically
- ///< used used by user-initiated actions creating
- ///< string literals.)
-#define ALOPT_MAX4K 0x08 ///< if string length is more than 4K, return the
- ///< accumulated length
-
-//@}
-
-/// Determine maximum length of string literal.
-///
-/// If the string literal has a length prefix (e.g., STRTYPE_LEN2 has
-/// a two-byte length prefix), the length of that prefix (i.e., 2)
-/// will be part of the returned value.
-///
-/// \param ea starting address
-/// \param strtype string type. one of \ref STRTYPE_
-/// \param options combination of \ref ALOPT_
-/// \return length of the string in octets (octet==8bit)
-
-idaman size_t ida_export get_max_strlit_length(
- ea_t ea,
- int32 strtype,
- int options = 0);
-
-/// \defgroup STRCONV_ string conversion flags
-/// passed as 'flags' parameter to get_strlit_contents()
-//@{
-#define STRCONV_ESCAPE 0x00000001 ///< convert non-printable characters to C escapes (\n, \xNN, \uNNNN)
-#define STRCONV_REPLCHAR 0x00000002 ///< convert non-printable characters to the Unicode replacement character (U+FFFD)
-#define STRCONV_INCLLEN 0x00000004 ///< for Pascal-style strings, include the prefixing length byte(s) as C-escaped sequence
-//@}
-
-/// Get contents of string literal, as UTF-8-encoded codepoints.
-/// This function returns the displayed part of the string
-/// It works even if the string has not been created in the database yet.
-///
-/// If 'len' is size_t(-1), it will be computed like so:
-/// - if a string literal is present at 'ea', get_item_size() * bytesize(ea) will be used
-/// - otherwise, get_max_strlit_length(..., ALOPT_IGNHEADS) will be used
-///
-/// About 'maxcps': this specifies a limit to the number of codepoints,
-/// not bytes in the UTF-8 output buffer. So for example although U+4e12
-/// will use 3 bytes in the output buffer, it still counts as only 1
-/// character -- unless STRCONV_ESCAPE is used.
-/// If 'STRCONV_ESCAPE' is used, U+4e12 will be converted to the string
-/// "\u4E12", and will use 6 bytes in the output buffer and also count
-/// as 6 codepoints.
-///
-/// If 'STRCONV_REPLCHAR', any undecodable byte will re represented
-/// as U+FFFD, occupy 3 bytes in the output buffer, and count for 1 codepoint.
-///
-/// \param[out] utf8 output buffer
-/// \param[in] ea linear address of the string
-/// \param[in] len length of the string, in octets (octet=8bit)
-/// \param[in] type type of the string. one of \ref STRTYPE_
-/// \param[in, out] maxcps maximum length of codepoints, after possible
-/// escaping, in output buffer (not counting terminating zero)
-/// on exit, will be set to 0 if string got truncated
-/// can be nullptr if not needed
-/// \param[in] flags combination of \ref STRCONV_
-/// \return length of generated text (in bytes) or -1
-
-idaman ssize_t ida_export get_strlit_contents(
- qstring *utf8,
- ea_t ea,
- size_t len,
- int32 type,
- size_t *maxcps = nullptr,
- int flags = 0);
-
-
-/// Convert to string literal and give a meaningful name.
-/// 'start' may be higher than 'end', the kernel will swap them in this case
-/// \param start starting address
-/// \param len length of the string in bytes.
-/// if 0, then get_max_strlit_length() will be used
-/// to determine the length
-/// \param strtype string type. one of \ref STRTYPE_
-/// \return success
-
-idaman bool ida_export create_strlit(ea_t start, size_t len, int32 strtype);
-
-
-
-//-------------------------------------------------------------------------
-/// \defgroup PSTF_ flags for use with get_strlit_type_info
-//@{
-#define PSTF_TNORM 0 ///< use normal name
-#define PSTF_TBRIEF 1 ///< use brief name (e.g., in the 'Strings window')
-#define PSTF_TINLIN 2 ///< use 'inline' name (e.g., in the structures comments)
-#define PSTF_TMASK 3 ///< type mask
-#define PSTF_HOTKEY 0x4 ///< have hotkey markers part of the name
-#define PSTF_ENC 0x8 ///< if encoding is specified, append it
-//@}
-
-
-/// Get string type information: the string type name (possibly
-/// decorated with hotkey markers), and the tooltip.
-///
-/// \param out the output buffer
-/// \param strtype the string type
-/// \param out_tooltip an optional output buffer for the tooltip
-/// \param flags or'ed PSTF_* constants
-/// \return length of generated text
-
-idaman bool ida_export print_strlit_type(
- qstring *out,
- int32 strtype,
- qstring *out_tooltip = nullptr,
- int flags = 0);
-
-
-/// Get additional information about an operand representation.
-/// \param buf buffer to receive the result. may not be nullptr
-/// \param ea linear address of item
-/// \param n number of operand, 0 or 1
-/// \param flags flags of the item
-/// \return nullptr if no additional representation information
-
-idaman opinfo_t *ida_export get_opinfo(
- opinfo_t *buf,
- ea_t ea,
- int n,
- flags_t flags);
-
-
-/// Set additional information about an operand representation.
-/// This function is a low level one. Only the kernel should use it.
-/// \param ea linear address of the item
-/// \param n number of operand, 0 or 1
-/// \param flag flags of the item
-/// \param ti additional representation information
-/// \param suppress_events do not generate changing_op_type and op_type_changed events
-/// \return success
-
-idaman bool ida_export set_opinfo(
- ea_t ea,
- int n,
- flags_t flag,
- const opinfo_t *ti,
- bool suppress_events=false);
-
-
-/// Get size of data type specified in flags 'F'.
-/// \param ea linear address of the item
-/// \param F flags
-/// \param ti additional information about the data type. For example,
-/// if the current item is a structure instance,
-/// then ti->tid is structure id. Otherwise is ignored (may be nullptr).
-/// If specified as nullptr, will be automatically retrieved from the database
-/// \return
-/// - byte : 1
-/// - word : 2
-/// - etc...
-///
-/// If flags doesn't specify a data, then return 1
-
-idaman asize_t ida_export get_data_elsize(ea_t ea, flags_t F, const opinfo_t *ti=nullptr);
-
-
-/// Get full size of data type specified in flags 'F'.
-/// takes into account processors with wide bytes
-/// e.g. returns 2 for a byte element with 16-bit bytes
-inline asize_t get_full_data_elsize(ea_t ea, flags_t F, const opinfo_t *ti=nullptr)
-{
- asize_t nbytes = get_data_elsize(ea, F, ti);
- return nbytes * bytesize(ea);
-}
-
-
-/// Is the item at 'ea' variable size?.
-/// \param ea linear address of the item
-/// \param F flags
-/// \param ti additional information about the data type. For example,
-/// if the current item is a structure instance,
-/// then ti->tid is structure id. Otherwise is ignored (may be nullptr).
-/// If specified as nullptr, will be automatically retrieved from the database
-/// \param itemsize if not nullptr and the item is varsize, itemsize
-/// will contain the calculated item size (for struct types, the minimal size is returned)
-/// \retval 1 varsize item
-/// \retval 0 fixed item
-/// \retval -1 error (bad data definition)
-
-idaman int ida_export is_varsize_item(
- ea_t ea,
- flags_t F,
- const opinfo_t *ti=nullptr,
- asize_t *itemsize=nullptr);
-
-
-/// Can define item (instruction/data) of the specified 'length', starting at 'ea'?
-/// \note if there is an item starting at 'ea', this function ignores it
-/// \note this function converts to unexplored all encountered data items
-/// with fixup information. Should be fixed in the future.
-/// \param flags if not 0, then the kernel will ignore the data types
-/// specified by the flags and destroy them. For example:
-///
-/// 1000 dw 5
-/// 1002 db 5 ; undef
-/// 1003 db 5 ; undef
-/// 1004 dw 5
-/// 1006 dd 5
-///
-/// can_define_item(1000, 6, 0) - false because of dw at 1004 \n
-/// can_define_item(1000, 6, word_flag()) - true, word at 1004 is destroyed
-/// \return 1-yes, 0-no
-///
-/// This function may return 0 if:
-/// - a new item would cross segment boundaries
-/// - a new item would overlap with existing items (except items specified by 'flags')
-
-idaman bool ida_export can_define_item(ea_t ea, asize_t length, flags_t flags);
-
-/// \defgroup FF_CODE Code bytes
-/// \ingroup FF_
-/// Represent characteristics of instructions
-//@{
-
-//-------------------------------------------------------------------------
-/// \defgroup FF_codebits Bits: code bytes
-//@{
-#define MS_CODE 0xF0000000LU ///< Mask for code bits
-#define FF_FUNC 0x10000000LU ///< function start?
-// 0x20000000LU // not used
-#define FF_IMMD 0x40000000LU ///< Has Immediate value ?
-#define FF_JUMP 0x80000000LU ///< Has jump table or switch_info?
-//@}
-
-/// \defgroup FF_codefuncs Functions: work with code bits
-//@{
-
-/// Has immediate value?
-
-inline THREAD_SAFE bool idaapi has_immd(flags_t F) { return is_code(F) && (F & FF_IMMD) != 0; }
-
-
-/// Is function start?
-
-inline THREAD_SAFE bool idaapi is_func(flags_t F) { return is_code(F) && (F & FF_FUNC) != 0; }
-
-
-/// Set 'has immediate operand' flag.
-/// Returns true if the #FF_IMMD bit was not set and now is set
-
-idaman bool ida_export set_immd(ea_t ea);
-
-
-//@} FF_codefuncs
-//@} FF_CODE
-
-//-----------------------------------------------------------------------
-// Custom data type and format definitions
-//-----------------------------------------------------------------------
-
-/// Information about a data type
-struct data_type_t
-{
- int cbsize; ///< size of this structure
- void *ud; ///< user-defined data to be passed to callbacks
- int props; ///< properties
-#define DTP_NODUP 0x0001 ///< do not use dup construct
- const char *name; ///< name of the data type. must be unique
- const char *menu_name; ///< Visible data type name to use in menus
- ///< if nullptr, no menu item will be created
- const char *hotkey; ///< Hotkey for the corresponding menu item
- ///< if nullptr, no hotkey will be associated with the menu item
- const char *asm_keyword; ///< keyword to use for this type in the assembly
- ///< if nullptr, the data type cannot be used in the listing
- ///< it can still be used in cpuregs window
- asize_t value_size; ///< size of the value in bytes
-
- /// Should this type be shown in UI menus
- /// \return success
- bool is_present_in_menus() const { return menu_name != nullptr && asm_keyword != nullptr; }
-
- /// May create data? nullptr means always may
- /// \param ud user-defined data
- /// \param ea address of the future item
- /// \param nbytes size of the future item
- bool (idaapi *may_create_at)(
- void *ud,
- ea_t ea,
- size_t nbytes);
-
- /// This function is used to determine size of the (possible) item at 'ea'.
- /// This callback is required only for varsize datatypes.
- /// \param ud user-defined data
- /// \param ea address of the item
- /// \param maxsize maximal size of the item
- /// \return 0 if no such item can be created/displayed
- asize_t (idaapi *calc_item_size)(
- void *ud,
- ea_t ea,
- asize_t maxsize);
-};
-
-/// Information about a data format
-struct data_format_t
-{
- int32 cbsize; ///< size of this structure
- void *ud; ///< user-defined data to be passed to callbacks
- int props; ///< properties (currently 0)
- const char *name; ///< Format name, must be unique
- const char *menu_name; ///< Visible format name to use in menus
- ///< if nullptr, no menu item will be created
- const char *hotkey; ///< Hotkey for the corresponding menu item
- ///< if nullptr, no hotkey will be associated with the menu item
- asize_t value_size; ///< size of the value in bytes
- ///< 0 means any size is ok
- ///< data formats that are registered for standard types (dtid 0)
- ///< may be called with any value_size (instruction operands only)
- int32 text_width; ///< Usual width of the text representation
- ///< This value is used to calculate the width
- ///< of the control to display values of this type
-
- /// Should this format be shown in UI menus
- /// \return success
- bool is_present_in_menus() const { return menu_name != nullptr; }
-
- /// Convert to colored string.
- /// \param ud user-defined data
- /// \param out output buffer. may be nullptr
- /// \param value value to print. may not be nullptr
- /// \param size size of value in 8-bit bytes
- /// \param current_ea current address (BADADDR if unknown)
- /// \param operand_num current operand number
- /// \param dtid custom data type id (0-standard built-in data type)
- /// \return success
- bool (idaapi *print)(
- void *ud,
- qstring *out,
- const void *value,
- asize_t size,
- ea_t current_ea,
- int operand_num,
- int dtid);
-
- /// Convert from uncolored string.
- /// \param ud user-defined data
- /// \param value output buffer. may be nullptr
- /// \param input input string. may not be nullptr
- /// \param current_ea current address (BADADDR if unknown)
- /// \param operand_num current operand number (-1 if unknown)
- /// \param errstr buffer for error message
- /// \return success
- bool (idaapi *scan)(
- void *ud,
- bytevec_t *value,
- const char *input,
- ea_t current_ea,
- int operand_num,
- qstring *errstr);
-
- /// Analyze custom data format occurrence
- /// This callback can be used to create xrefs from the current item.
- /// This callback may be missing.
- /// \param ud user-defined data
- /// \param current_ea current address (BADADDR if unknown)
- /// \param operand_num current operand number
- void (idaapi *analyze)(
- void *ud,
- ea_t current_ea,
- int operand_num);
-};
-
-
-/// Register a new data type.
-/// \param dtinfo description of the new data type
-/// \return > 0 : id of the new custom data type,
-/// < 0 : error when the custom data type with the same name has
-/// already been registered
-/// \note dtid 0 is reserved for built-in data types.
-
-idaman int ida_export register_custom_data_type(const data_type_t *dtinfo);
-
-
-/// Unregister a data type.
-/// When the idb is closed, all custom data types are automatically
-/// unregistered, but since it happens too late (plugin modules could
-/// already be unloaded) one has to unregister custom data types explicitly.
-/// The ids of unregistered custom data types remain allocated and when the
-/// same name is reused to register a custom data type, it will get assigned
-/// the same id.
-/// \param dtid data type to unregister
-/// \retval true ok
-/// \retval false no such dtid
-
-idaman bool ida_export unregister_custom_data_type(int dtid);
-
-
-/// Register a new data format.
-/// \param dtform description of the new data format
-/// \return > 0 : id of the new custom data format,
-/// < 0 : error when the custom data format with the same name has
-/// already been registered to the data type
-/// \note dfid 0 is unused.
-
-idaman int ida_export register_custom_data_format(const data_format_t *dtform);
-
-
-/// Unregister a data format.
-/// \sa unregister_custom_data_type()
-/// \param dfid data format to unregister
-/// \retval true ok
-/// \retval false no such dfid
-
-idaman bool ida_export unregister_custom_data_format(int dfid);
-
-
-/// Get definition of a registered custom data type.
-/// \param dtid data type id
-/// \return data type definition or nullptr
-
-idaman const data_type_t *ida_export get_custom_data_type(int dtid);
-
-
-/// Get definition of a registered custom data format.
-/// \param dfid data format id
-/// \return data format definition or nullptr
-
-idaman const data_format_t *ida_export get_custom_data_format(int dfid);
-
-
-/// Attach the data format to the data type.
-/// \param dtid data type id that can use the data format.
-/// 0 means all standard data types. Such data formats can be
-/// applied to any data item or instruction operands. For
-/// instruction operands, the data_format_t::value_size check
-/// is not performed by the kernel.
-/// \param dfid data format id
-/// \retval true ok
-/// \retval false no such `dtid', or no such `dfid', or the data format has
-/// already been attached to the data type
-
-idaman bool ida_export attach_custom_data_format(int dtid, int dfid);
-
-
-/// Detach the data format from the data type.
-/// Unregistering a custom data type detaches all attached data formats,
-/// no need to detach them explicitly. You still need unregister them.
-/// Unregistering a custom data format detaches it from all attached data
-/// types.
-/// \param dtid data type id to detach data format from
-/// \param dfid data format id to detach
-/// \retval true ok
-/// \retval false no such `dtid', or no such `dfid', or the data format was
-/// not attached to the data type
-
-idaman bool ida_export detach_custom_data_format(int dtid, int dfid);
-
-
-///
-
-idaman bool ida_export is_attached_custom_data_format(int dtid, int dfid);
-
-/// Get list of registered custom data type ids.
-/// \param out buffer for the output. may be nullptr
-/// \param min_size minimum value size
-/// \param max_size maximum value size
-/// \return number of custom data types with the specified size limits
-
-idaman int ida_export get_custom_data_types(
- intvec_t *out,
- asize_t min_size=0,
- asize_t max_size=BADADDR);
-
-
-/// Get list of attached custom data formats for the specified data type.
-/// \param out buffer for the output. may be nullptr
-/// \param dtid data type id
-/// \return number of returned custom data formats. if error, returns -1
-
-idaman int ida_export get_custom_data_formats(intvec_t *out, int dtid);
-
-
-/// Get id of a custom data type.
-/// \param name name of the custom data type
-/// \return id or -1
-
-idaman int ida_export find_custom_data_type(const char *name);
-
-
-/// Get id of a custom data format.
-/// \param name name of the custom data format
-/// \return id or -1
-
-idaman int ida_export find_custom_data_format(const char *name);
-
-
-//--------------------------------------------------------------------------
-// I N D E N T E D C O M M E N T S
-//--------------------------------------------------------------------------
-
-/// Set an indented comment.
-/// \param ea linear address
-/// \param comm comment string
-/// - nullptr: do nothing (return 0)
-/// - "" : delete comment
-/// \param rptble is repeatable?
-/// \return success
-
-idaman bool ida_export set_cmt(ea_t ea, const char *comm, bool rptble);
-
-
-/// Get an indented comment.
-/// \param buf output buffer, may be nullptr
-/// \param ea linear address. may point to tail byte, the function
-/// will find start of the item
-/// \param rptble get repeatable comment?
-/// \return size of comment or -1
-
-idaman ssize_t ida_export get_cmt(qstring *buf, ea_t ea, bool rptble);
-
-
-/// Append to an indented comment.
-/// Creates a new comment if none exists.
-/// Appends a newline character and the specified string otherwise.
-/// \param ea linear address
-/// \param str comment string to append
-/// \param rptble append to repeatable comment?
-/// \return success
-
-idaman bool ida_export append_cmt(ea_t ea, const char *str, bool rptble);
-
-
-//--------------------------------------------------------------------
-// P R E D E F I N E D C O M M E N T S
-//--------------------------------------------------------------------
-
-/// Get predefined comment.
-/// \param buf buffer for the comment
-/// \param ins current instruction information
-/// \return size of comment or -1
-
-idaman ssize_t ida_export get_predef_insn_cmt(
- qstring *buf,
- const insn_t &ins);
-
-
-//--------------------------------------------------------------------------
-// S E A R C H F U N C T I O N S
-//--------------------------------------------------------------------------
-/// Find forward a byte with the specified value (only 8-bit value from the database).
-/// example: ea=4 size=3 will inspect addresses 4, 5, and 6
-/// \param sEA linear address
-/// \param size number of bytes to inspect
-/// \param value value to find
-/// \param bin_search_flags combination of \ref BIN_SEARCH_
-/// \return address of byte or #BADADDR
-
-idaman ea_t ida_export find_byte(ea_t sEA, asize_t size, uchar value, int bin_search_flags);
-
-
-/// Find reverse a byte with the specified value (only 8-bit value from the database).
-/// example: ea=4 size=3 will inspect addresses 6, 5, and 4
-/// \param sEA the lower address of the search range
-/// \param size number of bytes to inspect
-/// \param value value to find
-/// \param bin_search_flags combination of \ref BIN_SEARCH_
-/// \return address of byte or #BADADDR
-
-idaman ea_t ida_export find_byter(ea_t sEA, asize_t size, uchar value, int bin_search_flags);
-
-
-//-------------------------------------------------------------------------
-struct compiled_binpat_t // compiled binary pattern compiled_binpat_t
-{
- bytevec_t bytes;
- bytevec_t mask;
- rangevec_t strlits; // range of string literals, in _bytes_ ranges (not CPs)
- int encidx;
-
- compiled_binpat_t() : encidx(-1) {}
- bool all_bytes_defined() const { return mask.empty(); }
- void qclear() { bytes.qclear(); mask.qclear(); strlits.qclear(); encidx = -1; }
-};
-DECLARE_TYPE_AS_MOVABLE(compiled_binpat_t);
-typedef qvector compiled_binpat_vec_t;
-
-#define PBSENC_DEF1BPU 0 /// Use the default 1 byte-per-unit IDB encoding
-#define PBSENC_ALL -1 /// Use all IDB encodings
-
-/// Convert user-specified binary string to internal representation.
-/// \param [out] out a vector of compiled binary patterns, for use with bin_search2()
-/// \param ea linear address to convert for (the conversion depends on the
-/// address, because the number of bits in a byte depend on the
-/// segment type)
-/// \param in input text string. contains space-separated:
-/// - numbers (numeric base is determined by 'radix')
-/// - if value of number fits a byte, it is considered as a byte
-/// - if value of number fits a word, it is considered as 2 bytes
-/// - if value of number fits a dword,it is considered as 4 bytes
-/// - "..." string constants
-/// - 'x' single-character constants
-/// - ? variable bytes
-/// \note Examples of search strings (assuming base 16):
-/// CD 21 - bytes 0xCD, 0x21
-/// 21CD - bytes 0xCD, 0x21 (little endian ) or 0x21, 0xCD (big-endian)
-/// "Hello", 0 - the null terminated string "Hello"
-/// L"Hello" - 'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0
-/// B8 ? ? ? ? 90 - byte 0xB8, 4 bytes with any value, byte 0x90
-///
-/// \param radix numeric base of numbers (8,10,16)
-/// \param strlits_encoding the target encoding into which the string
-/// literals present in 'in', should be encoded.
-/// Can be any from [1, get_encoding_qty()), or
-/// the special values PBSENC_*
-/// \param errbuf error buffer (can be nullptr)
-/// \return false either in case of parsing error, or if at least one
-/// requested target encoding couldn't encode the string
-/// literals present in "in".
-// true otherwise
-idaman bool ida_export parse_binpat_str(
- compiled_binpat_vec_t *out,
- ea_t ea,
- const char *in,
- int radix,
- int strlits_encoding=PBSENC_DEF1BPU,
- qstring *errbuf=nullptr);
-
-
-/// Search for a string in the program.
-/// \param start_ea linear address, start of range to search
-/// \param end_ea linear address, end of range to search (exclusive)
-/// \param data the prepared data to search for (see parse_binpat_str())
-/// \param flags combination of \ref BIN_SEARCH_
-/// \return #BADADDR (if pressed Ctrl-Break or not found) or string address.
-
-idaman ea_t ida_export bin_search2(
- ea_t start_ea,
- ea_t end_ea,
- const compiled_binpat_vec_t &data,
- int flags);
-
-inline ea_t bin_search2(
- ea_t start_ea,
- ea_t end_ea,
- const uchar *image,
- const uchar *mask,
- size_t len,
- int flags)
-{
- compiled_binpat_vec_t bbv;
- compiled_binpat_t &bv = bbv.push_back();
- bv.bytes.append(image, len);
- if ( mask != nullptr )
- bv.mask.append(mask, len);
- return bin_search2(start_ea, end_ea, bbv, flags);
-}
-
-//t
-/// \defgroup BIN_SEARCH_ Search flags
-/// passed as 'flags' parameter to bin_search()
-//@{
-#define BIN_SEARCH_CASE 0x01 ///< case sensitive
-#define BIN_SEARCH_NOCASE 0x00 ///< case insensitive
-#define BIN_SEARCH_NOBREAK 0x02 ///< don't check for Ctrl-Break
-#define BIN_SEARCH_INITED 0x04 ///< find_byte, find_byter: any initilized value
-#define BIN_SEARCH_NOSHOW 0x08 ///< don't show search progress or update screen
-#define BIN_SEARCH_FORWARD 0x00 ///< search forward for bytes
-#define BIN_SEARCH_BACKWARD 0x10 ///< search backward for bytes
-//@}
-
-
-/// Find the next initialized address
-
-inline ea_t idaapi next_inited(ea_t ea, ea_t maxea)
-{
- if ( ea >= maxea )
- return BADADDR;
- ++ea;
- return find_byte(ea, maxea-ea, 0, BIN_SEARCH_INITED);
-}
-
-/// Find the previous initialized address
-
-inline ea_t idaapi prev_inited(ea_t ea, ea_t minea)
-{
- if ( ea <= minea )
- return BADADDR;
- --ea;
- return find_byter(minea, ea-minea, 0, BIN_SEARCH_INITED);
-}
-
-/// Compare 'len' bytes of the program starting from 'ea' with 'image'.
-/// \param ea linear address
-/// \param image bytes to compare with
-/// \param mask array of 1/0 bytes, it's length is 'len'. 1 means to perform
-/// the comparison of the corresponding byte. 0 means not to perform.
-/// if mask == nullptr, then all bytes of 'image' will be compared.
-/// if mask == #SKIP_FF_MASK then 0xFF bytes will be skipped
-/// \param len length of block to compare in bytes.
-/// \param sense_case case-sensitive comparison?
-/// \retval 1 equal
-/// \retval 0 not equal
-
-idaman bool ida_export equal_bytes(
- ea_t ea,
- const uchar *image,
- const uchar *mask,
- size_t len,
- bool sense_case);
-
-/// Used by equal_bytes() to skip 0xFF when searching the program
-#define SKIP_FF_MASK ((const uchar *)0xFF)
-
-
-
-//------------------------------------------------------------------------
-// H I D D E N A R E A S
-//------------------------------------------------------------------------
-
-/// Hidden ranges - address ranges which can be replaced by their descriptions.
-/// There is also a possibility to hide individual items completely (nalt.hpp, hide_item)
-/// \note After modifying any of this struct's fields please call update_hidden_range()
-
-struct hidden_range_t : public range_t
-{
- char *description; ///< description to display if the range is collapsed
- char *header; ///< header lines to display if the range is expanded
- char *footer; ///< footer lines to display if the range is expanded
- bool visible; ///< the range state
- bgcolor_t color; ///< range color
-};
-
-/// Update hidden range information in the database.
-/// You cannot use this function to change the range boundaries
-/// \param ha range to update
-/// \return success
-
-idaman bool ida_export update_hidden_range(const hidden_range_t *ha);
-
-
-/// Mark a range of addresses as hidden.
-/// The range will be created in the invisible state with the default color
-/// \param ea1 linear address of start of the address range
-/// \param ea2 linear address of end of the address range
-/// \param description, header, footer range parameters
-/// \return success
-
-idaman bool ida_export add_hidden_range(
- ea_t ea1,
- ea_t ea2,
- const char *description,
- const char *header,
- const char *footer,
- bgcolor_t color);
-
-
-/// Get pointer to hidden range structure, in: linear address.
-/// \param ea any address in the hidden range
-
-idaman hidden_range_t *ida_export get_hidden_range(ea_t ea);
-
-
-/// Get pointer to hidden range structure, in: number of hidden range.
-/// \param n number of hidden range, is in range 0..get_hidden_range_qty()-1
-
-idaman hidden_range_t *ida_export getn_hidden_range(int n);
-
-
-/// Get number of hidden ranges
-
-idaman int ida_export get_hidden_range_qty(void);
-
-
-/// Get number of a hidden range.
-/// \param ea any address in the hidden range
-/// \return number of hidden range (0..get_hidden_range_qty()-1)
-
-idaman int ida_export get_hidden_range_num(ea_t ea);
-
-
-/// Get pointer to previous hidden range.
-/// \param ea any address in the program
-/// \return ptr to hidden range or nullptr if previous hidden range doesn't exist
-
-idaman hidden_range_t *ida_export get_prev_hidden_range(ea_t ea);
-
-
-/// Get pointer to next hidden range.
-/// \param ea any address in the program
-/// \return ptr to hidden range or nullptr if next hidden range doesn't exist
-
-idaman hidden_range_t *ida_export get_next_hidden_range(ea_t ea);
-
-
-/// Get pointer to the first hidden range.
-/// \return ptr to hidden range or nullptr
-
-idaman hidden_range_t *ida_export get_first_hidden_range(void);
-
-
-/// Get pointer to the last hidden range.
-/// \return ptr to hidden range or nullptr
-
-idaman hidden_range_t *ida_export get_last_hidden_range(void);
-
-
-/// Delete hidden range.
-/// \param ea any address in the hidden range
-/// \return success
-
-idaman bool ida_export del_hidden_range(ea_t ea);
-
-
-//--------------------------------------------------------------------------
-inline ea_t idaapi get_item_head(ea_t ea)
-{
- if ( is_tail(get_flags(ea)) )
- ea = prev_not_tail(ea);
- return ea;
-}
-
-//------------------------------------------------------------------------
-// M E M O R Y M A P P I N G
-//------------------------------------------------------------------------
-
-/// IDA supports memory mapping. References to the addresses from
-/// the mapped range use data and meta-data from the mapping range.
-/// \note You should set flag PR2_MAPPING in ph.flag2 to use memory mapping
-
-
-/// Add memory mapping range.
-/// \param from start of the mapped range (nonexistent address)
-/// \param to start of the mapping range (existent address)
-/// \param size size of the range
-/// \return success
-
-idaman bool ida_export add_mapping(ea_t from, ea_t to, asize_t size);
-
-
-/// Delete memory mapping range.
-/// \param ea any address in the mapped range
-
-idaman void ida_export del_mapping(ea_t ea);
-
-
-/// Translate address according to current mappings.
-/// \param ea address to translate
-/// \return translated address
-
-idaman ea_t ida_export use_mapping(ea_t ea);
-
-/// Get number of mappings.
-
-idaman size_t ida_export get_mappings_qty(void);
-
-/// Get memory mapping range by its number.
-/// \param from start of the mapped range
-/// \param to start of the mapping range
-/// \param size size of the range
-/// \param n number of mapping range (0..get_mappings_qty()-1)
-/// \return false if the specified range doesn't exist,
-/// otherwise returns `from', `to', `size'
-idaman bool ida_export get_mapping(
- ea_t *from,
- ea_t *to,
- asize_t *size,
- size_t n);
-
-
-#ifndef BYTES_SOURCE // undefined bit masks so no one can use them directly
-#undef MS_VAL
-#undef FF_IVL
-#undef MS_CLS
-#undef FF_CODE
-#undef FF_DATA
-#undef FF_TAIL
-#undef FF_UNK
-#undef MS_COMM
-#undef FF_COMM
-#undef FF_REF
-#undef FF_LINE
-#undef FF_NAME
-#undef FF_LABL
-#undef FF_ANYNAME
-#undef FF_FLOW
-#undef FF_SIGN
-#undef FF_BNOT
-#undef MS_0TYPE
-#undef FF_0VOID
-#undef FF_0NUMH
-#undef FF_0NUMD
-#undef FF_0CHAR
-#undef FF_0SEG
-#undef FF_0OFF
-#undef FF_0NUMB
-#undef FF_0NUMO
-#undef FF_0ENUM
-#undef FF_0FOP
-#undef FF_0STRO
-#undef FF_0STK
-#undef FF_0FLT
-#undef FF_0CUST
-#undef MS_1TYPE
-#undef FF_1VOID
-#undef FF_1NUMH
-#undef FF_1NUMD
-#undef FF_1CHAR
-#undef FF_1SEG
-#undef FF_1OFF
-#undef FF_1NUMB
-#undef FF_1NUMO
-#undef FF_1ENUM
-#undef FF_1FOP
-#undef FF_1STRO
-#undef FF_1STK
-#undef FF_1FLT
-#undef FF_1CUST
-#undef DT_TYPE
-#undef FF_BYTE
-#undef FF_WORD
-#undef FF_DWORD
-#undef FF_QWORD
-#undef FF_OWORD
-#undef FF_YWORD
-#undef FF_ZWORD
-#undef FF_FLOAT
-#undef FF_DOUBLE
-#undef FF_TBYTE
-#undef FF_PACKREAL
-#undef FF_STRLIT
-#undef FF_STRUCT
-#undef FF_ALIGN
-#undef FF_CUSTOM
-#undef MS_CODE
-#undef FF_FUNC
-#undef FF_IMMD
-//#undef FF_JUMP
-#undef MS_TAIL
-#undef TL_TSFT
-#undef TL_TOFF
-#undef MAX_TOFF
-#endif // BYTES_SOURCE
-
-// byte array to hex string
-inline THREAD_SAFE ssize_t get_hex_string(char *buf, size_t bufsize, const uchar *bytes, size_t len)
-{
- const char *const start = buf;
- const char *const end = buf + bufsize;
- for ( size_t i = 0; i < len; i++ )
- buf += ::qsnprintf(buf, end - buf, "%02X", *bytes++);
- return buf - start;
-}
-
-
-#ifndef NO_OBSOLETE_FUNCS
-idaman DEPRECATED ea_t ida_export bin_search(ea_t, ea_t, const uchar *, const uchar *, size_t, int, int); // use bin_search2()
-idaman DEPRECATED uchar ida_export get_8bit(ea_t *ea, uint32 *v, int *nbit); // use get_octet()
-#endif
-
-
-#endif // BYTES_HPP
diff --git a/idasdk75/include/compress.hpp b/idasdk75/include/compress.hpp
deleted file mode 100644
index 0994653..0000000
--- a/idasdk75/include/compress.hpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Interactive disassembler (IDA).
- * Copyright (c) 1990-2020 Hex-Rays
- * ALL RIGHTS RESERVED.
- *
- */
-
-#ifndef COMPRESS_HPP
-#define COMPRESS_HPP
-
-#include
-
-/*! \file compress.hpp
-
- \brief Data compression functions
-
-*/
-
-/// Compress data.
-/// This function depends on the value of legacy_idb, so it is not completely
-/// thread safe. However, legacy_idb does not change its value.
-/// \return \ref PKZ_
-
-idaman THREAD_SAFE int ida_export zip_deflate(
- void *ud,
- ssize_t (idaapi *file_reader)(void *ud, void *buf, size_t size),
- ssize_t (idaapi *file_writer)(void *ud, const void *buf, size_t size));
-
-
-/// Uncompress data.
-/// This function depends on the value of legacy_idb, so it is not completely
-/// thread safe. However, legacy_idb does not change its value.
-/// \return \ref PKZ_
-
-idaman THREAD_SAFE int ida_export zip_inflate(
- void *ud,
- ssize_t (idaapi *file_reader)(void *ud, void *buf, size_t size),
- ssize_t (idaapi *file_writer)(void *ud, const void *buf, size_t size));
-
-
-/// Process zip file and enumerate all files stored in it
-/// \param zipfile name of zip file
-/// \param callback callback for each file. params:
-/// - ud: user data
-/// - offset: offset in the zip file
-/// - method: compression method (\ref compression_methods)
-/// - csize: compressed size
-/// - ucsize: uncompressed size
-/// - attributes: file attributes
-/// \param ud user data
-/// \return \ref PKZ_
-
-idaman THREAD_SAFE int ida_export process_zipfile(
- const char *zipfile,
- int (idaapi *callback)(
- void *ud,
- qoff64_t offset,
- int method,
- uint64 csize,
- uint64 ucsize,
- uint32 attributes,
- const char *filename),
- void *ud = NULL);
-
-
-/// Process zip file and enumerate all files stored in it
-/// \param li input file
-/// \param callback callback for each file. params:
-/// - ud: user data
-/// - offset: offset in the zip file
-/// - method: compression method (\ref compression_methods)
-/// - csize: compressed size
-/// - ucsize: uncompressed size
-/// - attributes: file attributes
-/// \param ud user data
-/// \return \ref PKZ_
-
-idaman THREAD_SAFE int ida_export process_zip_linput(
- linput_t *li,
- int (idaapi *callback)(
- void *ud,
- qoff64_t offset,
- int method,
- uint64 csize,
- uint64 ucsize,
- uint32 attributes,
- const char *filename),
- void *ud = NULL);
-
-
-/// Search for specified entry in zip file, and calls the
-/// callback with it, if found.
-/// \param zipfile name of zip file
-/// \param entry entry in zip file. E.g., "path/to/entry.dat"
-/// \param callback callback for each file. params:
-/// - ud: user data
-/// - offset: offset in the zip file
-/// - method: compression method (\ref compression_methods)
-/// - csize: compressed size
-/// - ucsize: uncompressed size
-/// - attributes: file attributes
-/// \param ud user data
-/// \param case_sensitive should the search be case sensitive?
-/// \return \ref PKZ_
-
-idaman THREAD_SAFE int ida_export process_zipfile_entry(
- const char *zipfile,
- const char *entry,
- int (idaapi *callback)(
- void *ud,
- qoff64_t offset,
- int method,
- uint64 csize,
- uint64 ucsize,
- uint32 attributes,
- const char *filename),
- void *ud = NULL,
- bool case_sensitive = true);
-
-
-/// \defgroup PKZ_ Compression error codes
-/// Returned by functions in compress.hpp
-//@{
-#define PKZ_OK 0
-#define PKZ_ERRNO 1
-#define PKZ_STREAM_ERROR 2
-#define PKZ_DATA_ERROR 3
-#define PKZ_MEM_ERROR 4
-#define PKZ_BUF_ERROR 5
-#define PKZ_VERSION_ERROR 6
-#define PKZ_RERR 777 // read error
-#define PKZ_WERR 778 // write error
-//@}
-
-/// \defgroup compression_methods Compression methods
-/// passed as 'method' parameter to callback functions in compress.hpp
-//@{
-#define STORED 0
-#define SHRUNK 1
-#define REDUCED1 2
-#define REDUCED2 3
-#define REDUCED3 4
-#define REDUCED4 5
-#define IMPLODED 6
-#define TOKENIZED 7
-#define DEFLATED 8
-#define NUM_METHODS 9 /* index of last method + 1 */
-//@}
-
-extern bool legacy_idb; ///< for old idb files
-
-/// Upon closing outer linput, perform one of these actions
-enum linput_close_code_t
-{
- LOC_CLOSE, ///< close the inner linput
- LOC_UNMAKE, ///< unmake the inner linput
- LOC_KEEP, ///< do nothing
-};
-
-
-/// Create a linput to read a compressed input stream
-/// \param in linput with compressed data, seeked to the stream beginning
-/// \param insize size of compressed data. -1 - unknown
-/// \param loc what to do upon closing the resulting linput
-/// \return linput that can be used to read uncompressed data.
-/// NULL if any error (no more linput descriptors).
-
-idaman THREAD_SAFE linput_t *ida_export create_zip_linput(
- linput_t *in,
- ssize_t insize=-1,
- linput_close_code_t loc=LOC_CLOSE);
-
-#endif
diff --git a/idasdk75/include/config.hpp b/idasdk75/include/config.hpp
deleted file mode 100644
index c0c054e..0000000
--- a/idasdk75/include/config.hpp
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- * Interactive disassembler (IDA).
- * Copyright (c) 1990-2020 Hex-Rays
- * ALL RIGHTS RESERVED.
- *
- */
-
-#ifndef _CONFIG_HPP
-#define _CONFIG_HPP
-
-//-----------------------------------------------------------------------
-/// \defgroup IDPOPT_T Option value types
-/// Passed as 'value_type' parameter to ::set_options_t callbacks
-//@{
-#define IDPOPT_STR 1 ///< string constant (char *)
-#define IDPOPT_NUM 2 ///< number (uval_t *)
-#define IDPOPT_BIT 3 ///< bit, yes/no (int *)
-#define IDPOPT_I64 5 ///< 64bit number (int64 *)
-#define IDPOPT_CST 6 ///< lexer (lexer_t*)
- ///< Custom type, starting with a '{'
- ///< Values of this type should be handled by
- ///< ::set_options_t callbacks. E.g.,:
- ///< \code
- ///< ERROR_STRINGS =
- ///< {
- ///< {0, "Unknown error"},
- ///< {1, "Missing filename"},
- ///< {5, "Out-of-memory"}
- ///< }
- ///< \endcode
- ///< For values of this type, the data that will
- ///< be passed as the callback's 'value' parameter
- ///< is the lexer instance that is being used
- ///< to parse the configuration file.
- ///< You can use \ref parse_json() (see parsejson.hpp)
- ///< to parse JSON-format data
- ///< NB: the '{' is already consumed by the parser,
- ///< so you need to push it again if it's a part of the JSON object
-//@}
-
-/// \defgroup IDPOPT_RET Option result codes
-/// Predefined return values for ::set_options_t callbacks
-//@{
-#define IDPOPT_OK NULL ///< ok
-#define IDPOPT_BADKEY ((char*)1) ///< illegal keyword
-#define IDPOPT_BADTYPE ((char*)2) ///< illegal type of value
-#define IDPOPT_BADVALUE ((char*)3) ///< illegal value (bad range, for example)
-//@}
-
-
-/// Callback - called when a config directive is processed in IDA.
-/// Also see read_config_file() and processor_t::set_idp_options
-/// \param keyword keyword encountered in IDA.CFG/user config file.
-/// if NULL, then an interactive dialog form should be displayed
-/// \param value_type type of value of the keyword - one of \ref IDPOPT_T
-/// \param value pointer to value
-/// \param idb_loaded true if the ev_oldfile/ev_newfile events have been generated?
-/// \return one of \ref IDPOPT_RET, otherwise a pointer to an error message
-
-typedef const char *(idaapi set_options_t)(
- const char *keyword,
- int value_type,
- const void *value,
- bool idb_loaded);
-
-/// \defgroup IDAOPT_PRIO Option priority
-/// Specifies the priority of a configuration option. Since options may
-/// be specified in different way, and applied in various orders, we need
-/// option priorities.
-/// Normally the default priority option does not overwrite the existing value
-/// whereas the high priority one does.
-/// High priority options may be stored in the database to be available
-/// in the next session.
-//@{
-#define IDPOPT_PRI_DEFAULT 1 ///< default priority - taken from config file
-#define IDPOPT_PRI_HIGH 2 ///< high priority - received from UI or a script function
-//@}
-
-
-//-------------------------------------------------------------------------
-/// Parse the value type for the value token 'value'.
-/// This is mostly used for converting from values that a cfgopt_handler_t
-/// receives, into data that callbacks
-/// - processor_t::set_idp_options
-/// - debugger_t::set_dbg_options
-/// expect.
-///
-/// Plugins that wish to use options shouldn't rely on this,
-/// and use the cfgopt_t utility instead.
-///
-/// \param out parsed data
-/// \param lx the lexer in use
-/// \param value the value token
-/// \return true if guessing didn't lead to an error, false otherwise.
-/// note that even if 'true' is returned, it doesn't mean the
-/// type could be guessed: merely that no syntax error occurred.
-class lexer_t;
-struct token_t;
-idaman bool ida_export parse_config_value(
- idc_value_t *out,
- lexer_t *lx,
- const token_t &value);
-
-//-------------------------------------------------------------------------
-typedef const char *(idaapi cfgopt_handler_t)(
- lexer_t *lx,
- const token_t &keyword,
- const token_t &value);
-
-//-------------------------------------------------------------------------
-typedef const char *(idaapi cfgopt_handler2_t)(
- lexer_t *lx,
- const token_t &keyword,
- const token_t &value,
- int64 param1,
- int64 param2);
-
-//-------------------------------------------------------------------------
-typedef const char *(idaapi cfgopt_handler3_t)(
- lexer_t *lx,
- const token_t &keyword,
- const token_t &value,
- int64 param1,
- int64 param2,
- void *obj);
-
-//-----------------------------------------------------------------------
-/// used by cfgopt_t. You shouldn't have to deal with those directly.
-#define IDPOPT_NUM_INT (0)
-#define IDPOPT_NUM_CHAR (1 << 24)
-#define IDPOPT_NUM_SHORT (2 << 24)
-#define IDPOPT_NUM_RANGE (1 << 26)
-#define IDPOPT_NUM_UNS (1 << 27)
-
-#define IDPOPT_BIT_UINT 0
-#define IDPOPT_BIT_UCHAR (1 << 24)
-#define IDPOPT_BIT_USHORT (2 << 24)
-#define IDPOPT_BIT_BOOL (3 << 24)
-
-#define IDPOPT_STR_QSTRING (1 << 24)
-#define IDPOPT_STR_LONG (1 << 25)
-
-#define IDPOPT_I64_RANGES (1 << 24)
-#define IDPOPT_I64_UNS (1 << 25)
-
-#define IDPOPT_CST_PARAMS (1 << 24)
-
-#define IDPOPT_MBROFF (1 << 18)
-
-//-------------------------------------------------------------------------
-struct cfgopt_t;
-idaman const char *ida_export cfgopt_t__apply(
- const cfgopt_t *_this,
- int vtype,
- const void *vdata);
-idaman const char *ida_export cfgopt_t__apply2(
- const cfgopt_t *_this,
- int vtype,
- const void *vdata,
- void *obj);
-
-//-------------------------------------------------------------------------
-// cfgopt_t objects are suitable for being statically initialized, and
-// passed to 'read_config_file'.
-//
-// E.g.,
-// ---
-// static const cfgopt_t g_opts[] =
-// {
-// cfgopt_t("AUTO_UNDEFINE", &auto_undefine, -1, 1),
-// cfgopt_t("NOVICE", &novice, true),
-// cfgopt_t("EDITOR", editor_buf, sizeof(editor_buf)),
-// cfgopt_t("SCREEN_PALETTE", set_screen_palette), // specific handler for SCREEN_PALETTE
-// };
-//
-// ...
-//
-// read_config_file("myfile", g_opts, qnumber(g_opts), other_handler)
-// ---
-//
-// NOTES:
-// * so-called 'long' strings (the default) can span on multiple lines,
-// and are terminated by a ';'
-struct cfgopt_t
-{
- const char *name;
- union
- {
- void *ptr;
- size_t mbroff; // offset of a structure member
- cfgopt_handler_t *hnd; // to avoid reinterpret_cast and gcc's error:
- cfgopt_handler2_t *hnd2; // "a reinterpret_cast is not a constant expression"
- cfgopt_handler3_t *hnd3; //
- };
- int flags;
- struct num_range_t
- {
- constexpr num_range_t(int64 _min, int64 _max) : minval(_min), maxval(_max) {}
- int64 minval;
- int64 maxval;
- };
- struct params_t
- {
- constexpr params_t(int64 _p1, int64 _p2) : p1(_p1), p2(_p2) {}
- int64 p1;
- int64 p2;
- };
- union
- {
- size_t buf_size;
- num_range_t num_range;
- uint32 bit_flags;
- params_t params;
- void *mbroff_obj;
- };
-
- // IDPOPT_STR
- constexpr cfgopt_t(const char *_n, char *_p, size_t _sz, bool _long = true)
- : name(_n), ptr(_p), flags(IDPOPT_STR | (_long ? IDPOPT_STR_LONG : 0)), buf_size(_sz)
- {}
- constexpr cfgopt_t(const char *_n, qstring *_p, bool _long = true)
- : name(_n), ptr(_p), flags(IDPOPT_STR | IDPOPT_STR_QSTRING | (_long ? IDPOPT_STR_LONG : 0)), buf_size(0)
- {}
-
- // IDPOPT_NUM
- constexpr cfgopt_t(const char *_n, int *_p)
- : name(_n), ptr(_p), flags(IDPOPT_NUM), buf_size(0) {}
- constexpr cfgopt_t(const char *_n, uint *_p)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_UNS), buf_size(0) {}
- constexpr cfgopt_t(const char *_n, char *_p)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_CHAR), buf_size(0) {}
- constexpr cfgopt_t(const char *_n, uchar *_p)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_UNS | IDPOPT_NUM_CHAR), buf_size(0) {}
- constexpr cfgopt_t(const char *_n, short *_p)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_SHORT), buf_size(0) {}
- constexpr cfgopt_t(const char *_n, ushort *_p)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_UNS | IDPOPT_NUM_SHORT), buf_size(0) {}
- // IDPOPT_NUM + ranges
- constexpr cfgopt_t(const char *_n, int *_p, int _min, int _max)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_RANGE), num_range(_min, _max) {}
- constexpr cfgopt_t(const char *_n, uint *_p, uint _min, uint _max)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_UNS | IDPOPT_NUM_RANGE), num_range(_min, _max) {}
- constexpr cfgopt_t(const char *_n, char *_p, char _min, char _max)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_CHAR | IDPOPT_NUM_RANGE), num_range(_min, _max) {}
- constexpr cfgopt_t(const char *_n, uchar *_p, uchar _min, uchar _max)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_UNS | IDPOPT_NUM_CHAR | IDPOPT_NUM_RANGE), num_range(_min, _max) {}
- constexpr cfgopt_t(const char *_n, short *_p, short _min, short _max)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_RANGE | IDPOPT_NUM_SHORT), num_range(_min, _max) {}
- constexpr cfgopt_t(const char *_n, ushort *_p, ushort _min, ushort _max)
- : name(_n), ptr(_p), flags(IDPOPT_NUM | IDPOPT_NUM_UNS | IDPOPT_NUM_RANGE | IDPOPT_NUM_SHORT), num_range(_min, _max) {}
-
- // IDPOPT_BIT
- constexpr cfgopt_t(const char *_n, bool *_p, bool _flags) : name(_n), ptr(_p), flags(IDPOPT_BIT | IDPOPT_BIT_BOOL), bit_flags(_flags) {}
- constexpr cfgopt_t(const char *_n, uchar *_p, uchar _flags) : name(_n), ptr(_p), flags(IDPOPT_BIT | IDPOPT_BIT_UCHAR), bit_flags(_flags) {}
- constexpr cfgopt_t(const char *_n, ushort *_p, ushort _flags) : name(_n), ptr(_p), flags(IDPOPT_BIT | IDPOPT_BIT_USHORT), bit_flags(_flags) {}
- constexpr cfgopt_t(const char *_n, uint32 *_p, uint32 _flags) : name(_n), ptr(_p), flags(IDPOPT_BIT), bit_flags(_flags) {}
-
- // IDPOPT_I64
- constexpr cfgopt_t(const char *_n, int64 *_p) : name(_n), ptr(_p), flags(IDPOPT_I64), buf_size(0) {}
- constexpr cfgopt_t(const char *_n, uint64 *_p) : name(_n), ptr(_p), flags(IDPOPT_I64 | IDPOPT_NUM_UNS), buf_size(0) {}
- // IDPOPT_I64 + ranges
- constexpr cfgopt_t(const char *_n, int64 *_p, int64 _min, int64 _max)
- : name(_n), ptr(_p), flags(IDPOPT_I64 | IDPOPT_I64_RANGES), num_range(_min, _max) {}
- constexpr cfgopt_t(const char *_n, uint64 *_p, uint64 _min, uint64 _max)
- : name(_n), ptr(_p), flags(IDPOPT_I64 | IDPOPT_I64_UNS | IDPOPT_I64_RANGES), num_range(int64(_min), int64(_max)) {}
-
- // IDPOPT_CST
- constexpr cfgopt_t(const char *_n, cfgopt_handler_t *_p)
- : name(_n), hnd(_p), flags(IDPOPT_CST), buf_size(0) {}
- // IDPOPT_CST + params
- constexpr cfgopt_t(const char *_n, cfgopt_handler2_t *_p, int64 _p1=0, int64 _p2=0)
- : name(_n), hnd2(_p), flags(IDPOPT_CST | IDPOPT_CST_PARAMS), params(_p1, _p2) {}
-
- // configuration option based on the offset of a structure member
-
- // IDPOPT_STR
- template
- constexpr cfgopt_t(const char *_n, qstring T:: *, size_t _mbroff, bool _long = true)
- : name(_n),
- mbroff(_mbroff),
- flags(IDPOPT_MBROFF | IDPOPT_STR | IDPOPT_STR_QSTRING | (_long ? IDPOPT_STR_LONG : 0)),
- buf_size(0)
- {}
-#define CFGOPT_QS(nm, cfgt, cfgm, _long) \
- cfgopt_t(nm, &cfgt::cfgm, qoffsetof(cfgt, cfgm), _long)
-
-#define CFGOPT_INNER_QS(nm, cfgt, cfgm, mt, mf, _long) \
- cfgopt_t(nm, &mt::mf, qoffsetof(cfgt, cfgm) + qoffsetof(mt, mf), _long)
-
-
- // IDPOPT_NUM
-#define CTR_CFGOPT(ctrtype, ctrflags) \
- template \
- constexpr cfgopt_t(const char *_n, ctrtype T:: *, size_t _mbroff) \
- : name(_n), \
- mbroff(_mbroff), \
- flags(IDPOPT_MBROFF|IDPOPT_NUM|ctrflags), \
- buf_size(0) \
- {}
- CTR_CFGOPT(int, 0)
- CTR_CFGOPT(uint, IDPOPT_NUM_UNS)
- CTR_CFGOPT(char, IDPOPT_NUM_CHAR)
- CTR_CFGOPT(uchar, IDPOPT_NUM_UNS|IDPOPT_NUM_CHAR)
- CTR_CFGOPT(short, IDPOPT_NUM_SHORT)
- CTR_CFGOPT(ushort, IDPOPT_NUM_SHORT|IDPOPT_NUM_UNS)
-#undef CTR_CFGOPT
-
-#define CFGOPT_N(nm, cfgt, cfgm) \
- cfgopt_t(nm, &cfgt::cfgm, qoffsetof(cfgt, cfgm))
-
-#define CFGOPT_INNER_N(nm, cfgt, cfgm, mt, mf) \
- cfgopt_t(nm, &mt::mf, qoffsetof(cfgt, cfgm) + qoffsetof(mt, mf))
-
-
- // IDPOPT_NUM + ranges
-#define CTR_CFGOPT(ctrtype, ctrflags) \
- template \
- constexpr cfgopt_t(const char *_n, ctrtype T:: *, size_t _mbroff, int64 _min, int64 _max) \
- : name(_n), \
- mbroff(_mbroff), \
- flags(IDPOPT_MBROFF|IDPOPT_NUM|IDPOPT_NUM_RANGE|ctrflags), \
- num_range(_min, _max) \
- {}
- CTR_CFGOPT(int, 0)
- CTR_CFGOPT(uint, IDPOPT_NUM_UNS)
- CTR_CFGOPT(char, IDPOPT_NUM_CHAR)
- CTR_CFGOPT(uchar, IDPOPT_NUM_UNS|IDPOPT_NUM_CHAR)
- CTR_CFGOPT(short, IDPOPT_NUM_SHORT)
- CTR_CFGOPT(ushort, IDPOPT_NUM_SHORT|IDPOPT_NUM_UNS)
-#undef CTR_CFGOPT
-
-#define CFGOPT_R(nm, cfgt, cfgm, min, max) \
- cfgopt_t(nm, &cfgt::cfgm, qoffsetof(cfgt, cfgm), min, max)
-
-#define CFGOPT_INNER_R(nm, cfgt, cfgm, mt, mf, min, max) \
- cfgopt_t(nm, &mt::mf, qoffsetof(cfgt, cfgm) + qoffsetof(mt, mf), min, max)
-
-
- // IDPOPT_BIT
-#define CTR_CFGOPT(ctrtype, ctrflags) \
- template \
- constexpr cfgopt_t(const char *_n, ctrtype T:: *, size_t _mbroff, ctrtype _flags) \
- : name(_n), \
- mbroff(_mbroff), \
- flags(IDPOPT_MBROFF|IDPOPT_BIT|ctrflags), \
- bit_flags(_flags) \
- {}
- CTR_CFGOPT(bool, IDPOPT_BIT_BOOL);
- CTR_CFGOPT(uchar, IDPOPT_BIT_UCHAR);
- CTR_CFGOPT(ushort, IDPOPT_BIT_USHORT);
- CTR_CFGOPT(uint32, 0);
-#undef CTR_CFGOPT
-#define CFGOPT_B(nm, cfgt, cfgm, _flags) \
- cfgopt_t(nm, &cfgt::cfgm, qoffsetof(cfgt, cfgm), _flags)
-
-#define CFGOPT_INNER_B(nm, cfgt, cfgm, mt, mf, _flags) \
- cfgopt_t(nm, &mt::mf, qoffsetof(cfgt, cfgm) + qoffsetof(mt, mf), _flags)
-
-
- // IDPOPT_I64
- template
- constexpr cfgopt_t(const char *_n, int64 T:: *, size_t _mbroff)
- : name(_n),
- mbroff(_mbroff),
- flags(IDPOPT_MBROFF|IDPOPT_I64),
- buf_size(0)
- {}
- template
- constexpr cfgopt_t(const char *_n, uint64 T:: *, size_t _mbroff)
- : name(_n),
- mbroff(_mbroff),
- flags(IDPOPT_MBROFF|IDPOPT_I64|IDPOPT_NUM_UNS),
- buf_size(0)
- {}
-
- // IDPOPT_I64 + ranges
- template
- constexpr cfgopt_t(const char *_n, int64 T:: *, size_t _mbroff, int64 _min, int64 _max)
- : name(_n),
- mbroff(_mbroff),
- flags(IDPOPT_MBROFF|IDPOPT_I64|IDPOPT_I64_RANGES),
- num_range(_min, _max)
- {}
- template
- constexpr cfgopt_t(const char *_n, uint64 T:: *, size_t _mbroff, uint64 _min, uint64 _max)
- : name(_n),
- mbroff(_mbroff),
- flags(IDPOPT_MBROFF|IDPOPT_I64|IDPOPT_I64_UNS|IDPOPT_I64_RANGES),
- num_range(int64(_min), int64(_max))
- {}
-
- // IDPOPT_CST + params
- constexpr cfgopt_t(const char *_n, cfgopt_handler3_t *_p, int64 _p1=0, int64 _p2=0)
- : name(_n), hnd3(_p), flags(IDPOPT_MBROFF|IDPOPT_CST), params(_p1, _p2) {}
-
- int type() const { return flags & 0xf; }
- int qualifier() const { return flags & 0xf000000; }
-
- const char *apply(int vtype, const void *vdata, void *obj=nullptr) const
- {
- return cfgopt_t__apply2(this, vtype, vdata, obj);
- }
-};
-
-/// Parse the input, and apply options.
-///
-/// \param input input file name, or string
-/// \param is_file is input a string, or a file name
-/// \param opts options destcriptions
-/// \param nopts the number of entries present in the 'opts' array
-/// \param defhdlr a handler to be called, if a directive couldn't be found in 'opts'
-/// \param defines a list of preprocessor identifiers to define (so it is
-/// possible to use #ifdef checks in the file.)
-/// NB: the actual identifier defined by the parser will be
-/// surrounded with double underscores (e.g., passing 'FOO'
-/// will result in '__FOO__' being defined)
-/// Additionally, the parser will also define a similar macro
-/// with the current processor name (e.g., __ARM__)
-/// \param ndefines the number of defines in the list
-/// \param obj see cfgopt_t constructor based on the offset of a structure member
-/// \return true if parsing finished without errors, false if there was a
-/// syntax error, callback returned an error, or no file was found
-/// at all.
-
-idaman bool ida_export read_config(
- const char *input,
- bool is_file,
- const cfgopt_t opts[],
- size_t nopts,
- cfgopt_handler_t *defhdlr = NULL,
- const char *const *defines = NULL,
- size_t ndefines = 0);
-
-idaman bool ida_export read_config2(
- const char *input,
- bool is_file,
- const cfgopt_t opts[],
- size_t nopts,
- cfgopt_handler_t *defhdlr = nullptr,
- const char *const *defines = nullptr,
- size_t ndefines = 0,
- void *obj = nullptr);
-
-inline bool read_config_file2(
- const char *filename,
- const cfgopt_t opts[],
- size_t nopts,
- cfgopt_handler_t *defhdlr = nullptr,
- const char *const *defines = nullptr,
- size_t ndefines = 0,
- void *obj = nullptr)
-{
- return read_config2(filename, true, opts, nopts, defhdlr, defines, ndefines, obj);
-}
-
-/// Search for all IDA system files with the given name.
-/// This function will search, in that order, for the following files:
-/// -# %IDADIR%/cfg/
-/// -# for each directory 'ONEDIR' in %IDAUSR%: %ONEDIR%/cfg/
-///
-/// For each directive in each of those files, the same processing as
-/// that of read_config will be performed.
-
-inline bool read_config_file(
- const char *filename,
- const cfgopt_t opts[],
- size_t nopts,
- cfgopt_handler_t *defhdlr = NULL,
- const char *const *defines = NULL,
- size_t ndefines = 0)
-{
- return read_config(filename, true, opts, nopts, defhdlr, defines, ndefines);
-}
-
-
-/// For each directive in 'string', the same processing as that of
-/// read_config will be performed.
-inline bool read_config_string(
- const char *string,
- const cfgopt_t opts[],
- size_t nopts,
- cfgopt_handler_t *defhdlr = NULL,
- const char *const *defines = NULL,
- size_t ndefines = 0)
-{
- return read_config(string, false, opts, nopts, defhdlr, defines, ndefines);
-}
-
-
-/// Process one or more config directive(s).
-/// \param directive the directives to process
-/// \param priority priority \ref IDPOPT_RET
-/// In the case of errors this function displays a message and exits.
-
-idaman void ida_export process_config_directive(
- const char *directive,
- int priority=IDPOPT_PRI_HIGH);
-
-
-/// Register array of config options.
-/// This function can be used by a plugin to register the config options.
-/// After registering an option, it becomes usable by the
-/// process_config_directive() function.
-/// \param opts array of config options
-/// \param nopts number of options to install. 0 means uninstall
-/// \param cb callback that will be invoked upon changing a config option
-/// \param obj see cfgopt_t constructor based on the offset of a structure member
-/// \return success
-
-typedef void idaapi config_changed_cb_t(const cfgopt_t &opt, int vtype, const void *vdata);
-
-idaman bool ida_export register_cfgopts(
- const cfgopt_t opts[],
- size_t nopts,
- config_changed_cb_t cb=nullptr,
- void *obj=nullptr);
-
-
-/// Get one of config parameters defined by CC_PARMS in ida.cfg.
-/// All parameters for all compilers are stored in local map during last read
-/// of ida.cfg - this function just returns previously stored parameter value for
-/// given compiler (NULL if no such parameter)
-idaman const char *ida_export cfg_get_cc_parm(comp_t compid, const char *name);
-
-
-/// Get header path config parameter from ida.cfg.
-/// Also see cfg_get_cc_parm()
-
-inline const char *cfg_get_cc_header_path(comp_t compid)
-{
- return cfg_get_cc_parm(compid, "HEADER_PATH");
-}
-
-
-/// Get predefined macros config parameter from ida.cfg.
-/// Also see cfg_get_cc_parm()
-
-inline const char *cfg_get_cc_predefined_macros(comp_t compid)
-{
- return cfg_get_cc_parm(compid, "PREDEFINED_MACROS");
-}
-
-#endif // _CONFIG_HPP
diff --git a/idasdk75/include/dbg.hpp b/idasdk75/include/dbg.hpp
deleted file mode 100644
index b6c450b..0000000
--- a/idasdk75/include/dbg.hpp
+++ /dev/null
@@ -1,2624 +0,0 @@
-/*
- * Interactive disassembler (IDA).
- * Copyright (c) 1990-2020 Hex-Rays
- * ALL RIGHTS RESERVED.
- *
- */
-
-#ifndef DBG_HPP
-#define DBG_HPP
-
-#include
-#include
-#include // for callui() and ui_notification_t
-
-/*! \file dbg.hpp
-
- \brief Contains functions to control the debugging of a process.
-
- See \ref dbg_funcs for a complete explanation of these functions.
-
- These functions are inlined for the kernel.
- They are not inlined for the user-interfaces.
-*/
-
-//--------------------------------------------------------------------
-// D E B U G G E R I N F O R M A T I O N
-//--------------------------------------------------------------------
-
-/// This structure contains information about the current debugger.
-/// (NULL if no debugger was loaded) - see idd.hpp for details about this structure.
-///
-/// All functions defined in this structure should only be called by the kernel !!!
-idaman debugger_t ida_export_data *dbg;
-
-//--------------------------------------------------------------------
-// D E B U G G E R C A L L B A C K S
-//--------------------------------------------------------------------
-/// Debugger notification codes.
-///
-/// A plugin can receive notifications of all major events in the
-/// debugger, by calling the hook_to_notification_point() function
-/// with ::HT_DBG as ::hook_type_t (see loader.hpp for details about
-/// installing and removing such callbacks).
-///
-/// IDA generates two major different types of debugger notifications:
-///
-/// - debugger event notification:
-/// this notification monitors usual events occurring during the
-/// execution of a process.
-/// These event notifications are always generated for any process.
-/// Some of these event notifications are interpreted by IDA
-/// (high-level events), while others are directly generated by the
-/// debugger module (low-level events).
-/// Low-level events always return a ::debug_event_t structure as an argument.
-///
-/// - debugger asynchronous function result notification:
-/// such a notification occurs only when a debugger properly terminated
-/// the execution of an asynchronous function (see \ref dbg_funcs)
-///
-/// How to control the process execution (after the execution of all notification
-/// handlers) from the notification handler:
-///
-/// - to force the process to STOP:
-/// call suspend_process().
-/// In this case, the current debugger command will be aborted and no new
-/// request will be started.
-///
-/// - to force the process to CONTINUE:
-/// call continue_process().
-/// In this case, no new request will be started.
-///
-/// - to start new debugger command(s):
-/// call as many request_COMMAND() as needed, then call run_requests().
-/// In this case, the current debugger command (if any) will be aborted.
-/// (see \ref dbg_funcs in this file for more details about requests)
-///
-/// - else, the process execution will depend on the current debugger options or
-/// object settings. Some examples:
-/// - a new loaded library will stop the process depending on the associated debugger option.
-/// - a breakpoint will stop the process depending on its properties.
-///
-/// A plugin must not call asynchronous debugger functions from the notification handler!
-/// Use the REQUEST QUEUE mechanism instead (request_...()).
-///
-/// If the plugin wants to access the process memory from a notification point,
-/// it should call invalidate_dbgmem_config() and/or invalidate_dbgmem_contents()
-/// functions. The invalidate_dbgmem_config() is really slow, so do not call it
-/// unless the process memory config have changed after the last time the process
-/// was suspended. The invalidate_dbgmem_contents() is fast and flushes the
-/// memory cache in the ida kernel. Without it, functions like get_byte() would
-/// return stale values!
-enum dbg_notification_t
-{
- dbg_null = 0,
-
- // debugger low-level event notifications (see IDD.HPP for details).
-
- dbg_process_start, ///< \param event (const ::debug_event_t *)
- ///< \note This event notification is also an asynchronous
- ///< function result notification for start_process() !
-
- dbg_process_exit, ///< \param event (const ::debug_event_t *)
- ///< \note This event notification is also an asynchronous
- ///< function result notification for start_process() !
-
- dbg_process_attach, ///< \param event (const ::debug_event_t *)
- ///< \note This event notification is also an asynchronous
- ///< function result notification for start_process() !
-
- dbg_process_detach, ///< \param event (const ::debug_event_t *)
- ///< \note This event notification is also an asynchronous
- ///< function result notification for start_process() !
-
- dbg_thread_start, ///< \param event (const ::debug_event_t *)
-
- dbg_thread_exit, ///< \param event (const ::debug_event_t *)
-
- dbg_library_load, ///< \param event (const ::debug_event_t *)
-
- dbg_library_unload, ///< \param event (const ::debug_event_t *)
-
- dbg_information, ///< \param event (const ::debug_event_t *)
-
- dbg_exception, ///< \param event (const ::debug_event_t *)
- ///< \param[out] warn (int *) filled with:
- ///< - -1: display an exception warning dialog
- ///< if the process is suspended.
- ///< - 0: never display an exception warning dialog.
- ///< - 1: always display an exception warning dialog.
-
- // debugger high-level event notifications
-
- dbg_suspend_process, ///< The process is now suspended.
- ///< \param event (const ::debug_event_t *)
- ///< \note This event notification is also an asynchronous
- ///< function result notification for suspend_process() !
-
- dbg_bpt, ///< A user defined breakpoint was reached.
- ///< \param tid (::thid_t)
- ///< \param bptea (::ea_t)
- ///< \param[out] warn (int *) filled with:
- ///< - -1: display an exception warning dialog
- ///< if the process is suspended.
- ///< - 0: never display an exception warning dialog.
- ///< - 1: always display an exception warning dialog.
-
- dbg_trace, ///< A step occurred (one instruction was executed). This event
- ///< notification is only generated if step tracing is enabled.
- ///< \param tid (::thid_t) thread ID
- ///< \param ip (::ea_t) current instruction pointer.
- ///< usually points after the executed instruction
- ///< \retval 1 do not log this trace event
- ///< \retval 0 log it
-
- dbg_request_error, ///< An error occurred during the processing of a request.
- ///< \param failed_command (::ui_notification_t)
- ///< \param failed_dbg_notification (::dbg_notification_t)
-
- // debugger asynchronous function result notifications
- // Please note some low-level event notifications also act as asynchronous
- // function result notifications.
-
- dbg_step_into, ///< \param event (const ::debug_event_t *)
-
- dbg_step_over, ///< \param event (const ::debug_event_t *)
-
- dbg_run_to, ///< \param event (const ::debug_event_t *)
-
- dbg_step_until_ret, ///< \param event (const ::debug_event_t *)
-
- dbg_bpt_changed, ///< Breakpoint has been changed.
- ///< \param bptev_code (int) \ref BPTEV_
- ///< \param bpt (::bpt_t *)
-
- dbg_started_loading_bpts, ///< Started loading breakpoint info from idb
- dbg_finished_loading_bpts, ///< Finished loading breakpoint info from idb
-
- dbg_last, ///< The last debugger notification code
-};
-
-/// \defgroup BPTEV_ Breakpoint modification events
-/// Passed as 'bptev_code' parameter to ::dbg_bpt_changed callback
-//@{
-#define BPTEV_ADDED 0 ///< Breakpoint has been added
-#define BPTEV_REMOVED 1 ///< Breakpoint has been removed
-#define BPTEV_CHANGED 2 ///< Breakpoint has been modified
-//@}
-
-#ifndef __UI__
-
-//--------------------------------------------------------------------
-// D E B U G G E R F U N C T I O N S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs Debugger functions
-///
-/// Control the debugging of a process.
-///
-/// Debugger functions complete either SYNCHRONOUSLY or ASYNCHRONOUSLY:
-///
-/// - SYNCHRONOUS FUNCTIONS execute the entire action before the function returns.
-///
-/// - ASYNCHRONOUS FUNCTIONS return before the action has executed in its
-/// entirety. They simply start the action, but the result of the action will
-/// only be available later. For example, run_to() can execute a lot of
-/// instructions before terminating.
-/// Such functions provide a notification code to indicate the end of their
-/// execution (see the 'Notification' keyword in the function documentation).
-/// Install a callback using hook_to_notification_point() to be notified
-/// when the action is terminated.
-///
-/// DEBUGGER COMMANDS are functions who influence the execution of the debugged
-/// process. They are available in 2 forms:
-///
-/// - COMMAND(): (e.g. suspend_process())
-/// In this mode, the command will be directly executed. However, it is forbidden
-/// to use asynchronous commands in this mode from a debugger notification handler
-/// (see ::dbg_notification_t).
-///
-/// - request_COMMAND(): (e.g. request_suspend_process())
-/// In this mode, a REQUEST to run the command will be memorized at the end of
-/// the REQUEST QUEUE (see below). This is mandatory to use this mode for asynchronous
-/// commands from a debugger notification handler (see ::dbg_notification_t).
-///
-///
-/// The REQUEST QUEUE contains a list of planned debugger commands.
-/// These commands will be started only in the following cases:
-///
-/// - the previous command terminated, and no call to suspend_process()
-/// or continue_process() occurred in the asynchronous function result
-/// notification handler (if any).
-///
-/// - run_requests() was called.
-/// Please note that when called from a debugger notification handler the
-/// queued requests will only be started after the execution of all
-/// notification handlers.
-///
-/// A request which fails to start (by returning 0) will generate a
-/// ::dbg_request_error notification.
-//@{
-
-/// Execute requests until all requests are processed or an asynchronous
-/// function is called.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return false if not all requests could be processed
-/// (indicates an asynchronous function was started)
-/// \note If called from a notification handler, the execution of requests will
-/// be postponed to the end of the execution of all notification handlers.
-
-inline bool idaapi run_requests(void) { return callui(ui_dbg_run_requests).cnd; }
-
-
-/// Get the current running request.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return ui_null if no running request
-
-inline ui_notification_t idaapi get_running_request(void) { return (ui_notification_t)callui(ui_dbg_get_running_request).i; }
-
-
-/// Is a request currently running?
-
-inline bool is_request_running(void) { return get_running_request() != ui_null; }
-
-
-/// Get the notification associated (if any) with the current running request.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return dbg_null if no running request
-
-inline dbg_notification_t idaapi get_running_notification(void) { return (dbg_notification_t)callui(ui_dbg_get_running_notification).i; }
-
-
-/// Clear the queue of waiting requests.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \note If a request is currently running, this one isn't stopped.
-
-inline void idaapi clear_requests_queue(void) { callui(ui_dbg_clear_requests_queue); }
-//@} dbg_funcs
-
-//--------------------------------------------------------------------
-// P R O C E S S C O M M A N D S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_cmds Process commands
-/// \ingroup dbg_funcs
-///
-/// Use these functions to manipulate the debugged process.
-//@{
-
-/// Return the state of the currently debugged process.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return one of \ref DSTATE_
-
-inline int idaapi get_process_state(void) { return callui(ui_dbg_get_process_state).i; }
-
-#endif // __UI__
-
-/// \defgroup DSTATE_ Debugged process states
-/// See get_process_state(), set_process_state(), invalidate_dbg_state()
-//@{
-#define DSTATE_SUSP -1 ///< process is suspended and will not continue
-#define DSTATE_NOTASK 0 ///< no process is currently debugged
-#define DSTATE_RUN 1 ///< process is running
-//@}
-
-/// \defgroup DBGINV_ Debugged process invalidation options
-/// See set_process_state() and invalidate_dbg_state()
-//@{
-#define DBGINV_MEMORY 0x0001 ///< invalidate cached memory contents
-#define DBGINV_MEMCFG 0x0002 ///< invalidate cached process segmentation
-#define DBGINV_REGS 0x0004 ///< invalidate cached register values
-#define DBGINV_ALL 0x7FFF ///< invalidate everything
-#define DBGINV_REDRAW 0x8000 ///< refresh the screen
-#define DBGINV_NONE 0 ///< invalidate nothing
-//@}
-
-#ifndef __UI__
-
-/// Set new state for the debugged process.
-/// Notifies the IDA kernel about the change of the debugged process state.
-/// For example, a debugger module could call this function when it knows
-/// that the process is suspended for a short period of time.
-/// Some IDA API calls can be made only when the process is suspended.
-/// The process state is usually restored before returning control to the caller.
-/// You must know that it is ok to change the process state, doing it at arbitrary
-/// moments may crash the application or IDA.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param newstate new process state (one of \ref DSTATE_)
-/// if #DSTATE_NOTASK is passed then the state is not changed
-/// \param p_thid ptr to new thread id. may be NULL or pointer to #NO_THREAD.
-/// the pointed variable will contain the old thread id upon return
-/// \param dbginv \ref DBGINV_
-/// \return old debugger state (one of \ref DSTATE_)
-
-inline int idaapi set_process_state(int newstate, thid_t *p_thid, int dbginv) { return callui(ui_dbg_set_process_state, newstate, p_thid, dbginv).i; }
-
-
-/// Invalidate cached debugger information.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param dbginv \ref DBGINV_
-/// \return current debugger state (one of \ref DSTATE_)
-
-inline int idaapi invalidate_dbg_state(int dbginv)
-{
- return set_process_state(DSTATE_NOTASK, NULL, dbginv);
-}
-
-
-/// Start a process in the debugger.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_process_start}
-/// \note You can also use the run_to() function to easily start the execution
-/// of a process until a given address is reached.
-/// \note For all parameters, a NULL value indicates the debugger will take
-/// the value from the defined Process Options.
-/// \param path path to the executable to start
-/// \param args arguments to pass to process
-/// \param sdir starting directory for the process
-/// \retval -1 impossible to create the process
-/// \retval 0 the starting of the process was cancelled by the user
-/// \retval 1 the process was properly started
-
-inline int idaapi start_process(
- const char *path = NULL,
- const char *args = NULL,
- const char *sdir = NULL)
-{
- return callui(ui_dbg_start_process, path, args, sdir).i;
-}
-
-
-/// Post a start_process() request
-
-inline int idaapi request_start_process(
- const char *path = NULL,
- const char *args = NULL,
- const char *sdir = NULL)
-{
- return callui(ui_dbg_request_start_process, path, args, sdir).i;
-}
-
-
-/// Suspend the process in the debugger.
-/// \sq{
-/// Type,
-/// - Synchronous function (if in a notification handler)
-/// - Asynchronous function (everywhere else)
-/// - available as Request,
-/// Notification,
-/// - none (if in a notification handler)
-/// - ::dbg_suspend_process (everywhere else)
-/// }
-/// \note The suspend_process() function can be called from a notification
-/// handler to force the stopping of the process.
-/// In this case, no notification will be generated.
-/// When you suspend a process, the running command is always aborted.
-
-inline bool idaapi suspend_process(void) { return callui(ui_dbg_suspend_process).cnd; }
-
-/// Post a suspend_process() request
-
-inline bool idaapi request_suspend_process(void) { return callui(ui_dbg_request_suspend_process).cnd; }
-
-
-/// Continue the execution of the process in the debugger.
-/// \sq{Type, Synchronous function - available as Request,
-/// Notification, none (synchronous function)}
-/// \note The continue_process() function can be called from a notification
-/// handler to force the continuation of the process. In this case
-/// the request queue will not be examined, IDA will simply resume
-/// execution. Usually it makes sense to call request_continue_process()
-/// followed by run_requests(), so that IDA will first start a queued
-/// request (if any) and then resume the application.
-
-inline bool idaapi continue_process(void) { return callui(ui_dbg_continue_process).cnd; }
-
-/// Post a continue_process() request.
-/// \note This requires an explicit call to run_requests()
-
-inline bool idaapi request_continue_process(void) { return callui(ui_dbg_request_continue_process).cnd; }
-
-
-/// Terminate the debugging of the current process.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_process_exit}
-
-inline bool idaapi exit_process(void) { return callui(ui_dbg_exit_process).cnd; }
-
-/// Post an exit_process() request.
-
-inline bool idaapi request_exit_process(void) { return callui(ui_dbg_request_exit_process).cnd; }
-
-
-/// Take a snapshot of running processes and return their description.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param[out] array with information about each running process
-/// \return number of processes or -1 on error
-
-inline ssize_t idaapi get_processes(procinfo_vec_t *proclist) { return callui(ui_dbg_get_processes, proclist).ssize; }
-
-
-/// Attach the debugger to a running process.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_process_attach}
-/// \note This function shouldn't be called as a request if #NO_PROCESS is used.
-/// \param pid PID of the process to attach to. If #NO_PROCESS, a dialog box
-/// will interactively ask the user for the process to attach to.
-/// \retval -4 debugger was not inited
-/// \retval -3 the attaching is not supported
-/// \retval -2 impossible to find a compatible process
-/// \retval -1 impossible to attach to the given process (process died, privilege
-/// needed, not supported by the debugger plugin, ...)
-/// \retval 0 the user cancelled the attaching to the process
-/// \retval 1 the debugger properly attached to the process
-
-inline int idaapi attach_process(pid_t pid=NO_PROCESS, int event_id=-1) { return callui(ui_dbg_attach_process, pid, event_id).i; }
-
-/// Post an attach_process() request
-
-inline int idaapi request_attach_process(pid_t pid, int event_id) { return callui(ui_dbg_request_attach_process, pid, event_id).i; }
-
-
-/// Detach the debugger from the debugged process.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_process_detach}
-
-inline bool idaapi detach_process(void) { return callui(ui_dbg_detach_process).cnd; }
-
-/// Post a detach_process() request
-
-inline bool idaapi request_detach_process(void) { return callui(ui_dbg_request_detach_process).cnd; }
-
-
-/// Is the debugger busy?.
-/// Some debuggers do not accept any commands while the debugged application
-/// is running. For such a debugger, it is unsafe to do anything with the
-/// database (even simple queries like get_byte may lead to undesired consequences).
-/// Returns: true if the debugged application is running under such a debugger
-
-inline bool idaapi is_debugger_busy(void) { return callui(ui_dbg_is_busy).cnd; }
-
-//@} dbg_funcs_cmds
-
-
-//--------------------------------------------------------------------
-// T H R E A D S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_threads Threads
-/// \ingroup dbg_funcs
-///
-/// Inspect/Manipulate threads of debugged process.
-//@{
-
-/// Get number of threads.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline int idaapi get_thread_qty(void) { return callui(ui_dbg_get_thread_qty).i; }
-
-
-/// Get the ID of a thread.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of thread, is in range 0..get_thread_qty()-1
-/// \return #NO_THREAD if the thread doesn't exist.
-
-inline thid_t idaapi getn_thread(int n) { return (thid_t)callui(ui_dbg_getn_thread, n).i; }
-
-
-/// Get current thread ID.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline thid_t idaapi get_current_thread(void) { return callui(ui_dbg_get_current_thread).i; }
-
-
-/// Get the NAME of a thread
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of thread, is in range 0..get_thread_qty()-1
-/// or -1 for the current thread
-/// \return thread name or NULL if the thread doesn't exist.
-
-inline const char *idaapi getn_thread_name(int n) { return callui(ui_dbg_getn_thread_name, n).cptr; }
-
-
-/// Select the given thread as the current debugged thread.
-/// All thread related execution functions will work on this thread.
-/// The process must be suspended to select a new thread.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param tid ID of the thread to select
-/// \return false if the thread doesn't exist.
-
-inline bool idaapi select_thread(thid_t tid) { return callui(ui_dbg_select_thread, tid).cnd; }
-
-/// Post a select_thread() request
-
-inline bool idaapi request_select_thread(thid_t tid) { return callui(ui_dbg_request_select_thread, tid).cnd; }
-
-
-/// Suspend thread.
-/// Suspending a thread may deadlock the whole application if the suspended
-/// was owning some synchronization objects.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param tid thread id
-/// \retval -1 network error
-/// \retval 0 failed
-/// \retval 1 ok
-
-inline int idaapi suspend_thread(thid_t tid) { return callui(ui_dbg_suspend_thread, tid).i; }
-
-/// Post a suspend_thread() request
-
-inline int idaapi request_suspend_thread(thid_t tid) { return callui(ui_dbg_request_suspend_thread, tid).i; }
-
-
-/// Resume thread.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param tid thread id
-/// \retval -1 network error
-/// \retval 0 failed
-/// \retval 1 ok
-
-inline int idaapi resume_thread(thid_t tid) { return callui(ui_dbg_resume_thread, tid).i; }
-
-/// Post a resume_thread() request
-
-inline int idaapi request_resume_thread(thid_t tid) { return callui(ui_dbg_request_resume_thread, tid).i; }
-
-//@} dbg_funcs_threads
-
-
-//--------------------------------------------------------------------
-// M O D U L E S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_modules Modules
-/// \ingroup dbg_funcs
-///
-/// Functions to enumerate modules loaded into the process.
-///
-/// \param modinfo structure to receive the answer
-/// \return false if there are no (more) modules
-///
-/// Typical loop to enumerate modules would look like:
-/// \code
-/// modinfo_t minfo;
-/// for ( bool ok=get_first_module(&minfo); ok; ok=get_next_module(&minfo) )
-/// ...
-/// \endcode
-//@{
-inline bool idaapi get_first_module(modinfo_t *modinfo) ///< See \ref dbg_funcs_modules
-{ return callui(ui_dbg_get_first_module, modinfo).cnd; }
-
-inline bool idaapi get_next_module(modinfo_t *modinfo) ///< See \ref dbg_funcs_modules
-{ return callui(ui_dbg_get_next_module, modinfo).cnd; }
-
-//@}
-
-
-//--------------------------------------------------------------------
-// E X E C U T I O N F L O W C O N T R O L C O M M A N D S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_flow Execution flow control
-/// \ingroup dbg_funcs
-///
-/// Use these functions to run instructions in the debugged process.
-//@{
-
-/// Execute one instruction in the current thread.
-/// Other threads are kept suspended.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_step_into}
-
-inline bool idaapi step_into(void) { return callui(ui_dbg_step_into).cnd; }
-
-/// Post a step_into() request
-
-inline bool idaapi request_step_into(void) { return callui(ui_dbg_request_step_into).cnd; }
-
-
-/// Execute one instruction in the current thread,
-/// but without entering into functions.
-/// Others threads keep suspended.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_step_over}
-
-inline bool idaapi step_over(void) { return callui(ui_dbg_step_over).cnd; }
-
-/// Post a step_over() request
-
-inline bool idaapi request_step_over(void) { return callui(ui_dbg_request_step_over).cnd; }
-
-
-/// Execute the process until the given address is reached.
-/// If no process is active, a new process is started.
-/// Technically, the debugger sets up a temporary breakpoint at
-/// the given address, and continues (or starts) the execution of
-/// the whole process.
-/// So, all threads continue their execution!
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_run_to}
-/// \param ea target address
-/// \param pid not used yet. please do not specify this parameter.
-/// \param tid not used yet. please do not specify this parameter.
-
-inline bool idaapi run_to(ea_t ea, pid_t pid = NO_PROCESS, thid_t tid = NO_THREAD) { return callui(ui_dbg_run_to, ea, pid, tid).cnd; }
-
-/// Post a run_to() request
-
-inline bool idaapi request_run_to(ea_t ea, pid_t pid = NO_PROCESS, thid_t tid = NO_THREAD) { return callui(ui_dbg_request_run_to, ea, pid, tid).cnd; }
-
-/// Execute instructions in the current thread until
-/// a function return instruction is executed (aka "step out").
-/// Other threads are kept suspended.
-/// \sq{Type, Asynchronous function - available as Request,
-/// Notification, ::dbg_step_until_ret}
-
-inline bool idaapi step_until_ret(void) { return callui(ui_dbg_step_until_ret).cnd; }
-
-/// Post a step_until_ret() request
-
-inline bool idaapi request_step_until_ret(void) { return callui(ui_dbg_request_step_until_ret).cnd; }
-
-
-/// How to resume the application.
-/// Set resume mode but do not resume process.
-
-inline bool idaapi set_resume_mode(thid_t tid, resume_mode_t mode) { return callui(ui_dbg_set_resume_mode, tid, mode).cnd; }
-
-/// Post a set_resume_mode() request
-
-inline bool idaapi request_set_resume_mode(thid_t tid, resume_mode_t mode) { return callui(ui_dbg_request_set_resume_mode, tid, mode).cnd; }
-
-//@} dbg_funcs_flow
-
-
-//--------------------------------------------------------------------
-// R E G I S T E R S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_regs Registers
-/// \ingroup dbg_funcs
-///
-/// Inspect/Manipulate registers for debugged process.
-/// The debugger structure defines a set of hardware registers in \dbg{registers}
-/// IDA also recognizes register names for each defined bit in bit registers.
-/// You can use all these names to set or get a register value.
-///
-/// For example, with the x86 Userland Win32 debugger you can use
-/// register names like:
-/// - "EAX", ... "EBP", "ESP", "EFL": for classical integer registers
-/// - "CS", "DS", ... : for segment registers
-/// - "ST0", "ST1", ... : for FPU registers
-/// - "CF", "PF", "AF", "ZF", ... : for special bit values
-//@{
-
-/// Get register information
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi get_dbg_reg_info(const char *regname, register_info_t *ri) { return callui(ui_dbg_get_reg_info, regname, ri).cnd; }
-
-/// Read a register value from the current thread.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi get_reg_val(const char *regname, regval_t *regval) { return callui(ui_dbg_get_reg_val, regname, regval).cnd; }
-
-/// Get register value as an unsigned 64-bit int
-
-inline bool idaapi get_reg_val(const char *regname, uint64 *ival) { return callui(ui_dbg_get_reg_val_i, regname, ival).cnd; }
-
-
-/// Get value of the SP register for the current thread.
-/// Requires a suspended debugger.
-inline bool idaapi get_sp_val(ea_t *out) { return callui(ui_dbg_get_sp_val, out).cnd; }
-
-/// Get value of the IP (program counter) register for the current thread.
-/// Requires a suspended debugger.
-inline bool idaapi get_ip_val(ea_t *out) { return callui(ui_dbg_get_ip_val, out).cnd; }
-
-/// Write a register value to the current thread.
-/// \sq{Type, Synchronous function - available as Request,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi set_reg_val(const char *regname, const regval_t *regval) { return callui(ui_dbg_set_reg_val, regname, regval).cnd; }
-
-/// Write a register value to the current thread
-
-inline bool idaapi set_reg_val(const char *regname, uint64 ival) { return callui(ui_dbg_set_reg_val_i, regname, ival).cnd; }
-
-/// Post a set_reg_val() request
-
-inline bool idaapi request_set_reg_val(const char *regname, const regval_t *regval) { return callui(ui_dbg_request_set_reg_val, regname, regval).cnd; }
-
-
-/// Does a register contain an integer value?
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi is_reg_integer(const char *regname) { return callui(ui_dbg_get_reg_value_type, regname).i-2 == RVT_INT; }
-
-
-/// Does a register contain a floating point value?
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi is_reg_float(const char *regname) { return callui(ui_dbg_get_reg_value_type, regname).i-2 == RVT_FLOAT; }
-
-
-/// Does a register contain a value of a custom data type?
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi is_reg_custom(const char *regname) { return callui(ui_dbg_get_reg_value_type, regname).i >= 2; }
-
-//@} dbg_funcs_regs
-
-#endif // __UI__
-
-//--------------------------------------------------------------------
-// B R E A K P O I N T S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_bpts Breakpoints
-/// \ingroup dbg_funcs
-///
-/// Work with debugger breakpoints.
-//@{
-
-
-
-/// Helper function for ::bpt_location_t
-int idaapi set_bptloc_string(const char *s);
-const char *idaapi get_bptloc_string(int i); ///< \copydoc set_bptloc_string()
-
-
-/// Breakpoint location types
-enum bpt_loctype_t
-{
- BPLT_ABS, ///< absolute address: ea
- BPLT_REL, ///< relative address: module_path, offset
- BPLT_SYM, ///< symbolic: symbol_name, offset
- BPLT_SRC, ///< source level: filename, lineno
-};
-
-/// Describes a breakpoint location
-struct bpt_location_t
-{
-//private:
- ea_t info;
- int index;
- bpt_loctype_t loctype;
-//public:
- bpt_loctype_t type(void) const { return loctype; } ///< Get bpt type
- bool is_empty_path(void) const { return index == 0; } ///< No path/filename specified? (::BPLT_REL, ::BPLT_SRC)
- const char *path(void) const { return get_bptloc_string(index); } ///< Get path/filename (::BPLT_REL, ::BPLT_SRC)
- const char *symbol(void) const { return get_bptloc_string(index); } ///< Get symbol name (::BPLT_SYM)
- int lineno(void) const { return int(info); } ///< Get line number (::BPLT_SRC)
- uval_t offset(void) const { return (uval_t)info; } ///< Get offset (::BPLT_REL, ::BPLT_SYM)
- ea_t ea(void) const { return info; } ///< Get address (::BPLT_ABS)
-
- bpt_location_t(void) : info(BADADDR), index(0), loctype(BPLT_ABS) {} ///< Constructor (default type is ::BPLT_ABS)
-
- /// Specify an absolute address location
- void set_abs_bpt(ea_t a)
- {
- info = a;
- loctype = BPLT_ABS;
- }
-
- /// Specify a source level location
- void set_src_bpt(const char *fn, int _lineno)
- {
- index = set_bptloc_string(fn);
- info = _lineno;
- loctype = BPLT_SRC;
- }
-
- /// Specify a symbolic location
- void set_sym_bpt(const char *_symbol, uval_t _offset=0)
- {
- index = set_bptloc_string(_symbol);
- info = _offset;
- loctype = BPLT_SYM;
- }
-
- /// Specify a relative address location
- void set_rel_bpt(const char *mod, uval_t _offset)
- {
- index = set_bptloc_string(mod);
- info = _offset;
- loctype = BPLT_REL;
- }
-
- /// Lexically compare two breakpoint locations.
- /// Bpt locations are first compared based on type (i.e. ::BPLT_ABS < ::BPLT_REL).
- /// ::BPLT_ABS locations are compared based on their ea values.
- /// For all other location types, locations are first compared based on their
- /// string (path/filename/symbol), then their offset/lineno.
- int compare(const bpt_location_t &r) const { return callui(ui_dbg_compare_bpt_locs, this, &r).i; }
- bool operator==(const bpt_location_t &r) const { return compare(r) == 0; }
- bool operator!=(const bpt_location_t &r) const { return compare(r) != 0; }
- bool operator< (const bpt_location_t &r) const { return compare(r) < 0; }
- bool operator> (const bpt_location_t &r) const { return compare(r) > 0; }
- bool operator<=(const bpt_location_t &r) const { return compare(r) <= 0; }
- bool operator>=(const bpt_location_t &r) const { return compare(r) >= 0; }
-
- /// Internal function
- size_t print(qstring *buf) const;
-};
-
-/// Characteristics of a breakpoint
-struct bpt_t
-{
- size_t cb; ///< size of this structure
- qstring cndbody; ///< Condition as entered by the user
- bpt_location_t loc; ///< Location
- pid_t pid; ///< breakpoint process id
- thid_t tid; ///< breakpoint thread id
- ea_t ea; ///< Address, if known. For #BPLT_SRC, index into an internal data struct
- bpttype_t type; ///< Breakpoint type
- int pass_count; ///< Number of times the breakpoint is hit before stopping
- ///< (default is 0: stop always)
- uint32 flags; ///< \ref BPT_T
-/// \defgroup BPT_T Breakpoint property bits
-/// Used by bpt_t::flags
-//@{
-#define BPT_BRK 0x001 ///< suspend execution upon hit
-#define BPT_TRACE 0x002 ///< add trace information upon hit
-#define BPT_UPDMEM 0x004 ///< refresh the memory layout and contents before evaluating bpt condition
-#define BPT_ENABLED 0x008 ///< enabled?
-#define BPT_LOWCND 0x010 ///< condition is calculated at low level (on the server side)
-#define BPT_TRACEON 0x020 ///< enable tracing when the breakpoint is reached
-#define BPT_TRACE_INSN 0x040 ///< instruction tracing
-#define BPT_TRACE_FUNC 0x080 ///< function tracing
-#define BPT_TRACE_BBLK 0x100 ///< basic block tracing
-#define BPT_TRACE_TYPES (BPT_TRACE_INSN|BPT_TRACE_FUNC|BPT_TRACE_BBLK)
- ///< trace insns, functions, and basic blocks.
- ///< if any of #BPT_TRACE_TYPES bits are set but #BPT_TRACEON is clear,
- ///< then turn off tracing for the specified trace types
-#define BPT_ELANG_MASK 0xF0000000u
-#define BPT_ELANG_SHIFT 28 ///< index of the extlang (scripting language) of the condition
-//@}
-
- uint32 props; ///< \ref BKPT_
-/// \defgroup BKPT_ Internal breakpoint properties
-/// Used by bpt_t::props
-//@{
-#define BKPT_BADBPT 0x01 ///< failed to write the bpt to the process memory (at least one location)
-#define BKPT_LISTBPT 0x02 ///< include in bpt list (user-defined bpt)
-#define BKPT_TRACE 0x04 ///< trace bpt; should not be deleted when the process gets suspended
-#define BKPT_ACTIVE 0x08 ///< active?
-#define BKPT_PARTIAL 0x10 ///< partially active? (some locations were not written yet)
-#define BKPT_CNDREADY 0x20 ///< condition has been compiled
-#define BKPT_FAKEPEND 0x40 ///< fake pending bpt: it is inactive but another
- ///< bpt of the same type is active at the same address(es)
-#define BKPT_PAGE 0x80 ///< written to the process as a page bpt. is available
- ///< only after writing the bpt to the process.
-//@}
-
- int size; ///< Size of the breakpoint (0 for software breakpoints)
- int cndidx; ///< Internal number of the condition (<0-none)
-
- bpt_t(void) : cb(sizeof(*this)), pid(NO_PROCESS), tid(NO_THREAD), ea(BADADDR),
- type(BPT_SOFT), pass_count(0), flags(BPT_BRK|BPT_ENABLED),
- props(0), size(0), cndidx(-1) {}
-
- bool is_hwbpt(void) const { return type != BPT_SOFT; } ///< Is hardware breakpoint?
- bool enabled(void) const { return (flags & BPT_ENABLED) != 0; } ///< Is breakpoint enabled?
- bool is_low_level(void) const { return (flags & BPT_LOWCND) != 0; } ///< Is bpt condition calculated at low level?
- bool badbpt(void) const { return (props & BKPT_BADBPT) != 0; } ///< Failed to write bpt to process memory?
- bool listbpt(void) const { return (props & BKPT_LISTBPT) != 0; } ///< Include in the bpt list?
- bool is_compiled(void) const { return (props & BKPT_CNDREADY) != 0; } ///< Condition has been compiled?
- /// Written completely to process?
- bool is_active(void) const { return (props & (BKPT_PARTIAL|BKPT_ACTIVE)) == BKPT_ACTIVE; }
- /// Written partially to process?
- bool is_partially_active(void) const { return (props & BKPT_PARTIAL) != 0; }
- /// Not written to process at all?
- bool is_inactive(void) const { return (props & (BKPT_PARTIAL|BKPT_ACTIVE)) == 0; }
- /// Page breakpoint?
- bool is_page_bpt(void) const { return (props & BKPT_PAGE) != 0; }
-
- /// Get bpt size
- int get_size(void) const { return is_hwbpt() ? size : 1; }
- /// Set bpt location to an absolute address
- void set_abs_bpt(ea_t a) { loc.set_abs_bpt(a); ea = a; }
- /// Set bpt location to a source line
- void set_src_bpt(const char *fn, int lineno) { loc.set_src_bpt(fn, lineno); ea = BADADDR; }
- /// Set bpt location to a symbol
- void set_sym_bpt(const char *sym, uval_t o) { loc.set_sym_bpt(sym, o); ea = BADADDR; }
- /// Set bpt location to a relative address
- void set_rel_bpt(const char *mod, uval_t o) { loc.set_rel_bpt(mod, o); ea = BADADDR; }
-
- bool is_absbpt(void) const { return loc.type() == BPLT_ABS; } ///< Is absolute address breakpoint?
- bool is_relbpt(void) const { return loc.type() == BPLT_REL; } ///< Is relative address breakpoint?
- bool is_symbpt(void) const { return loc.type() == BPLT_SYM; } ///< Is symbolic breakpoint?
- bool is_srcbpt(void) const { return loc.type() == BPLT_SRC; } ///< Is source level breakpoint?
-
- /// Does breakpoint trace anything?
- bool is_tracemodebpt(void) const { return (flags & BPT_TRACE_TYPES) != 0; }
- /// Is this a tracing breakpoint, and is tracing enabled?
- bool is_traceonbpt(void) const { return is_tracemodebpt() && (flags & BPT_TRACEON) != 0; }
- /// Is this a tracing breakpoint, and is tracing disabled?
- bool is_traceoffbpt(void) const { return is_tracemodebpt() && (flags & BPT_TRACEON) == 0; }
- /// Configure tracing options
- bool set_trace_action(bool enable, int trace_types)
- {
- trace_types &= BPT_TRACE_TYPES;
- if ( trace_types == 0 )
- return false;
- flags |= trace_types;
- setflag(flags, BPT_TRACEON, enable);
- return true;
- }
-
- /// Get the scripting language name for the condition string
- const char *get_cnd_elang() const;
-
- /// Set the scripting language name for the condition string
- /// \return false if too many languages were used
- bool set_cnd_elang(const char *name);
-
- size_t get_cnd_elang_idx() const { return flags >> BPT_ELANG_SHIFT; }
-
- void set_cond(const char *cnd); ///< Internal function
- bool eval_cond(ea_t ea, bool *fire, const char *bpt_type); ///< Internal function
-};
-typedef qvector bpt_vec_t; ///< vector of breakpoints
-
-
-enum movbpt_code_t
-{
- MOVBPT_OK, // moved ok
- MOVBPT_NOT_FOUND, // source bpt not found
- MOVBPT_DEST_BUSY, // destination location is busy (we already have such a bpt)
- MOVBPT_BAD_TYPE, // BPLT_ABS is not supported
-};
-typedef qvector movbpt_codes_t;
-
-struct movbpt_info_t
-{
- bpt_location_t from;
- bpt_location_t to;
-};
-DECLARE_TYPE_AS_MOVABLE(movbpt_info_t);
-typedef qvector movbpt_infos_t;
-
-#ifndef __UI__
-
-
-/// Get number of breakpoints.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline int idaapi get_bpt_qty(void) { return callui(ui_dbg_get_bpt_qty).i; }
-
-
-/// Get the characteristics of a breakpoint.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of breakpoint, is in range 0..get_bpt_qty()-1
-/// \param[out] bpt filled with the characteristics.
-/// \return false if no breakpoint exists
-
-inline bool idaapi getn_bpt(int n, bpt_t *bpt) { return callui(ui_dbg_getn_bpt, n, bpt).cnd; }
-
-
-/// Get the characteristics of a breakpoint.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param ea any address in the breakpoint range
-/// \param[out] bpt if not NULL, is filled with the characteristics.
-/// \return false if no breakpoint exists
-
-inline bool idaapi get_bpt(ea_t ea, bpt_t *bpt) { return callui(ui_dbg_get_bpt, ea, bpt).cnd; }
-
-
-/// Does a breakpoint exist at the given location?
-
-inline bool exist_bpt(ea_t ea) { return get_bpt(ea, NULL); }
-
-
-/// Add a new breakpoint in the debugged process.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \note Only one breakpoint can exist at a given address.
-/// \param ea any address in the process memory space.
-/// Depending on the architecture, hardware breakpoints
-/// always be setup at random address. For example, on x86,
-/// hardware breakpoints should be aligned depending on their size.
-/// Moreover, on the x86 architecture, it is impossible to setup
-/// more than 4 hardware breakpoints.
-/// \param size size of the breakpoint (irrelevant for software breakpoints):
-/// As for the address, hardware breakpoints can't always be setup
-/// with random size.
-/// \param type type of the breakpoint (#BPT_SOFT for software breakpoint)
-/// special case #BPT_DEFAULT (#BPT_SOFT|#BPT_EXEC):
-/// try to add instruction breakpoint of the appropriate type
-/// as follows: software bpt if supported, hwbpt otherwise
-
-inline bool idaapi add_bpt(ea_t ea, asize_t size = 0, bpttype_t type = BPT_DEFAULT) { return callui(ui_dbg_add_oldbpt, ea, size, type).cnd; }
-
-/// Post an add_bpt(ea_t, asize_t, bpttype_t) request
-
-inline bool idaapi request_add_bpt(ea_t ea, asize_t size = 0, bpttype_t type = BPT_DEFAULT) { return callui(ui_dbg_request_add_oldbpt, ea, size, type).cnd; }
-
-
-/// Add a new breakpoint in the debugged process.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param bpt Breakpoint to add. It describes the break condition,
-/// type, flags, location (module relative, source breakpoint
-/// or absolute) and other attributes.
-
-inline bool idaapi add_bpt(const bpt_t &bpt) { return callui(ui_dbg_add_bpt, &bpt).cnd; }
-
-/// Post an add_bpt(const bpt_t &) request
-
-inline bool idaapi request_add_bpt(const bpt_t &bpt) { return callui(ui_dbg_request_add_bpt, &bpt).cnd; }
-
-
-/// Delete an existing breakpoint in the debugged process.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param ea any address in the breakpoint range
-
-inline bool idaapi del_bpt(ea_t ea) { return callui(ui_dbg_del_oldbpt, ea).cnd; }
-
-/// Post a del_bpt(ea_t) request
-
-inline bool idaapi request_del_bpt(ea_t ea) { return callui(ui_dbg_request_del_oldbpt, ea).cnd; }
-
-
-/// Delete an existing breakpoint in the debugged process.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param bptloc Breakpoint location
-
-inline bool idaapi del_bpt(const bpt_location_t &bptloc) { return callui(ui_dbg_del_bpt, &bptloc).cnd; }
-
-/// Post a del_bpt(const bpt_location_t &) request
-
-inline bool idaapi request_del_bpt(const bpt_location_t &bptloc) { return callui(ui_dbg_request_del_bpt, &bptloc).cnd; }
-
-
-/// Update modifiable characteristics of an existing breakpoint.
-/// To update the breakpoint location, use change_bptlocs()
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \note Only the following fields can be modified:
-/// - bpt_t::cndbody
-/// - bpt_t::pass_count
-/// - bpt_t::flags
-/// - bpt_t::size
-/// - bpt_t::type
-/// \note Changing some properties will require removing and then re-adding
-/// the breakpoint to the process memory (or the debugger backend), which
-/// can lead to race conditions (i.e., breakpoint(s) can be missed) in
-/// case the process is not suspended.
-/// Here are a list of scenarios that will require the breakpoint
-/// to be removed & then re-added:
-/// - bpt_t::size is modified
-/// - bpt_t::type is modified
-/// - bpt_t::flags's BPT_ENABLED is modified
-/// - bpt_t::flags's BPT_LOWCND is changed
-/// - bpt_t::flags's BPT_LOWCND remains set, but cndbody changed
-
-inline bool idaapi update_bpt(const bpt_t *bpt) { return callui(ui_dbg_update_bpt, bpt).cnd; }
-
-
-/// Find a breakpoint by location.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param bptloc Breakpoint location
-/// \param bpt bpt is filled if the breakpoint was found
-
-inline bool idaapi find_bpt(const bpt_location_t &bptloc, bpt_t *bpt) { return callui(ui_dbg_find_bpt, &bptloc, bpt).cnd; }
-
-
-/// Move breakpoint(s) from one location to another
-/// \param movinfo what bpts to move and where to
-/// \param codes vector of return codes, if detailed error info is required
-/// \param del_hindering_bpts should delete hindering breakpoints?
-/// \return number of moved bpts
-
-inline int idaapi change_bptlocs(
- const movbpt_infos_t &movinfo,
- movbpt_codes_t *codes = NULL,
- bool del_hindering_bpts = true)
-{
- return callui(ui_dbg_change_bptlocs, &movinfo, codes, del_hindering_bpts).i;
-}
-
-
-
-/// \name enable/disable breakpoints
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// Enable or disable an existing breakpoint.
-/// A disabled breakpoint isn't available anymore in the process.
-//@{
-inline bool idaapi enable_bpt(ea_t ea, bool enable = true) { return callui(ui_dbg_enable_oldbpt, ea, enable).cnd; }
-inline bool idaapi enable_bpt(const bpt_location_t &bptloc, bool enable = true) { return callui(ui_dbg_enable_bpt, &bptloc, enable).cnd; }
-inline bool disable_bpt(ea_t ea) { return enable_bpt(ea, false); }
-inline bool disable_bpt(const bpt_location_t &bptloc) { return enable_bpt(bptloc, false); }
-inline bool idaapi request_enable_bpt(ea_t ea, bool enable = true) { return callui(ui_dbg_request_enable_oldbpt, ea, enable).cnd; }
-inline bool idaapi request_enable_bpt(const bpt_location_t &bptloc, bool enable = true) { return callui(ui_dbg_request_enable_bpt, &bptloc, enable).cnd; }
-inline bool request_disable_bpt(ea_t ea) { return request_enable_bpt(ea, false); }
-inline bool request_disable_bpt(const bpt_location_t &bptloc) { return request_enable_bpt(bptloc, false); }
-//@}
-
-
-/// Check the breakpoint at the specified address.
-/// \return one of \ref BPTCK_
-
-inline int idaapi check_bpt(ea_t ea) { return callui(ui_dbg_check_bpt, ea).i; }
-
-#endif // __UI__
-
-/// \defgroup BPTCK_ Breakpoint status codes
-/// Return values for check_bpt()
-//@{
-#define BPTCK_NONE -1 ///< breakpoint does not exist
-#define BPTCK_NO 0 ///< breakpoint is disabled
-#define BPTCK_YES 1 ///< breakpoint is enabled
-#define BPTCK_ACT 2 ///< breakpoint is active (written to the process)
-//@}
-
-#ifndef SWIG
-/// Visit all breakpoints.
-/// To use this class, derive your own class from it and call for_all_bpts().
-/// It is forbidden to add/del bpts from the visit_bpt() function.
-/// If bpts are nevertheless modified, the enumeration should be stopped
-struct bpt_visitor_t
-{
- int _for_all_bpts(int bvflags); ///< do not use this function.
- range_t range; ///< if specified, restricts the address range
- const char *name; ///< if specified, restricts bpts to the ones that match the given name
- bpt_visitor_t(void) : range(0, BADADDR), name(NULL) {}
- /// Defines action taken when breakpoint is visited
- virtual int idaapi visit_bpt(const bpt_t *bpt) = 0;
- int idaapi for_all_bpts(int bvflags)
- {
- return callui(ui_dbg_for_all_bpts, this, bvflags).i;
- }
-};
-
-/// \defgroup BVF_ Breakpoint visitor flags
-/// Passed as 'bvflags' parameter to bpt_visitor_t::_for_all_bpts()
-/// \note it is forbidden to modify bpt states from the bpt_visitor_t::visit_bpt()
-/// function if #BVF_STATE is not #BVFS_ANY
-//@{
-#define BVF_ABS 0x0001 ///< include absolute bpts
-#define BVF_REL 0x0002 ///< include relative bpts
-#define BVF_SYM 0x0004 ///< include symbolic bpts
-#define BVF_SRC 0x0008 ///< include source bpts
-#define BVF_ALL 0x000F ///< include all bpt location types
-#define BVF_STATE 0x0030 ///< bpt state mask
-#define BVFS_ANY 0x0000 ///< any state
-#define BVFS_INPROC 0x0010 ///< written to process memory
-#define BVFS_PENDING 0x0020 ///< pending
-#define BVFS_DISABLED 0x0030 ///< disabled.
-//@}
-#endif // SWIG
-
-
-//@} dbg_funcs_bpts
-
-
-#ifndef __UI__
-
-/// \defgroup dbg_funcs_tracing Tracing
-/// \ingroup dbg_funcs
-///
-/// Trace instructions/functions/basic blocks
-
-//--------------------------------------------------------------------
-// T R A C I N G B U F F E R
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_trcbuf Tracing buffer
-/// \ingroup dbg_funcs_tracing
-///
-/// Work with debugger trace buffer.
-/// IDA memorizes various types of trace events in a circular buffer:
-/// instruction tracing, function call and return, breakpoint access ...
-//@{
-
-
-/// Specify the new size of the circular buffer.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param size if 0, buffer isn't circular and events are never removed.
-/// If the new size is smaller than the existing number of trace events,
-/// a corresponding number of trace events are removed.
-/// \note If you specify 0, all available memory can be quickly used !!!
-
-inline bool idaapi set_trace_size(int size) { return callui(ui_dbg_set_trace_size, size).cnd; }
-
-
-/// Clear all events in the trace buffer.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-
-inline void idaapi clear_trace(void) { callui(ui_dbg_clear_trace); }
-
-/// Post a clear_trace() request
-
-inline void idaapi request_clear_trace(void) { callui(ui_dbg_request_clear_trace); }
-
-//@} dbg_funcs_trcbuf
-
-
-//--------------------------------------------------------------------
-// S T E P T R A C I N G
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_strace Step tracing
-/// \ingroup dbg_funcs_tracing
-///
-/// Plugins can use these functions to implement a custom tracing engine.
-/// When enabled, IDA uses single-stepping feature of the debugger
-/// and generates a dbg_trace notification after each step in the current thread.
-/// Tracing buffer is not maintained in this mode (you need to use one of the
-/// higher level tracing types for it)
-//@{
-
-/// Get current state of step tracing.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi is_step_trace_enabled(void) { return callui(ui_dbg_is_step_trace_enabled).cnd; }
-
-
-/// \name Enable/Disable step tracing
-/// Enable or disable the step tracing
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-/// \param enable
-/// - 1 : enable step tracing
-/// - 0 : disable step tracing
-/// - -1 : temporarily disable step tracing
-/// (trace-over breakpoints are conserved:
-/// these could re-enable step tracing later)
-//@{
-
-inline bool idaapi enable_step_trace(int enable = 1) { return callui(ui_dbg_enable_step_trace, enable).cnd; }
-inline bool disable_step_trace(void) { return enable_step_trace(0); }
-inline bool idaapi request_enable_step_trace(int enable = 1) { return callui(ui_dbg_request_enable_step_trace, enable).cnd; }
-inline bool request_disable_step_trace(void) { return request_enable_step_trace(false); }
-//@}
-
-#endif // __UI__
-
-
-/// \defgroup ST_ Step trace options
-/// Flags returned by get_step_trace_options()
-//@{
-#define ST_OVER_DEBUG_SEG 0x01 ///< step tracing will be disabled when IP is in a debugger segment
-#define ST_OVER_LIB_FUNC 0x02 ///< step tracing will be disabled when IP is in a library function
-#define ST_ALREADY_LOGGED 0x04 ///< step tracing will be disabled when IP is already logged
-#define ST_SKIP_LOOPS 0x08 ///< step tracing will try to skip loops already recorded
-#define ST_DIFFERENTIAL 0x10 ///< tracing: log only new instructions (not previously logged)
-/// mask of available options, to ensure compatibility with newer IDA versions
-#define ST_OPTIONS_MASK (ST_OVER_DEBUG_SEG|ST_OVER_LIB_FUNC|ST_ALREADY_LOGGED|ST_SKIP_LOOPS|ST_DIFFERENTIAL)
-#define ST_OPTIONS_DEFAULT (ST_OVER_DEBUG_SEG|ST_OVER_LIB_FUNC)
-//@}
-
-/// specific options for instruction tracing (see set_insn_trace_options())
-#define IT_LOG_SAME_IP 0x01 ///< instruction tracing will log new instructions even when IP doesn't change
-/// specific options for function tracing (see set_func_trace_options())
-#define FT_LOG_RET 0x01 ///< function tracing will log returning instructions
-/// specific options for basic block tracing (see set_bblk_trace_options())
-#define BT_LOG_INSTS 0x01 ///< log all instructions in the current basic block
-
-#ifndef __UI__
-
-/// Get current step tracing options.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return \ref ST_
-
-inline int idaapi get_step_trace_options(void) { return callui(ui_dbg_get_step_trace_options).i; }
-
-/// Modify step tracing options.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-
-inline void idaapi set_step_trace_options(int options) { callui(ui_dbg_set_step_trace_options, options); }
-
-/// Post a set_step_trace_options() request
-
-inline void idaapi request_set_step_trace_options(int options) { callui(ui_dbg_request_set_step_trace_options, options); }
-
-//@} dbg_funcs_strace
-
-
-//--------------------------------------------------------------------
-// I N S T R U C T I O N S T R A C I N G
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_trcins Instruction tracing
-/// \ingroup dbg_funcs_tracing
-///
-/// When instruction tracing is active, each executed instruction is stored
-/// in the tracing buffer.
-/// Internally, IDA uses step tracing to record register values after the
-/// execution of the instruction.
-//@{
-
-/// Get current state of instruction tracing.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi is_insn_trace_enabled(void) { return callui(ui_dbg_is_insn_trace_enabled).cnd; }
-
-/// \name Enable/Disable instruction tracing
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-//@{
-inline bool idaapi enable_insn_trace(bool enable = true) { return callui(ui_dbg_enable_insn_trace, enable).cnd; }
-inline bool disable_insn_trace(void) { return enable_insn_trace(false); }
-inline bool idaapi request_enable_insn_trace(bool enable = true) { return callui(ui_dbg_request_enable_insn_trace, enable).cnd; }
-inline bool request_disable_insn_trace(void) { return request_enable_insn_trace(false); }
-//@}
-
-
-/// Get current instruction tracing options.
-/// Also see #IT_LOG_SAME_IP
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline int idaapi get_insn_trace_options(void) { return callui(ui_dbg_get_insn_trace_options).i; }
-
-
-/// Modify instruction tracing options.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-
-inline void idaapi set_insn_trace_options(int options) { callui(ui_dbg_set_insn_trace_options, options); }
-
-/// Post a set_insn_trace_options() request
-
-inline void idaapi request_set_insn_trace_options(int options) { callui(ui_dbg_request_set_insn_trace_options, options); }
-
-//@} dbg_funcs_trcins
-
-
-//--------------------------------------------------------------------
-// F U N C T I O N S T R A C I N G
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_trcfunc Functions tracing
-/// \ingroup dbg_funcs_tracing
-///
-/// Each call to a function or return from a function is stored
-/// in the tracing buffer.
-//@{
-
-/// Get current state of functions tracing.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline bool idaapi is_func_trace_enabled(void) { return callui(ui_dbg_is_func_trace_enabled).cnd; }
-
-
-/// \name Enable/Disable functions tracing
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-//@{
-inline bool idaapi enable_func_trace(bool enable = true) { return callui(ui_dbg_enable_func_trace, enable).cnd; }
-inline bool disable_func_trace(void) { return enable_func_trace(false); }
-inline bool idaapi request_enable_func_trace(bool enable = true) { return callui(ui_dbg_request_enable_func_trace, enable).cnd; }
-inline bool request_disable_func_trace(void) { return request_enable_func_trace(false); }
-//@}
-
-
-/// Get current function tracing options.
-/// Also see #FT_LOG_RET
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline int idaapi get_func_trace_options(void) { return callui(ui_dbg_get_func_trace_options).i; }
-
-
-/// Modify function tracing options.
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-
-inline void idaapi set_func_trace_options(int options) { callui(ui_dbg_set_func_trace_options, options); }
-
-/// Post a set_func_trace_options() request
-
-inline void idaapi request_set_func_trace_options(int options) { callui(ui_dbg_request_set_func_trace_options, options); }
-
-//@} dbg_funcs_trcfunc
-
-
-//--------------------------------------------------------------------
-// B A S I C B L O C K T R A C I N G
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_trcbb Basic block tracing
-/// \ingroup dbg_funcs_tracing
-//@{
-
-// Modify basic block tracing options.
-// Type: Synchronous function - available as Request
-// Notification: none (synchronous function)
-
-
-/// \name Enable/Disable basic blocks tracing
-/// \sq{Type, Synchronous function - available as request,
-/// Notification, none (synchronous function)}
-//@{
-inline bool idaapi enable_bblk_trace(bool enable = true) { return callui(ui_dbg_enable_bblk_trace, enable).cnd; }
-inline bool disable_bblk_trace(void) { return enable_bblk_trace(false); }
-inline bool idaapi request_enable_bblk_trace(bool enable = true) { return callui(ui_dbg_request_enable_bblk_trace, enable).cnd; }
-inline bool request_disable_bblk_trace(void) { return request_enable_bblk_trace(false); }
-inline bool idaapi is_bblk_trace_enabled(void) { return callui(ui_dbg_is_bblk_trace_enabled).cnd; }
-//@}
-
-/// Get current basic block tracing options.
-/// Also see #BT_LOG_INSTS
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline int idaapi get_bblk_trace_options(void) { return callui(ui_dbg_get_bblk_trace_options).i; }
-
-
-/// Modify basic block tracing options (see #BT_LOG_INSTS)
-
-inline void idaapi set_bblk_trace_options(int options) { callui(ui_dbg_set_bblk_trace_options, options); }
-
-/// Post a set_bblk_trace_options() request
-
-inline void idaapi request_set_bblk_trace_options(int options) { callui(ui_dbg_request_set_bblk_trace_options, options); }
-
-//@} dbg_funcs_trcbb
-
-#endif // __UI__
-
-//--------------------------------------------------------------------
-// T R A C I N G E V E N T S
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_trcev Tracing events
-/// \ingroup dbg_funcs_tracing
-//@{
-
-/// Trace event types
-enum tev_type_t
-{
- tev_none = 0, ///< no event
- tev_insn, ///< an instruction trace
- tev_call, ///< a function call trace
- tev_ret, ///< a function return trace
- tev_bpt, ///< write, read/write, execution trace
- tev_mem, ///< memory layout changed
- tev_event, ///< debug event occurred
- tev_max, ///< first unused event type
-};
-
-typedef qvector dbgevt_vec_t; ///< vector of debug events
-
-/// Common information for all trace events
-struct tev_info_t
-{
- tev_type_t type; ///< trace event type
- thid_t tid; ///< thread where the event was recorded
- ea_t ea; ///< address where the event occurred
-};
-typedef qvector tevinfo_vec_t; ///< vector of trace event info objects
-
-
-/// Required typedef for get_insn_tev_reg_mem()
-struct memreg_info_t
-{
- ea_t ea;
- bytevec_t bytes;
-};
-DECLARE_TYPE_AS_MOVABLE(memreg_info_t);
-typedef qvector memreg_infos_t;
-
-
-#ifndef __UI__
-
-/// Get number of trace events available in trace buffer.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline int idaapi get_tev_qty(void) { return callui(ui_dbg_get_tev_qty).i; }
-
-
-/// Get main information about a trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \param[out] tev_info result
-/// \return success
-
-inline bool idaapi get_tev_info(int n, tev_info_t *tev_info) { return callui(ui_dbg_get_tev_info, n, tev_info).cnd; }
-
-
-/// Read a register value from an instruction trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \param regname name of desired register
-/// \param[out] regval result
-/// \return false if not an instruction event.
-/// \note This is the value of the register before the execution of
-/// the instruction.
-
-inline bool idaapi get_insn_tev_reg_val(int n, const char *regname, regval_t *regval) { return callui(ui_dbg_get_insn_tev_reg_val, n, regname, regval).cnd; }
-
-inline bool idaapi get_insn_tev_reg_val(int n, const char *regname, uint64 *ival) { return callui(ui_dbg_get_insn_tev_reg_val_i, n, regname, ival).cnd; }
-
-
-/// Read the memory pointed by register values from an instruction trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \param[out] memmap result
-/// \return false if not an instruction event or no memory is available
-
-inline bool idaapi get_insn_tev_reg_mem(int n, memreg_infos_t *memmap) { return callui(ui_dbg_get_insn_tev_reg_mem, n, memmap).cnd; }
-
-
-/// Read the resulting register value from an instruction trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \param regname name of desired register
-/// \param[out] regval result
-/// \return false if not an instruction trace event or register wasn't modified.
-
-inline bool idaapi get_insn_tev_reg_result(int n, const char *regname, regval_t *regval) { return callui(ui_dbg_get_insn_tev_reg_result, n, regname, regval).cnd; }
-
-inline bool idaapi get_insn_tev_reg_result(int n, const char *regname, uint64 *ival) { return callui(ui_dbg_get_insn_tev_reg_result_i, n, regname, ival).cnd; }
-
-
-/// Get the called function from a function call trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \return #BADADDR if not a function call event.
-
-inline ea_t idaapi get_call_tev_callee(int n) { ea_t ea; callui(ui_dbg_get_call_tev_callee, n, &ea); return ea; }
-
-
-/// Get the return address from a function return trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \return #BADADDR if not a function return event.
-
-inline ea_t idaapi get_ret_tev_return(int n) { ea_t ea; callui(ui_dbg_get_ret_tev_return, n, &ea); return ea; }
-
-
-/// Get the address associated to a read, read/write or execution trace event.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \return #BADADDR if not a read, read/write or execution trace event.
-/// \note Usually, a breakpoint is associated with a read, read/write or execution
-/// trace event. However, the returned address could be any address in the
-/// range of this breakpoint.
-/// If the breakpoint was deleted after the trace event, the address no longer
-/// corresponds to a valid breakpoint.
-
-inline ea_t idaapi get_bpt_tev_ea(int n) { ea_t ea; callui(ui_dbg_get_bpt_tev_ea, n, &ea); return ea; }
-
-
-/// Get the memory layout, if any, for the specified tev object.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \param[out] mi result
-/// \return false if the tev_t object is not of type ::tev_mem, true otherwise,
-/// with the new memory layout in "mi".
-
-inline bool idaapi get_tev_memory_info(int n, meminfo_vec_t *mi) { return callui(ui_dbg_get_tev_memory_info, n, mi).cnd; }
-
-
-/// Get the corresponding debug event, if any, for the specified tev object.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \param n number of trace event, is in range 0..get_tev_qty()-1.
-/// 0 represents the latest added trace event.
-/// \param[out] d result
-/// \return false if the tev_t object doesn't have any associated debug
-/// event, true otherwise, with the debug event in "d".
-
-inline bool idaapi get_tev_event(int n, debug_event_t *d) { return callui(ui_dbg_get_tev_event, n, d).cnd; }
-
-
-/// Get the base address of the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return the base address of the currently loaded trace
-
-inline ea_t idaapi get_trace_base_address(void) { ea_t ea; callui(ui_dbg_get_trace_base_address, &ea); return ea; }
-
-
-/// Set the base address of the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi set_trace_base_address(ea_t ea) { callui(ui_dbg_set_trace_base_address, ea); }
-
-
-/// Add a thread to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi dbg_add_thread(thid_t tid) { callui(ui_dbg_add_thread, tid); }
-
-
-/// Delete a thread from the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi dbg_del_thread(thid_t tid) { callui(ui_dbg_del_thread, tid); }
-
-
-/// Add a new trace element to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi dbg_add_tev(tev_type_t type, thid_t tid, ea_t address) { callui(ui_dbg_add_tev, type, tid, address); }
-
-#endif // __UI__
-
-/// Structure used for dbg_add_many_tevs()
-struct tev_reg_value_t
-{
- regval_t value;
- int reg_idx;
-
- tev_reg_value_t(int _reg_idx = -1, uint64 _value = uint64(-1)) : reg_idx(_reg_idx)
- {
- value._set_int(_value);
- }
-};
-DECLARE_TYPE_AS_MOVABLE(tev_reg_value_t);
-typedef qvector tev_reg_values_t; ///< vector of trace event reg values
-
-/// Structure used for dbg_add_many_tevs()
-struct tev_info_reg_t
-{
- tev_info_t info;
- tev_reg_values_t registers;
-};
-DECLARE_TYPE_AS_MOVABLE(tev_info_reg_t);
-typedef qvector tevinforeg_vec_t; ///< vector of trace elements
-
-
-/// Se dbg_add_insn_tev()
-enum save_reg_values_t
-{
- SAVE_ALL_VALUES = 0,
- SAVE_DIFF,
- SAVE_NONE
-};
-
-#ifndef __UI__
-
-/// Add many new trace elements to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return false if the operation failed for any ::tev_info_t object
-
-inline bool idaapi dbg_add_many_tevs(tevinforeg_vec_t *new_tevs) { return callui(ui_dbg_add_many_tevs, new_tevs).cnd; }
-
-
-/// Add a new instruction trace element to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return false if the operation failed, true otherwise
-
-inline bool idaapi dbg_add_insn_tev(thid_t tid, ea_t ea, save_reg_values_t save = SAVE_DIFF) { return callui(ui_dbg_add_insn_tev, tid, ea, save).cnd; }
-
-
-/// Add a new breakpoint trace element to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-/// \return false if the operation failed, true otherwise
-
-inline bool idaapi dbg_add_bpt_tev(thid_t tid, ea_t ea, ea_t bp) { return callui(ui_dbg_add_bpt_tev, tid, ea, bp).cnd; }
-
-
-/// Add a new call trace element to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi dbg_add_call_tev(thid_t tid, ea_t caller, ea_t callee) { callui(ui_dbg_add_call_tev, tid, caller, callee); }
-
-
-/// Add a new return trace element to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi dbg_add_ret_tev(thid_t tid, ea_t ret_insn, ea_t return_to) { callui(ui_dbg_add_ret_tev, tid, ret_insn, return_to); }
-
-
-/// Add a new debug event to the current trace.
-/// \sq{Type, Synchronous function,
-/// Notification, none (synchronous function)}
-
-inline void idaapi dbg_add_debug_event(debug_event_t *event) { callui(ui_dbg_add_debug_event, event); }
-
-//@} dbg_funcs_trcev
-
-
-//---------------------------------------------------------------------------
-// Trace management functions
-//---------------------------------------------------------------------------
-/// \defgroup dbg_funcs_trcm Trace management functions
-/// \ingroup dbg_funcs_tracing
-//@{
-
-/// Load a recorded trace file in the trace window.
-/// If the call succeeds and 'buf' is not null, the description of the
-/// trace stored in the binary trace file will be returned in 'buf'
-
-inline bool idaapi load_trace_file(qstring *buf, const char *filename) { return callui(ui_dbg_load_trace_file, buf, filename).cnd; }
-
-
-/// Save the current trace in the specified file
-
-inline bool idaapi save_trace_file(const char *filename, const char *description) { return callui(ui_dbg_save_trace_file, filename, description).cnd; }
-
-
-/// Is the specified file a valid trace file for the current database?
-
-inline bool idaapi is_valid_trace_file(const char *filename) { return callui(ui_dbg_is_valid_trace_file, filename).cnd; }
-
-
-/// Change the description of the specified trace file
-
-inline bool idaapi set_trace_file_desc(const char *filename, const char *description) { return callui(ui_dbg_set_trace_file_desc, filename, description).cnd; }
-
-
-/// Get the file header of the specified trace file
-
-inline bool idaapi get_trace_file_desc(qstring *buf, const char *filename) { return callui(ui_dbg_get_trace_file_desc, buf, filename).cnd; }
-
-
-/// Show the choose trace dialog
-
-inline bool idaapi choose_trace_file(qstring *buf) { return callui(ui_dbg_choose_trace_file, buf).cnd; }
-
-
-/// Show difference between the current trace and the one from 'filename'
-
-inline bool idaapi diff_trace_file(const char *NONNULL filename) { return callui(ui_dbg_diff_trace_file, filename).cnd; }
-
-
-/// Show the trace callgraph
-
-inline bool idaapi graph_trace(void) { return callui(ui_dbg_graph_trace).cnd; }
-
-
-/// Set highlight trace parameters.
-
-inline void idaapi set_highlight_trace_options(
- bool hilight,
- bgcolor_t color,
- bgcolor_t diff)
-{
- callui(ui_dbg_set_highlight_trace_options, hilight, color, diff);
-}
-
-
-/// Set platform name of current trace
-
-inline void idaapi set_trace_platform(const char *platform) { callui(ui_dbg_set_trace_platform, platform); }
-
-
-/// Get platform name of current trace
-
-inline const char *idaapi get_trace_platform() { return callui(ui_dbg_get_trace_platform).cptr; }
-
-
-/// Set dynamic register set of current trace
-
-inline void idaapi set_trace_dynamic_register_set(dynamic_register_set_t &idaregs) { callui(ui_dbg_set_trace_dynamic_register_set, &idaregs); }
-
-
-/// Get dynamic register set of current trace
-
-inline void idaapi get_trace_dynamic_register_set(dynamic_register_set_t *idaregs) { callui(ui_dbg_get_trace_dynamic_register_set, idaregs); }
-
-//@} dbg_funcs_trcm
-
-#endif // __UI__
-
-//---------------------------------------------------------------------------
-// High level functions (usable from scripts)
-//--------------------------------------------------------------------
-/// \defgroup dbg_funcs_high High level functions
-/// \ingroup dbg_funcs
-///
-/// These functions can be used from scripts
-//@{
-
-/// Wait for the next debugger event.
-/// See also get_process_state() to get info about the current state
-/// of the debugged application
-
-/// Debugger event codes
-enum dbg_event_code_t
-{
- DEC_NOTASK = -2, ///< process does not exist
- DEC_ERROR = -1, ///< error
- DEC_TIMEOUT = 0, ///< timeout
-};
-
-/// \defgroup WFNE_ Wait for debugger event flags
-/// Passed as 'wfne' parameter to wait_for_next_event()
-//@{
-#define WFNE_ANY 0x0001 ///< return the first event (even if it doesn't suspend the process)
-#define WFNE_SUSP 0x0002 ///< wait until the process gets suspended
-#define WFNE_SILENT 0x0004 ///< 1: be slient, 0:display modal boxes if necessary
-#define WFNE_CONT 0x0008 ///< continue from the suspended state
-#define WFNE_NOWAIT 0x0010 ///< do not wait for any event, immediately return ::DEC_TIMEOUT
- ///< (to be used with #WFNE_CONT)
-#define WFNE_USEC 0x0020 ///< timeout is specified in microseconds
- ///< (minimum non-zero timeout is 40000us)
-//@}
-
-/// \defgroup DOPT_ Debugger options
-/// Passed as 'options' parameter to set_debugger_options()
-//@{
-#define DOPT_SEGM_MSGS 0x00000001 ///< log debugger segments modifications
-#define DOPT_START_BPT 0x00000002 ///< break on process start
-#define DOPT_THREAD_MSGS 0x00000004 ///< log thread starts/exits
-#define DOPT_THREAD_BPT 0x00000008 ///< break on thread start/exit
-#define DOPT_BPT_MSGS 0x00000010 ///< log breakpoints
-//#define DOPT_BINS_BPT 0x00000020 // break on breakpoint instruction
-#define DOPT_LIB_MSGS 0x00000040 ///< log library loads/unloads
-#define DOPT_LIB_BPT 0x00000080 ///< break on library load/unload
-#define DOPT_INFO_MSGS 0x00000100 ///< log debugging info events
-#define DOPT_INFO_BPT 0x00000200 ///< break on debugging information
-#define DOPT_REAL_MEMORY 0x00000400 ///< do not hide breakpoint instructions
-#define DOPT_REDO_STACK 0x00000800 ///< reconstruct the stack
-#define DOPT_ENTRY_BPT 0x00001000 ///< break on program entry point
-#define DOPT_EXCDLG 0x00006000 ///< exception dialogs:
-# define EXCDLG_NEVER 0x00000000 ///< never display exception dialogs
-# define EXCDLG_UNKNOWN 0x00002000 ///< display for unknown exceptions
-# define EXCDLG_ALWAYS 0x00006000 ///< always display
-#define DOPT_LOAD_DINFO 0x00008000 ///< automatically load debug files (pdb)
-#define DOPT_END_BPT 0x00010000 ///< evaluate event condition on process end
-#define DOPT_TEMP_HWBPT 0x00020000 ///< when possible use hardware bpts for temp bpts
-//@}
-
-
-#ifndef __UI__
-
-/// Wait for the next event.
-///
-/// This function (optionally) resumes the process execution,
-/// and waits for a debugger event until a possible timeout occurs.
-///
-/// \param wfne combination of \ref WFNE_ constants
-/// \param timeout number of seconds to wait, -1-infinity
-/// \return either an event_id_t (if > 0), or a dbg_event_code_t (if <= 0)
-
-inline dbg_event_code_t idaapi wait_for_next_event(int wfne, int timeout) { return dbg_event_code_t(callui(ui_dbg_wait_for_next_event, wfne, timeout).i); }
-
-
-/// Get the current debugger event
-
-inline const debug_event_t *idaapi get_debug_event(void) { return (const debug_event_t *)callui(ui_dbg_get_debug_event).vptr; }
-
-
-/// Set debugger options.
-/// Replaces debugger options with the specification combination \ref DOPT_
-/// \return the old debugger options
-
-inline uint idaapi set_debugger_options(uint options) { return callui(ui_dbg_set_debugger_options, options).i; }
-
-
-/// Set remote debugging options.
-/// Should be used before starting the debugger.
-/// \param host If empty, IDA will use local debugger.
-/// If NULL, the host will not be set.
-/// \param pass If NULL, the password will not be set
-/// \param port If -1, the default port number will be used
-
-inline void idaapi set_remote_debugger(const char *host, const char *pass, int port=-1) { callui(ui_dbg_set_remote_debugger, host, pass, port); }
-
-
-/// Get process options.
-/// Any of the arguments may be NULL
-
-inline void idaapi get_process_options(
- qstring *path,
- qstring *args,
- qstring *sdir,
- qstring *host,
- qstring *pass,
- int *port)
-{
- callui(ui_dbg_get_process_options, path, args, sdir, host, pass, port);
-}
-
-
-/// Set process options.
-/// Any of the arguments may be NULL, which means 'do not modify'
-
-inline void idaapi set_process_options(
- const char *path,
- const char *args,
- const char *sdir,
- const char *host,
- const char *pass,
- int port)
-{
- callui(ui_dbg_set_process_options, path, args, sdir, host, pass, port);
-}
-
-
-/// Retrieve the exception information.
-/// You may freely modify the returned vector and add/edit/delete exceptions
-/// You must call store_exceptions() after any modifications
-/// Note: exceptions with code zero, multiple exception codes or names are prohibited
-
-inline excvec_t *idaapi retrieve_exceptions(void) { return (excvec_t *)callui(ui_dbg_retrieve_exceptions).vptr; }
-
-
-/// Update the exception information stored in the debugger module by
-/// invoking its dbg->set_exception_info callback
-
-inline bool idaapi store_exceptions(void) { return callui(ui_dbg_store_exceptions).cnd; }
-
-
-/// Convenience function: define new exception code.
-/// \param code exception code (cannot be 0)
-/// \param name exception name (cannot be empty or NULL)
-/// \param desc exception description (maybe NULL)
-/// \param flags combination of \ref EXC_
-/// \return failure message or NULL.
-/// You must call store_exceptions() if this function succeeds
-
-inline const char *idaapi define_exception(uint code, const char *name, const char *desc, int flags) { return callui(ui_dbg_define_exception, code, name, desc, flags).cptr; }
-
-#endif // __UI__
-
-
-//--------------------------------------------------------------------
-
-/// Is set_dbg_options() present in ::debugger_t?
-
-inline THREAD_SAFE bool have_set_options(const debugger_t *_dbg)
-{
- return _dbg != NULL && _dbg->set_dbg_options != NULL;
-}
-
-//--------------------------------------------------------------------
-
-/// Convenience function to set debugger specific options. It checks if the debugger
-/// is present and the function is present and calls it.
-
-inline const char *idaapi set_dbg_options(
- debugger_t *_dbg,
- const char *keyword,
- int pri,
- int value_type,
- const void *value)
-{
- const char *code = IDPOPT_BADKEY;
- if ( have_set_options(_dbg) )
- code = _dbg->set_dbg_options(keyword, pri, value_type, value);
- return code;
-}
-
-
-inline const char *idaapi set_dbg_default_options(
- debugger_t *_dbg,
- const char *keyword,
- int value_type,
- const void *value)
-{
- return set_dbg_options(_dbg, keyword, IDPOPT_PRI_DEFAULT, value_type, value);
-}
-
-inline const char *idaapi set_int_dbg_options(
- debugger_t *_dbg,
- const char *keyword,
- int32 value)
-{
- sval_t sv = value;
- return set_dbg_default_options(_dbg, keyword, IDPOPT_NUM, &sv);
-}
-
-#ifndef __KERNEL__
-/// Set options for ::dbg
-
-inline const char *idaapi set_dbg_options(
- const char *keyword,
- int pri,
- int value_type,
- const void *value)
-{
- return set_dbg_options(dbg, keyword, pri, value_type, value);
-}
-
-/// Set ::dbg options with #IDPOPT_PRI_DEFAULT
-
-inline const char *idaapi set_dbg_default_options(
- const char *keyword,
- int value_type,
- const void *value)
-{
- return set_dbg_options(keyword, IDPOPT_PRI_DEFAULT, value_type, value);
-}
-
-/// Set an integer value option for ::dbg
-
-inline const char *idaapi set_int_dbg_options(
- const char *keyword,
- int32 value)
-{
- sval_t sv = value;
- return set_dbg_default_options(keyword, IDPOPT_NUM, &sv);
-}
-#endif // __KERNEL__
-
-//@} dbg_funcs_high
-
-//---------------------------------------------------------------------------
-// S O U R C E I N F O R M A T I O N P R O V I D E R S
-//---------------------------------------------------------------------------
-/// \defgroup dbg_funcs_srcinfo Source information providers
-/// \ingroup dbg_funcs
-///
-/// These providers supply information about the source files and lines
-/// to the source level debugger.
-///
-/// \note objects that inherit from ::qrefcnt_obj_t must be freed
-/// using the release() method. do not use the 'delete' operator!
-/// See description for qrefcnt_obj_t::release()
-///
-/// Currently this interface is not frozen and may change.
-/// We will freeze it once we settle things down.
-//@{
-
-class srcinfo_provider_t;
-
-class idc_value_t;
-class rangeset_t;
-class source_item_t;
-class argloc_t;
-
-/// Maintain a reference count for source items
-typedef qrefcnt_t source_item_ptr;
-/// Iterator for source items
-typedef qiterator