Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_types.h>
Go to the source code of this file.
Classes | |
struct | bitvector_t |
structure for bitvector More... | |
Macros | |
#define | rz_bv_neg rz_bv_complement_2 |
#define | rz_bv_not rz_bv_complement_1 |
#define | rz_bv_new_zero(l) rz_bv_new(l) |
#define | rz_bv_new_one(l) rz_bv_new_from_ut64(l, 1) |
#define | rz_bv_new_two(l) rz_bv_new_from_ut64(l, 2) |
#define | rz_bv_new_minus_one(l) rz_bv_new_from_st64(l, -1) |
Typedefs | |
typedef struct bitvector_t | RzBitVector |
#define rz_bv_neg rz_bv_complement_2 |
Definition at line 58 of file rz_bitvector.h.
#define rz_bv_new_minus_one | ( | l | ) | rz_bv_new_from_st64(l, -1) |
Definition at line 108 of file rz_bitvector.h.
#define rz_bv_new_one | ( | l | ) | rz_bv_new_from_ut64(l, 1) |
Definition at line 106 of file rz_bitvector.h.
#define rz_bv_new_two | ( | l | ) | rz_bv_new_from_ut64(l, 2) |
Definition at line 107 of file rz_bitvector.h.
#define rz_bv_new_zero | ( | l | ) | rz_bv_new(l) |
Definition at line 105 of file rz_bitvector.h.
#define rz_bv_not rz_bv_complement_1 |
Definition at line 59 of file rz_bitvector.h.
typedef struct bitvector_t RzBitVector |
RZ_API RZ_OWN RzBitVector* rz_bv_add | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y, | ||
RZ_NULLABLE bool * | carry | ||
) |
Result of (x + y) mod 2^length Both operands must have the same length.
x | RzBitVector, Operand |
y | RzBitVector, Operand |
carry | bool*, bool pointer to where to save the carry value. |
Definition at line 683 of file bitvector.c.
References a, b, NULL, pos, rz_bv_get(), rz_bv_new(), rz_bv_set(), rz_return_val_if_fail, rz_warn_if_reached, and x.
Referenced by rz_bv_mul(), rz_bv_sub(), and rz_il_handler_add().
RZ_API RZ_OWN RzBitVector* rz_bv_and | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of x AND y (and
operation to every bits) Both operands must have the same length.
x | RzBitVector, operand |
y | RzBitVector, operand |
Definition at line 546 of file bitvector.c.
References bitvector_t::_elem_len, bitvector_t::bits, i, bitvector_t::large_a, NULL, rz_bv_new(), rz_return_val_if_fail, bitvector_t::small_u, and x.
Referenced by rz_il_handler_logical_and().
RZ_API RZ_OWN RzBitVector* rz_bv_append | ( | RZ_NONNULL RzBitVector * | high, |
RZ_NONNULL RzBitVector * | low | ||
) |
Append bv2 to bv1 to get new bitvector
high | bitvector to occupy the most significant part of the result |
low | bitvector to occupy the least significant part of the result |
Definition at line 326 of file bitvector.c.
References bitvector_t::len, NULL, rz_bv_copy_nbits(), rz_bv_new(), and rz_return_val_if_fail.
Referenced by rz_il_handler_append().
RZ_API RZ_OWN RzBitVector* rz_bv_append_zero | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | delta_len | ||
) |
Return a new bitvector appended with n zero bits
bv | RzBitVector, pointer to bitvector |
delta_len,the | number of zero bits |
Definition at line 258 of file bitvector.c.
References i, NULL, pos, rz_bv_get(), rz_bv_new(), rz_bv_set(), and rz_return_val_if_fail.
RZ_API RZ_OWN char* rz_bv_as_hex_string | ( | RZ_NONNULL RzBitVector * | bv, |
bool | pad | ||
) |
Return bitvector string in hexadecimal format
bv | RzBitVector, pointer to bitvector |
pad | whether to prepend leading zeroes to indicate the bitvector size |
Definition at line 121 of file bitvector.c.
References hex, i, malloc(), NULL, pad(), PFMT64x, rz_return_val_if_fail, rz_str_newf(), rz_strf, and cmd_descs_generate::str.
Referenced by il_opdmp_bitv(), rz_il_event_json(), rz_il_event_stringify(), rz_il_value_stringify(), and rzil_print_register_bitv().
RZ_API RZ_OWN char* rz_bv_as_string | ( | RZ_NONNULL RzBitVector * | bv | ) |
Return bitvector string
bv | RzBitVector, pointer to bitvector |
Definition at line 98 of file bitvector.c.
References i, malloc(), NULL, rz_bv_get(), rz_return_val_if_fail, and cmd_descs_generate::str.
Referenced by rz_il_handler_empty().
RZ_API ut32 rz_bv_clz | ( | RZ_NONNULL RzBitVector * | bv | ) |
Count leading (most significant) zeroes All bits are considered leading zeroes for a zero bitvector.
Definition at line 1107 of file bitvector.c.
References i, r, rz_bv_get(), rz_bv_len(), and rz_return_val_if_fail.
Referenced by rz_bv_div().
RZ_API bool rz_bv_cmp | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Check if x equals to y Both operands must have the same length.
x | RzBitVector, operand |
y | RzBitVector, operand |
Definition at line 1086 of file bitvector.c.
References i, rz_bv_get(), rz_return_val_if_fail, rz_warn_if_reached, and x.
RZ_API RZ_OWN RzBitVector* rz_bv_complement_1 | ( | RZ_NONNULL RzBitVector * | bv | ) |
Get the 1's complement of bv
bv | RzBitVector, operand |
Definition at line 625 of file bitvector.c.
References bitvector_t::bits, i, bitvector_t::large_a, bitvector_t::len, NULL, rz_bv_free(), rz_bv_new(), rz_return_val_if_fail, rz_return_val_if_reached, bitvector_t::small_u, and UT64_MAX.
RZ_API RZ_OWN RzBitVector* rz_bv_complement_2 | ( | RZ_NONNULL RzBitVector * | bv | ) |
Get the 2's complement of bv
bv | RzBitVector, operand |
Definition at line 652 of file bitvector.c.
References i, NULL, rz_bv_dup(), rz_bv_get(), rz_bv_toggle(), and rz_return_val_if_fail.
RZ_API ut32 rz_bv_copy | ( | RZ_NONNULL const RzBitVector * | src, |
RZ_NONNULL RzBitVector * | dst | ||
) |
Copy from source bitvector to destination bitvector the maximum copied size depends on MIN(src_len, dst_len)
src | RzBitVector, the source bitvector |
dst | RzBitVector, the destination bitvector |
Definition at line 186 of file bitvector.c.
References dst, memcpy(), rz_return_val_if_fail, and src.
Referenced by rz_bv_dup(), rz_bv_lshift_fill(), rz_bv_mul(), and rz_bv_rshift_fill().
RZ_API ut32 rz_bv_copy_nbits | ( | RZ_NONNULL const RzBitVector * | src, |
ut32 | src_start_pos, | ||
RZ_NONNULL RzBitVector * | dst, | ||
ut32 | dst_start_pos, | ||
ut32 | nbit | ||
) |
Copy n bits from start position of source to start position of dest, return num of copied bits
src | RzBitVector, data source |
src_start_pos | ut32, start position in source bitvector of copy |
dst | RzBitVector, destination of copy |
dst_start_pos | ut32, start position in destination bitvector |
nbit | ut32, control the size of copy (in bits) |
Definition at line 210 of file bitvector.c.
References c, dst, i, rz_bv_get(), rz_bv_set(), RZ_MIN, rz_return_val_if_fail, and src.
Referenced by rz_bv_append(), rz_bv_lshift_fill(), rz_bv_rshift_fill(), rz_il_handler_cast(), rz_il_vm_sync_from_reg(), and rz_il_vm_sync_to_reg().
RZ_API ut32 rz_bv_ctz | ( | RZ_NONNULL RzBitVector * | bv | ) |
Count trailing (least significant) zeroes All bits are considered trailing zeroes for a zero bitvector.
Definition at line 1123 of file bitvector.c.
References i, r, rz_bv_get(), rz_bv_len(), and rz_return_val_if_fail.
RZ_API RZ_OWN RzBitVector* rz_bv_cut_head | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | delta_len | ||
) |
Return a new bitvector, cut n zero bits from head
bv | RzBitVector, pointer to bitvector |
delta_len,the | number of zero bits |
Definition at line 281 of file bitvector.c.
References NULL, pos, rz_bv_get(), rz_bv_new(), rz_bv_set(), and rz_return_val_if_fail.
RZ_API RZ_OWN RzBitVector* rz_bv_cut_tail | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | delta_len | ||
) |
Return a new bitvector, cut n zero bits from tail
bv | RzBitVector, pointer to bitvector |
delta_len,the | number of zero bits |
Definition at line 303 of file bitvector.c.
References i, NULL, pos, rz_bv_get(), rz_bv_new(), rz_bv_set(), and rz_return_val_if_fail.
RZ_API RZ_OWN RzBitVector* rz_bv_div | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of (x / y) mod 2^length Both operands must have the same length. If y
is a zero vector, the result defined as a vector of all ones.
x | dividend |
y | divisor |
Definition at line 808 of file bitvector.c.
References b, bv_unsigned_cmp(), NULL, rz_bv_clz(), rz_bv_dup(), rz_bv_free(), rz_bv_is_zero_vector(), rz_bv_len(), rz_bv_lshift(), rz_bv_new(), rz_bv_new_from_ut64(), rz_bv_new_one, rz_bv_new_zero, rz_bv_rshift(), rz_bv_set(), rz_bv_set_all(), rz_bv_sub(), rz_bv_to_ut64(), rz_bv_ule(), rz_return_val_if_fail, shift(), autogen_x86imm::tmp, and x.
Referenced by rz_bv_mod(), rz_bv_sdiv(), and rz_il_handler_div().
RZ_API RZ_OWN RzBitVector* rz_bv_dup | ( | const RZ_NONNULL RzBitVector * | bv | ) |
Clone a bitvector
bv | RzBitVector, pointer to the source bitvector |
Definition at line 167 of file bitvector.c.
References NULL, rz_bv_copy(), rz_bv_free(), rz_bv_new(), and rz_return_val_if_fail.
Referenced by rz_bv_complement_2(), rz_bv_div(), rz_bv_mod(), rz_il_effect_label_dup(), rz_il_event_mem_read_new(), rz_il_event_mem_write_new(), rz_il_event_pc_write_new(), rz_il_handler_bitv(), rz_il_handler_goto(), rz_il_handler_shiftl(), rz_il_handler_shiftr(), rz_il_handler_var(), rz_il_op_pure_dup(), rz_il_value_dup(), rz_il_value_to_bv(), rz_il_vm_create_label(), and rz_il_vm_update_label().
RZ_API bool rz_bv_eq | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Check if x == y
Definition at line 1041 of file bitvector.c.
References bv_unsigned_cmp(), rz_bv_len(), rz_return_val_if_fail, and x.
Referenced by rz_il_handler_eq(), and rz_il_value_eq().
RZ_API void rz_bv_fini | ( | RZ_NONNULL RzBitVector * | bv | ) |
Clear a RzBitVector structure.
Definition at line 58 of file bitvector.c.
References free(), memset(), and rz_return_if_fail.
Referenced by rz_bv_free(), rz_bv_lshift_fill(), rz_bv_mul(), and rz_bv_rshift_fill().
RZ_API void rz_bv_free | ( | RZ_NULLABLE RzBitVector * | bv | ) |
Free a bitvector
bv | RzBitVector, pointer to the bitvector you want to free |
Definition at line 85 of file bitvector.c.
References free(), and rz_bv_fini().
Referenced by bf_syscall_read(), bf_syscall_write(), perform_jump(), rz_bv_complement_1(), rz_bv_div(), rz_bv_dup(), rz_bv_mod(), rz_bv_mul(), rz_bv_sdiv(), rz_bv_smod(), rz_bv_sub(), rz_core_analysis_il_vm_set(), rz_il_effect_label_free(), rz_il_event_free(), rz_il_handler_add(), rz_il_handler_append(), rz_il_handler_cast(), rz_il_handler_div(), rz_il_handler_eq(), rz_il_handler_is_zero(), rz_il_handler_load(), rz_il_handler_loadw(), rz_il_handler_logical_and(), rz_il_handler_logical_not(), rz_il_handler_logical_or(), rz_il_handler_logical_xor(), rz_il_handler_lsb(), rz_il_handler_mod(), rz_il_handler_msb(), rz_il_handler_mul(), rz_il_handler_neg(), rz_il_handler_sdiv(), rz_il_handler_shiftl(), rz_il_handler_shiftr(), rz_il_handler_sle(), rz_il_handler_smod(), rz_il_handler_store(), rz_il_handler_storew(), rz_il_handler_sub(), rz_il_handler_ule(), rz_il_op_new_bitv_from_st64(), rz_il_op_new_bitv_from_ut64(), rz_il_op_pure_free(), rz_il_value_free(), rz_il_value_stringify(), rz_il_vm_fini(), rz_il_vm_mem_store(), rz_il_vm_mem_storew(), rz_il_vm_step(), rz_il_vm_sync_from_reg(), rz_il_vm_sync_to_reg(), and rz_il_vm_update_label().
RZ_API bool rz_bv_get | ( | RZ_NONNULL const RzBitVector * | bv, |
ut32 | pos | ||
) |
Get bit at position from bitvector
bv | RzBitVector, pointer to bv |
pos | int, position |
Definition at line 429 of file bitvector.c.
References BV_ELEM_SIZE, len, pos, and rz_return_val_if_fail.
Referenced by bv_unsigned_cmp(), rz_bv_add(), rz_bv_append_zero(), rz_bv_as_string(), rz_bv_clz(), rz_bv_cmp(), rz_bv_complement_2(), rz_bv_copy_nbits(), rz_bv_ctz(), rz_bv_cut_head(), rz_bv_cut_tail(), rz_bv_lsb(), rz_bv_msb(), rz_bv_mul(), rz_bv_prepend_zero(), rz_bv_to_ut16(), rz_bv_to_ut32(), rz_bv_to_ut64(), rz_bv_to_ut8(), and rz_bv_toggle().
RZ_API ut32 rz_bv_hash | ( | RZ_NULLABLE RzBitVector * | x | ) |
Calculates the hash from the bitvector data
x | BitVector |
Definition at line 1372 of file bitvector.c.
RZ_API bool rz_bv_init | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | length | ||
) |
Initialize a RzBitVector structure.
bv | Pointer to a uninitialized RzBitVector instance |
length | int, the length of bitvector |
Definition at line 38 of file bitvector.c.
References BV_ELEM_SIZE, length, memset(), NELEM, RZ_NEWS0, rz_return_val_if_fail, and autogen_x86imm::tmp.
Referenced by rz_bv_lshift_fill(), rz_bv_mul(), rz_bv_new(), and rz_bv_rshift_fill().
RZ_API bool rz_bv_is_zero_vector | ( | RZ_NONNULL const RzBitVector * | x | ) |
Check if the bitvector is zero
x | RzBitVector, pointer to bv |
Definition at line 1021 of file bitvector.c.
References i, rz_return_val_if_fail, and x.
Referenced by rz_bv_div(), rz_bv_mod(), rz_il_handler_div(), rz_il_handler_is_zero(), and rz_il_vm_sync_to_reg().
RZ_API ut32 rz_bv_len | ( | RZ_NONNULL const RzBitVector * | bv | ) |
Get the length of bitvector in bits
bv | RzBitVector |
Definition at line 1140 of file bitvector.c.
References rz_return_val_if_fail.
Referenced by adjust_unsigned(), rz_bv_clz(), rz_bv_ctz(), rz_bv_div(), rz_bv_eq(), rz_il_mem_store(), rz_il_value_get_sort(), rz_il_vm_get_pc_len(), rz_il_vm_mem_storew(), rz_il_vm_sync_from_reg(), rz_il_vm_sync_to_reg(), rz_reg_set_bv(), and VALIDATOR_PURE().
RZ_API ut32 rz_bv_len_bytes | ( | RZ_NONNULL const RzBitVector * | bv | ) |
Get the length of bitvector in bytes
bv | RzBitVector |
Definition at line 1150 of file bitvector.c.
References rz_return_val_if_fail.
Referenced by read_n_bits(), rz_bv_set_to_bytes_be(), rz_bv_set_to_bytes_le(), and write_n_bits().
RZ_API bool rz_bv_lsb | ( | RZ_NONNULL RzBitVector * | bv | ) |
Get the least significant bit of bitvector
bv | RzBitVector, operand |
Definition at line 1012 of file bitvector.c.
References rz_bv_get().
Referenced by rz_il_handler_lsb().
RZ_API bool rz_bv_lshift | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | size | ||
) |
Left shift bitvector (WARN : This operation will change the bitvector in argument) Fill with zero bits when shift
bv | RzBitVector, pointert to bv |
size | int, shift bits |
Definition at line 446 of file bitvector.c.
References rz_bv_lshift_fill().
Referenced by rz_bv_div(), and rz_bv_mul().
RZ_API bool rz_bv_lshift_fill | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | size, | ||
bool | fill_bit | ||
) |
Left shift bitvector (WARN : This operation will change the bitvector in argument) Fill the bitvector with fill_bit
bv | RzBitVector, pointert to bv |
size | int, shift bits |
fill_bit | bool, bit used in filling |
Definition at line 469 of file bitvector.c.
References rz_bv_copy(), rz_bv_copy_nbits(), rz_bv_fini(), rz_bv_init(), rz_bv_set_all(), rz_return_val_if_fail, and autogen_x86imm::tmp.
Referenced by rz_bv_lshift(), and rz_il_handler_shiftl().
RZ_API RZ_OWN RzBitVector* rz_bv_mod | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of (x mod y) mod 2^length Both operands must have the same length. If y
== 0, the result is x
x | dividend |
y | divisor |
Definition at line 865 of file bitvector.c.
References NULL, r, rz_bv_div(), rz_bv_dup(), rz_bv_free(), rz_bv_is_zero_vector(), rz_bv_mul(), rz_bv_sub(), rz_return_val_if_fail, and x.
Referenced by rz_bv_smod(), and rz_il_handler_mod().
RZ_API bool rz_bv_msb | ( | RZ_NONNULL RzBitVector * | bv | ) |
Get the most significant bit of bitvector
bv | RzBitVector, operand |
Definition at line 1003 of file bitvector.c.
References rz_bv_get().
Referenced by rz_bv_sdiv(), rz_bv_sle(), rz_bv_smod(), and rz_il_handler_msb().
RZ_API RZ_OWN RzBitVector* rz_bv_mul | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of (x * y) mod 2^length Both operands must have the same length.
x | RzBitVector, Operand |
y | RzBitVector, Operand |
Definition at line 734 of file bitvector.c.
References test-lz4-list::exit, i, NULL, rz_bv_add(), rz_bv_copy(), rz_bv_fini(), rz_bv_free(), rz_bv_get(), rz_bv_init(), rz_bv_lshift(), rz_bv_new(), rz_return_val_if_fail, rz_warn_if_reached, autogen_x86imm::tmp, and x.
Referenced by rz_bv_mod(), and rz_il_handler_mul().
RZ_API RZ_OWN RzBitVector* rz_bv_new | ( | ut32 | length | ) |
New a length
-bits bitvector
length | int, the length of bitvector |
Definition at line 71 of file bitvector.c.
References free(), length, NULL, rz_bv_init(), RZ_NEW, and rz_return_val_if_fail.
Referenced by rz_bv_add(), rz_bv_and(), rz_bv_append(), rz_bv_append_zero(), rz_bv_complement_1(), rz_bv_cut_head(), rz_bv_cut_tail(), rz_bv_div(), rz_bv_dup(), rz_bv_mul(), rz_bv_new_from_bytes_be(), rz_bv_new_from_bytes_le(), rz_bv_new_from_st64(), rz_bv_new_from_ut64(), rz_bv_or(), rz_bv_prepend_zero(), rz_bv_xor(), rz_il_handler_cast(), and rz_il_handler_div().
RZ_API RZ_OWN RzBitVector* rz_bv_new_from_bytes_be | ( | RZ_IN RZ_NONNULL const ut8 * | buf, |
ut32 | bit_offset, | ||
ut32 | size | ||
) |
Create a new bitvector of size
bits and apply rz_bv_set_from_bytes_be() to it
Definition at line 1207 of file bitvector.c.
References NULL, rz_bv_new(), rz_bv_set_from_bytes_be(), and rz_return_val_if_fail.
Referenced by rz_reg_get_bv().
RZ_API RZ_OWN RzBitVector* rz_bv_new_from_bytes_le | ( | RZ_IN RZ_NONNULL const ut8 * | buf, |
ut32 | bit_offset, | ||
ut32 | size | ||
) |
Create a new bitvector of size
bits and apply rz_bv_set_from_bytes_le() to it
Definition at line 1194 of file bitvector.c.
References NULL, rz_bv_new(), rz_bv_set_from_bytes_le(), and rz_return_val_if_fail.
Referenced by rz_reg_get_bv().
RZ_API RZ_OWN RzBitVector* rz_bv_new_from_st64 | ( | ut32 | length, |
st64 | value | ||
) |
Convert st64 to length
-bits bitvector
length | ut32, length of bitvector |
value | st64, the value to convert |
Definition at line 1179 of file bitvector.c.
References length, NULL, rz_bv_new(), rz_bv_set_from_st64(), RZ_LOG_ERROR, rz_return_val_if_fail, and value.
Referenced by rz_il_op_new_bitv_from_st64().
RZ_API RZ_OWN RzBitVector* rz_bv_new_from_ut64 | ( | ut32 | length, |
ut64 | value | ||
) |
Convert ut64 to length
-bits bitvector
length | ut32, length of bitvector |
value | ut64, the value to convert |
Definition at line 1161 of file bitvector.c.
References length, NULL, rz_bv_new(), rz_bv_set_from_ut64(), RZ_LOG_ERROR, rz_return_val_if_fail, and value.
Referenced by bf_syscall_read(), il_config(), rz_bv_div(), rz_core_analysis_il_vm_set(), rz_il_mem_load(), rz_il_op_new_bitv_from_ut64(), rz_il_value_to_bv(), rz_il_vm_init(), and rz_il_vm_step().
RZ_API RZ_OWN RzBitVector* rz_bv_or | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of x OR y (or
operation to every bits) Both operands must have the same length.
x | RzBitVector, operand |
y | RzBitVector, operand |
Definition at line 573 of file bitvector.c.
References bitvector_t::_elem_len, bitvector_t::bits, i, bitvector_t::large_a, NULL, rz_bv_new(), rz_return_val_if_fail, bitvector_t::small_u, and x.
Referenced by rz_il_handler_logical_or().
RZ_API RZ_OWN RzBitVector* rz_bv_prepend_zero | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | delta_len | ||
) |
Return a new bitvector prepended with bv with n zero bits
bv | RzBitVector, pointer to bitvector instance |
delta_len | ut32, the number of zero bits |
Definition at line 236 of file bitvector.c.
References i, NULL, rz_bv_get(), rz_bv_new(), rz_bv_set(), and rz_return_val_if_fail.
RZ_API bool rz_bv_rshift | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | size | ||
) |
Right shift bitvector (WARN : This operation will change the bitvector in argument) Fill with zero bits when shift
bv | RzBitVector, pointert to bv |
size | int, shift bits |
Definition at line 457 of file bitvector.c.
References rz_bv_rshift_fill().
Referenced by rz_bv_div().
RZ_API bool rz_bv_rshift_fill | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | size, | ||
bool | fill_bit | ||
) |
Right shift bitvector (WARN : This operation will change the bitvector in argument) Fill the bitvector with fill_bit
bv | RzBitVector, pointert to bv |
size | int, shift bits |
fill_bit | bool, bit used in filling |
Definition at line 508 of file bitvector.c.
References rz_bv_copy(), rz_bv_copy_nbits(), rz_bv_fini(), rz_bv_init(), rz_bv_set_all(), rz_return_val_if_fail, and autogen_x86imm::tmp.
Referenced by rz_bv_rshift(), and rz_il_handler_shiftr().
RZ_API RZ_OWN RzBitVector* rz_bv_sdiv | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of (x / y) mod 2^length (signed algorithm) / | div x y : if not mx /\ not my | neg (div (neg x) y) if mx /\ not my x sdiv y = < | neg (div x (neg y)) if not mx /\ my | div (neg x) (neg y) if mx /\ my \
where mx = msb x, and my = msb y.
x | RzBitVector, Operand |
y | RzBitVector, Operand |
Definition at line 893 of file bitvector.c.
References NULL, rz_bv_div(), rz_bv_free(), rz_bv_msb(), rz_bv_neg, rz_return_val_if_fail, autogen_x86imm::tmp, and x.
Referenced by rz_il_handler_sdiv().
RZ_API bool rz_bv_set | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | pos, | ||
bool | b | ||
) |
Set a bit at position to true or false
bv | RzBitVector, pointer to bv |
pos | ut32, position |
b | bit, true or false (set or unset) |
pos
after this operation Definition at line 341 of file bitvector.c.
References b, BV_ELEM_SIZE, len, pos, and rz_return_val_if_fail.
Referenced by rz_bv_add(), rz_bv_append_zero(), rz_bv_copy_nbits(), rz_bv_cut_head(), rz_bv_cut_tail(), rz_bv_div(), rz_bv_prepend_zero(), rz_bv_set_from_bytes_be(), rz_bv_set_from_bytes_le(), rz_bv_set_from_st64(), rz_bv_set_from_ut64(), and rz_bv_toggle().
RZ_API bool rz_bv_set_all | ( | RZ_NONNULL RzBitVector * | bv, |
bool | b | ||
) |
Set all bits to true or false
bv | RzBitVector, pointer to bv |
b | bit, true or false (set or unset) |
Definition at line 367 of file bitvector.c.
References b, BV_ELEM_SIZE, memset(), mod(), rz_num_bitmask(), rz_return_val_if_fail, and UT64_MAX.
Referenced by rz_bv_div(), rz_bv_lshift_fill(), rz_bv_rshift_fill(), rz_il_handler_cast(), rz_il_handler_div(), and rz_il_vm_sync_from_reg().
RZ_API void rz_bv_set_from_bytes_be | ( | RZ_NONNULL RzBitVector * | bv, |
RZ_IN RZ_NONNULL const ut8 * | buf, | ||
ut32 | bit_offset, | ||
ut32 | size | ||
) |
Set the bitvector's contents from the given bits. The bitvector's size is unchanged. If bv->len < size, additional bits are cut off, if bv->len > size, the rest is filled up with 0.
buf | big endian buffer of at least (bit_offset + size + 7) / 8 bytes |
bit_offset | offset inside buf to start reading from, in bits |
size | number of bits to read from buf |
Definition at line 1296 of file bitvector.c.
References bit, i, setup::idx, reverse_byte, reverse_lt_8bits(), rz_bv_set(), RZ_MIN, rz_return_if_fail, and ut8.
Referenced by read_n_bits(), and rz_bv_new_from_bytes_be().
RZ_API void rz_bv_set_from_bytes_le | ( | RZ_NONNULL RzBitVector * | bv, |
RZ_IN RZ_NONNULL const ut8 * | buf, | ||
ut32 | bit_offset, | ||
ut32 | size | ||
) |
Set the bitvector's contents from the given bits. The bitvector's size is unchanged. If bv->len < size, additional bits are cut off, if bv->len > size, the rest is filled up with 0.
buf | little endian buffer of at least (bit_offset + size + 7) / 8 bytes |
bit_offset | offset inside buf to start reading from, in bits |
size | number of bits to read from buf |
Definition at line 1265 of file bitvector.c.
References bit, i, setup::idx, rz_bv_set(), rz_bv_set_from_ut64(), RZ_MIN, rz_return_if_fail, ut64(), UT64_MAX, and val.
Referenced by read_n_bits(), and rz_bv_new_from_bytes_le().
RZ_API bool rz_bv_set_from_st64 | ( | RZ_NONNULL RzBitVector * | bv, |
st64 | value | ||
) |
Convert st64 to N-bits bitvector
bv | RzBitVector, pointer to bitvector |
value | st64, the value to convert |
Definition at line 1243 of file bitvector.c.
References i, rz_bv_set(), rz_return_val_if_fail, ut64(), UT64_MAX, and value.
Referenced by rz_bv_new_from_st64().
RZ_API bool rz_bv_set_from_ut64 | ( | RZ_NONNULL RzBitVector * | bv, |
ut64 | value | ||
) |
Convert ut64 to N-bits bitvector
bv | RzBitVector, pointer to bitvector |
value | ut64, the value to convert |
Definition at line 1222 of file bitvector.c.
References i, rz_bv_set(), rz_return_val_if_fail, UT64_MAX, and value.
Referenced by rz_bv_new_from_ut64(), rz_bv_set_from_bytes_le(), and rz_il_vm_sync_to_reg().
RZ_API void rz_bv_set_to_bytes_be | ( | RZ_NONNULL const RzBitVector * | bv, |
RZ_OUT RZ_NONNULL ut8 * | buf | ||
) |
Set the buffer contents from the given bitvector's bits in big endian format.
bv | BitVector to use as source of the bits |
buf | buffer to write big endian data. |
Definition at line 1349 of file bitvector.c.
References bytes, test_evm::end, i, rz_bv_len_bytes(), rz_return_if_fail, ut64(), and val.
Referenced by rz_reg_set_bv(), and write_n_bits().
RZ_API void rz_bv_set_to_bytes_le | ( | RZ_NONNULL const RzBitVector * | bv, |
RZ_OUT RZ_NONNULL ut8 * | buf | ||
) |
Set the buffer contents from the given bitvector's bits in little endian format.
bv | BitVector to use as source of the bits |
buf | buffer to write little endian data. |
Definition at line 1318 of file bitvector.c.
References bytes, i, rz_bv_len_bytes(), rz_return_if_fail, ut64(), and val.
Referenced by rz_reg_set_bv(), and write_n_bits().
RZ_API bool rz_bv_sle | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Check if x <= y (as signed value)
x | RzBitVector, operand |
y | RzBitVector, operand |
Definition at line 1064 of file bitvector.c.
References rz_bv_msb(), rz_bv_ule(), rz_return_val_if_fail, and x.
Referenced by rz_il_handler_sle().
RZ_API RZ_OWN RzBitVector* rz_bv_smod | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of (x mod y) mod 2^length (signed algorithm) / | x % y : if not mx /\ not my | neg (neg x % y) if mx /\ not my x smodulo y = < | neg (x % (neg y)) if not mx /\ my | neg (neg x % neg y) mod m if mx /\ my \
where mx = msb x and my = msb y.
x | RzBitVector, Operand |
y | RzBitVector, Operand |
Definition at line 952 of file bitvector.c.
References NULL, rz_bv_free(), rz_bv_mod(), rz_bv_msb(), rz_bv_neg, rz_return_val_if_fail, autogen_x86imm::tmp, and x.
Referenced by rz_il_handler_smod().
RZ_API RZ_OWN RzBitVector* rz_bv_sub | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y, | ||
RZ_NULLABLE bool * | borrow | ||
) |
Result of (x - y) mod 2^length Both operands must have the same length.
x | RzBitVector, Operand |
y | RzBitVector, Operand |
borrow | bool*, bool pointer to where to save the borrow value. |
Definition at line 715 of file bitvector.c.
References NULL, rz_bv_add(), rz_bv_free(), rz_bv_neg, rz_return_val_if_fail, and x.
Referenced by rz_bv_div(), rz_bv_mod(), and rz_il_handler_sub().
RZ_API ut16 rz_bv_to_ut16 | ( | RZ_NONNULL const RzBitVector * | x | ) |
Convert bitv to ut16 value
x | BitVector |
Definition at line 1416 of file bitvector.c.
References i, rz_bv_get(), rz_return_val_if_fail, UT16_MAX, and x.
RZ_API ut32 rz_bv_to_ut32 | ( | RZ_NONNULL const RzBitVector * | x | ) |
Convert bitv to ut32 value
x | BitVector |
Definition at line 1435 of file bitvector.c.
References i, rz_bv_get(), rz_return_val_if_fail, UT32_MAX, and x.
Referenced by bf_syscall_write(), rz_il_handler_shiftl(), and rz_il_handler_shiftr().
RZ_API ut64 rz_bv_to_ut64 | ( | RZ_NONNULL const RzBitVector * | x | ) |
Convert RzBitVector to ut64
x | RzBitVector, pointer to the bitvector |
Definition at line 1454 of file bitvector.c.
References i, rz_bv_get(), rz_return_val_if_fail, ut64(), and x.
Referenced by read_n_bits(), rz_analysis_il_vm_step(), rz_bv_div(), rz_il_mem_load(), rz_il_mem_store(), rz_reg_set_bv(), and write_n_bits().
RZ_API ut8 rz_bv_to_ut8 | ( | RZ_NONNULL const RzBitVector * | x | ) |
Convert bitv to a ut8 value
x | BitVector |
Definition at line 1397 of file bitvector.c.
References i, rz_bv_get(), rz_return_val_if_fail, UT8_MAX, and x.
Referenced by rz_il_mem_store().
RZ_API bool rz_bv_toggle | ( | RZ_NONNULL RzBitVector * | bv, |
ut32 | pos | ||
) |
Invert a bit at position
bv | RzBitVector, pointer to bv |
pos | ut32, position |
b | bit, true or false (set or unset) |
pos
after this operation Definition at line 396 of file bitvector.c.
References pos, rz_bv_get(), rz_bv_set(), and rz_return_val_if_fail.
Referenced by rz_bv_complement_2().
RZ_API bool rz_bv_toggle_all | ( | RZ_NONNULL RzBitVector * | bv | ) |
Invert all bits
bv | RzBitVector, pointer to bv |
b | bit, true or false (set or unset) |
Definition at line 410 of file bitvector.c.
References i, and rz_return_val_if_fail.
RZ_API bool rz_bv_ule | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Check if x <= y (as unsigned value)
x | RzBitVector, operand |
y | RzBitVector, operand |
Definition at line 1052 of file bitvector.c.
References bv_unsigned_cmp(), rz_return_val_if_fail, and x.
Referenced by rz_bv_div(), rz_bv_sle(), and rz_il_handler_ule().
RZ_API RZ_OWN RzBitVector* rz_bv_xor | ( | RZ_NONNULL RzBitVector * | x, |
RZ_NONNULL RzBitVector * | y | ||
) |
Result of x XOR y (xor
operation to every bits) Both operands must have the same length.
x | RzBitVector, operand |
y | RzBitVector, operand |
Definition at line 600 of file bitvector.c.
References bitvector_t::_elem_len, bitvector_t::bits, i, bitvector_t::large_a, NULL, rz_bv_new(), rz_return_val_if_fail, bitvector_t::small_u, and x.
Referenced by rz_il_handler_logical_xor().