IDA SDK

- Main Page
- Header Files
- Classes
- Modules

- File List
- File Members

Classes | Functions | Namespaces | Macros | Typedefs | Enumerations | Variables
pro.h File Reference

## 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:

__OS2__ - OS/2
__MSDOS__ - MS DOS 32-bit extender
__NT__ - MS Windows (all platforms)
__LINUX__ - Linux
__MAC__ - MAC OS X
__BSD__ - FreeBSD

UNDER_CE - Compiling for WindowsCE

__EA64__ - 64-bit address size (sizeof(ea_t)==8)
__X64__ - 64-bit IDA itself (sizeof(void*)==8)

__X86__ - Intel x86 processor (default)
__PPC__ - PowerPC
__ARM__ - ARM

## Classes
struct | qstatbuf64
| Describes miscellaneous file attributes. More...
class | qvector< T >
| Reimplementation of vector class from STL. More...
class | qstack< T >
| Reimplementation of stack class from STL. 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...
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. More...
struct | janitor_t< T >
| Resource janitor to facilitate use of the RAII idiom. More...
struct | hit_counter_t
| Statistical counter for profiling. More...
class | incrementer_t
| Formalized counter increment - see hit_counter_t. More...
struct | channel_redir_t
| Tools for command line parsing. More...
struct | instant_dbgopts_t
| Options for instant debugging. More...
struct | launch_process_params_t
| Information for launching a process with IDA API. More...
struct | __qthread_t
| Thread opaque handle. More...
struct | __qsemaphore_t
| Semaphore. More...
struct | __qmutex_t
| Mutex. More...
class | qmutex_locker_t
| Mutex locker object. Will lock a given mutex upon creation and unlock it when the object is destroyed. More...

## Functions
int64 | qatoll (const char *nptr)
| Convert string to 64 bit integer.
uint32 | get_secs (qtime64_t t)
| Get the 'seconds since the epoch' part of a qtime64_t.
uint32 | get_usecs (qtime64_t t)
| Get the microseconds part of a qtime64_t.
qtime64_t | make_qtime64 (uint32 secs, int32 usecs=0)
| Get a qtime64_t instance from a seconds value and microseconds value. More...
idaman THREAD_SAFE bool ida_export | qctime (char *buf, size_t bufsize, qtime32_t t)
| Converts calendar time into a string. More...
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). More...
idaman THREAD_SAFE bool ida_export | qlocaltime (struct tm *_tm, qtime32_t t)
| Converts a time value to a tm structure. More...
THREAD_SAFE bool | qlocaltime64 (struct tm *_tm, qtime64_t t)
| Same as qlocaltime(struct tm *, qtime32_t), but accepts a 64-bit time value.
idaman THREAD_SAFE size_t ida_export | qstrftime (char *buf, size_t bufsize, const char *format, qtime32_t t)
| Get string representation of a qtime32_t. More...
idaman THREAD_SAFE size_t ida_export | qstrftime64 (char *buf, size_t bufsize, const char *format, qtime64_t t)
| Same as qstrftime(), but accepts a 64-bit time value.
idaman THREAD_SAFE void ida_export | qsleep (int milliseconds)
| Suspend execution for given number of milliseconds.
idaman THREAD_SAFE void ida_export | get_nsec_stamp (uint64 *nsecs)
| High resolution timer. More...
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. More...
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.
idaman THREAD_SAFE NORETURN void ida_export | interr (int code)
| Show internal error message and terminate execution.
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. More...
idaman THREAD_SAFE char *ida_export | strrpl (char *str, int char1, int char2)
| Replace all occurrences of a character within a string. More...
char * | tail (char *str)
| Get tail of a string.
const char * | tail (const char *str)
| Get tail of a string. More...
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. More...
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()). More...
char *idaapi | stristr (char *s1, const char *s2)
| Same as stristr(const char *, const char *) but returns a non-const result.
bool ida_local | qisspace (char c)
| is...() functions misbehave with 'char' argument. introduce more robust function
bool ida_local | qisalpha (char c)
| see qisspace()
bool ida_local | qisalnum (char c)
| see qisspace()
bool ida_local | qispunct (char c)
| see qisspace()
bool ida_local | qislower (char c)
| see qisspace()
bool ida_local | qisupper (char c)
| see qisspace()
bool ida_local | qisprint (char c)
| see qisspace()
bool ida_local | qisdigit (char c)
| see qisspace()
bool ida_local | qisxdigit (char c)
| see qisspace()
int ida_local | qtolower (char c)
| Get lowercase equivalent of given char.
int ida_local | qtoupper (char c)
| Get uppercase equivalent of given char.
idaman THREAD_SAFE int ida_export | qsnprintf (char *buffer, size_t n, const char *format,...)
| A safer snprintf.
idaman THREAD_SAFE int ida_export | qsscanf (const char *input, const char *format,...)
| A safer sscanf.
idaman THREAD_SAFE int ida_export | qvsnprintf (char *buffer, size_t n, const char *format, va_list va)
| See qsnprintf()
idaman THREAD_SAFE int ida_export | qvsscanf (const char *input, const char *format, va_list va)
| See qsscanf()
idaman THREAD_SAFE int ida_export | append_snprintf (char *buf, const char *end, const char *format,...)
| Append result of sprintf to 'buf'.
| GCC_DIAG_OFF (format-nonliteral)
| qsnprintf that does not check its arguments. More...
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. More...
idaman void ida_export | qgetcwd (char *buf, size_t bufsize)
| Get the current working directory. More...
idaman THREAD_SAFE bool ida_export | qdirname (char *buf, size_t bufsize, const char *path)
| Get the directory part of the path. More...
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. More...
idaman THREAD_SAFE char *ida_export | qsplitfile (char *file, char **base, char **ext)
| Split filename into base name and extension. More...
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. More...
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 (const char *file, char *buf, size_t bufsize, bool search_cwd)
| Search for a file in the PATH environment variable or the current directory. More...
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. More...
idaman THREAD_SAFE const char *ida_export | get_file_ext (const char *file)
| Get pointer to extension of file name. More...
bool idaapi | has_file_ext (const char *file)
| Does the given file name have an extension?
char *idaapi | make_file_ext (char *buf, size_t bufsize, const char *file, const char *ext)
| Set file name extension if none exists. More...
idaman THREAD_SAFE bool ida_export | sanitize_file_name (char *name, size_t namesize)
| Sanitize the file name. More...
idaman THREAD_SAFE int ida_export | qopen (const char *file, int mode)
| Works the same as it's counterpart from Clib. More...
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. More...
idaman THREAD_SAFE int ida_export | qwrite (int h, const void *buf, size_t n)
| Works the same as it's counterpart from Clib. More...
idaman THREAD_SAFE int32 ida_export | qtell (int h)
| Works the same as it's counterpart from Clib. More...
idaman THREAD_SAFE int32 ida_export | qseek (int h, int32 offset, int whence)
| Works the same as it's counterpart from Clib. More...
idaman THREAD_SAFE int ida_export | qclose (int h)
| Works the same as it's counterpart from Clib. More...
idaman THREAD_SAFE int ida_export | qdup (int h)
| Works the same as it's counterpart from Clib. More...
idaman THREAD_SAFE int ida_export | qfsync (int h)
| Works the same as it's counterpart from Clib. More...
idaman THREAD_SAFE uint32 ida_export | qfilesize (const char *fname)
| Get the file size. More...
idaman THREAD_SAFE uint32 ida_export | qfilelength (int h)
| Get file length in bytes. More...
idaman THREAD_SAFE int ida_export | qchsize (int h, uint32 fsize)
| Change file size. More...
idaman THREAD_SAFE int ida_export | qmkdir (const char *file, int mode)
| Create an empty directory. More...
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 qoff64_t ida_export | qtell64 (int h)
| Same as qtell(), but with large file (>2Gb) support.
idaman THREAD_SAFE qoff64_t ida_export | qseek64 (int h, qoff64_t offset, int whence)
| Same as qseek(), but with large file (>2Gb) support.
idaman THREAD_SAFE uint64 ida_export | qfilesize64 (const char *fname)
| Same as qfilesize(), but with large file (>2Gb) support.
idaman THREAD_SAFE uint64 ida_export | qfilelength64 (int h)
| Same as qfilelength(), but with large file (>2Gb) support.
idaman THREAD_SAFE int ida_export | qchsize64 (int h, uint64 fsize)
| Same as qchsize(), but with large file (>2Gb) support.
idaman THREAD_SAFE bool ida_export | qfileexist64 (const char *file)
| Same as qfileexist(), but with large file (>2Gb) support.
idaman THREAD_SAFE int ida_export | qstat64 (const char *path, qstatbuf64 *buf)
| Same as qstat(), but with large file (>2Gb) support.
idaman THREAD_SAFE int ida_export | qfstat64 (int h, qstatbuf64 *buf)
| Same as qfstat(), but with large file (>2Gb) support.
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. More...
template<class T >
T | qabs (T x)
bool idaapi | test_bit (const uchar *bitmap, size_t bit)
| Test if 'bit' is set in 'bitmap'.
void idaapi | set_bit (uchar *bitmap, size_t bit)
| Set 'bit' in 'bitmap'.
void idaapi | clear_bit (uchar *bitmap, size_t bit)
| Clear 'bit' in 'bitmap'.
void idaapi | set_all_bits (uchar *bitmap, size_t nbits)
| Set first 'nbits' of 'bitmap'.
void idaapi | clear_all_bits (uchar *bitmap, size_t nbits)
| Clear first 'nbits' of 'bitmap'.
bool | interval::overlap (uval_t off1, asize_t s1, uval_t off2, asize_t s2)
| Do (off1,s1) and (off2,s2) overlap?
bool | interval::includes (uval_t off1, asize_t s1, uval_t off2, asize_t s2)
| Does (off1,s1) include (off2,s2)?
bool | interval::contains (uval_t off1, asize_t s1, uval_t off)
| Does (off1,s1) contain off?
template<class T >
T | left_shift (const T &value, int shift)
| Shift by the amount exceeding the operand size*8 is undefined by the standard. More...
template<class T >
T | right_ushift (const T &value, int shift)
| Shift by the amount exceeding the operand size*8 is undefined by the standard. More...
template<class T >
T | right_sshift (const T &value, int shift)
| Shift by the amount exceeding the operand size*8 is undefined by the standard. More...
template<class T >
T | qrotl (T value, size_t count)
| Rotate left.
template<class T >
T | qrotr (T value, size_t count)
| Rotate right.
template<class T >
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 T >
bool | is_add_ok (T x, T y)
| Check that unsigned addition does not overflow.
idaman uint64 ida_export | extend_sign (uint64 v, int nbytes, bool sign_extend)
| Sign-, or zero-extend the value 'v' to occupy 64 bits. More...
idaman THREAD_SAFE int ida_export | readbytes (int h, uint32 *res, int size, bool mf)
| Read at most 4 bytes from file. More...
idaman THREAD_SAFE int ida_export | writebytes (int h, uint32 l, int size, bool mf)
| Write at most 4 bytes to file. More...
idaman THREAD_SAFE int ida_export | read2bytes (int h, uint16 *res, bool mf)
| Read a 2 byte entity from a file. More...
uint32 | swap32 (uint32 x)
| Switch endianness of given value.
ushort | swap16 (ushort x)
| Switch endianness of given value. More...
idaman THREAD_SAFE void ida_export | swap_value (void *dst, const void *src, int size)
| Swap endianness of a given value in memory. More...
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. More...
template<class T >
void | qswap (T &a, T &b)
| Swap 2 objects of the same type using memory copies.
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. More...
template<class T >
int | lexcompare (const T &a, const T &b)
| Standard lexical comparison. More...
template<class T >
int | lexcompare_vectors (const T &a, const T &b)
| Lexical comparison of two vectors. More...
idaman THREAD_SAFE bool ida_export | relocate_relobj (struct relobj_t *_relobj, ea_t ea, bool mf)
template<class T >
T | align_up (T val, int elsize)
| Align element up to nearest boundary.
template<class T >
T | align_down (T val, int elsize)
| Align element down to nearest boundary.
idaman void ida_export | reg_hit_counter (hit_counter_t *, bool do_reg)
idaman THREAD_SAFE hit_counter_t *ida_export | create_hit_counter (const char *name)
| Create new hit_counter_t with given name.
idaman THREAD_SAFE void ida_export | hit_counter_timer (hit_counter_t *, bool enable)
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. More...
idaman THREAD_SAFE bool ida_export | replace_tabs (qstring *out, const char *str, int tabsize)
| Convert tabulations to spaces. More...
idaman THREAD_SAFE bool ida_export | u2cstr (const wchar16_t *in, qstring *out, int nsyms=-1)
| Unicode -> char. More...
idaman THREAD_SAFE bool ida_export | c2ustr (const char *in, qwstring *out, int nsyms=-1)
idaman THREAD_SAFE int ida_export | utf8_unicode (const char *in, wchar16_t *out, size_t outsize)
| utf-8 -> 16bit unicode
idaman THREAD_SAFE bool ida_export | unicode_utf8 (qstring *res, const wchar16_t *in, int nsyms)
| 16bit unicode -> utf8
idaman THREAD_SAFE bool ida_export | win_utf2idb (char *buf)
| Windows utf-8 (<0xFFFF) -> idb representation (oem)
idaman THREAD_SAFE wchar32_t ida_export | get_utf8_char (const char **pptr)
| Read one utf-8 character from string. if error, return -1.
idaman void ida_export | char2oem (char *inout)
| Do not use windows CharToOem/OemToChar functions - ida can replace CodePage.
idaman void ida_export | oem2char (char *inout)
| Do not use windows CharToOem/OemToChar functions - ida can replace CodePage. More...
idaman bool ida_export | set_codepages (int acp, int oemcp)
| Set codepages to be used for char2oem/oem2char (Windows only). More...
idaman int ida_export | get_codepages (int *oemcp)
| Get codepages used for char2oem/oem2char (Windows only). More...
idaman int ida_export | convert_codepage (const void *in, int insize, void *out, size_t outsize, int incp, int outcp, int flags=0)
| Convert data from codepage incp to outcp. More...
idaman int ida_export | convert_encoding (const char *fromcode, const char *tocode, const bytevec_t *indata, bytevec_t *out, int flags=0)
| Convert data from encoding fromcode into tocode. More...
idaman THREAD_SAFE size_t ida_export | parse_command_line3 (const char *cmdline, qstrvec_t *args, channel_redirs_t *redirs, int flags)
| Parse a space separated string (escaping with backslash is supported). More...
idaman char **ida_export | expand_argv (int *p_argc, int argc, const char *const argv[])
| Copy and expand command line arguments. More...
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. More...
idaman bool ida_export | parse_dbgopts (struct instant_dbgopts_t *ido, const char *r_switch)
| Parse the -r command line switch (for instant debugging). More...
idaman THREAD_SAFE void *ida_export | launch_process (const launch_process_params_t &lpp, qstring *errbuf)
| Launch the specified process in parallel. More...
idaman THREAD_SAFE int ida_export | term_process (void *handle)
| Forcibly terminate a running process. More...
idaman THREAD_SAFE int ida_export | qwait_timed (int child, int *status, int flags, int timeout_ms)
| Wait for state changes in a child process (UNIX only). More...
idaman THREAD_SAFE int ida_export | check_process_exit (void *handle, int *exit_code, int msecs=-1)
| Check whether process has terminated or not. More...
idaman THREAD_SAFE 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). More...
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. More...
idaman THREAD_SAFE void ida_export | qcontrol_tty (void)
| Make the current terminal the controlling terminal of the calling process. More...
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)
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 | 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, qstring *buf=NULL)
| Thread safe function to work with the environment. More...
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.
idaman THREAD_SAFE bool ida_export | qmutex_free (qmutex_t m)
| Free a mutex.
idaman THREAD_SAFE qmutex_t ida_export | qmutex_create ()
| 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. More...
idaman THREAD_SAFE ssize_t ida_export | qpipe_read (qhandle_t handle, void *buf, size_t size)
| Read from a pipe. More...
idaman THREAD_SAFE ssize_t ida_export | qpipe_write (qhandle_t handle, const void *buf, size_t size)
| Write to a pipe. More...
idaman THREAD_SAFE int ida_export | qpipe_close (qhandle_t handle)
| Close a pipe. More...
idaman THREAD_SAFE int ida_export | qwait_for_handles (const qhandle_t *handles, int n, uint32 write_bitmask, int *idx, int timeout_ms)
| Wait for file/socket/pipe handles. More...
strlen
Get the length of the given string
size_t idaapi | qstrlen (const char *s)
size_t idaapi | qstrlen (const uchar *s)
idaman THREAD_SAFE size_t ida_export | qstrlen (const wchar16_t *s)
strcmp
Lexical comparison of strings. Returns 0 if two strings are identical > 0 if 's1' is larger than 's2' < 0 if 's2' is larger than 's1' otherwise return first nonzero comparison between chars in 's1' and 's2'
int idaapi | qstrcmp (const char *s1, const char *s2)
int idaapi | qstrcmp (const uchar *s1, const uchar *s2)
idaman THREAD_SAFE int ida_export | qstrcmp (const wchar16_t *s1, const wchar16_t *s2)
strstr
Find a string within another string. Returns a pointer to the first occurrence of 's2' within 's1', NULL if s2 is not found in s1
const char *idaapi | qstrstr (const char *s1, const char *s2)
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', NULL if c is not found in s1
char *idaapi | qstrchr (char *s1, char c)
const char *idaapi | qstrchr (const char *s1, char c)
uchar *idaapi | qstrchr (uchar *s1, uchar c)
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 *ida_export | 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', NULL if c is not found in s1
const char *idaapi | qstrrchr (const char *s1, char c)
char *idaapi | qstrrchr (char *s1, char c)
const uchar *idaapi | qstrrchr (const uchar *s1, uchar c)
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 *ida_export | qstrrchr (wchar16_t *s1, wchar16_t c)

## Namespaces
| interval
| Functions to work with intervals.

## Macros
#define | IDA_SDK_VERSION 695
| IDA SDK v6.95.
#define | __X86__
| x86 processor by default
#define | BADMEMSIZE 0xFFFFFFFF
| Invalid memory size.
#define | ENUM_SIZE(t) : t
| Compiler-independent way to specify size of enum values.
#define | WIN32_LEAN_AND_MEAN
| compile faster
#define | STL_SUPPORT_PRESENT
#define | EXTERNC extern "C"
| specify C linkage
#define | C_INCLUDE
| helper for 'extern "C" {}' statements More...
#define | C_INCLUDE_END }
| helper for 'extern "C" {}' statements More...
#define | INLINE inline
| inline keyword for c++
#define | MAXSTR 1024
| maximum string size
#define | SMAXSTR QSTRINGIZE(MAXSTR)
| get MAXSTR as a string
#define | NT_CDECL __cdecl
| Some NT functions require __cdecl calling convention.
#define | DEPRECATED __declspec(deprecated)
| identifies parts of the IDA API that are considered deprecated
#define | NORETURN __declspec(noreturn)
| function does not return
#define | PACKED
| type is packed
#define | AS_PRINTF(format_idx, varg_idx)
| function accepts printf-style format and args
#define | AS_SCANF(format_idx, varg_idx)
| function accepts scanf-style format and args
#define | GCC_DIAG_OFF(x)
| disable a specific GCC warning for the following code
#define | GCC_DIAG_ON(x)
| enable or restore a specific GCC warning for the following code
#define | __MF__ 0
| byte sex of our platform (Most significant byte First). More...
#define | qnotused(x) (void)x
| Macro to avoid of message 'Parameter x is never used'.
#define | QUNUSED
#define | va_argi(va, type) va_arg(va, type)
| GNU C complains about some data types in va_arg because they are promoted to int and proposes to replace them by int.
#define | CONST_CAST(x) const_cast<x>
| cast a const to non-const
#define | _QSTRINGIZE(x) #x
| return x as a string. See SMAXSTR for example
#define | QSTRINGIZE(x) _QSTRINGIZE(x)
| see _QSTRINGIZE
#define | idaapi __stdcall
| specifies __stdcall calling convention
#define | ida_export idaapi
| functions marked with this keyword are available as part of the IDA SDK
#define | idaman EXTERNC
| specifies c linkage
#define | ida_export_data
| data items marked with this keyword are available as part of the IDA SDK
#define | ida_module_data
| identifies a data item that will be exported
#define | ida_local
| identifies a non-public type definition
#define | THREAD_SAFE
| Functions callable from any thread are marked with this keyword.
#define | strtoull _strtoui64
#define | FMT_64 "I64"
| compiler-specific printf format specifier for 64-bit numbers
#define | FMT_Z "u"
| compiler-specific printf format specifier for size_t
#define | FMT_ZS "d"
| compiler-specific printf format specifier for ssize_t
#define | SVAL_MIN INT_MIN
| minimum value for an object of type int
#define | SVAL_MAX INT_MAX
| maximum value for an object of type int
#define | FMT_EA ""
| format specifier for ea_t values
#define | BADADDR ea_t(-1)
| this value is used for 'bad address'
#define | BADSEL sel_t(-1)
| 'bad selector' value
#define | qoff64_t int64
| file offset
#define | for if(0); else for
| MSVC <= 1200 is not compliant to the ANSI standard.
#define | eOk 0
| no error
#define | eOS 1
| os error, see errno
#define | eDiskFull 2
| disk full
#define | eReadError 3
| read error
#define | eFileTooLarge 4
| file too large
#define | ZZZ msg("%s:%d\n", __FILE__, __LINE__)
| debug print
#define | BPT __debugbreak()
| trigger a breakpoint from IDA. More...
#define | __CASSERT_N0__(l) COMPILE_TIME_ASSERT_ ## l
| compile time assertion
#define | __CASSERT_N1__(l) __CASSERT_N0__(l)
| compile time assertion
#define | __CASSERT_N2__(l) dummy_var_ ## __CASSERT_N0__(l)
#define | CASSERT(cnd) typedef char __CASSERT_N1__(__LINE__) [(cnd) ? 1 : -1] QUNUSED
| results in a compile error if the cnd is not true
#define | CASSERT0(cnd) (sizeof(char [1 - 2*!(cnd)]) - 1)
| returns 0 if cnd is true - otherwise results in a compile error
#define | INTERR(code) do { if ( under_debugger ) BPT; interr(code); } while(1)
| Show internal error message and terminate execution abnormally. More...
#define | QASSERT(code, cond) do if ( !(cond) ) INTERR(code); while (0)
| run time assertion
#define | QBUFCHECK(buf, size, src) ida_fill_buffer(buf, size, src, __FILE__, __LINE__)
| run time assertion
#define | qnew(t) ((t*)qalloc(sizeof(t)))
| create a new object in memory
#define | qnewarray(t, n) use_qalloc_array
| qalloc_array() is safer than qnewarray
#define | qnumber(array) _countof(array)
| determine capacity of an array
#define | qoffsetof offsetof
| gcc complains about offsetof() - we had to make our version
#define | va_copy(dst, src) dst = src
| copy a va_list
#define | set_vva(va2, vp) va_copy(va2, va_arg(vp, va_list))
| extracts a va_list passed as a variadic function argument
#define | strnicmp _strnicmp
| see 'VS posix names'
#define | stricmp _stricmp
| see 'VS posix names'
#define | strcpy dont_use_strcpy
| use qstrncpy()
#define | stpcpy dont_use_stpcpy
| use qstpncpy()
#define | strncpy dont_use_strncpy
| use qstrncpy()
#define | strcat dont_use_strcat
| use qstrncat()
#define | strncat dont_use_strncat
| use qstrncat()
#define | gets dont_use_gets
| use qfgets()
#define | sprintf dont_use_sprintf
| use qsnprintf()
#define | snprintf dont_use_snprintf
| use qsnprintf()
#define | wsprintfA dont_use_wsprintf
| use qsnprintf()
#define | strcmpi dont_use_strcmpi
| use stricmp()
#define | strncmpi dont_use_strncmpi
| use strnicmp()
#define | getenv dont_use_getenv
| use qgetenv()
#define | setenv dont_use_setenv
| use qsetenv()
#define | putenv dont_use_putenv
| use qsetenv()
#define | strtok dont_use_strrok
| use qstrtok()
#define | strlwr dont_use_strlwr
| use qstrlwr()
#define | strupr dont_use_strupr
| use qstrupr()
#define | waitid dont_use_waitid
| use qwait()
#define | waitpid dont_use_waitpid
| use qwait()
#define | wait dont_use_wait
| use qwait()
#define | streq(s1, s2) (strcmp((s1), (s2)) == 0)
| convenient check for string equality
#define | strieq(s1, s2) (stricmp((s1), (s2)) == 0)
| see streq
#define | strneq(s1, s2, count) (strncmp((s1), (s2), (count)) == 0)
| see streq
#define | strnieq(s1, s2, count) (strnicmp((s1), (s2), (count)) == 0)
| see streq
#define | QMAXPATH 260
| maximum number of characters in a path specification
#define | QMAXFILE 260
| maximum number of characters in a filename specification
#define | DELIMITER ";"
| Delimiter of directory lists. More...
#define | SEEK_SET 0
| beginning of file
#define | SEEK_CUR 1
| current position of the file *
#define | SEEK_END 2
| end of file *
#define | qmin(a, b) ((a) < (b)? (a): (b))
| universal min
#define | qmax(a, b) ((a) > (b)? (a): (b))
| universal max
#define | OPERATOR_NEW(type, count) new type[count]
| GCC does not check for an integer overflow in 'operator new[]'. More...
#define | MC2(c1, c2) ushort(((c2)<<8)|c1)
| We can not use multi-character constants because they are not portable - use this macro instead.
#define | MC3(c1, c2, c3) uint32(((((c3)<<8)|(c2))<<8)|c1)
| We can not use multi-character constants because they are not portable - use this macro instead. More...
#define | MC4(c1, c2, c3, c4) uint32(((((((c4)<<8)|(c3))<<8)|(c2))<<8)|c1)
| We can not use multi-character constants because they are not portable - use this macro instead. More...
#define | read4bytes(h, res, mf) readbytes(h, res, 4, mf)
| see readbytes()
#define | write2bytes(h, l, mf) writebytes(h, l, 2, mf)
| see writebytes()
#define | write4bytes(h, l, mf) writebytes(h, l, 4, mf)
| see writebytes()
#define | swapea swap32
| Switch endianness of an ea_t value.
#define | qhtons(x) swap16(x)
| Switch endianness of given value. More...
#define | qntohs(x) swap16(x)
| Switch endianness of given value. More...
#define | qhtonl(x) swap32(x)
| Switch endianness of given value. More...
#define | qntohl(x) swap32(x)
| Switch endianness of given value. More...
#define | PLACEMENT_DELETE void operator delete(void *, void *) {}
| bcc complains about placement delete
#define | DEFINE_MEMORY_ALLOCATION_FUNCS()
| Convenience macro to declare memory allocation functions. More...
#define | DECLARE_COMPARISON_OPERATORS(type)
| Macro to declare standard inline comparison operators. More...
#define | DECLARE_COMPARISONS(type)
| Macro to declare comparisons for our classes. More...
#define | RELOBJ_MASK 0xF
| the first byte describes the relocation entry types
#define | RELSIZE_1 0
| 8-bit relocations
#define | RELSIZE_2 1
| 16-bit relocations
#define | RELSIZE_4 2
| 32-bit relocations
#define | RELSIZE_8 3
| 64-bit relocations
#define | RELSIZE_CUST 15
| custom relocations, should be handled internally
#define | RELOBJ_CNT 0x80
| counter present (not used yet)
#define | QLIST_DEFINED
| signal that the qlist class has been defined
#define | DEFINE_LIST_ITERATOR(iter, constness, cstr)
| Used for defining the 'iterator' and 'const_iterator' classes for qlist.
#define | DEFINE_REVERSE_ITERATOR(riter, iter)
#define | DEFINE_VIRTUAL_DTOR(name) virtual idaapi ~name(void) {}
| GCC generates multiple destructors and they occupy multiple slots of the virtual function table. More...
#define | DECLARE_VIRTUAL_DTOR(name) virtual idaapi ~name(void)
| see DEFINE_VIRTUAL_DTOR
#define | DECLARE_UNCOPYABLE(T) T &operator=(const T &); T(const T &);
| Declare class as uncopyable. More...
#define | CP_UTF8 65001
| utf-8 codepage
#define | CP_UTF16 1200
| utf-16 codepage
#define | INVALID_FILE_ATTRIBUTES ((DWORD)-1)
| old Visual C++ compilers were not defining this
#define | BELOW_NORMAL_PRIORITY_CLASS 0x00004000
| old Visual C++ compilers were not defining this More...
#define | DEFCOLOR bgcolor_t(-1)
| default color (used in function, segment definitions)
#define | IOREDIR_INPUT 0x01
| input redirection
#define | IOREDIR_OUTPUT 0x02
| output redirection
#define | IOREDIR_APPEND 0x04
| append, do not overwrite the output file
#define | IOREDIR_QUOTED 0x08
| the file name was quoted
#define | LP_NEW_CONSOLE 0x0001
| create new console (only ms windows)
#define | LP_TRACE 0x0002
| debug: unix: ptrace(TRACEME), windows: DEBUG_PROCESS
#define | LP_PATH_WITH_ARGS 0x0004
| 'args' contains executable path too
#define | LP_USE_SHELL 0x0008
| use shell to launch the command. More...
#define | LP_LAUNCH_32_BIT 0x0010
| prefer to launch 32-bit part of file (only mac)
#define | LP_LAUNCH_64_BIT 0x0020
| prefer to launch 64-bit part of file (only mac) More...
#define | LP_NO_ASLR 0x0040
| disable ASLR (only mac)
#define | LP_DETACH_TTY 0x0080
| detach the current tty (unix)
VS posix names
Shut up Visual Studio (VS deprecated posix names but there seems to be no good reason for that)
#define | chdir _chdir
#define | fileno _fileno
#define | getcwd _getcwd
#define | memicmp _memicmp
#define | access _access
#define | F_OK 0
#define | W_OK 2
#define | R_OK 4
Safe buffer append
In the following macros, 'buf' must be always less than 'end'. When we run up to the end, we put a 0 there and don't increase buf anymore
#define | APPCHAR(buf, end, chr)
| Append a character to the buffer checking the buffer size. More...
#define | APPZERO(buf, end)
| Put a zero byte at buffer. More...
#define | APPEND(buf, end, name)
| Append a string to the buffer checking the buffer size. More...

## Typedefs
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 longlong | int64
| signed 64 bit value
typedef ulonglong | uint64
| unsigned 64 bit value
typedef wchar_t | wchar16_t
| 2-byte char
typedef uint32 | wchar32_t
| 4-byte char
typedef ptrdiff_t | ssize_t
| Signed size_t - used to check for size overflows when the counter becomes negative. More...
typedef uint32 | ea_t
| effective address
typedef uint32 | sel_t
| segment selector
typedef uint32 | asize_t
| memory chunk size
typedef int32 | adiff_t
| address difference
typedef asize_t | uval_t
| unsigned value used by the processor. More...
typedef adiff_t | sval_t
| signed value used by the processor. More...
typedef int | error_t
| Error code (errno)
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 _qstring< char > | qstring
| regular string
typedef _qstring< uchar > | qtype
| type string
typedef _qstring< wchar16_t > | qwstring
| unicode string
typedef qvector< uval_t > | uvalvec_t
| vector of unsigned values
typedef qvector< sval_t > | svalvec_t
| vector of signed values
typedef qvector< ea_t > | eavec_t
| vector of addresses
typedef qvector< int > | intvec_t
| vector of integers
typedef qvector< qstring > | qstrvec_t
| vector of strings
typedef qvector< qwstring > | qwstrvec_t
| vector of unicode strings
typedef qvector< bool > | boolvec_t
| vector of bools
typedef uint32 | flags_t
| 32-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_t > | channel_redirs_t
| vector of channel_redir_t objects
typedef int(idaapi * | qthread_cb_t) (void *ud)
| THREADS. More...
typedef struct __qthread_t * | qthread_t
| Thread opaque handle.
typedef struct __qsemaphore_t * | qsemaphore_t
| Semaphore. More...
typedef struct __qmutex_t * | qmutex_t
| Mutex.
typedef void * | qhandle_t
| MS Windows HANDLE.

## Enumerations
enum | tty_control_t { TCT_UNKNOWN = 0, TCT_OWNER, TCT_NOT_OWNER }
| Teletype control.

## Variables
idaman bool ida_export_data | is_ida_kernel
| Is this IDA kernel? If not, we are executing a standalone application.
idaman bool ida_export_data | under_debugger
| is IDA running under a debugger?
idaman ida_export_data char | SubstChar
| default char, used if a char cannot be represented in a codepage

## Macro Definition Documentation

#define C_INCLUDE

Value:
EXTERNC \
{
EXTERNC
#define EXTERNC
specify C linkage
Definition: pro.h:127

helper for 'extern "C" {}' statements

#define C_INCLUDE_END }

helper for 'extern "C" {}' statements

#define __MF__ 0

byte sex of our platform (Most significant byte First).

0: little endian (Intel 80x86). 1: big endian (PowerPC).

#define BPT __debugbreak()

trigger a breakpoint from IDA.

also see INTERR

#define INTERR | ( |  | code | ) | do { if ( under_debugger ) BPT; interr(code); } while(1)

Show internal error message and terminate execution abnormally.

When IDA is being run under a debugger this will ensure that the debugger will break immediately.

#define DELIMITER ";"

Delimiter of directory lists.

for MS DOS, Windows, other systems - ':' for Unix

#define OPERATOR_NEW | ( |  | type,
|  |  | count
| ) |  | new type[count]

GCC does not check for an integer overflow in 'operator new[]'.

We have to do it ourselves. Please note that 'char' arrays can still be allocated with plain 'operator new'.

#define MC3 | ( |  | c1,
|  |  | c2,
|  |  | c3
| ) |  | uint32(((((c3)<<8)|(c2))<<8)|c1)

We can not use multi-character constants because they are not portable - use this macro instead.

#define MC4 | ( |  | c1,
|  |  | c2,
|  |  | c3,
|  |  | c4
| ) |  | uint32(((((((c4)<<8)|(c3))<<8)|(c2))<<8)|c1)

We can not use multi-character constants because they are not portable - use this macro instead.

#define qhtons | ( |  | x | ) | swap16(x)

Switch endianness of given value.

#define qntohs | ( |  | x | ) | swap16(x)

Switch endianness of given value.

#define qhtonl | ( |  | x | ) | swap32(x)

Switch endianness of given value.

#define qntohl | ( |  | x | ) | swap32(x)

Switch endianness of given value.

#define APPCHAR | ( |  | buf,
|  |  | end,
|  |  | chr
| ) |  |

Value:
do \
{ \
char __chr = (chr); \
QASSERT(518, (buf) < (end)); \
*(buf)++ = __chr; \
if ( (buf) >= (end) ) \
{ \
(buf) = (end)-1; \
(buf)[0] = '\0'; \
} \
} while (0)

Append a character to the buffer checking the buffer size.

#define APPZERO | ( |  | buf,
|  |  | end
| ) |  |

Value:
do \
{ \
QASSERT(519, (buf) < (end)); \
*(buf) = '\0'; \
} while (0)

Put a zero byte at buffer.

NB: does not increase buf pointer!

#define APPEND | ( |  | buf,
|  |  | end,
|  |  | name
| ) |  |

Value:
do \
{ \
QASSERT(520, (buf) < (end)); \
const char *__ida_in = (name); \
while ( true ) \
{ \
if ( (buf) == (end)-1 ) \
{ \
(buf)[0] = '\0'; \
break; \
} \
if ( (*(buf) = *__ida_in++) == '\0' ) \
break; \
(buf)++; \
} \
} while ( 0 )

Append a string to the buffer checking the buffer size.

#define DEFINE_MEMORY_ALLOCATION_FUNCS | ( |  | ) |

Value:
void *operator new (size_t _s) { return qalloc_or_throw(_s); } \
void *operator new[](size_t _s) { return qalloc_or_throw(_s); } \
void *operator new(size_t /*size*/, void *_v) { return _v; } \
void operator delete (void *_blk) { qfree(_blk); } \
void operator delete[](void *_blk) { qfree(_blk); } \
PLACEMENT_DELETE
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
qfree
idaman THREAD_SAFE void ida_export qfree(void *alloc)
System independent free.

Convenience macro to declare memory allocation functions.

It must be used for all classes that can be allocated/freed by the IDA kernel.

#define DECLARE_COMPARISON_OPERATORS | ( |  | type | ) |

Value:
bool operator==(const type &r) const { return compare(r) == 0; } \
bool operator!=(const type &r) const { return compare(r) != 0; } \
bool operator< (const type &r) const { return compare(r) < 0; } \
bool operator> (const type &r) const { return compare(r) > 0; } \
bool operator<=(const type &r) const { return compare(r) <= 0; } \
bool operator>=(const type &r) const { return compare(r) >= 0; }
operator<
bool operator<(const bytevec_t &v1, const bytevec_t &v2)
Compare two bytevecs with '<'.
Definition: typeinf.hpp:525

Macro to declare standard inline comparison operators.

#define DECLARE_COMPARISONS | ( |  | type | ) |

Value:
DECLARE_COMPARISON_OPERATORS(type) \
friend int compare(const type &a, const type &b) { return a.compare(b); } \
int compare(const type &r) const
DECLARE_COMPARISON_OPERATORS
#define DECLARE_COMPARISON_OPERATORS(type)
Macro to declare standard inline comparison operators.
Definition: pro.h:1550

Macro to declare comparisons for our classes.

All comparison operators call the compare() function which returns -1/0/1

#define DEFINE_REVERSE_ITERATOR | ( |  | riter,
|  |  | iter
| ) |  |

Value:
class riter \
{ \
iter p; \
public: \
riter(void) {} \
riter(const iter &x) : p(x) {} \
typename iter::value_type &operator*(void) const { iter q=p; return *--q; } \
typename iter::value_type *operator->(void) const { return &(operator*()); } \
riter &operator++(void) { --p; return *this; } \
riter operator++(int) { iter q=p; --p; return q; } \
riter &operator--(void) { ++p; return *this; } \
riter operator--(int) { iter q=p; ++p; return q; } \
bool operator==(const riter &x) const { return p == x.p; } \
bool operator!=(const riter &x) const { return p != x.p; } \
};

#define DEFINE_VIRTUAL_DTOR | ( |  | name | ) | virtual idaapi ~name(void) {}

GCC generates multiple destructors and they occupy multiple slots of the virtual function table.

Since it makes the vft incompatible with other compilers - we simply never generate virtual destructors for gcc. This is not an ideal solution but it works. We have this problem only under MS Windows. On other platforms everything is compiled with GCC so the vft layout is the same for the kernel and plugins.

#define DECLARE_UNCOPYABLE | ( |  | T | ) | T &operator=(const T &); T(const T &);

Declare class as uncopyable.

(copy assignment and copy ctr are undefined, so if anyone calls them, there will be a compilation or link error)

#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000

old Visual C++ compilers were not defining this

## Typedef Documentation

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.

typedef asize_t uval_t

unsigned value used by the processor.

- for 32-bit ea_t - uint32
- for 64-bit ea_t - uint64

typedef adiff_t sval_t

signed value used by the processor.

- for 32-bit ea_t - int32
- for 64-bit ea_t - int64

typedef int(idaapi * qthread_cb_t) (void *ud)

THREADS.

Thread callback function

typedef struct __qsemaphore_t * qsemaphore_t

Semaphore.

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

## Function Documentation

qtime64_t make_qtime64 | ( | uint32 | secs,
|  | int32 | usecs = `0`
| ) |  |
| inline

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

Parameters

  secs | seconds
  usecs | microseconds

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

  buf | output buffer
  bufsize | size of the output buffer
  t | calendar time

Returns
  success

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

  buf | output buffer
  bufsize | of the output buffer
  t | calendar time

Returns
  success

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

Converts a time value to a tm structure.

Parameters

  [out] | _tm | result
  | t | local time

Returns
  success

idaman THREAD_SAFE size_t ida_export qstrftime | ( | char * | buf,
|  | size_t | bufsize,
|  | const char * | format,
|  | qtime32_t | t
| ) |  |

Get string representation of a qtime32_t.

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

Parameters

  buf | output buffer
  bufsize | of the output buffer
  format | format string
  t | time value

Returns
  length of the resulting string

idaman THREAD_SAFE void ida_export get_nsec_stamp | ( | uint64 * | nsecs | ) |

High resolution timer.

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

Parameters

  [out] | nsecs | result

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

Generate a random buffer.

Parameters

  [out] | buffer | pointer to result
  | bufsz | size of buffer

Returns
  success

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

Reverse memory block.

Analog of strrev() function

Parameters

  buf | pointer to buffer to reverse
  size | size of buffer

Returns
  pointer to buffer

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

Replace all occurrences of a character within a string.

Parameters

  str | to modify
  char1 | char to be replaced
  char2 | replacement char

Returns
  pointer to resulting string

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

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.

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

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

  s1 | string to be searched
  s2 | string to search for

Returns
  a pointer to the first occurrence of s2 within s1, NULL if none exists

GCC_DIAG_OFF | ( | format- | nonliteral | ) |

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!

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

  buf | output buffer. Can be == s1, but must not be NULL
  bufsize | size of buffer

Returns
  pointer to result

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

Get the current working directory.

Parameters

  buf | output buffer
  bufsize | size of buffer This function calls error() if any problem occurs.

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] | buf | buffer for the directory part. can be NULL.
  [out] | bufsize | size of this buffer
  | path | path to split

Return values

  true | ok
  false | input buffer did not have the directory part. In this case the buffer is filled with "."

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

  buf | output buffer. Can be == base, but must not be NULL
  bufsize | size of buffer
  base | base name
  ext | extension

Returns
  pointer to result

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

Split filename into base name and extension.

Parameters

  file | filename, may be changed
  base | filled with base part, can be NULL
  ext | filled with extension part, can be NULL

Returns
  the base part

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

Get the file name part of the given path.

Returns
  NULL if path is NULL

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

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

Parameters

  file | the file name to look for. If the file is an absolute path then buf will return the file value.
  buf | output buffer to hold the full file path
  bufsize | output buffer size
  search_cwd | search the current directory if file was not found in the PATH

Returns
  true if the file was found and false otherwise

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

  outbuf | buffer to hold the answer. may be the same as the file name.
  bufsize | output buffer size
  file | the file name
  ext | new extension (with or without '.')

Returns
  pointer to the new file name

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

Get pointer to extension of file name.

Parameters

  file | filename

Returns
  pointer to the file extension or NULL if extension doesn't exist

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

  buf | output buffer
  bufsize | size of the output buffer
  file | file name
  ext | extension (with or without '.')

Returns
  pointer to the new 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

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

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

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

idaman THREAD_SAFE int32 ida_export qtell | ( | int | h | ) |

Works the same as it's counterpart from Clib.

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

idaman THREAD_SAFE int32 ida_export qseek | ( | int | h,
|  | int32 | offset,
|  | int | whence
| ) |  |

Works the same as it's counterpart from Clib.

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

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

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

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

idaman THREAD_SAFE uint32 ida_export qfilesize | ( | const char * | fname | ) |

Get the file size.

This function may return 0 if the file is not found or if the file is too large (>4GB). Call get_qerrno() and compare against eFileTooLarge to tell between the two cases.

idaman THREAD_SAFE uint32 ida_export qfilelength | ( | int | h | ) |

Get file length in bytes.

Parameters

  h | file descriptor

Returns
  file length in bytes, -1 if error

idaman THREAD_SAFE int ida_export qchsize | ( | int | h,
|  | uint32 | fsize
| ) |  |

Change file size.

Parameters

  h | file descriptor
  fsize | desired size

Return values

  0 | on success
  -1 | otherwise and qerrno is set

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

Create an empty directory.

Parameters

  file | name (or full path) of directory to be created
  mode | permissions (only used on unix systems)

Returns
  0 success
  -1 otherwise and qerrno is set

idaman THREAD_SAFE NORETURN void ida_export qexit | ( | int | code | ) |

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

Parameters

  code | exit code

template<class T >

T left_shift | ( | const T & | value,
|  | int | shift
| ) |  |

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.

template<class T >

T right_ushift | ( | const T & | value,
|  | int | shift
| ) |  |

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.

template<class T >

T right_sshift | ( | const T & | value,
|  | int | shift
| ) |  |

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.

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'.

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

Read at most 4 bytes from file.

Parameters

  h | file handle
  res | value read from file
  size | size of value in bytes (1,2,4)
  mf | is MSB first?

Returns
  0 on success, nonzero otherwise

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

Write at most 4 bytes to file.

Parameters

  h | file handle
  l | value to write
  size | size of value in bytes (1,2,4)
  mf | is MSB first?

Returns
  0 on success, nonzero otherwise

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

Read a 2 byte entity from a file.

Parameters

  h | file handle
  res | value read from file
  mf | is MSB first?

Returns
  0 on success, nonzero otherwise

ushort swap16 | ( | ushort | x | ) |
| inline

Switch endianness of given 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

  dst | result of swap
  src | value to be swapped
  size | size of value: can be 1, 2, 4, 8, or 16. For any other values of size this function does nothing

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

  x | value to rotate
  count | shift amount
  bits | number of bits to rotate (32 will rotate a dword)
  offset | number of first bit to rotate. (bits=8 offset=16 will rotate the third byte of the value)

Returns
  the rotated value

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

Change capacity of given qvector.

Parameters

  vec | a pointer to a qvector
  old | a pointer to the qvector's array
  cnt | number of elements to reserve
  elsize | size of each element

Returns
  a pointer to the newly allocated array

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

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'

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

Decode base64.

Decode base64

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

Convert tabulations to spaces.

Parameters

  out | output buffer to append to
  str | input string. can not be equal to out->c_str()
  tabsize | tabulation size

Returns
  true-replaced some tabs

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

Unicode -> char.

Char -> unicode

idaman void ida_export oem2char | ( | char * | inout | ) |

Do not use windows CharToOem/OemToChar functions - ida can replace CodePage.

idaman bool ida_export set_codepages | ( | int | acp,
|  | int | oemcp
| ) |  |

Set codepages to be used for char2oem/oem2char (Windows only).

if parameter == -1, use CP_ACP and CP_OEMCP

Returns
  false if codepage unsupported

idaman int ida_export get_codepages | ( | int * | oemcp | ) |

Get codepages used for char2oem/oem2char (Windows only).

Parameters

  [out] | oemcp | pointer to oem codepage

Returns
  current codepage

idaman int ida_export convert_codepage | ( | const void * | in,
|  | int | insize,
|  | void * | out,
|  | size_t | outsize,
|  | int | incp,
|  | int | outcp,
|  | int | flags = `0`
| ) |  |

Convert data from codepage incp to outcp.

Either codepage can be CP_UTF16 for Unicode text (buffer sizes are still in bytes!) flags: 1: convert control characters (0x01-0x1F) to glyphs

Parameters

  insize | insize == -1: input is null-terminated

Returns
  number of bytes after conversion (not counting termination zero)

idaman int ida_export convert_encoding | ( | const char * | fromcode,
|  | const char * | tocode,
|  | const bytevec_t * | indata,
|  | bytevec_t * | out,
|  | int | flags = `0`
| ) |  |

Convert data from encoding fromcode into tocode.

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

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

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

Parameters

  | cmdline | the string to be parsed
  [out] | args | a string vector to hold the results
  [out] | redirs | map of channel redirections found in cmdline if NULL, redirections won't be parsed if there are syntax errors in redirections, consider them as arguments
  | flags | LP_PATH_WITH_ARGS or 0

Returns
  the number of parsed arguments

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

Copy and expand command line arguments.

For '' arguments the file contents are inserted into the resulting argv. Format of the file: one switch per line, ';' for comment lines

Parameters

  [out] | p_argc | size of the returned argv array
  | argc | number of entries in argv array
  | argv | array of strings

Returns
  new argv (terminated by NULL). It must be freed with free_argv()

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 "*.c" because * may be inadvertently expanded by the shell

Returns
  true: modified 'arg'

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+

Returns
  true-ok, false-parse error

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

Launch the specified process in parallel.

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

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()

idaman THREAD_SAFE int ida_export qwait_timed | ( | int | child,
|  | int * | status,
|  | 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()

Parameters

  timeout_ms | timeout in milliseconds

idaman THREAD_SAFE int ida_export check_process_exit | ( | void * | handle,
|  | int * | exit_code,
|  | int | msecs = `-1`
| ) |  |

Check whether process has terminated or not.

Parameters

  | handle | process handle to wait for
  [out] | exit_code | pointer to the buffer for the exit code
  | msecs | how long to wait. special values: 0: do not wait 1 or -1: wait infinitely other values: timeout in milliseconds

Return values

  0 | process has exited, and the exit code is available. if *exit_code < 0: the process was killed with a signal -*exit_code
  1 | process has not exited yet
  -1 | error happened, see error code for winerr() in *exit_code

idaman THREAD_SAFE 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.

Note
  The current terminal is supposed to be /dev/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

idaman THREAD_SAFE bool ida_export qgetenv | ( | const char * | varname,
|  | qstring * | buf = `NULL`
| ) |  |

Thread safe function to work with the environment.

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)

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

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

idaman THREAD_SAFE int ida_export qpipe_close | ( | qhandle_t | handle | ) |

Close a pipe.

Returns
  error code (0-ok)

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

Wait for file/socket/pipe handles.

Parameters

  handles | handles to wait for
  n | number of handles
  write_bitmask | bitmask of indexes of handles opened for writing
  idx | handle index
  timeout_ms | timeout value in milliseconds

Returns
  error code. on timeout, returns 0 and sets idx to -1