IDA C++ SDK 9.2
Loading...
Searching...
No Matches
pro.h File Reference

This is the first header included in the IDA project. More...

Go to the source code of this file.

Classes

struct  qstatbuf
 Describes miscellaneous file attributes. More...
struct  interr_exc_t
struct  qnumber_check_type
struct  qnumber_check_type::is_array
class  qvector< T >
 Reimplementation of vector class from STL. More...
class  qstack< T >
 Reimplementation of stack class from STL. More...
class  pool_allocator_t< T >
 A custom allocator for containers. More...
class  qrefcnt_t< T >
 Smart pointer to objects derived from qrefcnt_obj_t. More...
class  qrefcnt_obj_t
 Base class for reference count objects. More...
class  qiterator< T >
 Interface class for iterator types. More...
class  _qstring< qchar >
 Reimplementation of the string class from STL. More...
struct  std::hash< _qstring< T > >
class  bytevec_t
 Vector of bytes (use for dynamic memory) More...
struct  reloc_info_t
 Relocation information (relocatable objects - see relobj_t) More...
struct  relobj_t
 Relocatable object. More...
class  qlist< T >
 Linked list Note: linked list is not movable! More...
struct  memory_deserializer_t
struct  memory_serializer_t
struct  janitor_t< T >
 Resource janitor to facilitate use of the RAII idiom. More...
struct  qfree_deleter_t< T >
struct  has_compare_method< typename, typename >
 Template to compare any 2 values of the same type. Returns -1/0/1. More...
struct  has_compare_method< T, qvoid_t< decltype(std::declval< T >().compare(std::declval< T >()))> >
struct  channel_redir_t
 Tools for command line parsing. More...
struct  cliopt_t
struct  plugin_options_t
struct  instant_dbgopts_t
 Options for instant debugging. More...
struct  launch_process_params_t
 Information for launching a process with IDA API Note: all string data such as paths (e.g., 'path', 'args' & 'startdir') or 'env' should be UTF-8 encoded. More...
class  qmutex_locker_t
 Mutex locker object. Will lock a given mutex upon creation and unlock it when the object is destroyed. More...

Namespaces

namespace  interval
 Functions to work with intervals.
namespace  std

Typedefs

typedef int bool
typedef unsigned char uchar
 unsigned 8 bit value
typedef unsigned short ushort
 unsigned 16 bit value
typedef unsigned int uint
 unsigned 32 bit value
typedef char int8
 signed 8 bit value
typedef signed char sint8
 signed 8 bit value
typedef unsigned char uint8
 unsigned 8 bit value
typedef short int16
 signed 16 bit value
typedef unsigned short uint16
 unsigned 16 bit value
typedef int int32
 signed 32 bit value
typedef unsigned int uint32
 unsigned 32 bit value
typedef wchar_t wchar16_t
typedef uint32 wchar32_t
typedef ptrdiff_t ssize_t
 Signed size_t - used to check for size overflows when the counter becomes negative.
typedef uint64 ea_t
typedef uint64 sel_t
typedef uint64 asize_t
typedef int64 adiff_t
typedef asize_t uval_t
 unsigned value used by the processor.
typedef adiff_t sval_t
 signed value used by the processor.
typedef uint32 ea32_t
 32-bit address, regardless of IDA bitness.
typedef uint64 ea64_t
 64-bit address, regardless of IDA bitness.
typedef int error_t
 Error code (errno)
typedef uint8 op_dtype_t
typedef uval_t inode_t
 The inode_t type is the specialization specific inode number.
typedef size_t diffpos_t
typedef int32 qtime32_t
 we use our own time type because time_t can be 32-bit or 64-bit depending on the compiler
typedef uint64 qtime64_t
 64-bit time value expressed as seconds and microseconds since the Epoch
typedef qvector< uval_tuvalvec_t
 vector of unsigned values
typedef qvector< sval_tsvalvec_t
 vector of signed values
typedef qvector< ea_teavec_t
 vector of addresses
typedef qvector< int > intvec_t
 vector of integers
typedef qvector< boolboolvec_t
 vector of bools
typedef qvector< size_t > sizevec_t
 vector of sizes
typedef _qstring< char > qstring
 regular string
typedef _qstring< ucharqtype
 type string
typedef _qstring< wchar16_tqwstring
 unicode string
typedef qvector< qstringqstrvec_t
 vector of strings
typedef qvector< qwstringqwstrvec_t
 vector of unicode strings
template<typename T>
using qalloc_janitor_t = std::unique_ptr<T, qfree_deleter_t<T>>
template<class...>
using qvoid_t = void
typedef struct bytevec_tag bytevec_t
typedef uint32 flags_t
 32-bit flags for each address
typedef uint64 flags64_t
 64-bit flags for each address
typedef ea_t tid_t
 type id (for enums, structs, etc)
typedef uint32 bgcolor_t
 background color in RGB
typedef qvector< channel_redir_tchannel_redirs_t
 vector of channel_redir_t objects
typedef void cliopt_handler_t(const char *value, void *ud)
typedef void cliopt_poly_handler_t(int argc, const char **argv, void *ud)
typedef qvector< plugin_option_t > plugin_option_vec_t
typedef int idaapi qthread_cb_t(void *ud)
 THREADS.
typedef voidqhandle_t
 MS Windows HANDLE.

Enumerations

enum  tty_control_t { TCT_UNKNOWN = 0 , TCT_OWNER , TCT_NOT_OWNER }
 Teletype control. More...

Functions

INLINE int64 qatoll (const char *nptr)
INLINE THREAD_SAFE uint32 get_secs (qtime64_t t)
 Get the 'seconds since the epoch' part of a qtime64_t.
INLINE THREAD_SAFE uint32 get_usecs (qtime64_t t)
 Get the microseconds part of a qtime64_t.
INLINE THREAD_SAFE qtime64_t make_qtime64 (uint32 secs, DEFARG(int32 usecs, 0))
 Get a qtime64_t instance from a seconds value and microseconds value.
idaman THREAD_SAFE bool ida_export qctime (char *buf, size_t bufsize, qtime32_t t)
 Converts calendar time into a string.
idaman THREAD_SAFE bool ida_export qctime_utc (char *buf, size_t bufsize, qtime32_t t)
 Converts calendar time into a string using Coordinated Universal Time (UTC).
idaman THREAD_SAFE bool ida_export qlocaltime (struct tm *_tm, time_t t)
 Converts a time value to a tm structure (local time)
INLINE THREAD_SAFE bool qlocaltime64 (struct tm *_tm, qtime64_t t)
 Same as qlocaltime(struct tm *, time_t), but accepts a 64-bit time value.
idaman bool ida_export qgmtime (struct tm *_tm, time_t t)
 Converts a time value to a tm structure (UTC time)
INLINE THREAD_SAFE bool qgmtime64 (struct tm *_tm, qtime64_t t)
 Same as qgmtime(struct tm *, time_t), but accepts a 64-bit time value.
idaman time_t ida_export qtimegm (const struct tm *ptm)
idaman AS_STRFTIME (3) THREAD_SAFE size_t ida_export qstrftime(char *buf
 Get string representation of a time_t (local time) Copies into 'buf' the content of 'format', expanding its format specifiers into the corresponding values that represent the time described in 't', with a limit of 'bufsize' characters see http://www.cplusplus.com/reference/ctime/strftime/ for more.
idaman THREAD_SAFE void ida_export qsleep (int milliseconds)
 Suspend execution for given number of milliseconds.
idaman THREAD_SAFE uint64 ida_export get_nsec_stamp (void)
 High resolution timer.
idaman THREAD_SAFE qtime64_t ida_export qtime64 (void)
 Get the current time with microsecond resolution (in fact the resolution is worse on windows)
idaman THREAD_SAFE bool ida_export gen_rand_buf (void *buffer, size_t bufsz)
 Generate a random buffer.
idaman THREAD_SAFE error_t ida_export set_qerrno (error_t code)
 Set qerrno.
idaman THREAD_SAFE error_t ida_export get_qerrno (void)
 Get qerrno.
NORETURN void __debugbreak (void)
idaman THREAD_SAFE NORETURN void ida_export interr (int code)
 Show internal error message and terminate execution.
idaman THREAD_SAFE bool ida_export set_interr_throws (bool enable)
idaman THREAD_SAFE void *ida_export qalloc (size_t size)
 System independent malloc.
idaman THREAD_SAFE void *ida_export qrealloc (void *alloc, size_t newsize)
 System independent realloc.
idaman THREAD_SAFE void *ida_export qcalloc (size_t nitems, size_t itemsize)
 System independent calloc.
idaman THREAD_SAFE void ida_export qfree (void *alloc)
 System independent free.
idaman THREAD_SAFE char *ida_export qstrdup (const char *string)
 System independent strdup.
template<class T>
T * qalloc_array (size_t n)
 Use this class to avoid integer overflows when allocating arrays.
template<class T>
T * qrealloc_array (T *ptr, size_t n)
 Use this class to avoid integer overflows when allocating arrays.
idaman THREAD_SAFE void *ida_export memrev (void *buf, ssize_t size)
 Reverse memory block.
idaman THREAD_SAFE int ida_export memicmp (const void *x, const void *y, size_t size)
idaman THREAD_SAFE char *ida_export strrpl (char *str, int char1, int char2)
 Replace all occurrences of a character within a string.
INLINE THREAD_SAFE char * tail (char *str)
 Get tail of a string.
THREAD_SAFE const char * tail (const char *str)
 Get tail of a string.
idaman THREAD_SAFE char *ida_export qstrncpy (char *dst, const char *src, size_t dstsize)
 A safer strncpy - makes sure that there is a terminating zero.
idaman THREAD_SAFE char *ida_export qstpncpy (char *dst, const char *src, size_t dstsize)
 A safer stpncpy - returns pointer to the end of the destination nb: ssize_t(dstsize) must be > 0.
idaman THREAD_SAFE char *ida_export qstrncat (char *dst, const char *src, size_t dstsize)
 A safer strncat - accepts the size of the 'dst' as 'dstsize' and returns dst nb: ssize_t(dstsize) must be > 0.
idaman THREAD_SAFE char *ida_export qstrtok (char *s, const char *delim, char **save_ptr)
 Thread-safe version of strtok.
idaman THREAD_SAFE char *ida_export qstrlwr (char *str)
 Convert the string to lowercase.
idaman THREAD_SAFE char *ida_export qstrupr (char *str)
 Convert the string to uppercase.
idaman THREAD_SAFE const char *ida_export stristr (const char *s1, const char *s2)
 Find one string in another (Case insensitive analog of strstr()).
char *idaapi stristr (char *s1, const char *s2)
 Same as stristr(const char *, const char *) but returns a non-const result.
INLINE THREAD_SAFE bool ida_local qisascii (char c)
INLINE THREAD_SAFE bool ida_local qisspace (char c)
INLINE THREAD_SAFE bool ida_local qisalpha (char c)
INLINE THREAD_SAFE bool ida_local qisalnum (char c)
INLINE THREAD_SAFE bool ida_local qispunct (char c)
INLINE THREAD_SAFE bool ida_local qislower (char c)
INLINE THREAD_SAFE bool ida_local qisupper (char c)
INLINE THREAD_SAFE bool ida_local qisprint (char c)
INLINE THREAD_SAFE bool ida_local qisdigit (char c)
INLINE THREAD_SAFE bool ida_local qisxdigit (char c)
INLINE THREAD_SAFE int ida_local qtolower (char c)
 Get lowercase equivalent of given char.
INLINE THREAD_SAFE int ida_local qtoupper (char c)
 Get uppercase equivalent of given char.
idaman AS_PRINTF (3, 4) THREAD_SAFE int ida_export qsnprintf(char *buffer
idaman size_t const char idaman AS_SCANF (2, 3) THREAD_SAFE int ida_export qsscanf(const char *input
 A safer snprintf.
idaman size_t const char idaman const char idaman AS_PRINTF (3, 0) THREAD_SAFE int ida_export qvsnprintf(char *buffer
 A safer sscanf.
idaman AS_SCANF (2, 0) THREAD_SAFE int ida_export qvsscanf(const char *input
idaman const char const char GCC_DIAG_OFF (format-nonliteral)
 Append result of sprintf to 'buf'.
INLINE int nowarn_qsnprintf (char *buf, size_t size, const char *format,...)
 GCC_DIAG_ON (format-nonliteral)
idaman THREAD_SAFE char *ida_export vqmakepath (char *buf, size_t bufsize, const char *s1, va_list)
 See qmakepath()
idaman THREAD_SAFE char *ida_export qmakepath (char *buf, size_t bufsize, const char *s1,...)
 Construct a path from a null-terminated sequence of strings.
idaman void ida_export qgetcwd (char *buf, size_t bufsize)
 Get the current working directory.
idaman int ida_export qchdir (const char *path)
 Change the current working directory.
idaman THREAD_SAFE bool ida_export qdirname (char *buf, size_t bufsize, const char *path)
 Get the directory part of the path.
idaman THREAD_SAFE char *ida_export qmakefile (char *buf, size_t bufsize, const char *base, const char *ext)
 Construct filename from base name and extension.
idaman THREAD_SAFE char *ida_export qsplitfile (char *file, char **base, char **ext)
 Split filename into base name and extension.
idaman THREAD_SAFE bool ida_export qisabspath (const char *file)
 Is the file name absolute (not relative to the current dir?)
idaman THREAD_SAFE const char *ida_export qbasename (const char *path)
 Get the file name part of the given path.
char * qbasename (char *path)
 Same as qbasename(const char *), but accepts and returns non-const char pointers.
idaman THREAD_SAFE char *ida_export qmake_full_path (char *dst, size_t dstsize, const char *src)
 Convert relative path to absolute path.
idaman THREAD_SAFE bool ida_export search_path (char *buf, size_t bufsize, const char *file, bool search_cwd)
 Search for a file in the PATH environment variable or the current directory.
idaman THREAD_SAFE char *ida_export set_file_ext (char *outbuf, size_t bufsize, const char *file, const char *ext)
 Set file name extension unconditionally.
idaman THREAD_SAFE const char *ida_export get_file_ext (const char *file)
 Get pointer to extension of file name.
THREAD_SAFE bool idaapi has_file_ext (const char *file)
 Does the given file name have an extension?
THREAD_SAFE char *idaapi make_file_ext (char *buf, size_t bufsize, const char *file, const char *ext)
 Set file name extension if none exists.
idaman THREAD_SAFE bool ida_export sanitize_file_name (char *name, size_t namesize)
 Sanitize the file name.
bool wildcard_match (const char *name, const char *pattern)
 Match a name against a pattern.
bool wildcard_path_match (const char *name, const char *_pattern, int flags=0)
 Match a path against a pattern.
idaman int ida_export regex_match (const char *str, const char *pattern, bool sense_case)
 Match a string with a regular expression.
idaman THREAD_SAFE int ida_export qopen (const char *file, int mode)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE int ida_export qopen_shared (const char *file, int mode, int share_mode)
 Open file with given sharing_mode (use O_RDONLY, O_WRONLY, O_RDWR flags), sets qerrno.
idaman THREAD_SAFE int ida_export qcreate (const char *file, int stat)
 Create new file with O_RDWR, sets qerrno.
idaman THREAD_SAFE int ida_export qread (int h, void *buf, size_t n)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE int ida_export qwrite (int h, const void *buf, size_t n)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE qoff64_t ida_export qtell (int h)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE qoff64_t ida_export qseek (int h, int64 offset, int whence)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE int ida_export qclose (int h)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE int ida_export qdup (int h)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE int ida_export qfsync (int h)
 Works the same as it's counterpart from Clib.
idaman THREAD_SAFE uint64 ida_export qfilesize (const char *fname)
 Get the file size.
idaman THREAD_SAFE uint64 ida_export qfilelength (int h)
 Get file length in bytes.
idaman THREAD_SAFE int ida_export qchsize (int h, uint64 fsize)
 Change file size.
idaman THREAD_SAFE int ida_export qmkdir (const char *file, int mode)
 Create an empty directory.
idaman THREAD_SAFE int ida_export qrmdir (const char *file)
 Delete a directory.
idaman THREAD_SAFE bool ida_export qfileexist (const char *file)
 Does the given file exist?
idaman THREAD_SAFE bool ida_export qisdir (const char *file)
 Does the given path specify a directory?
idaman THREAD_SAFE int ida_export qstat (const char *path, struct qstatbuf *buf)
 Get file status.
idaman THREAD_SAFE int ida_export qfstat (int fd, struct qstatbuf *buf)
idaman THREAD_SAFE int ida_export qtouchfile (const char *file_name)
 touch: set access and modification times of the file to the current time
idaman THREAD_SAFE void ida_export qatexit (void(idaapi *func)(void))
 Add a function to be called at exit time.
idaman THREAD_SAFE void ida_export del_qatexit (void(idaapi *func)(void))
 Remove a previously added exit-time function.
idaman THREAD_SAFE NORETURN void ida_export qexit (int code)
 Call qatexit functions, shut down UI and kernel, and exit.
template<class T>
qabs (T x)
int qabs (int x)
INLINE THREAD_SAFE bool idaapi test_bit (const uchar *bitmap, size_t bit)
 Test if 'bit' is set in 'bitmap'.
INLINE THREAD_SAFE void idaapi set_bit (uchar *bitmap, size_t bit)
 Set 'bit' in 'bitmap'.
INLINE THREAD_SAFE void idaapi clear_bit (uchar *bitmap, size_t bit)
 Clear 'bit' in 'bitmap'.
INLINE THREAD_SAFE void idaapi set_bits (uchar *bitmap, size_t low, size_t high)
 Set bits between [low, high) in 'bitmap'.
INLINE THREAD_SAFE void idaapi clear_bits (uchar *bitmap, size_t low, size_t high)
 Clear bits between [low, high) in 'bitmap'.
INLINE THREAD_SAFE void idaapi set_all_bits (uchar *bitmap, size_t nbits)
 Set first 'nbits' of 'bitmap'.
INLINE THREAD_SAFE void idaapi clear_all_bits (uchar *bitmap, size_t nbits)
 Clear first 'nbits' of 'bitmap'.
idaman int ida_export log2ceil (uint64 d64)
 calculate ceil(log2(d64)) or floor(log2(d64)), it returns 0 if d64 == 0
idaman int ida_export log2floor (uint64 d64)
idaman int ida_export bitcount (uint64 x)
 count the number of non-zero bits (the population count)
idaman int ida_export bitcountr_zero (uint64 x)
 count the number of consecutive trailing zero bits (line C++20 std::countr_zero())
idaman uint32 ida_export round_up_power2 (uint32 x)
 round up or down to a power of 2
idaman uint32 ida_export round_down_power2 (uint32 x)
template<class T>
constexpr bool is_pow2 (T val)
 is power of 2? (or zero)
template<class T>
round_up (T val, T base)
 round up or down to an arbitrary number
template<class T>
round_down (T val, T base)
THREAD_SAFE constexpr uval_t interval::last (uval_t off, asize_t s)
 max offset of the interval (assume s != 0)
THREAD_SAFE constexpr bool interval::overlap (uval_t off1, asize_t s1, uval_t off2, asize_t s2)
 Do (off1,s1) and (off2,s2) overlap?
THREAD_SAFE constexpr bool interval::includes (uval_t off1, asize_t s1, uval_t off2, asize_t s2)
 Does (off1,s1) include (off2,s2)?
THREAD_SAFE constexpr bool interval::contains (uval_t off1, asize_t s1, uval_t off)
 Does (off1,s1) contain off?
template<class T>
constexpr T left_shift (const T &value, int shift)
 Shift by the amount exceeding the operand size*8 is undefined by the standard.
template<class T>
constexpr T right_ushift (const T &value, int shift)
 Shift by the amount exceeding the operand size*8 is undefined by the standard.
template<class T>
constexpr T right_sshift (const T &value, int shift)
 Shift by the amount exceeding the operand size*8 is undefined by the standard.
template<class T>
qrotl (T value, size_t count)
 Rotate left.
template<class T>
qrotr (T value, size_t count)
 Rotate right.
template<class T>
constexpr T make_mask (int count)
 Make a mask of 'count' bits.
template<class T, class U>
void idaapi setflag (T &where, U bit, bool cnd)
 Set a 'bit' in 'where' if 'value' if not zero.
template<class T>
bool is_mul_ok (T count, T elsize)
 Check that unsigned multiplication does not overflow.
template<class U, class T>
bool is_add_ok (U x, T y)
 Check that unsigned or unsigned+signed addition does not overflow.
template<class T>
bool is_udiv_ok (T, T b)
 Check that unsigned division is permissible.
template<class T>
bool is_sdiv_ok (T a, T b)
 Check that signed division is permissible.
template<typename T>
THREAD_SAFE constexpr T extend_sign_bits (T v, int nbits)
 Sign, or zero-extend V depending on the high bit of V.
idaman uint64 ida_export extend_sign (uint64 v, int nbytes, bool sign_extend)
 Sign-, or zero-extend the value 'v' to occupy 64 bits.
idaman THREAD_SAFE int ida_export readbytes (int h, uint32 *res, int size, bool mf)
 Read at most 4 bytes from file.
idaman THREAD_SAFE int ida_export writebytes (int h, uint32 l, int size, bool mf)
 Write at most 4 bytes to file.
idaman THREAD_SAFE int ida_export read2bytes (int h, uint16 *res, bool mf)
 Read a 2 byte entity from a file.
THREAD_SAFE constexpr uint32 swap32 (uint32 x)
THREAD_SAFE constexpr ushort swap16 (ushort x)
idaman THREAD_SAFE void ida_export swap_value (void *dst, const void *src, int size)
 Swap endianness of a given value in memory.
idaman THREAD_SAFE void ida_export reloc_value (void *value, int size, adiff_t delta, bool mf)
idaman THREAD_SAFE uval_t ida_export rotate_left (uval_t x, int count, size_t bits, size_t offset)
 Rotate left - can be used to rotate a value to the right if the count is negative.
template<class T>
THREAD_SAFE void qswap (T &a, T &b)
 Swap 2 objects of the same type using memory copies.
THREAD_SAFE uchar *idaapi pack_db (uchar *ptr, uchar *end, uchar x)
 Pack a byte into a character string.
THREAD_SAFE uchar idaapi unpack_db (const uchar **pptr, const uchar *end)
 Unpack a byte from a character string, pack_db()
idaman THREAD_SAFE uchar *ida_export pack_dw (uchar *ptr, uchar *end, uint16 x)
 pack a word, see pack_db()
idaman THREAD_SAFE uchar *ida_export pack_dd (uchar *ptr, uchar *end, uint32 x)
 pack a double word, see pack_db()
idaman THREAD_SAFE uchar *ida_export pack_dq (uchar *ptr, uchar *end, uint64 x)
 pack a quadword, see pack_db()
idaman THREAD_SAFE ushort ida_export unpack_dw (const uchar **pptr, const uchar *end)
 unpack a word, see unpack_db()
idaman THREAD_SAFE uint32 ida_export unpack_dd (const uchar **pptr, const uchar *end)
 unpack a double word, see unpack_db()
idaman THREAD_SAFE uint64 ida_export unpack_dq (const uchar **pptr, const uchar *end)
 unpack a quadword, see unpack_db()
THREAD_SAFE ucharpack_ea (uchar *ptr, uchar *end, ea_t ea)
 Pack an ea value into a character string, see pack_dd()/pack_dq()
THREAD_SAFE ea_t unpack_ea (const uchar **ptr, const uchar *end)
 Unpack an ea value, see unpack_dd()/unpack_dq()
THREAD_SAFE ea64_t unpack_ea64 (const uchar **ptr, const uchar *end)
 Unpack an ea value (always use 64bit, use delta 1)
THREAD_SAFE void *idaapi unpack_obj (void *destbuf, size_t destsize, const uchar **pptr, const uchar *end)
 Unpack an object of a known size.
THREAD_SAFE void *idaapi unpack_buf (const uchar **pptr, const uchar *end)
 Unpack an object of an unknown size (packed with append_buf()).
THREAD_SAFE const void *idaapi unpack_obj_inplace (const uchar **pptr, const uchar *end, size_t objsize)
 In-place version of unpack_obj().
THREAD_SAFE const void *idaapi unpack_buf_inplace (const uchar **pptr, const uchar *end)
 In-place version of unpack_buf().
idaman THREAD_SAFE uchar *ida_export pack_ds (uchar *ptr, uchar *end, const char *x, size_t len=0)
 Pack a string.
idaman THREAD_SAFE char *ida_export unpack_ds (const uchar **pptr, const uchar *end, bool empty_null)
 Unpack a string.
THREAD_SAFE bool unpack_ds_to_buf (char *dst, size_t dstsize, const uchar **pptr, const uchar *end)
 Unpack a string.
idaman THREAD_SAFE bool ida_export unpack_xleb128 (void *res, int nbits, bool is_signed, const uchar **pptr, const uchar *end)
 Unpack an LEB128 encoded (DWARF-3 style) signed/unsigned value.
template<class T>
THREAD_SAFE bool unpack_uleb128 (T *res, const uchar **pptr, const uchar *end)
template<class T>
THREAD_SAFE bool unpack_sleb128 (T *res, const uchar **pptr, const uchar *end)
THREAD_SAFE int ds_packed_size (const char *s)
THREAD_SAFE constexpr int dw_size (uchar first_byte)
THREAD_SAFE constexpr int dd_size (uchar first_byte)
template<class T>
THREAD_SAFE uchar extract_db (T &v)
template<class T>
THREAD_SAFE voidextract_obj (T &v, void *destbuf, size_t destsize)
template<class T>
THREAD_SAFE uint16 extract_dw (T &v)
template<class T>
THREAD_SAFE uint32 extract_dd (T &v)
template<class T>
THREAD_SAFE uint64 extract_dq (T &v)
template<class T>
THREAD_SAFE ea_t extract_ea (T &v)
template<class T>
THREAD_SAFE voidextract_buf (T &v, size_t size)
template<class T>
THREAD_SAFE voidextract_array (T &v, size_t *sz, size_t maxsize)
const char * unpack_str (const uchar **pptr, const uchar *end)
idaman THREAD_SAFE void *ida_export qalloc_or_throw (size_t size)
 qalloc() 'size' bytes, and throw a "not enough memory" error if failed
idaman THREAD_SAFE void *ida_export qrealloc_or_throw (void *ptr, size_t size)
 qrealloc() 'ptr' by 'size', and throw a "not enough memory" error if failed
idaman THREAD_SAFE void *ida_export qvector_reserve (void *vec, void *old, size_t cnt, size_t elsize)
 Change capacity of given qvector.
template<class T>
void shift_down (T *dst, T *src, size_t cnt)
 Move data down in memory.
template<class T>
void shift_up (T *dst, T *src, size_t cnt)
 Move data up in memory.
template<class T>
int lexcompare (const T &a, const T &b)
 Standard lexical comparison.
template<class T>
int lexcompare_vectors (const T &a, const T &b)
 Lexical comparison of two vectors.
idaman THREAD_SAFE bool ida_export relocate_relobj (struct relobj_t *_relobj, ea_t ea, bool mf)
THREAD_SAFE void unpack_eavec (eavec_t *vec, ea_t ea, const uchar **ptr, const uchar *end)
 Unpack a vector of ea values.
THREAD_SAFE bool unpack_bytevec (bytevec_t *out, const uchar **pptr, const uchar *end)
bool unpack_str (qstring *out, const uchar **pptr, const uchar *end)
template<class T, typename std::enable_if< has_compare_method< T >::value, int >::type = 0>
int compare (const T &a, const T &b)
template<class T>
int compare (const qvector< T > &a, const qvector< T > &b)
template<class T>
int compare (const qlist< T > &a, const qlist< T > &b)
template<class T, class U>
int compare (const std::pair< T, U > &a, const std::pair< T, U > &b)
template<class T>
int compare_containers (const T &l, const T &r)
 Template to compare any 2 containers of the same type. Returns -1/0/1.
template<class T, class U>
int compare (const std::map< T, U > &a, const std::map< T, U > &b)
template<class T>
int compare (const std::set< T > &a, const std::set< T > &b)
template<class T>
align_up (T val, int elsize)
 Align element up to nearest boundary.
template<class T>
align_down (T val, int elsize)
 Align element down to nearest boundary.
idaman THREAD_SAFE uint32 ida_export calc_crc32 (uint32 crc, const void *buf, size_t len)
 Calculate CRC32 (polynom 0xEDB88320, zlib compatible).
idaman THREAD_SAFE uint32 ida_export calc_file_crc32 (class linput_t *fp)
 Calculate an input source CRC32.
idaman THREAD_SAFE bool ida_export base64_encode (qstring *output, const void *input, size_t size)
 Encode base64.
idaman THREAD_SAFE bool ida_export base64_decode (bytevec_t *output, const char *input, size_t size)
 Decode base64.
idaman THREAD_SAFE bool ida_export replace_tabs (qstring *out, const char *str, int tabsize)
 Convert tabulations to spaces.
idaman THREAD_SAFE char *ida_export str2user (char *dst, const char *src, size_t dstsize)
 Make a user representation.
idaman THREAD_SAFE char *ida_export user2str (char *dst, const char *src, size_t dstsize)
 Make an internal representation.
idaman THREAD_SAFE char ida_export back_char (const char **p)
 Translate char after '\'.
idaman THREAD_SAFE void ida_export qstr2user (qstring *dst, const char *src, int nsyms=-1)
 see str2user()
THREAD_SAFE void qstr2user (qstring *dst, const qstring &src)
idaman THREAD_SAFE void ida_export user2qstr (qstring *dst, const qstring &src)
 see user2str()
idaman THREAD_SAFE void ida_export qstr2user (qstring *dst, const qstring *src)
 see str2user()
idaman THREAD_SAFE void ida_export user2qstr (qstring *dst, const qstring *src)
 see user2str()
constexpr bool is_utf8_head (char in)
 Does this byte correspond to the head of a UTF-8 byte sequence?
constexpr bool is_utf8_tail (char in)
 Does this byte correspond to the tail of a UTF-8 byte sequence?
idaman THREAD_SAFE bool ida_export is_valid_utf8 (const char *in)
 Does byte sequence consist of valid UTF-8-encoded codepoints?
idaman THREAD_SAFE bool ida_export utf8_utf16 (qwstring *out, const char *in, int nsyms=-1)
 UTF-8 -> UTF-16.
idaman THREAD_SAFE bool ida_export utf16_utf8 (qstring *out, const wchar16_t *in, int nsyms=-1)
 UTF-16 -> UTF-8.
constexpr bool is_lead_surrogate (wchar32_t wch)
constexpr bool is_tail_surrogate (wchar32_t wch)
constexpr wchar32_t utf16_surrogates_to_cp (wchar16_t lead_surrogate, wchar16_t tail_surrogate)
idaman THREAD_SAFE bool ida_export idb_utf8 (qstring *out, const char *in, int nsyms=-1, int flags=0)
 IDB default C string encoding -> UTF-8.
idaman THREAD_SAFE bool ida_export change_codepage (qstring *out, const char *in, int incp, int outcp)
INLINE THREAD_SAFE bool acp_utf8 (qstring *out, const char *in)
THREAD_SAFE constexpr wchar16_t utf8_wchar16 (uchar b0, uchar b1)
THREAD_SAFE constexpr wchar16_t utf8_wchar16 (uchar b0, uchar b1, uchar b2)
THREAD_SAFE constexpr wchar32_t utf8_wchar32 (uchar b0, uchar b1, uchar b2, uchar b3)
idaman THREAD_SAFE wchar32_t ida_export get_utf8_char (const char **pptr)
 Read one UTF-8 character from string. if error, return BADCP.
idaman THREAD_SAFE bool ida_export prev_utf8_char (wchar32_t *out_cp, const char **p, const char *begin)
 Get the UTF-8 character from string, before 'p'.
idaman THREAD_SAFE size_t ida_export skip_utf8 (const char **putf8, size_t n)
 Advance by n codepoints into the UTF-8 buffer.
idaman THREAD_SAFE ssize_t ida_export put_utf8_char (char *out, wchar32_t cp)
 Encode the codepoint into a UTF-8 byte sequence, and add terminating zero.
idaman THREAD_SAFE bool ida_export is_cp_graphical (wchar32_t cp)
 Is the provided codepoint graphical?
idaman THREAD_SAFE size_t ida_export qustrlen (const char *utf8)
idaman THREAD_SAFE bool ida_export qustrncpy (char *dst, const char *utf8, size_t dstsize)
 A safer strncpy - makes sure that there is a terminating zero.
idaman bool ida_export is_cvt64 ()
 is IDA converting IDB into I64?
idaman ssize_t ida_export convert_encoding (bytevec_t *out, const char *fromcode, const char *tocode, const uchar *indata, ssize_t insize, DEFARG(int flags, 0))
 Convert data from encoding fromcode into tocode.
ssize_t convert_encoding (bytevec_t *out, const char *fromcode, const char *tocode, const bytevec_t *indata, DEFARG(int flags, 0))
idaman THREAD_SAFE size_t ida_export parse_command_line (qstrvec_t *args, channel_redirs_t *redirs, const char *cmdline, int flags)
 Parse a space separated string (escaping with backslash is supported).
char ** expand_argv (int *p_argc, int argc, const char *const argv[])
 Copy and expand command line arguments.
INLINE void free_argv (int argc, char **argv)
 Free 'argc' elements of 'argv'.
idaman bool ida_export quote_cmdline_arg (qstring *arg)
 Quote a command line argument if it contains escape characters.
 DECLARE_TYPE_AS_MOVABLE (cliopt_t)
 DEFINE_PLUGIN_OPTION_T_HELPERS (idaman) struct plugin_option_t
 Named option, supports two kinds of options: string option: <name>=bool option: <name>=[on|off].
 DECLARE_TYPE_AS_MOVABLE (plugin_option_t)
idaman bool ida_export parse_plugin_options (plugin_options_t *opts, const char *optstring)
 Parse plugin options from IDA command line specified by -O<plugin_name>:<optstring> Note such options can be used not only for plugins, for example, currently we use them for merge (-Omerge:...) and vault server credentials (-Ovault:...)
idaman void ida_export build_plugin_options (qstring *out, const plugin_options_t &opts, const char *optname=nullptr)
 Build the plugin options, suitable for IDA command line of the form <name1>=<value1>:... If optname is provided, the -O<optname>: token will be prepended.
idaman bool ida_export parse_dbgopts (struct instant_dbgopts_t *ido, const char *r_switch)
 Parse the -r command line switch (for instant debugging).
idaman THREAD_SAFE void *ida_export launch_process (const launch_process_params_t &lpp, qstring *errbuf=nullptr)
 Launch the specified process in parallel.
idaman THREAD_SAFE void *ida_export launch_process (const struct launch_process_params_t *lpp, qstring *errbuf)
idaman THREAD_SAFE int ida_export term_process (void *handle)
 Forcibly terminate a running process.
idaman THREAD_SAFE int ida_export qwait_timed (int *status, int child, int flags, int timeout_ms)
 Wait for state changes in a child process (UNIX only).
THREAD_SAFE int qwait (int *status, int child, int flags)
idaman THREAD_SAFE int ida_export check_process_exit (void *handle, int *exit_code, DEFARG(int msecs,-1))
 Check whether process has terminated or not.
idaman THREAD_SAFE enum tty_control_t ida_export is_control_tty (int fd)
 Check if the current process is the owner of the TTY specified by 'fd' (typically an opened descriptor to /dev/tty).
idaman THREAD_SAFE void ida_export qdetach_tty (void)
 If the current terminal is the controlling terminal of the calling process, give up this controlling terminal.
idaman THREAD_SAFE void ida_export qcontrol_tty (void)
 Make the current terminal the controlling terminal of the calling process.
 OPAQUE_HANDLE (qthread_t)
idaman THREAD_SAFE qthread_t ida_export qthread_create (qthread_cb_t *thread_cb, void *ud)
 Create a thread and return a thread handle.
idaman THREAD_SAFE void ida_export qthread_free (qthread_t q)
 Free a thread resource (does not kill the thread) (calls pthread_detach under unix)
idaman THREAD_SAFE bool ida_export qthread_join (qthread_t q)
 Wait a thread until it terminates.
idaman THREAD_SAFE bool ida_export qthread_kill (qthread_t q)
 Forcefully kill a thread (calls pthread_cancel under unix)
idaman THREAD_SAFE qthread_t ida_export qthread_self (void)
 Get current thread. Must call qthread_free() to free it!
idaman THREAD_SAFE bool ida_export qthread_same (qthread_t q)
 Is the current thread the same as 'q'?
idaman THREAD_SAFE bool ida_export qthread_equal (qthread_t q1, qthread_t q2)
 Are two threads equal?
idaman THREAD_SAFE bool ida_export is_main_thread (void)
 Are we running in the main thread?
idaman THREAD_SAFE bool ida_export qsetenv (const char *varname, const char *value)
 Thread safe function to work with the environment.
idaman THREAD_SAFE bool ida_export qgetenv (const char *varname, DEFARG(qstring *buf, nullptr))
 Thread safe function to work with the environment.
 OPAQUE_HANDLE (qsemaphore_t)
 Semaphore.
idaman THREAD_SAFE qsemaphore_t ida_export qsem_create (const char *name, int init_count)
 Create a new semaphore.
idaman THREAD_SAFE bool ida_export qsem_free (qsemaphore_t sem)
 Free a semaphore.
idaman THREAD_SAFE bool ida_export qsem_post (qsemaphore_t sem)
 Unlock a semaphore.
idaman THREAD_SAFE bool ida_export qsem_wait (qsemaphore_t sem, int timeout_ms)
 Lock and decrement a semaphore. timeout = -1 means block indefinitely.
 OPAQUE_HANDLE (qmutex_t)
 Mutex.
idaman THREAD_SAFE bool ida_export qmutex_free (qmutex_t m)
 Free a mutex.
idaman THREAD_SAFE qmutex_t ida_export qmutex_create (void)
 Create a new mutex.
idaman THREAD_SAFE bool ida_export qmutex_lock (qmutex_t m)
 Lock a mutex.
idaman THREAD_SAFE bool ida_export qmutex_unlock (qmutex_t m)
 Unlock a mutex.
idaman THREAD_SAFE int ida_export qpipe_create (qhandle_t handles[2])
 Create a pipe.
idaman THREAD_SAFE ssize_t ida_export qpipe_read (qhandle_t handle, void *buf, size_t size)
 Read from a pipe.
idaman THREAD_SAFE bool ida_export qpipe_read_n (qhandle_t handle, bytevec_t *out_bytes, size_t n)
 Read a specific amount of bytes from a pipe.
idaman THREAD_SAFE ssize_t ida_export qpipe_write (qhandle_t handle, const void *buf, size_t size)
 Write to a pipe.
idaman THREAD_SAFE int ida_export qpipe_close (qhandle_t handle)
 Close a pipe.
idaman void *ida_export pipe_process (qhandle_t *read_handle, qhandle_t *write_handle, launch_process_params_t *lpp, qstring *errbuf=nullptr)
 Launch a process and establish 2-way comminucation with it.
idaman THREAD_SAFE int ida_export qwait_for_handles (int *idx, const qhandle_t *handles, int n, uint32 write_bitmask, int timeout_ms)
 Wait for file/socket/pipe handles.
idaman THREAD_SAFE bool ida_export get_login_name (qstring *out)
 Get the user name for the current desktop session.
idaman THREAD_SAFE int ida_export get_physical_core_count ()
 Get the total CPU physical core count.
idaman THREAD_SAFE int ida_export get_logical_core_count ()
 Get the total CPU logical core count.
idaman THREAD_SAFE int ida_export get_available_core_count ()
 Get the number of logical CPU cores available to the current process if supported by the OS.
qstrlen

Get the length of the given string

THREAD_SAFE size_t idaapi qstrlen (const char *s)
THREAD_SAFE size_t idaapi qstrlen (const uchar *s)
idaman THREAD_SAFE size_t ida_export qstrlen (const wchar16_t *s)
qstrcmp

Lexical comparison of strings.

Returns
code
Return values
0if two strings are identical
>0 if 's1' is larger than 's2'
<0 if 's2' is larger than 's1'
otherwisereturn first nonzero comparison between chars in 's1' and 's2'
THREAD_SAFE int idaapi qstrcmp (const char *s1, const char *s2)
THREAD_SAFE int idaapi qstrcmp (const uchar *s1, const uchar *s2)
idaman THREAD_SAFE int ida_export qstrcmp (const wchar16_t *s1, const wchar16_t *s2)
qstrncmp

Lexical comparison of string prefixes.

Returns
code
Return values
0if two strings are identical
>0 if 's1' is larger than 's2'
<0 if 's2' is larger than 's1'
otherwisereturn first nonzero comparison between chars in 's1' and 's2'
THREAD_SAFE int idaapi qstrncmp (const char *s1, const char *s2, size_t len)
THREAD_SAFE int idaapi qstrncmp (const uchar *s1, const uchar *s2, size_t len)
idaman THREAD_SAFE int ida_export qstrncmp (const wchar16_t *s1, const wchar16_t *s2, size_t len)
qstrstr

Find a string within another string.

Returns
a pointer to the first occurrence of 's2' within 's1', nullptr if s2 is not found in s1
THREAD_SAFE char *idaapi qstrstr (char *s1, const char *s2)
THREAD_SAFE const char *idaapi qstrstr (const char *s1, const char *s2)
THREAD_SAFE const uchar *idaapi qstrstr (const uchar *s1, const uchar *s2)
strchr

Find a character within a string.

Returns
a pointer to the first occurrence of 'c' within 's1', nullptr if c is not found in s1
THREAD_SAFE char *idaapi qstrchr (char *s1, char c)
THREAD_SAFE const char *idaapi qstrchr (const char *s1, char c)
THREAD_SAFE uchar *idaapi qstrchr (uchar *s1, uchar c)
THREAD_SAFE const uchar *idaapi qstrchr (const uchar *s1, uchar c)
idaman THREAD_SAFE const wchar16_t *ida_export qstrchr (const wchar16_t *s1, wchar16_t c)
THREAD_SAFE wchar16_t *idaapi qstrchr (wchar16_t *s1, wchar16_t c)
qstrrchr

Find a last occurrence of a character within a string.

Returns
a pointer to the last occurrence of 'c' within 's1', nullptr if c is not found in s1
THREAD_SAFE const char *idaapi qstrrchr (const char *s1, char c)
THREAD_SAFE char *idaapi qstrrchr (char *s1, char c)
THREAD_SAFE const uchar *idaapi qstrrchr (const uchar *s1, uchar c)
THREAD_SAFE uchar *idaapi qstrrchr (uchar *s1, uchar c)
idaman THREAD_SAFE const wchar16_t *ida_export qstrrchr (const wchar16_t *s1, wchar16_t c)
THREAD_SAFE wchar16_t *idaapi qstrrchr (wchar16_t *s1, wchar16_t c)

Variables

constexpr diffpos_t BADDIFF = diffpos_t(-1)
idaman size_t bufsize
idaman size_t const char * format
idaman size_t const char time_t t
idaman bool ida_export_data under_debugger
 is IDA running under a debugger?
idaman size_t n
idaman size_t const char idaman const char idaman size_t const char va_list va
 See qsnprintf()
idaman const char * end
const qhandle_t NULL_PIPE_HANDLE = nullptr

Detailed Description

This is the first header included in the IDA project.

It defines the most common types, functions and data. Also, it tries to make system dependent definitions.

The following preprocessor macros are used in the project (the list may be incomplete)

Platform must be specified as one of:

NT - MS Windows (all platforms)
LINUX - Linux
MAC - MAC OS X

EA64 - 64-bit address size (sizeof(ea_t)==8)
X86 - 32-bit debug servers (sizeof(void*)==4)
X64 - x64 processor (sizeof(void*)==8) default
PPC - PowerPC
ARM - ARM

Typedef Documentation

◆ bool

typedef int bool

◆ uchar

typedef unsigned char uchar

unsigned 8 bit value

◆ ushort

typedef unsigned short ushort

unsigned 16 bit value

◆ uint

typedef unsigned int uint

unsigned 32 bit value

◆ int8

typedef char int8

signed 8 bit value

◆ sint8

typedef signed char sint8

signed 8 bit value

◆ uint8

typedef unsigned char uint8

unsigned 8 bit value

◆ int16

typedef short int16

signed 16 bit value

◆ uint16

typedef unsigned short uint16

unsigned 16 bit value

◆ int32

typedef int int32

signed 32 bit value

◆ uint32

typedef unsigned int uint32

unsigned 32 bit value

◆ wchar16_t

typedef uint16 wchar16_t

◆ wchar32_t

typedef uint32 wchar32_t

◆ ssize_t

typedef ptrdiff_t ssize_t

Signed size_t - used to check for size overflows when the counter becomes negative.

Also signed size_t allows us to signal an error condition using a negative value, for example, as a function return value.

◆ ea_t

typedef uint32 ea_t

◆ sel_t

typedef uint32 sel_t

◆ asize_t

typedef uint32 asize_t

◆ adiff_t

typedef int32 adiff_t

◆ uval_t

typedef asize_t uval_t

unsigned value used by the processor.

◆ sval_t

typedef adiff_t sval_t

signed value used by the processor.

◆ ea32_t

typedef uint32 ea32_t

32-bit address, regardless of IDA bitness.

this type can be used when we know in advance that 32 bits are enough to hold an address.

◆ ea64_t

typedef uint64 ea64_t

64-bit address, regardless of IDA bitness.

we need this type for interoperability with debug servers, lumina, etc

◆ error_t

typedef int error_t

Error code (errno)

◆ op_dtype_t

typedef uint8 op_dtype_t

◆ inode_t

typedef uval_t inode_t

The inode_t type is the specialization specific inode number.

For example, it can represent a local type ordinal or a structure id.

◆ diffpos_t

typedef size_t diffpos_t

◆ qtime32_t

typedef int32 qtime32_t

we use our own time type because time_t can be 32-bit or 64-bit depending on the compiler

◆ qtime64_t

typedef uint64 qtime64_t

64-bit time value expressed as seconds and microseconds since the Epoch

◆ uvalvec_t

vector of unsigned values

◆ svalvec_t

vector of signed values

◆ eavec_t

typedef qvector<ea_t> eavec_t

vector of addresses

◆ intvec_t

typedef qvector<int> intvec_t

vector of integers

◆ boolvec_t

vector of bools

◆ sizevec_t

typedef qvector<size_t> sizevec_t

vector of sizes

◆ qstring

typedef struct qstring_tag qstring

regular string

◆ qtype

typedef _qstring<uchar> qtype

type string

◆ qwstring

typedef struct qwstring_tag qwstring

unicode string

◆ qstrvec_t

typedef struct qstrvec_tag qstrvec_t

vector of strings

◆ qwstrvec_t

vector of unicode strings

◆ qalloc_janitor_t

template<typename T>
using qalloc_janitor_t = std::unique_ptr<T, qfree_deleter_t<T>>

◆ qvoid_t

template<class...>
using qvoid_t = void

◆ bytevec_t

typedef struct bytevec_tag bytevec_t

◆ flags_t

typedef uint32 flags_t

32-bit flags for each address

◆ flags64_t

typedef uint64 flags64_t

64-bit flags for each address

◆ tid_t

typedef ea_t tid_t

type id (for enums, structs, etc)

◆ bgcolor_t

typedef uint32 bgcolor_t

background color in RGB

◆ channel_redirs_t

typedef struct channel_redirs_tag channel_redirs_t

vector of channel_redir_t objects

◆ cliopt_handler_t

typedef void cliopt_handler_t(const char *value, void *ud)

◆ cliopt_poly_handler_t

typedef void cliopt_poly_handler_t(int argc, const char **argv, void *ud)

◆ plugin_option_vec_t

typedef qvector<plugin_option_t> plugin_option_vec_t

◆ qthread_cb_t

typedef int idaapi qthread_cb_t(void *ud)

THREADS.

Thread callback function

◆ qhandle_t

typedef int qhandle_t

MS Windows HANDLE.

file handle in Unix

Enumeration Type Documentation

◆ tty_control_t

Teletype control.

Enumerator
TCT_UNKNOWN 
TCT_OWNER 
TCT_NOT_OWNER 

Function Documentation

◆ qatoll()

INLINE int64 qatoll ( const char * nptr)

◆ get_secs()

INLINE THREAD_SAFE uint32 get_secs ( qtime64_t t)

Get the 'seconds since the epoch' part of a qtime64_t.

◆ get_usecs()

INLINE THREAD_SAFE uint32 get_usecs ( qtime64_t t)

Get the microseconds part of a qtime64_t.

◆ make_qtime64()

INLINE THREAD_SAFE qtime64_t make_qtime64 ( uint32 secs,
DEFARG(int32 usecs, 0)  )

Get a qtime64_t instance from a seconds value and microseconds value.

Parameters
secsseconds
usecsmicroseconds

◆ qctime()

idaman THREAD_SAFE bool ida_export qctime ( char * buf,
size_t bufsize,
qtime32_t t )

Converts calendar time into a string.

Puts 'wrong timestamp\n' into the buffer if failed

Parameters
bufoutput buffer
bufsizesize of the output buffer
tcalendar time
Returns
success See also qstrftime()

◆ qctime_utc()

idaman THREAD_SAFE bool ida_export qctime_utc ( char * buf,
size_t bufsize,
qtime32_t t )

Converts calendar time into a string using Coordinated Universal Time (UTC).

Function is equivalent to asctime(gmtime(t)). Puts 'wrong timestamp\n' into the buffer if failed.

Parameters
bufoutput buffer
bufsizeof the output buffer
tcalendar time
Returns
success

◆ qlocaltime()

idaman THREAD_SAFE bool ida_export qlocaltime ( struct tm * _tm,
time_t t )

Converts a time value to a tm structure (local time)

Parameters
[out]_tmresult
tcalendar time
Returns
success

◆ qlocaltime64()

INLINE THREAD_SAFE bool qlocaltime64 ( struct tm * _tm,
qtime64_t t )

Same as qlocaltime(struct tm *, time_t), but accepts a 64-bit time value.

◆ qgmtime()

idaman bool ida_export qgmtime ( struct tm * _tm,
time_t t )

Converts a time value to a tm structure (UTC time)

Parameters
[out]_tmresult
tcalendar time
Returns
success

◆ qgmtime64()

INLINE THREAD_SAFE bool qgmtime64 ( struct tm * _tm,
qtime64_t t )

Same as qgmtime(struct tm *, time_t), but accepts a 64-bit time value.

◆ qtimegm()

idaman time_t ida_export qtimegm ( const struct tm * ptm)

◆ AS_STRFTIME()

idaman AS_STRFTIME ( 3 )

Get string representation of a time_t (local time) Copies into 'buf' the content of 'format', expanding its format specifiers into the corresponding values that represent the time described in 't', with a limit of 'bufsize' characters see http://www.cplusplus.com/reference/ctime/strftime/ for more.

Same as qstrftime(), but accepts a 64-bit time value.

Parameters
bufoutput buffer
bufsizeof the output buffer
formatformat string
tcalendar time value
Returns
length of the resulting string See also qctime()

◆ qsleep()

idaman THREAD_SAFE void ida_export qsleep ( int milliseconds)

Suspend execution for given number of milliseconds.

◆ get_nsec_stamp()

idaman THREAD_SAFE uint64 ida_export get_nsec_stamp ( void )

High resolution timer.

On Unix systems, returns current time in nanoseconds. On Windows, returns a high resolution counter (QueryPerformanceCounter)

Returns
stamp in nanoseconds

◆ qtime64()

idaman THREAD_SAFE qtime64_t ida_export qtime64 ( void )

Get the current time with microsecond resolution (in fact the resolution is worse on windows)

◆ gen_rand_buf()

idaman THREAD_SAFE bool ida_export gen_rand_buf ( void * buffer,
size_t bufsz )

Generate a random buffer.

Parameters
[out]bufferpointer to result
bufszsize of buffer
Returns
success

◆ set_qerrno()

idaman THREAD_SAFE error_t ida_export set_qerrno ( error_t code)

Set qerrno.

◆ get_qerrno()

idaman THREAD_SAFE error_t ida_export get_qerrno ( void )

Get qerrno.

◆ __debugbreak()

NORETURN void __debugbreak ( void )

◆ interr()

idaman THREAD_SAFE NORETURN void ida_export interr ( int code)

Show internal error message and terminate execution.

◆ set_interr_throws()

idaman THREAD_SAFE bool ida_export set_interr_throws ( bool enable)
Parameters
enableif true, interr() throws interr_exc_t otherwise it terminates IDA after showing an error message
Returns
previous setting

◆ qalloc()

idaman THREAD_SAFE void *ida_export qalloc ( size_t size)

System independent malloc.

◆ qrealloc()

idaman THREAD_SAFE void *ida_export qrealloc ( void * alloc,
size_t newsize )

System independent realloc.

◆ qcalloc()

idaman THREAD_SAFE void *ida_export qcalloc ( size_t nitems,
size_t itemsize )

System independent calloc.

◆ qfree()

idaman THREAD_SAFE void ida_export qfree ( void * alloc)

System independent free.

◆ qstrdup()

idaman THREAD_SAFE char *ida_export qstrdup ( const char * string)

System independent strdup.

◆ qalloc_array()

template<class T>
T * qalloc_array ( size_t n)

Use this class to avoid integer overflows when allocating arrays.

◆ qrealloc_array()

template<class T>
T * qrealloc_array ( T * ptr,
size_t n )

Use this class to avoid integer overflows when allocating arrays.

◆ memrev()

idaman THREAD_SAFE void *ida_export memrev ( void * buf,
ssize_t size )

Reverse memory block.

Analog of strrev() function

Parameters
bufpointer to buffer to reverse
sizesize of buffer
Returns
pointer to buffer

◆ memicmp()

idaman THREAD_SAFE int ida_export memicmp ( const void * x,
const void * y,
size_t size )

◆ strrpl()

idaman THREAD_SAFE char *ida_export strrpl ( char * str,
int char1,
int char2 )

Replace all occurrences of a character within a string.

Parameters
strto modify
char1char to be replaced
char2replacement char
Returns
pointer to resulting string

◆ tail() [1/2]

INLINE THREAD_SAFE char * tail ( char * str)

Get tail of a string.

◆ tail() [2/2]

THREAD_SAFE const char * tail ( const char * str)
inline

Get tail of a string.

◆ qstrncpy()

idaman THREAD_SAFE char *ida_export qstrncpy ( char * dst,
const char * src,
size_t dstsize )

A safer strncpy - makes sure that there is a terminating zero.

nb: this function doesn't fill the whole buffer zeroes as strncpy does nb: ssize_t(dstsize) must be > 0

◆ qstpncpy()

idaman THREAD_SAFE char *ida_export qstpncpy ( char * dst,
const char * src,
size_t dstsize )

A safer stpncpy - returns pointer to the end of the destination nb: ssize_t(dstsize) must be > 0.

◆ qstrncat()

idaman THREAD_SAFE char *ida_export qstrncat ( char * dst,
const char * src,
size_t dstsize )

A safer strncat - accepts the size of the 'dst' as 'dstsize' and returns dst nb: ssize_t(dstsize) must be > 0.

◆ qstrtok()

idaman THREAD_SAFE char *ida_export qstrtok ( char * s,
const char * delim,
char ** save_ptr )

Thread-safe version of strtok.

◆ qstrlwr()

idaman THREAD_SAFE char *ida_export qstrlwr ( char * str)

Convert the string to lowercase.

◆ qstrupr()

idaman THREAD_SAFE char *ida_export qstrupr ( char * str)

Convert the string to uppercase.

◆ stristr() [1/2]

idaman THREAD_SAFE const char *ida_export stristr ( const char * s1,
const char * s2 )

Find one string in another (Case insensitive analog of strstr()).

Parameters
s1string to be searched
s2string to search for
Returns
a pointer to the first occurrence of s2 within s1, nullptr if none exists

◆ stristr() [2/2]

char *idaapi stristr ( char * s1,
const char * s2 )
inline

Same as stristr(const char *, const char *) but returns a non-const result.

◆ qtolower()

INLINE THREAD_SAFE int ida_local qtolower ( char c)

Get lowercase equivalent of given char.

◆ qtoupper()

INLINE THREAD_SAFE int ida_local qtoupper ( char c)

Get uppercase equivalent of given char.

◆ GCC_DIAG_OFF()

idaman const char const char GCC_DIAG_OFF ( format- nonliteral)

Append result of sprintf to 'buf'.

qsnprintf that does not check its arguments. Normally gcc complains about the non-literal formats. However, sometimes we still need to call qsnprintf with a dynamically built format string. OTOH, there are absolutely no checks of the input arguments, so be careful!

◆ nowarn_qsnprintf()

INLINE int nowarn_qsnprintf ( char * buf,
size_t size,
const char * format,
... )

◆ GCC_DIAG_ON()

GCC_DIAG_ON ( format- nonliteral)

◆ vqmakepath()

idaman THREAD_SAFE char *ida_export vqmakepath ( char * buf,
size_t bufsize,
const char * s1,
va_list  )

◆ qmakepath()

idaman THREAD_SAFE char *ida_export qmakepath ( char * buf,
size_t bufsize,
const char * s1,
... )

Construct a path from a null-terminated sequence of strings.

Parameters
bufoutput buffer. Can be == s1, but must not be nullptr
bufsizesize of buffer
s1the first path component. it may be followed by more components. the argument list must end with nullptr.
Returns
pointer to result

◆ qgetcwd()

idaman void ida_export qgetcwd ( char * buf,
size_t bufsize )

Get the current working directory.

Parameters
bufoutput buffer
bufsizesize of buffer This function calls error() if any problem occurs.

◆ qchdir()

idaman int ida_export qchdir ( const char * path)

Change the current working directory.

Parameters
paththe new directory The possible return values are the same as those of the POSIX 'chdir'

◆ qdirname()

idaman THREAD_SAFE bool ida_export qdirname ( char * buf,
size_t bufsize,
const char * path )

Get the directory part of the path.

path and buf may point to the same buffer

Parameters
[out]bufbuffer for the directory part. can be nullptr.
[out]bufsizesize of this buffer
pathpath to split
Return values
trueok
falseinput buffer did not have the directory part. In this case the buffer is filled with "."

◆ qmakefile()

idaman THREAD_SAFE char *ida_export qmakefile ( char * buf,
size_t bufsize,
const char * base,
const char * ext )

Construct filename from base name and extension.

Parameters
bufoutput buffer. Can be == base, but must not be nullptr
bufsizesize of buffer
basebase name
extextension
Returns
pointer to result

◆ qsplitfile()

idaman THREAD_SAFE char *ida_export qsplitfile ( char * file,
char ** base,
char ** ext )

Split filename into base name and extension.

Parameters
filefilename, may be changed
basefilled with base part, can be nullptr
extfilled with extension part, can be nullptr
Returns
the base part

◆ qisabspath()

idaman THREAD_SAFE bool ida_export qisabspath ( const char * file)

Is the file name absolute (not relative to the current dir?)

◆ qbasename() [1/2]

idaman THREAD_SAFE const char *ida_export qbasename ( const char * path)

Get the file name part of the given path.

Returns
nullptr if path is nullptr

◆ qbasename() [2/2]

char * qbasename ( char * path)
inline

Same as qbasename(const char *), but accepts and returns non-const char pointers.

◆ qmake_full_path()

idaman THREAD_SAFE char *ida_export qmake_full_path ( char * dst,
size_t dstsize,
const char * src )

Convert relative path to absolute path.

◆ search_path()

idaman THREAD_SAFE bool ida_export search_path ( char * buf,
size_t bufsize,
const char * file,
bool search_cwd )

Search for a file in the PATH environment variable or the current directory.

Parameters
bufoutput buffer to hold the full file path
bufsizeoutput buffer size
filethe file name to look for. If the file is an absolute path then buf will return the file value.
search_cwdsearch the current directory if file was not found in the PATH
Returns
true if the file was found and false otherwise

◆ set_file_ext()

idaman THREAD_SAFE char *ida_export set_file_ext ( char * outbuf,
size_t bufsize,
const char * file,
const char * ext )

Set file name extension unconditionally.

Parameters
outbufbuffer to hold the answer. may be the same as the file name.
bufsizeoutput buffer size
filethe file name
extnew extension (with or without '.')
Returns
pointer to the new file name

◆ get_file_ext()

idaman THREAD_SAFE const char *ida_export get_file_ext ( const char * file)

Get pointer to extension of file name.

Parameters
filefilename
Returns
pointer to the file extension or nullptr if extension doesn't exist

◆ has_file_ext()

THREAD_SAFE bool idaapi has_file_ext ( const char * file)
inline

Does the given file name have an extension?

◆ make_file_ext()

THREAD_SAFE char *idaapi make_file_ext ( char * buf,
size_t bufsize,
const char * file,
const char * ext )
inline

Set file name extension if none exists.

This function appends the extension to a file name. It won't change file name if extension already exists

Parameters
bufoutput buffer
bufsizesize of the output buffer
filefile name
extextension (with or without '.')
Returns
pointer to the new file name

◆ sanitize_file_name()

idaman THREAD_SAFE bool ida_export sanitize_file_name ( char * name,
size_t namesize )

Sanitize the file name.

Remove the directory path, and replace wildcards ? * and chars<' ' with _. If the file name is empty, then:

  • namesize != 0: generate a new temporary name, return true
  • namesize == 0: return false

◆ wildcard_match()

bool wildcard_match ( const char * name,
const char * pattern )

Match a name against a pattern.

Only * and ? wildcards are supported.

Parameters
namename to match
patternpattern to match against
Returns
true is matched

◆ wildcard_path_match()

bool wildcard_path_match ( const char * name,
const char * _pattern,
int flags = 0 )

Match a path against a pattern.

**, *, ?, and ranges like [a-zA-Z] are supported.

Parameters
namename to match
_patternpattern to match against
flagscombination of WPM_... bits
Returns
true is matched

◆ regex_match()

idaman int ida_export regex_match ( const char * str,
const char * pattern,
bool sense_case )

Match a string with a regular expression.

Return values
0no match
1match
-1error

◆ qopen()

idaman THREAD_SAFE int ida_export qopen ( const char * file,
int mode )

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qopen_shared()

idaman THREAD_SAFE int ida_export qopen_shared ( const char * file,
int mode,
int share_mode )

Open file with given sharing_mode (use O_RDONLY, O_WRONLY, O_RDWR flags), sets qerrno.

◆ qcreate()

idaman THREAD_SAFE int ida_export qcreate ( const char * file,
int stat )

Create new file with O_RDWR, sets qerrno.

◆ qread()

idaman THREAD_SAFE int ida_export qread ( int h,
void * buf,
size_t n )

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qwrite()

idaman THREAD_SAFE int ida_export qwrite ( int h,
const void * buf,
size_t n )

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qtell()

idaman THREAD_SAFE qoff64_t ida_export qtell ( int h)

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qseek()

idaman THREAD_SAFE qoff64_t ida_export qseek ( int h,
int64 offset,
int whence )

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qclose()

idaman THREAD_SAFE int ida_export qclose ( int h)

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qdup()

idaman THREAD_SAFE int ida_export qdup ( int h)

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qfsync()

idaman THREAD_SAFE int ida_export qfsync ( int h)

Works the same as it's counterpart from Clib.

The only difference is that it sets 'qerrno' variable too

◆ qfilesize()

idaman THREAD_SAFE uint64 ida_export qfilesize ( const char * fname)

Get the file size.

This function may return 0 if the file is not found.

◆ qfilelength()

idaman THREAD_SAFE uint64 ida_export qfilelength ( int h)

Get file length in bytes.

Parameters
hfile descriptor
Returns
file length in bytes, -1 if error

◆ qchsize()

idaman THREAD_SAFE int ida_export qchsize ( int h,
uint64 fsize )

Change file size.

Parameters
hfile descriptor
fsizedesired size
Return values
0on success
-1otherwise and qerrno is set

◆ qmkdir()

idaman THREAD_SAFE int ida_export qmkdir ( const char * file,
int mode )

Create an empty directory.

Parameters
filename (or full path) of directory to be created
modepermissions (only used on unix systems)
Returns
error code
Return values
0success
-1otherwise and qerrno is set

◆ qrmdir()

idaman THREAD_SAFE int ida_export qrmdir ( const char * file)

Delete a directory.

Parameters
filename (or full path) of directory to be removed
Returns
error code
Return values
0success
-1otherwise and qerrno is set

◆ qfileexist()

idaman THREAD_SAFE bool ida_export qfileexist ( const char * file)

Does the given file exist?

◆ qisdir()

idaman THREAD_SAFE bool ida_export qisdir ( const char * file)

Does the given path specify a directory?

◆ qstat()

idaman THREAD_SAFE int ida_export qstat ( const char * path,
struct qstatbuf * buf )

Get file status.

◆ qfstat()

idaman THREAD_SAFE int ida_export qfstat ( int fd,
struct qstatbuf * buf )

◆ qtouchfile()

idaman THREAD_SAFE int ida_export qtouchfile ( const char * file_name)

touch: set access and modification times of the file to the current time

◆ qatexit()

idaman THREAD_SAFE void ida_export qatexit ( void(idaapi *func)(void) )

Add a function to be called at exit time.

◆ del_qatexit()

idaman THREAD_SAFE void ida_export del_qatexit ( void(idaapi *func)(void) )

Remove a previously added exit-time function.

◆ qexit()

idaman THREAD_SAFE NORETURN void ida_export qexit ( int code)

Call qatexit functions, shut down UI and kernel, and exit.

Parameters
codeexit code

◆ qabs() [1/2]

template<class T>
T qabs ( T x)

◆ qabs() [2/2]

int qabs ( int x)

◆ test_bit()

INLINE THREAD_SAFE bool idaapi test_bit ( const uchar * bitmap,
size_t bit )

Test if 'bit' is set in 'bitmap'.

◆ set_bit()

INLINE THREAD_SAFE void idaapi set_bit ( uchar * bitmap,
size_t bit )

Set 'bit' in 'bitmap'.

◆ clear_bit()

INLINE THREAD_SAFE void idaapi clear_bit ( uchar * bitmap,
size_t bit )

Clear 'bit' in 'bitmap'.

◆ set_bits()

INLINE THREAD_SAFE void idaapi set_bits ( uchar * bitmap,
size_t low,
size_t high )

Set bits between [low, high) in 'bitmap'.

◆ clear_bits()

INLINE THREAD_SAFE void idaapi clear_bits ( uchar * bitmap,
size_t low,
size_t high )

Clear bits between [low, high) in 'bitmap'.

◆ set_all_bits()

INLINE THREAD_SAFE void idaapi set_all_bits ( uchar * bitmap,
size_t nbits )

Set first 'nbits' of 'bitmap'.

◆ clear_all_bits()

INLINE THREAD_SAFE void idaapi clear_all_bits ( uchar * bitmap,
size_t nbits )

Clear first 'nbits' of 'bitmap'.

◆ log2ceil()

idaman int ida_export log2ceil ( uint64 d64)

calculate ceil(log2(d64)) or floor(log2(d64)), it returns 0 if d64 == 0

◆ log2floor()

idaman int ida_export log2floor ( uint64 d64)

◆ bitcount()

idaman int ida_export bitcount ( uint64 x)

count the number of non-zero bits (the population count)

◆ bitcountr_zero()

idaman int ida_export bitcountr_zero ( uint64 x)

count the number of consecutive trailing zero bits (line C++20 std::countr_zero())

◆ round_up_power2()

idaman uint32 ida_export round_up_power2 ( uint32 x)

round up or down to a power of 2

◆ round_down_power2()

idaman uint32 ida_export round_down_power2 ( uint32 x)

◆ is_pow2()

template<class T>
bool is_pow2 ( T val)
constexpr

is power of 2? (or zero)

◆ round_up()

template<class T>
T round_up ( T val,
T base )

round up or down to an arbitrary number

◆ round_down()

template<class T>
T round_down ( T val,
T base )

◆ left_shift()

template<class T>
T left_shift ( const T & value,
int shift )
constexpr

Shift by the amount exceeding the operand size*8 is undefined by the standard.

Indeed, GNUC may decide not to rotate the operand in some cases. We have to check this manually.

◆ right_ushift()

template<class T>
T right_ushift ( const T & value,
int shift )
constexpr

Shift by the amount exceeding the operand size*8 is undefined by the standard.

Indeed, GNUC may decide not to rotate the operand in some cases. We have to check this manually.

◆ right_sshift()

template<class T>
T right_sshift ( const T & value,
int shift )
constexpr

Shift by the amount exceeding the operand size*8 is undefined by the standard.

Indeed, GNUC may decide not to rotate the operand in some cases. We have to check this manually.

◆ qrotl()

template<class T>
T qrotl ( T value,
size_t count )

Rotate left.

◆ qrotr()

template<class T>
T qrotr ( T value,
size_t count )

Rotate right.

◆ make_mask()

template<class T>
T make_mask ( int count)
constexpr

Make a mask of 'count' bits.

◆ setflag()

template<class T, class U>
void idaapi setflag ( T & where,
U bit,
bool cnd )

Set a 'bit' in 'where' if 'value' if not zero.

◆ is_mul_ok()

template<class T>
bool is_mul_ok ( T count,
T elsize )

Check that unsigned multiplication does not overflow.

◆ is_add_ok()

template<class U, class T>
bool is_add_ok ( U x,
T y )

Check that unsigned or unsigned+signed addition does not overflow.

◆ is_udiv_ok()

template<class T>
bool is_udiv_ok ( T ,
T b )

Check that unsigned division is permissible.

◆ is_sdiv_ok()

template<class T>
bool is_sdiv_ok ( T a,
T b )

Check that signed division is permissible.

◆ extend_sign_bits()

template<typename T>
THREAD_SAFE constexpr T extend_sign_bits ( T v,
int nbits )
inlineconstexpr

Sign, or zero-extend V depending on the high bit of V.

V is considered to be of NBITS bits.

◆ extend_sign()

idaman uint64 ida_export extend_sign ( uint64 v,
int nbytes,
bool sign_extend )

Sign-, or zero-extend the value 'v' to occupy 64 bits.

The value 'v' is considered to be of size 'nbytes'.

◆ readbytes()

idaman THREAD_SAFE int ida_export readbytes ( int h,
uint32 * res,
int size,
bool mf )

Read at most 4 bytes from file.

Parameters
hfile handle
resvalue read from file
sizesize of value in bytes (1,2,4)
mfis MSB first?
Returns
0 on success, nonzero otherwise

◆ writebytes()

idaman THREAD_SAFE int ida_export writebytes ( int h,
uint32 l,
int size,
bool mf )

Write at most 4 bytes to file.

Parameters
hfile handle
lvalue to write
sizesize of value in bytes (1,2,4)
mfis MSB first?
Returns
0 on success, nonzero otherwise

◆ read2bytes()

idaman THREAD_SAFE int ida_export read2bytes ( int h,
uint16 * res,
bool mf )

Read a 2 byte entity from a file.

Parameters
hfile handle
resvalue read from file
mfis MSB first?
Returns
0 on success, nonzero otherwise

◆ swap32()

THREAD_SAFE constexpr uint32 swap32 ( uint32 x)
inlineconstexpr

◆ swap16()

THREAD_SAFE constexpr ushort swap16 ( ushort x)
inlineconstexpr

◆ swap_value()

idaman THREAD_SAFE void ida_export swap_value ( void * dst,
const void * src,
int size )

Swap endianness of a given value in memory.

Parameters
dstresult of swap
srcvalue to be swapped
sizesize of value: can be 1, 2, 4, 8, or 16. For any other values of size this function does nothing

◆ reloc_value()

idaman THREAD_SAFE void ida_export reloc_value ( void * value,
int size,
adiff_t delta,
bool mf )

◆ rotate_left()

idaman THREAD_SAFE uval_t ida_export rotate_left ( uval_t x,
int count,
size_t bits,
size_t offset )

Rotate left - can be used to rotate a value to the right if the count is negative.

Parameters
xvalue to rotate
countshift amount
bitsnumber of bits to rotate (32 will rotate a dword)
offsetnumber of first bit to rotate. (bits=8 offset=16 will rotate the third byte of the value)
Returns
the rotated value

◆ qswap()

template<class T>
THREAD_SAFE void qswap ( T & a,
T & b )
inline

Swap 2 objects of the same type using memory copies.

◆ pack_db()

THREAD_SAFE uchar *idaapi pack_db ( uchar * ptr,
uchar * end,
uchar x )
inline

Pack a byte into a character string.

This function encodes numbers using an encoding similar to UTF. The smaller the number, the better the packing.

Parameters
ptrpointer to output buffer
endpointer to end of output buffer
xvalue to pack
Returns
pointer to end of resulting string

◆ unpack_db()

THREAD_SAFE uchar idaapi unpack_db ( const uchar ** pptr,
const uchar * end )
inline

Unpack a byte from a character string, pack_db()

◆ pack_dw()

idaman THREAD_SAFE uchar *ida_export pack_dw ( uchar * ptr,
uchar * end,
uint16 x )

pack a word, see pack_db()

◆ pack_dd()

idaman THREAD_SAFE uchar *ida_export pack_dd ( uchar * ptr,
uchar * end,
uint32 x )

pack a double word, see pack_db()

◆ pack_dq()

idaman THREAD_SAFE uchar *ida_export pack_dq ( uchar * ptr,
uchar * end,
uint64 x )

pack a quadword, see pack_db()

◆ unpack_dw()

idaman THREAD_SAFE ushort ida_export unpack_dw ( const uchar ** pptr,
const uchar * end )

unpack a word, see unpack_db()

◆ unpack_dd()

idaman THREAD_SAFE uint32 ida_export unpack_dd ( const uchar ** pptr,
const uchar * end )

unpack a double word, see unpack_db()

◆ unpack_dq()

idaman THREAD_SAFE uint64 ida_export unpack_dq ( const uchar ** pptr,
const uchar * end )

unpack a quadword, see unpack_db()

◆ pack_ea()

THREAD_SAFE uchar * pack_ea ( uchar * ptr,
uchar * end,
ea_t ea )
inline

Pack an ea value into a character string, see pack_dd()/pack_dq()

◆ unpack_ea()

THREAD_SAFE ea_t unpack_ea ( const uchar ** ptr,
const uchar * end )
inline

Unpack an ea value, see unpack_dd()/unpack_dq()

◆ unpack_ea64()

THREAD_SAFE ea64_t unpack_ea64 ( const uchar ** ptr,
const uchar * end )
inline

Unpack an ea value (always use 64bit, use delta 1)

◆ unpack_obj()

THREAD_SAFE void *idaapi unpack_obj ( void * destbuf,
size_t destsize,
const uchar ** pptr,
const uchar * end )
inline

Unpack an object of a known size.

Parameters
destbufoutput buffer
destsizesize of output buffer
pptrpointer to packed object
endpointer to end of packed object
Returns
pointer to the destination buffer. if any error, returns nullptr.

◆ unpack_buf()

THREAD_SAFE void *idaapi unpack_buf ( const uchar ** pptr,
const uchar * end )
inline

Unpack an object of an unknown size (packed with append_buf()).

Parameters
pptrpointer to packed object
endpointer to end of packed object
Returns
pointer to the destination buffer, which is allocated in the dynamic memory.
the caller should use qfree() to deallocate it.
if any error, returns nullptr.
NB: zero size objects will return nullptr too.

◆ unpack_obj_inplace()

THREAD_SAFE const void *idaapi unpack_obj_inplace ( const uchar ** pptr,
const uchar * end,
size_t objsize )
inline

In-place version of unpack_obj().

It does not copy any data. It just returns a pointer to the object in the packed string. If any error, it returns nullptr.

◆ unpack_buf_inplace()

THREAD_SAFE const void *idaapi unpack_buf_inplace ( const uchar ** pptr,
const uchar * end )
inline

In-place version of unpack_buf().

It does not copy any data. It just returns a pointer to the object in the packed string. If any error, it returns nullptr.

◆ pack_ds()

idaman THREAD_SAFE uchar *ida_export pack_ds ( uchar * ptr,
uchar * end,
const char * x,
size_t len = 0 )

Pack a string.

Parameters
ptrpointer to output buffer
endpointer to end of output buffer
xstring to pack. If nullptr, empty string is packed
lennumber of chars to pack. If 0, the length of given string is used
Returns
pointer to end of packed string

◆ unpack_ds()

idaman THREAD_SAFE char *ida_export unpack_ds ( const uchar ** pptr,
const uchar * end,
bool empty_null )

Unpack a string.

Parameters
pptrpointer to packed string
endpointer to end of packed string
empty_nullif true, then return nullptr for empty strings.
otherwise return an empty string (not nullptr).
Returns
pointer to unpacked string.
this string will be allocated in dynamic memory.
the caller should use qfree() to deallocate it.

◆ unpack_ds_to_buf()

THREAD_SAFE bool unpack_ds_to_buf ( char * dst,
size_t dstsize,
const uchar ** pptr,
const uchar * end )
inline

Unpack a string.

Parameters
dstpointer to buffer string will be copied to
dstsizebuffer size
pptrpointer to packed string
endpointer to end of packed string
Returns
success

◆ unpack_xleb128()

idaman THREAD_SAFE bool ida_export unpack_xleb128 ( void * res,
int nbits,
bool is_signed,
const uchar ** pptr,
const uchar * end )

Unpack an LEB128 encoded (DWARF-3 style) signed/unsigned value.

Do not use this function directly - see Template unpacking

◆ ds_packed_size()

THREAD_SAFE int ds_packed_size ( const char * s)
inline

◆ dw_size()

THREAD_SAFE constexpr int dw_size ( uchar first_byte)
inlineconstexpr

◆ dd_size()

THREAD_SAFE constexpr int dd_size ( uchar first_byte)
inlineconstexpr

◆ extract_db()

template<class T>
THREAD_SAFE uchar extract_db ( T & v)
inline

◆ extract_obj()

template<class T>
THREAD_SAFE void * extract_obj ( T & v,
void * destbuf,
size_t destsize )
inline

◆ extract_dw()

template<class T>
THREAD_SAFE uint16 extract_dw ( T & v)
inline

◆ extract_dd()

template<class T>
THREAD_SAFE uint32 extract_dd ( T & v)
inline

◆ extract_dq()

template<class T>
THREAD_SAFE uint64 extract_dq ( T & v)
inline

◆ extract_ea()

template<class T>
THREAD_SAFE ea_t extract_ea ( T & v)
inline

◆ extract_buf()

template<class T>
THREAD_SAFE void * extract_buf ( T & v,
size_t size )
inline

◆ extract_array()

template<class T>
THREAD_SAFE void * extract_array ( T & v,
size_t * sz,
size_t maxsize )
inline

◆ unpack_str() [1/2]

const char * unpack_str ( const uchar ** pptr,
const uchar * end )
inline

◆ qalloc_or_throw()

idaman THREAD_SAFE void *ida_export qalloc_or_throw ( size_t size)

qalloc() 'size' bytes, and throw a "not enough memory" error if failed

◆ qrealloc_or_throw()

idaman THREAD_SAFE void *ida_export qrealloc_or_throw ( void * ptr,
size_t size )

qrealloc() 'ptr' by 'size', and throw a "not enough memory" error if failed

◆ qvector_reserve()

idaman THREAD_SAFE void *ida_export qvector_reserve ( void * vec,
void * old,
size_t cnt,
size_t elsize )

Change capacity of given qvector.

Parameters
veca pointer to a qvector
olda pointer to the qvector's array
cntnumber of elements to reserve
elsizesize of each element
Returns
a pointer to the newly allocated array

◆ shift_down()

template<class T>
void shift_down ( T * dst,
T * src,
size_t cnt )
inline

Move data down in memory.

Parameters
dstdestination ptr
srcsource ptr
cntnumber of elements to move

◆ shift_up()

template<class T>
void shift_up ( T * dst,
T * src,
size_t cnt )
inline

Move data up in memory.

Parameters
dstdestination ptr
srcsource ptr
cntnumber of elements to move

◆ lexcompare()

template<class T>
int lexcompare ( const T & a,
const T & b )

Standard lexical comparison.

Returns
-1 if a < b, 1 if a > b, and 0 if a == b

◆ lexcompare_vectors()

template<class T>
int lexcompare_vectors ( const T & a,
const T & b )

Lexical comparison of two vectors.

Also see lexcompare().

Returns
0 if the two vectors are identical 1 if 'a' is larger than 'b' -1 if 'a' is smaller than 'b' otherwise return the first nonzero lexical comparison between each element in 'a' and 'b'

◆ qstrlen() [1/3]

THREAD_SAFE size_t idaapi qstrlen ( const char * s)
inline

◆ qstrlen() [2/3]

THREAD_SAFE size_t idaapi qstrlen ( const uchar * s)
inline

◆ qstrlen() [3/3]

idaman THREAD_SAFE size_t ida_export qstrlen ( const wchar16_t * s)

◆ qstrcmp() [1/3]

THREAD_SAFE int idaapi qstrcmp ( const char * s1,
const char * s2 )
inline

◆ qstrcmp() [2/3]

THREAD_SAFE int idaapi qstrcmp ( const uchar * s1,
const uchar * s2 )
inline

◆ qstrcmp() [3/3]

idaman THREAD_SAFE int ida_export qstrcmp ( const wchar16_t * s1,
const wchar16_t * s2 )

◆ qstrncmp() [1/3]

THREAD_SAFE int idaapi qstrncmp ( const char * s1,
const char * s2,
size_t len )
inline

◆ qstrncmp() [2/3]

THREAD_SAFE int idaapi qstrncmp ( const uchar * s1,
const uchar * s2,
size_t len )
inline

◆ qstrncmp() [3/3]

idaman THREAD_SAFE int ida_export qstrncmp ( const wchar16_t * s1,
const wchar16_t * s2,
size_t len )

◆ qstrstr() [1/3]

THREAD_SAFE char *idaapi qstrstr ( char * s1,
const char * s2 )
inline

◆ qstrstr() [2/3]

THREAD_SAFE const char *idaapi qstrstr ( const char * s1,
const char * s2 )
inline

◆ qstrstr() [3/3]

THREAD_SAFE const uchar *idaapi qstrstr ( const uchar * s1,
const uchar * s2 )
inline

◆ qstrchr() [1/6]

THREAD_SAFE char *idaapi qstrchr ( char * s1,
char c )
inline

◆ qstrchr() [2/6]

THREAD_SAFE const char *idaapi qstrchr ( const char * s1,
char c )
inline

◆ qstrchr() [3/6]

THREAD_SAFE uchar *idaapi qstrchr ( uchar * s1,
uchar c )
inline

◆ qstrchr() [4/6]

THREAD_SAFE const uchar *idaapi qstrchr ( const uchar * s1,
uchar c )
inline

◆ qstrchr() [5/6]

idaman THREAD_SAFE const wchar16_t *ida_export qstrchr ( const wchar16_t * s1,
wchar16_t c )

◆ qstrchr() [6/6]

THREAD_SAFE wchar16_t *idaapi qstrchr ( wchar16_t * s1,
wchar16_t c )
inline

◆ qstrrchr() [1/6]

THREAD_SAFE const char *idaapi qstrrchr ( const char * s1,
char c )
inline

◆ qstrrchr() [2/6]

THREAD_SAFE char *idaapi qstrrchr ( char * s1,
char c )
inline

◆ qstrrchr() [3/6]

THREAD_SAFE const uchar *idaapi qstrrchr ( const uchar * s1,
uchar c )
inline

◆ qstrrchr() [4/6]

THREAD_SAFE uchar *idaapi qstrrchr ( uchar * s1,
uchar c )
inline

◆ qstrrchr() [5/6]

idaman THREAD_SAFE const wchar16_t *ida_export qstrrchr ( const wchar16_t * s1,
wchar16_t c )

◆ qstrrchr() [6/6]

THREAD_SAFE wchar16_t *idaapi qstrrchr ( wchar16_t * s1,
wchar16_t c )
inline

◆ relocate_relobj()

idaman THREAD_SAFE bool ida_export relocate_relobj ( struct relobj_t * _relobj,
ea_t ea,
bool mf )

◆ unpack_eavec()

THREAD_SAFE void unpack_eavec ( eavec_t * vec,
ea_t ea,
const uchar ** ptr,
const uchar * end )
inline

Unpack a vector of ea values.

Parameters
[out]vecresulting vector
eabase value that was used to pack the eavec (see pack_eavec())
ptrpointer to packed eavec
endpointer to end of packed eavec

◆ unpack_bytevec()

THREAD_SAFE bool unpack_bytevec ( bytevec_t * out,
const uchar ** pptr,
const uchar * end )
inline

◆ unpack_str() [2/2]

bool unpack_str ( qstring * out,
const uchar ** pptr,
const uchar * end )
inline

◆ compare() [1/6]

template<class T, typename std::enable_if< has_compare_method< T >::value, int >::type = 0>
int compare ( const T & a,
const T & b )

◆ compare() [2/6]

template<class T>
int compare ( const qvector< T > & a,
const qvector< T > & b )

◆ compare() [3/6]

template<class T>
int compare ( const qlist< T > & a,
const qlist< T > & b )

◆ compare() [4/6]

template<class T, class U>
int compare ( const std::pair< T, U > & a,
const std::pair< T, U > & b )

◆ compare_containers()

template<class T>
int compare_containers ( const T & l,
const T & r )

Template to compare any 2 containers of the same type. Returns -1/0/1.

◆ compare() [5/6]

template<class T, class U>
int compare ( const std::map< T, U > & a,
const std::map< T, U > & b )

◆ compare() [6/6]

template<class T>
int compare ( const std::set< T > & a,
const std::set< T > & b )

◆ align_up()

template<class T>
T align_up ( T val,
int elsize )

Align element up to nearest boundary.

◆ align_down()

template<class T>
T align_down ( T val,
int elsize )

Align element down to nearest boundary.

◆ calc_crc32()

idaman THREAD_SAFE uint32 ida_export calc_crc32 ( uint32 crc,
const void * buf,
size_t len )

Calculate CRC32 (polynom 0xEDB88320, zlib compatible).

Note
in IDA versions before 6.0 a different, incompatible algorithm was used

◆ calc_file_crc32()

idaman THREAD_SAFE uint32 ida_export calc_file_crc32 ( class linput_t * fp)

Calculate an input source CRC32.

◆ base64_encode()

idaman THREAD_SAFE bool ida_export base64_encode ( qstring * output,
const void * input,
size_t size )

Encode base64.

◆ base64_decode()

idaman THREAD_SAFE bool ida_export base64_decode ( bytevec_t * output,
const char * input,
size_t size )

Decode base64.

Decode base64

◆ replace_tabs()

idaman THREAD_SAFE bool ida_export replace_tabs ( qstring * out,
const char * str,
int tabsize )

Convert tabulations to spaces.

Parameters
outoutput buffer to append to
strinput string. cannot be equal to out->c_str()
tabsizetabulation size
Returns
true-replaced some tabs

◆ is_utf8_head()

bool is_utf8_head ( char in)
inlineconstexpr

Does this byte correspond to the head of a UTF-8 byte sequence?

Note that this does not tell us anything regarding the number of bytes that compose the byte sequence; 1-byte sequences (i.e., ASCII) are still UTF-8 byte sequences.

Parameters
inthe byte to check
Returns
success

◆ is_utf8_tail()

bool is_utf8_tail ( char in)
inlineconstexpr

Does this byte correspond to the tail of a UTF-8 byte sequence?

Parameters
inthe byte to check
Returns
success

◆ is_valid_utf8()

idaman THREAD_SAFE bool ida_export is_valid_utf8 ( const char * in)

Does byte sequence consist of valid UTF-8-encoded codepoints?

Parameters
inthe byte sequence
Returns
success

◆ utf8_utf16()

idaman THREAD_SAFE bool ida_export utf8_utf16 ( qwstring * out,
const char * in,
int nsyms = -1 )

UTF-8 -> UTF-16.

Parameters
outthe output buffer
inthe input UTF-8 byte stream
nsymsthe number of UTF-8-encoded codepoints in the byte stream
Returns
success

◆ utf16_utf8()

idaman THREAD_SAFE bool ida_export utf16_utf8 ( qstring * out,
const wchar16_t * in,
int nsyms = -1 )

UTF-16 -> UTF-8.

Parameters
outthe output buffer
inthe input UTF-16 stream
nsymsthe number of 16-bit items in 'in'. This does not necessarily correspond to the number of codepoints: each surrogate pair will take 2 items.
Returns
success

◆ is_lead_surrogate()

bool is_lead_surrogate ( wchar32_t wch)
inlineconstexpr

◆ is_tail_surrogate()

bool is_tail_surrogate ( wchar32_t wch)
inlineconstexpr

◆ utf16_surrogates_to_cp()

wchar32_t utf16_surrogates_to_cp ( wchar16_t lead_surrogate,
wchar16_t tail_surrogate )
inlineconstexpr

◆ idb_utf8()

idaman THREAD_SAFE bool ida_export idb_utf8 ( qstring * out,
const char * in,
int nsyms = -1,
int flags = 0 )

IDB default C string encoding -> UTF-8.

Returns
success (i.e., all bytes converted)

◆ change_codepage()

INLINE THREAD_SAFE bool idaapi change_codepage ( qstring * out,
const char * in,
int incp,
int outcp )

◆ acp_utf8()

INLINE THREAD_SAFE bool acp_utf8 ( qstring * out,
const char * in )

◆ utf8_wchar16() [1/2]

THREAD_SAFE constexpr wchar16_t utf8_wchar16 ( uchar b0,
uchar b1 )
inlineconstexpr

◆ utf8_wchar16() [2/2]

THREAD_SAFE constexpr wchar16_t utf8_wchar16 ( uchar b0,
uchar b1,
uchar b2 )
inlineconstexpr

◆ utf8_wchar32()

THREAD_SAFE constexpr wchar32_t utf8_wchar32 ( uchar b0,
uchar b1,
uchar b2,
uchar b3 )
inlineconstexpr

◆ get_utf8_char()

idaman THREAD_SAFE wchar32_t ida_export get_utf8_char ( const char ** pptr)

Read one UTF-8 character from string. if error, return BADCP.

◆ prev_utf8_char()

idaman THREAD_SAFE bool ida_export prev_utf8_char ( wchar32_t * out_cp,
const char ** p,
const char * begin )

Get the UTF-8 character from string, before 'p'.

Parameters
out_cpthe output codepoint storage. May be nullptr.
pthe pointer, pointing in the 'begin' string right after the UTF-8-encoded codepoint we want to retrieve
beginthe beginning of the string
Returns
success

◆ skip_utf8()

idaman THREAD_SAFE size_t ida_export skip_utf8 ( const char ** putf8,
size_t n )

Advance by n codepoints into the UTF-8 buffer.

Each bad byte (i.e., can't be decoded as UTF-8) will count as 1 codepoint. In addition, encountering an unexpected end-of-string (i.e., '\0') will cause this function to stop and return a non-zero value.

Parameters
putf8a pointer to the UTF-8 bytes buffer to advance into
nthe number of codepoints to advance into the buffer
Returns
the number of codepoints that we failed to decode, thus: 0 - success, >0 - a terminating zero was encountered.

◆ put_utf8_char()

idaman THREAD_SAFE ssize_t ida_export put_utf8_char ( char * out,
wchar32_t cp )

Encode the codepoint into a UTF-8 byte sequence, and add terminating zero.

Parameters
outoutput buffer (must be at least MAX_UTF8_SEQ_LEN bytes wide)
cpthe codepoint to encode
Returns
how many bytes were put into the output buffer (without the terminating zero), or size_t(-1) on failure

◆ is_cp_graphical()

idaman THREAD_SAFE bool ida_export is_cp_graphical ( wchar32_t cp)

Is the provided codepoint graphical?

◆ qustrlen()

idaman THREAD_SAFE size_t ida_export qustrlen ( const char * utf8)

◆ qustrncpy()

idaman THREAD_SAFE bool ida_export qustrncpy ( char * dst,
const char * utf8,
size_t dstsize )

A safer strncpy - makes sure that there is a terminating zero.

nb: this function doesn't truncate the last UTF-8 character.

See also
qstrncpy()
Return values
falseif the input buffer was truncated

◆ is_cvt64()

idaman bool ida_export is_cvt64 ( )

is IDA converting IDB into I64?

◆ convert_encoding() [1/2]

idaman ssize_t ida_export convert_encoding ( bytevec_t * out,
const char * fromcode,
const char * tocode,
const uchar * indata,
ssize_t insize,
DEFARG(int flags, 0)  )

Convert data from encoding fromcode into tocode.

Parameters
outthe output buffer
fromcodethe encoding of the input data
tocodethe encoding of the output data
indatathe input data
insizesize of input data in bytes
flagsConvert encoding flags*
Returns
number of input bytes converted (can be less than actual size if there was an invalid character) -1 if source or target encoding is not supported possible encoding names: windows codepages ("CP1251" etc), charset names ("Shift-JIS"), and many encodings supported by iconv

◆ convert_encoding() [2/2]

ssize_t convert_encoding ( bytevec_t * out,
const char * fromcode,
const char * tocode,
const bytevec_t * indata,
DEFARG(int flags, 0)  )
inline

◆ parse_command_line()

idaman THREAD_SAFE size_t ida_export parse_command_line ( qstrvec_t * args,
channel_redirs_t * redirs,
const char * cmdline,
int flags )

Parse a space separated string (escaping with backslash is supported).

Parameters
[out]argsa string vector to hold the results
[out]redirsmap of channel redirections found in cmdline
  • if nullptr, redirections won't be parsed
  • if there are syntax errors in redirections, consider them as arguments
cmdlinethe string to be parsed
flags#LP_PATH_WITH_ARGS or 0
Returns
the number of parsed arguments

◆ expand_argv()

char ** expand_argv ( int * p_argc,
int argc,
const char *const argv[] )

Copy and expand command line arguments.

For '@filename' arguments the file contents are inserted into the resulting argv. Format of the file: one switch per line, ';' for comment lines On windows, argv will also be interpreted as OEM codepage, and will be decoded as such and re-encoded into UTF-8.

Parameters
[out]p_argcsize of the returned argv array
argcnumber of entries in argv array
argvarray of strings
Returns
new argv (terminated by nullptr). It must be freed with free_argv()

◆ free_argv()

INLINE void free_argv ( int argc,
char ** argv )

Free 'argc' elements of 'argv'.

◆ quote_cmdline_arg()

idaman bool ida_export quote_cmdline_arg ( qstring * arg)

Quote a command line argument if it contains escape characters.

For example, .c will be converted into "</em>.c" because * may be inadvertently expanded by the shell

Returns
true: modified 'arg'

◆ DECLARE_TYPE_AS_MOVABLE() [1/2]

DECLARE_TYPE_AS_MOVABLE ( cliopt_t )

◆ DEFINE_PLUGIN_OPTION_T_HELPERS()

DEFINE_PLUGIN_OPTION_T_HELPERS ( idaman )

Named option, supports two kinds of options: string option: <name>=bool option: <name>=[on|off].

◆ DECLARE_TYPE_AS_MOVABLE() [2/2]

DECLARE_TYPE_AS_MOVABLE ( plugin_option_t )

◆ parse_plugin_options()

idaman bool ida_export parse_plugin_options ( plugin_options_t * opts,
const char * optstring )

Parse plugin options from IDA command line specified by -O<plugin_name>:<optstring> Note such options can be used not only for plugins, for example, currently we use them for merge (-Omerge:...) and vault server credentials (-Ovault:...)

Parameters
[out]optspointer to vector for parsed options
optstringoption string <name1>=<value1>:...

◆ build_plugin_options()

idaman void ida_export build_plugin_options ( qstring * out,
const plugin_options_t & opts,
const char * optname = nullptr )

Build the plugin options, suitable for IDA command line of the form <name1>=<value1>:... If optname is provided, the -O<optname>: token will be prepended.

Parameters
[out]outthe output buffer
optsthe plugin options to serialize
optnamethe optional option name to prepend to the plugin options string

◆ parse_dbgopts()

idaman bool ida_export parse_dbgopts ( struct instant_dbgopts_t * ido,
const char * r_switch )

Parse the -r command line switch (for instant debugging).

r_switch points to the value of the -r switch. Example: win32@localhost+

Returns
true-ok, false-parse error

◆ launch_process() [1/2]

idaman THREAD_SAFE void *ida_export launch_process ( const launch_process_params_t & lpp,
qstring * errbuf = nullptr )

Launch the specified process in parallel.

Returns
handle (unix: child pid), nullptr - error

◆ launch_process() [2/2]

idaman THREAD_SAFE void *ida_export launch_process ( const struct launch_process_params_t * lpp,
qstring * errbuf )

◆ term_process()

idaman THREAD_SAFE int ida_export term_process ( void * handle)

Forcibly terminate a running process.

Returns
0-ok, otherwise an error code that can be passed to winerr()

◆ qwait_timed()

idaman THREAD_SAFE int ida_export qwait_timed ( int * status,
int child,
int flags,
int timeout_ms )

Wait for state changes in a child process (UNIX only).

Here: child, status, flags - the same as in system call waitpid() Param 'timeout_ms' is a timeout in milliseconds

Returns
PID of the process with the changed status

◆ qwait()

THREAD_SAFE int qwait ( int * status,
int child,
int flags )
inline

◆ check_process_exit()

idaman THREAD_SAFE int ida_export check_process_exit ( void * handle,
int * exit_code,
DEFARG(int msecs,-1)  )

Check whether process has terminated or not.

Parameters
handleprocess handle to wait for
[out]exit_codepointer to the buffer for the exit code
msecshow long to wait. special values:
  • 0: do not wait
  • 1 or -1: wait infinitely
  • other values: timeout in milliseconds
Return values
0process has exited, and the exit code is available. if *exit_code < 0: the process was killed with a signal -*exit_code
1process has not exited yet
-1error happened, see error code for winerr() in *exit_code

◆ is_control_tty()

idaman THREAD_SAFE enum tty_control_t ida_export is_control_tty ( int fd)

Check if the current process is the owner of the TTY specified by 'fd' (typically an opened descriptor to /dev/tty).

◆ qdetach_tty()

idaman THREAD_SAFE void ida_export qdetach_tty ( void )

If the current terminal is the controlling terminal of the calling process, give up this controlling terminal.

Note
The current terminal is supposed to be /dev/tty

◆ qcontrol_tty()

idaman THREAD_SAFE void ida_export qcontrol_tty ( void )

Make the current terminal the controlling terminal of the calling process.

Note
The current terminal is supposed to be /dev/tty

◆ OPAQUE_HANDLE() [1/3]

OPAQUE_HANDLE ( qthread_t )

◆ qthread_create()

idaman THREAD_SAFE qthread_t ida_export qthread_create ( qthread_cb_t * thread_cb,
void * ud )

Create a thread and return a thread handle.

◆ qthread_free()

idaman THREAD_SAFE void ida_export qthread_free ( qthread_t q)

Free a thread resource (does not kill the thread) (calls pthread_detach under unix)

◆ qthread_join()

idaman THREAD_SAFE bool ida_export qthread_join ( qthread_t q)

Wait a thread until it terminates.

◆ qthread_kill()

idaman THREAD_SAFE bool ida_export qthread_kill ( qthread_t q)

Forcefully kill a thread (calls pthread_cancel under unix)

◆ qthread_self()

idaman THREAD_SAFE qthread_t ida_export qthread_self ( void )

Get current thread. Must call qthread_free() to free it!

◆ qthread_same()

idaman THREAD_SAFE bool ida_export qthread_same ( qthread_t q)

Is the current thread the same as 'q'?

◆ qthread_equal()

idaman THREAD_SAFE bool ida_export qthread_equal ( qthread_t q1,
qthread_t q2 )

Are two threads equal?

◆ is_main_thread()

idaman THREAD_SAFE bool ida_export is_main_thread ( void )

Are we running in the main thread?

◆ qsetenv()

idaman THREAD_SAFE bool ida_export qsetenv ( const char * varname,
const char * value )

Thread safe function to work with the environment.

◆ qgetenv()

idaman THREAD_SAFE bool ida_export qgetenv ( const char * varname,
DEFARG(qstring *buf, nullptr)  )

Thread safe function to work with the environment.

◆ OPAQUE_HANDLE() [2/3]

OPAQUE_HANDLE ( qsemaphore_t )

Semaphore.

Named semaphores are public, nameless ones are local to the process

◆ qsem_create()

idaman THREAD_SAFE qsemaphore_t ida_export qsem_create ( const char * name,
int init_count )

Create a new semaphore.

◆ qsem_free()

idaman THREAD_SAFE bool ida_export qsem_free ( qsemaphore_t sem)

Free a semaphore.

◆ qsem_post()

idaman THREAD_SAFE bool ida_export qsem_post ( qsemaphore_t sem)

Unlock a semaphore.

◆ qsem_wait()

idaman THREAD_SAFE bool ida_export qsem_wait ( qsemaphore_t sem,
int timeout_ms )

Lock and decrement a semaphore. timeout = -1 means block indefinitely.

◆ OPAQUE_HANDLE() [3/3]

OPAQUE_HANDLE ( qmutex_t )

Mutex.

◆ qmutex_free()

idaman THREAD_SAFE bool ida_export qmutex_free ( qmutex_t m)

Free a mutex.

◆ qmutex_create()

idaman THREAD_SAFE qmutex_t ida_export qmutex_create ( void )

Create a new mutex.

◆ qmutex_lock()

idaman THREAD_SAFE bool ida_export qmutex_lock ( qmutex_t m)

Lock a mutex.

◆ qmutex_unlock()

idaman THREAD_SAFE bool ida_export qmutex_unlock ( qmutex_t m)

Unlock a mutex.

◆ qpipe_create()

idaman THREAD_SAFE int ida_export qpipe_create ( qhandle_t handles[2])

Create a pipe.

Parameters
[out]handles
  • handles[0] : read handle
  • handles[1] : write handle
Returns
error code (0-ok)

◆ qpipe_read()

idaman THREAD_SAFE ssize_t ida_export qpipe_read ( qhandle_t handle,
void * buf,
size_t size )

Read from a pipe.

Returns
number of read bytes. -1-error

◆ qpipe_read_n()

idaman THREAD_SAFE bool ida_export qpipe_read_n ( qhandle_t handle,
bytevec_t * out_bytes,
size_t n )

Read a specific amount of bytes from a pipe.

Parameters
handlepipe handle to read from
[out]out_bytesbyte vector to which the bytes will be appended
nnumber of bytes to read
Returns
success

◆ qpipe_write()

idaman THREAD_SAFE ssize_t ida_export qpipe_write ( qhandle_t handle,
const void * buf,
size_t size )

Write to a pipe.

Returns
number of written bytes. -1-error

◆ qpipe_close()

idaman THREAD_SAFE int ida_export qpipe_close ( qhandle_t handle)

Close a pipe.

Returns
error code (0-ok)

◆ pipe_process()

idaman void *ida_export pipe_process ( qhandle_t * read_handle,
qhandle_t * write_handle,
launch_process_params_t * lpp,
qstring * errbuf = nullptr )

Launch a process and establish 2-way comminucation with it.

The process's stdin and stdout will be redirected to 'out_handles'.

Parameters
[out]read_handlehandle from which the caller will read. can be nullptr
[out]write_handlehandle to which the caller will write. can be nullptr
lppprocess to run
[out]errbufbuffer for the error message, if any
Returns
nullptr on error, otherwise the process handle

◆ qwait_for_handles()

idaman THREAD_SAFE int ida_export qwait_for_handles ( int * idx,
const qhandle_t * handles,
int n,
uint32 write_bitmask,
int timeout_ms )

Wait for file/socket/pipe handles.

Note
On Windows this function just calls WaitForMultipleObjects(). So it cannot wait for file/socket/pipe handles. It simply returns 0 and sets idx to 0 for such handles.
Parameters
[out]idxhandle index
handleshandles to wait for
nnumber of handles
write_bitmaskbitmask of indexes of handles opened for writing
timeout_mstimeout value in milliseconds
Returns
error code. on timeout, returns 0 and sets idx to -1

◆ get_login_name()

idaman THREAD_SAFE bool ida_export get_login_name ( qstring * out)

Get the user name for the current desktop session.

Parameters
[out]outoutput buffer
Returns
success

◆ get_physical_core_count()

idaman THREAD_SAFE int ida_export get_physical_core_count ( )

Get the total CPU physical core count.

Returns
the physical core count, or -1 on error

◆ get_logical_core_count()

idaman THREAD_SAFE int ida_export get_logical_core_count ( )

Get the total CPU logical core count.

Returns
the logical core count, or -1 on error

◆ get_available_core_count()

idaman THREAD_SAFE int ida_export get_available_core_count ( )

Get the number of logical CPU cores available to the current process if supported by the OS.

Returns
the logical core count available for the process, or -1 on error

Variable Documentation

◆ BADDIFF

diffpos_t BADDIFF = diffpos_t(-1)
constexpr

◆ bufsize

idaman size_t bufsize

◆ t

idaman size_t const char qtime64_t t

◆ under_debugger

idaman bool ida_export_data under_debugger

is IDA running under a debugger?

◆ NULL_PIPE_HANDLE

const qhandle_t NULL_PIPE_HANDLE = nullptr