IDA C++ SDK 9.2
Loading...
Searching...
No Matches
qsnprintf/qsscanf

safer versions of sprintf/sscanf More...

Functions

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

Variables

idaman size_t n
idaman size_t const char * format
idaman size_t const char idaman const char idaman size_t const char va_list va
 See qsnprintf()
idaman const char * end

File I/O

The following functions work just like their counterparts from Clib, only they are safer, system independent, and they set qerrno (see get_qerrno()).

idaman THREAD_SAFE const char * format
idaman THREAD_SAFE va_list va
 See qsscanf()
idaman THREAD_SAFE const char va_list va
int code = qvfprintf(fp, format, va)
idaman THREAD_SAFE AS_PRINTF (1, 0) void ida_export vqperror(const char *format
 Print error message to stderr (analog of perror)
THREAD_SAFE AS_PRINTF (1, 2) inline void qperror(const char *format
 See vqperror()
THREAD_SAFE va_start (va, format)
 va_end (va)
idaman THREAD_SAFE FILE *ida_export qfopen (const char *file, const char *mode)
idaman THREAD_SAFE ssize_t ida_export qfread (FILE *fp, void *buf, size_t n)
idaman THREAD_SAFE ssize_t ida_export qfwrite (FILE *fp, const void *buf, size_t n)
idaman THREAD_SAFE qoff64_t ida_export qftell (FILE *fp)
idaman THREAD_SAFE int ida_export qfseek (FILE *fp, qoff64_t offset, int whence)
idaman THREAD_SAFE int ida_export qfclose (FILE *fp)
idaman THREAD_SAFE int ida_export qflush (FILE *fp)
idaman THREAD_SAFE int ida_export qfputc (int chr, FILE *fp)
idaman THREAD_SAFE int ida_export qfgetc (FILE *fp)
idaman THREAD_SAFE char *ida_export qfgets (char *s, size_t len, FILE *fp)
idaman THREAD_SAFE int ida_export qfputs (const char *s, FILE *fp)
idaman FILE *ida_export qtmpfile (void)
idaman THREAD_SAFE int ida_export qunlink (const char *fname)
idaman THREAD_SAFE int ida_export qaccess (const char *fname, int mode)
idaman THREAD_SAFE char *ida_export qgets (char *line, size_t linesize)
idaman THREAD_SAFE uint64 ida_export qfsize (FILE *fp)
idaman THREAD_SAFE AS_PRINTF (2, 0) int ida_export qvfprintf(FILE *fp
idaman THREAD_SAFE AS_SCANF (2, 0) int ida_export qvfscanf(FILE *fp
THREAD_SAFE AS_PRINTF (2, 3) inline int qfprintf(FILE *fp
 Display a dialog box and wait for the user to input an segment name (ui_ask_seg).
THREAD_SAFE AS_SCANF (2, 3) inline int qfscanf(FILE *fp

Detailed Description

safer versions of sprintf/sscanf

Our definitions of sprintf-like functions support one additional format specifier

 "%a"              which corresponds to ::ea_t

Usual optional fields like the width can be used too: %04a. The width specifier will be doubled for 64-bit version. These function return the number of characters actually written to the output string. excluding the terminating zero. (which is different from the snprintf). They always terminate the output with a zero byte (if n > 0).

Function Documentation

◆ AS_PRINTF() [1/6]

idaman AS_PRINTF ( 3 ,
4  )

◆ AS_SCANF() [1/4]

idaman size_t const char idaman AS_SCANF ( 2 ,
3  ) const

A safer snprintf.

◆ AS_PRINTF() [2/6]

idaman size_t const char idaman const char idaman AS_PRINTF ( 3 ,
0  )

A safer sscanf.

◆ AS_SCANF() [2/4]

idaman AS_SCANF ( 2 ,
0  ) const

◆ AS_PRINTF() [3/6]

THREAD_SAFE AS_PRINTF ( 1 ,
0  ) const

Print error message to stderr (analog of perror)

Output a formatted string to the output window [analog of printf()].

Display "no memory for module ..." dialog box and exit.

Display info dialog box and wait for the user to press Enter or Esc.

Display warning dialog box and wait for the user to press Enter or Esc.

See show_wait_box()

This messagebox will by default contain a "Don't display this message again"
checkbox if the message is repetitively displayed. If checked, the message
won't be displayed anymore during the current IDA session.

Parameters
formatprintf() style format string. It may have some prefixes, see 'Format of dialog box' for details.
vapointer to variadic arguments.
Returns
< 0 in case the warning was inhibited, >= 0 otherwise

This messagebox will by default contain a "Don't display this message again"
checkbox. If checked, the message will never be displayed anymore (state saved
in the Windows registry or the idareg.cfg file for a non-Windows version).

Parameters
formatprintf() style format string. It may have some prefixes, see 'Format of dialog box' for details.
vapointer to variadic arguments.
Returns
< 0 in case the message was inhibited, >= 0 otherwise
Parameters
formatprintf() style message string.
vapointer to variadic arguments.

Everything appearing on the output window may be written to a text file. For this the user should define the following environment variable:
set IDALOG=idalog.txt

Parameters
formatprintf() style message string.
vapointer to variadic arguments.
Returns
number of bytes output

◆ AS_PRINTF() [4/6]

THREAD_SAFE AS_PRINTF ( 1 ,
2  ) const

See vqperror()

Display error dialog box and exit.

Show a message box asking to send the input file to suppo.nosp@m.rt@h.nosp@m.ex-ra.nosp@m.ys.c.nosp@m.om.

Replace the label of "Please wait dialog box".

Display a dialog box with "Please wait...".

The behavior of the dialog box can be configured with well-known
tokens, that should be placed at the start of the format string:
"NODELAY\n": the dialog will show immediately, instead of
appearing after usual grace threshold
"HIDECANCEL\n": the cancel button won't be added to the dialog box
and user_cancelled() will always return false (but
can be called to refresh UI)
Using "HIDECANCEL" implies "NODELAY"
Plugins must call hide_wait_box() to close the dialog box, otherwise
the user interface will remain disabled.
Note that, if the wait dialog is already visible, show_wait_box() will
1) push the currently-displayed text on a stack
2) display the new text
Then, when hide_wait_box() is called, if that stack isn't empty its top
label will be popped and restored in the wait dialog.
This implies that a plugin should call hide_wait_box() exactly as many
times as it called show_wait_box(), or the wait dialog might remain
visible and block the UI.
Also, in case the plugin knows the wait dialog is currently displayed,
alternatively it can call replace_wait_box(), to replace the text of the
dialog without pushing the currently-displayed text on the stack.

Parameters
formatthe reason why the input file is bad

If you just want to display an error message and let IDA continue, do NOT use this function! Use warning() or info() instead.

Parameters
formatprintf() style message string. It may have some prefixes, see 'Format of dialog box' for details.

◆ va_start()

va_start ( va ,
format  )
Initial value:
{
va_list va
idaman THREAD_SAFE va_list va
See qsscanf()
Definition err.h:21

◆ va_end()

va_end ( va )

◆ qfopen()

idaman THREAD_SAFE FILE *ida_export qfopen ( const char * file,
const char * mode )

◆ qfread()

idaman THREAD_SAFE ssize_t ida_export qfread ( FILE * fp,
void * buf,
size_t n )

◆ qfwrite()

idaman THREAD_SAFE ssize_t ida_export qfwrite ( FILE * fp,
const void * buf,
size_t n )

◆ qftell()

idaman THREAD_SAFE qoff64_t ida_export qftell ( FILE * fp)

◆ qfseek()

idaman THREAD_SAFE int ida_export qfseek ( FILE * fp,
qoff64_t offset,
int whence )

◆ qfclose()

idaman THREAD_SAFE int ida_export qfclose ( FILE * fp)

◆ qflush()

idaman THREAD_SAFE int ida_export qflush ( FILE * fp)

◆ qfputc()

idaman THREAD_SAFE int ida_export qfputc ( int chr,
FILE * fp )

◆ qfgetc()

idaman THREAD_SAFE int ida_export qfgetc ( FILE * fp)

◆ qfgets()

idaman THREAD_SAFE char *ida_export qfgets ( char * s,
size_t len,
FILE * fp )

◆ qfputs()

idaman THREAD_SAFE int ida_export qfputs ( const char * s,
FILE * fp )

◆ qtmpfile()

idaman FILE *ida_export qtmpfile ( void )

◆ qunlink()

idaman THREAD_SAFE int ida_export qunlink ( const char * fname)

◆ qaccess()

idaman THREAD_SAFE int ida_export qaccess ( const char * fname,
int mode )

◆ qgets()

idaman THREAD_SAFE char *ida_export qgets ( char * line,
size_t linesize )

◆ qfsize()

idaman THREAD_SAFE uint64 ida_export qfsize ( FILE * fp)

◆ AS_PRINTF() [5/6]

idaman THREAD_SAFE AS_PRINTF ( 2 ,
0  )

◆ AS_SCANF() [3/4]

idaman THREAD_SAFE AS_SCANF ( 2 ,
0  )

◆ AS_PRINTF() [6/6]

AS_PRINTF ( 2 ,
3  )

Display a dialog box and wait for the user to input an segment name (ui_ask_seg).

Display a dialog box and wait for the user to input an identifier.

Display a dialog box and get choice from "Yes", "No", "Cancel".

Display a dialog box and wait for the user to input an number (ui_ask_long).

This function allows to enter segment register names, segment base paragraphs, segment names to denote a segment.

Parameters
selin/out parameter. contains selector of the segment
formatprintf() style format string with the question
Return values
0if the user pressed Esc.
1ok, the user entered an segment name

The number is represented in C-style. This function allows to enter any IDC expression and properly calculates it.

Parameters
valuein/out parameter. contains pointer to the number
formatprintf() style format string with the question
Return values
0if the user pressed Esc.
1ok, the user entered a valid number.
Parameters
defltdefault choice: one of Button IDs
formatThe question in printf() style format
Returns
the selected button (one of Button IDs). Esc key returns #ASKBTN_CANCEL.

If the user enters a non-valid identifier, this function displays a warning and allows the user to correct it. CPU register names are usually forbidden.

Parameters
strqstring to fill. Can contain the default value. Cannot be nullptr.
formatprintf() style format string with the question
Returns
false if the user cancelled the dialog, otherwise returns true.

If the user enters a non-valid identifier, this function displays a warning and allows the user to correct it. CPU register names are permitted.

Parameters
strqstring to fill. Can contain the default value. Cannot be nullptr.
formatprintf() style format string with the question
Returns
false if the user cancelled the dialog, otherwise returns true.

◆ AS_SCANF() [4/4]

THREAD_SAFE AS_SCANF ( 2 ,
3  )

Variable Documentation

◆ n

idaman size_t const char idaman const char idaman size_t n

◆ format [1/2]

idaman const char const char* format

◆ va [1/3]

idaman const char va_list va

See qsnprintf()

See qsscanf()

◆ end

idaman const char* end

◆ format [2/2]

idaman const char const char * format

◆ va [2/3]

idaman const char va_list va
Initial value:
{
return (cexpr_t *)HEXDSP(hx_vcreate_helper, standalone, &type, format, va)
idaman THREAD_SAFE const char * format
Definition fpro.h:78
const tinfo_t & type
Definition hexrays.hpp:7301
@ hx_vcreate_helper
Definition hexrays.hpp:9035
Ctree item: expression.
Definition hexrays.hpp:6381

See qsscanf()

◆ va [3/3]

idaman THREAD_SAFE const char va_list va

◆ code

return code = qvfprintf(fp, format, va)