functions that convert between string encodings More...
Modules | |
String to address conversion flags | |
passed as 'flags' parameter to str2ea_ex() | |
Macros | |
#define | MAX_NUMBUF (128+8) |
16-byte value in binary base (0b00101010...) | |
#define | b2a b2a32 |
shortcut for number->string conversion, see b2a32() | |
#define | btoa btoa32 |
shortcut for number->string conversion, see btoa32() | |
#define | atob atob32 |
shortcut for string->number conversion, see atob32() | |
Functions | |
bool | ea2str (qstring *out, ea_t ea) |
Convert linear address to UTF-8 string. | |
idaman bool ida_export | str2ea (ea_t *out, const char *str, ea_t screen_ea=BADADDR) |
Convert string to linear address. More... | |
idaman bool ida_export | str2ea_ex (ea_t *out, const char *str, ea_t screen_ea=BADADDR, int flags=0) |
Same as str2ea() but possibly with some steps skipped. More... | |
idaman bool ida_export | atoea (ea_t *out, const char *str) |
Convert a number in C notation to an address. More... | |
idaman size_t ida_export | stoa (qstring *out, ea_t from, sel_t seg) |
Convert segment selector to UTF-8 string. | |
idaman int ida_export | atos (sel_t *seg, const char *str) |
Convert UTF-8 string to segment selector. More... | |
idaman size_t ida_export | b2a_width (int nbytes, int radix) |
Get the number of UTF-8 characters required to represent a number with the specified number of bytes and radix. More... | |
idaman size_t ida_export | b2a32 (char *buf, size_t bufsize, uint32 x, int nbytes, int radix) |
Convert number to UTF-8 string (includes leading zeroes). More... | |
idaman size_t ida_export | b2a64 (char *buf, size_t bufsize, uint64 x, int nbytes, int radix) |
Same as b2a32(), but can handle 'nbytes' = 8. | |
idaman size_t ida_export | btoa_width (int nbytes, flags64_t flag, int n) |
Get max number of UTF-8 characters required to represent a given type of value, with a given size (without leading zeroes). More... | |
idaman size_t ida_export | btoa32 (char *buf, size_t bufsize, uint32 x, int radix=0) |
Same as b2a32(), but will generate a string without any leading zeroes. More... | |
idaman size_t ida_export | btoa64 (char *buf, size_t bufsize, uint64 x, int radix=0) |
64-bit equivalent of btoa32() | |
idaman size_t ida_export | btoa128 (char *buf, size_t bufsize, uint128 x, int radix=0) |
128-bit equivalent of btoa32() | |
idaman size_t ida_export | numop2str (char *buf, size_t bufsize, ea_t ea, int n, uint64 x, int nbytes, int radix=0) |
Convert instruction operand immediate number to UTF-8. More... | |
idaman bool ida_export | atob32 (uint32 *x, const char *str) |
Convert UTF-8 to a number using the current assembler formats. More... | |
idaman bool ida_export | atob64 (uint64 *x, const char *str) |
64-bit equivalent of atob32() | |
idaman size_t ida_export | pretty_print_size (char *buf, size_t bufsize, uint64 value) |
Pretty-print a size. More... | |
idaman bool ida_export | parse_pretty_size (uint64 *out, const char *in) |
Parse a pretty-printed size. More... | |
idaman void ida_export | append_disp (qstring *buf, adiff_t disp, bool tag=true) |
Auxiliary function. More... | |
idaman THREAD_SAFE int ida_export | r50_to_asc (char *p, const ushort *r, int k) |
Convert RADIX50 -> UTF-8. More... | |
int THREAD_SAFE | asc_to_r50 (ushort *r, const char *p, int k) |
Convert UTF-8 -> RADIX50 (see r50_to_asc()) | |
Detailed Description
functions that convert between string encodings
Function Documentation
◆ str2ea()
idaman bool ida_export str2ea | ( | ea_t * | out, |
const char * | str, | ||
ea_t | screen_ea = BADADDR |
||
) |
Convert string to linear address.
Tries to interpret the string as:
1) "current IP" keyword if supported by assembler (e.g. "$" in x86)
2) segment:offset expression, where "segment" may be a name or a fixed segment register (e.g. cs, ds)
3) just segment name/register (translated to segment's start address)
4) a name in the database (or debug name during debugging)
5) hexadecimal value without prefix or suffix
6) +delta or -delta, where numerical 'delta' is added to or subtracted from 'screen_ea'
7) register name (only during debugging)
8) if all else fails, try to evaluate 'str' as an IDC expression
- Parameters
-
out[out] the buffer to put the result str string to parse screen_ea the current address in the disassembly/pseudocode view
- Returns
- success
◆ str2ea_ex()
idaman bool ida_export str2ea_ex | ( | ea_t * | out, |
const char * | str, | ||
ea_t | screen_ea = BADADDR , |
||
int | flags = 0 |
||
) |
Same as str2ea() but possibly with some steps skipped.
- Parameters
-
[out] out the buffer to put the result str string to parse screen_ea the current address in the disassembly/pseudocode view flags see String to address conversion flags
- Returns
- success
◆ atoea()
idaman bool ida_export atoea | ( | ea_t * | out, |
const char * | str | ||
) |
Convert a number in C notation to an address.
decimal: 1234
octal: 0123
hexadecimal: 0xabcd
binary: 0b00101010
- Parameters
-
[out] out the buffer to put the result str the string to parse
◆ atos()
idaman int ida_export atos | ( | sel_t * | seg, |
const char * | str | ||
) |
Convert UTF-8 string to segment selector.
- Return values
-
0 fail 1 ok (hex) 2 ok (segment name or reg)
◆ b2a_width()
idaman size_t ida_export b2a_width | ( | int | nbytes, |
int | radix | ||
) |
Get the number of UTF-8 characters required to represent a number with the specified number of bytes and radix.
- Parameters
-
nbytes if 0, use default number of bytes, usually 4 or 8 depending on __EA64__ radix if 0, use default radix, usually 16
◆ b2a32()
idaman size_t ida_export b2a32 | ( | char * | buf, |
size_t | bufsize, | ||
uint32 | x, | ||
int | nbytes, | ||
int | radix | ||
) |
Convert number to UTF-8 string (includes leading zeroes).
- Parameters
-
x value to convert buf output buffer bufsize size of output buffer nbytes 1, 2, 3, or 4 radix 2, 8, 10, or 16
- Returns
- size of resulting string
◆ btoa_width()
idaman size_t ida_export btoa_width | ( | int | nbytes, |
flags64_t | flag, | ||
int | n | ||
) |
Get max number of UTF-8 characters required to represent a given type of value, with a given size (without leading zeroes).
- Parameters
-
nbytes size of number flag should be one of FF_ for #MS_0TYPE n if 1, shr 'flag' by 4
◆ btoa32()
idaman size_t ida_export btoa32 | ( | char * | buf, |
size_t | bufsize, | ||
uint32 | x, | ||
int | radix = 0 |
||
) |
Same as b2a32(), but will generate a string without any leading zeroes.
Can be used to output some numbers in the instructions.
◆ numop2str()
idaman size_t ida_export numop2str | ( | char * | buf, |
size_t | bufsize, | ||
ea_t | ea, | ||
int | n, | ||
uint64 | x, | ||
int | nbytes, | ||
int | radix = 0 |
||
) |
Convert instruction operand immediate number to UTF-8.
This is the main function to output numbers in the instruction operands.
It prints the number with or without the leading zeroes depending on the flags.
This function is called from out_value(). Please use out_value() if you can.
◆ atob32()
idaman bool ida_export atob32 | ( | uint32 * | x, |
const char * | str | ||
) |
Convert UTF-8 to a number using the current assembler formats.
e.g. for ibmpc, '12o' is octal, '12h' is hex, etc.
- Returns
- success
◆ pretty_print_size()
idaman size_t ida_export pretty_print_size | ( | char * | buf, |
size_t | bufsize, | ||
uint64 | value | ||
) |
Pretty-print a size.
The output is concise and easy to grasp, like 23k, 1.2G, or 8.56T. Values >= 1000TB are printed as "infty".
- Parameters
-
buf the output buffer bufsize size of the output buffer. 8 is enough. value value to print
- Returns
- number of bytes stored into buf. if the buffer is too small, the output will be truncated.
◆ parse_pretty_size()
idaman bool ida_export parse_pretty_size | ( | uint64 * | out, |
const char * | in | ||
) |
Parse a pretty-printed size.
This performs the reverse operation of pretty_print_size()
- Parameters
-
out the resulting value in the formatted string
- Returns
- success
◆ append_disp()
idaman void ida_export append_disp | ( | qstring * | buf, |
adiff_t | disp, | ||
bool | tag = true |
||
) |
Auxiliary function.
Print displacement to a name (+disp or -disp) in the natural radix
- Parameters
-
buf output buffer to append to disp displacement to output. 0 leads to no modifications tag whether to output color tags
◆ r50_to_asc()
idaman THREAD_SAFE int ida_export r50_to_asc | ( | char * | p, |
const ushort * | r, | ||
int | k | ||
) |
Convert RADIX50 -> UTF-8.
- Parameters
-
p pointer to UTF-8 string r pointer to radix50 string k number of elements in the input string
(element of radix50 string is a word)
(element of UTF-8 string is a character)
- Returns
- number of elements left unprocessed in the input string,
because the input string contains unconvertible elements.
0-ok, all elements are converted
Generated by 1.9.3