Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_util/rz_mem.h>
#include <rz_types.h>
#include <rz_list.h>
#include <rz_util/rz_assert.h>
Go to the source code of this file.
Classes | |
struct | rz_buffer_methods_t |
struct | rz_buf_t |
struct | rz_buf_sparse_chunk_t |
Macros | |
#define | RZ_BUF_SET 0 |
#define | RZ_BUF_CUR 1 |
#define | RZ_BUF_END 2 |
#define | DEFINE_RZ_BUF_READ_BLE(size) |
#define | DEFINE_RZ_BUF_WRITE_BLE(size) |
#define | DEFINE_RZ_BUF_READ_OFFSET_BLE(size) |
Read a big endian or little endian (ut16, ut32, ut64) at the specified address or cursor in the buffer. More... | |
#define | DEFINE_RZ_BUF_WRITE_OFFSET_BLE(size) |
#define | rz_buf_read_ble8_at(b, addr, result, endian) rz_buf_read8_at(b, addr, result) |
#define | rz_buf_write_ble8_at(b, addr, value, endian) rz_buf_write8_at(b, addr, value) |
#define | rz_buf_read_le16(b, result) rz_buf_read_ble16(b, result, false) |
Read a big endian or little endian (ut16, ut32, ut64) at the specified offset in the buffer and shifts the offset. More... | |
#define | rz_buf_read_le32(b, result) rz_buf_read_ble32(b, result, false) |
#define | rz_buf_read_le64(b, result) rz_buf_read_ble64(b, result, false) |
#define | rz_buf_read_le16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, false) |
#define | rz_buf_read_le32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, false) |
#define | rz_buf_read_le64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, false) |
#define | rz_buf_read8_offset(b, offset, result) rz_buf_read_ble8_offset(b, offset, result, false) |
#define | rz_buf_read_le16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, false) |
#define | rz_buf_read_le32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, false) |
#define | rz_buf_read_le64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, false) |
#define | rz_buf_read_be16(b, result) rz_buf_read_ble16(b, result, true) |
#define | rz_buf_read_be32(b, result) rz_buf_read_ble32(b, result, true) |
#define | rz_buf_read_be64(b, result) rz_buf_read_ble64(b, result, true) |
#define | rz_buf_read_be16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, true) |
#define | rz_buf_read_be32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, true) |
#define | rz_buf_read_be64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, true) |
#define | rz_buf_read_be16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, true) |
#define | rz_buf_read_be32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, true) |
#define | rz_buf_read_be64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, true) |
#define | rz_buf_write_le16(b, value) rz_buf_write_ble16(b, value, false) |
#define | rz_buf_write_le32(b, value) rz_buf_write_ble32(b, value, false) |
#define | rz_buf_write_le64(b, value) rz_buf_write_ble64(b, value, false) |
#define | rz_buf_write_le16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, false) |
#define | rz_buf_write_le32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, false) |
#define | rz_buf_write_le64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, false) |
#define | rz_buf_write8_offset(b, offset, value) rz_buf_write_ble8_offset(b, offset, value, false) |
#define | rz_buf_write_le16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, false) |
#define | rz_buf_write_le32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, false) |
#define | rz_buf_write_le64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, false) |
#define | rz_buf_write_be16(b, value) rz_buf_write_ble16(b, value, true) |
#define | rz_buf_write_be32(b, value) rz_buf_write_ble32(b, value, true) |
#define | rz_buf_write_be64(b, value) rz_buf_write_ble64(b, value, true) |
#define | rz_buf_write_be16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, true) |
#define | rz_buf_write_be32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, true) |
#define | rz_buf_write_be64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, true) |
#define | rz_buf_write_be16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, true) |
#define | rz_buf_write_be32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, true) |
#define | rz_buf_write_be64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, true) |
Typedefs | |
typedef struct rz_buf_t | RzBuffer |
typedef bool(* | RzBufferInit) (RzBuffer *b, const void *user) |
typedef bool(* | RzBufferFini) (RzBuffer *b) |
typedef st64(* | RzBufferRead) (RzBuffer *b, ut8 *buf, ut64 len) |
typedef st64(* | RzBufferWrite) (RzBuffer *b, const ut8 *buf, ut64 len) |
typedef ut64(* | RzBufferGetSize) (RzBuffer *b) |
typedef bool(* | RzBufferResize) (RzBuffer *b, ut64 newsize) |
typedef st64(* | RzBufferSeek) (RzBuffer *b, st64 addr, int whence) |
typedef ut8 *(* | RzBufferGetWholeBuf) (RzBuffer *b, ut64 *sz) |
typedef void(* | RzBufferFreeWholeBuf) (RzBuffer *b) |
typedef RzList *(* | RzBufferNonEmptyList) (RzBuffer *b) |
typedef struct rz_buffer_methods_t | RzBufferMethods |
typedef struct rz_buf_sparse_chunk_t | RzBufferSparseChunk |
typedef ut64(* | RzBufferFwdScan) (RZ_BORROW RZ_NONNULL const ut8 *buf, ut64 len, RZ_NULLABLE void *user) |
Enumerations | |
enum | RzBufferSparseWriteMode { RZ_BUF_SPARSE_WRITE_MODE_SPARSE , RZ_BUF_SPARSE_WRITE_MODE_THROUGH } |
#define DEFINE_RZ_BUF_READ_BLE | ( | size | ) |
#define DEFINE_RZ_BUF_READ_OFFSET_BLE | ( | size | ) |
Read a big endian or little endian (ut16, ut32, ut64) at the specified address or cursor in the buffer.
b | ... |
addr | (optional) |
result | ... |
big_endian | ... |
Write a big endian or little endian ut16 at the specified address or cursor in the buffer.
b | ... |
addr | (optional) |
result | ... |
big_endian | ... |
#define DEFINE_RZ_BUF_WRITE_BLE | ( | size | ) |
#define DEFINE_RZ_BUF_WRITE_OFFSET_BLE | ( | size | ) |
#define rz_buf_read_ble8_at | ( | b, | |
addr, | |||
result, | |||
endian | |||
) | rz_buf_read8_at(b, addr, result) |
Read a big endian or little endian (ut16, ut32, ut64) at the specified offset in the buffer and shifts the offset.
b | ... |
offset | ... |
result | ... |
big_endian | ... |
Write a big endian or little endian ut16 at the specified address or cursor in the buffer and shifts the offset.
b | ... |
addr | (optional) |
result | ... |
big_endian | ... |
typedef ut64(* RzBufferFwdScan) (RZ_BORROW RZ_NONNULL const ut8 *buf, ut64 len, RZ_NULLABLE void *user) |
typedef struct rz_buffer_methods_t RzBufferMethods |
typedef struct rz_buf_sparse_chunk_t RzBufferSparseChunk |
Enumerator | |
---|---|
RZ_BUF_SPARSE_WRITE_MODE_SPARSE | all writes are performed in the sparse overlay |
RZ_BUF_SPARSE_WRITE_MODE_THROUGH | all writes are performed in the underlying base buffer |
Definition at line 59 of file rz_buf.h.
RZ_API bool rz_buf_append_buf | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL RzBuffer * | a | ||
) |
Append the content of the buffer a to the buffer b.
dst | the destination buffer with write permission |
src | the source buffer |
The function append the content of the buffer a, the two buffer don't need to have the same back end. WARNING: This function can allocate a lot of memory.
Definition at line 685 of file buf.c.
References a, b, get_whole_buf(), rz_buf_append_bytes(), rz_return_val_if_fail, autogen_x86imm::tmp, and ut64().
Referenced by build(), and xnu_generate_corefile().
RZ_API bool rz_buf_append_buf_slice | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL RzBuffer * | a, | ||
ut64 | offset, | ||
ut64 | size | ||
) |
Append a slice of the buffer a to the buffer b.
dst | the destination buffer with write permission |
src | the source buffer |
offset | The starting offset in the buffer a. |
size | The number of bytes that will be extract from the buffer a. |
The function append a slice of the buffer a, the two buffer don't need to have the same back end. WARNING: This function can allocate a lot of memory.
Definition at line 705 of file buf.c.
References a, b, free(), r, rz_buf_append_bytes(), rz_buf_read_at(), RZ_NEWS, rz_return_val_if_fail, st64, and autogen_x86imm::tmp.
RZ_API bool rz_buf_append_bytes | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const ut8 * | buf, | ||
ut64 | length | ||
) |
Append an array of bytes to the buffer.
dst | the destination buffer with write permission |
src | the source buffer |
length | ... |
Definition at line 732 of file buf.c.
References b, length, RZ_BUF_END, rz_buf_seek(), rz_buf_write(), and rz_return_val_if_fail.
Referenced by build(), flirt_write_module(), flirt_write_node(), gprobe_debugoff(), gprobe_debugon(), gprobe_frame_sp(), gprobe_get_reply_sp(), gprobe_getdeviceid(), gprobe_getinformation(), gprobe_read(), gprobe_reset(), gprobe_runcode(), gprobe_write(), rz_buf_append_buf(), rz_buf_append_buf_slice(), rz_buf_append_string(), rz_buf_append_ut16(), rz_buf_append_ut32(), rz_buf_append_ut64(), rz_buf_set_bytes(), rz_egg_append(), rz_egg_append_bytes(), rz_egg_assemble_asm(), rz_egg_include(), rz_egg_load(), rz_egg_printf(), rz_egg_raw(), rz_sign_flirt_write_compressed_pattern_to_buffer(), rz_write_vle16(), rz_write_vle32(), socket_slurp(), xnu_generate_corefile(), and xnu_write_mem_maps_to_buffer().
RZ_API bool rz_buf_append_nbytes | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | length | ||
) |
Extend the size of the buffer.
b | A buffer with write permission. |
length | The number of bytes to add at the end of the buffer. |
Definition at line 748 of file buf.c.
References b, length, rz_buf_resize(), rz_buf_size(), and rz_return_val_if_fail.
RZ_API st64 rz_buf_append_string | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const char * | str | ||
) |
Append a string to the buffer.
b | A buffer with write permission. |
str | ... |
...
Definition at line 962 of file buf.c.
References b, rz_buf_append_bytes(), rz_return_val_if_fail, and cmd_descs_generate::str.
Referenced by add_spaces(), fill_level(), flirt_pat_write_line(), flirt_write_module(), rz_analysis_reflines_str(), rz_sign_flirt_write_compressed_pattern_to_buffer(), and rz_sign_flirt_write_string_pattern_to_buffer().
RZ_API bool rz_buf_append_ut16 | ( | RZ_NONNULL RzBuffer * | b, |
ut16 | n | ||
) |
Add a ut16 number at the end of the buffer.
b | A buffer with write permission. |
n |
...
Definition at line 762 of file buf.c.
References b, n, rz_buf_append_bytes(), and rz_return_val_if_fail.
RZ_API bool rz_buf_append_ut32 | ( | RZ_NONNULL RzBuffer * | b, |
ut32 | n | ||
) |
Add a ut32 number at the end of the buffer.
b | A buffer with write permission. |
n |
...
Definition at line 776 of file buf.c.
References b, n, rz_buf_append_bytes(), and rz_return_val_if_fail.
RZ_API bool rz_buf_append_ut64 | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | n | ||
) |
Add a ut64 number at the end of the buffer.
b | A buffer with write permission. |
n |
...
Definition at line 790 of file buf.c.
References b, n, rz_buf_append_bytes(), and rz_return_val_if_fail.
RZ_DEPRECATE RZ_API RZ_BORROW ut8* rz_buf_data | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL RZ_OUT ut64 * | size | ||
) |
Return a borrowed array of bytes representing the buffer data.
b | Buffer to get the data from. |
size | Size of the returned data. |
WARNING: this function should be used with care because it may allocate the entire buffer in memory. Consider using the rz_buf_read* APIs or rz_buf_fwd_scan API instead and read only the chunks you need.
Definition at line 1287 of file buf.c.
References b, get_whole_buf(), NULL, and rz_return_val_if_fail.
Referenced by buf_get_whole_buf(), check_buffer(), create(), gprobe_frame_sp(), gprobe_getinformation(), gprobe_send_request_sp(), io_default_get_buf(), load_buffer(), rz_bin_file_xtr_load_buffer(), rz_cmd_debug(), rz_egg_finalize(), rz_egg_run(), rz_egg_run_rop(), rz_egg_shellcode(), rz_io_open_buffer(), rz_io_zip_flush_file(), rz_main_rz_bin(), and rz_main_rz_gg().
RZ_API bool rz_buf_dump | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const char * | file | ||
) |
Dump the content of the buffer to a file.
b | A buffer with write permission. |
file | The output file where the buffer content while be outputted. |
...
Definition at line 806 of file buf.c.
References b, get_whole_buf(), rz_file_dump(), rz_return_val_if_fail, autogen_x86imm::tmp, and ut64().
Free all internal data hold by the buffer.
b | A buffer with write permission. |
...
Definition at line 822 of file buf.c.
References b, buf_fini(), and buf_whole_buf_free().
Referenced by rz_asm_op_fini(), and rz_buf_free().
RZ_API st64 rz_buf_fread | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL ut8 * | buf, | ||
RZ_NONNULL const char * | fmt, | ||
int | n | ||
) |
...
b | ... |
buf | ... |
fmt | ... |
n | ... |
...
Definition at line 978 of file buf.c.
References b, buf_format(), dst, n, rz_buf_free(), rz_buf_new_with_pointers(), rz_return_val_if_fail, st64, and UT64_MAX.
Referenced by rz_bin_coff_init_hdr(), and rz_buf_fread_at().
RZ_API st64 rz_buf_fread_at | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | addr, | ||
RZ_NONNULL ut8 * | buf, | ||
RZ_NONNULL const char * | fmt, | ||
int | n | ||
) |
...
b | ... |
addr | ... |
buf | ... |
fmt | ... |
n | ... |
...
Definition at line 1001 of file buf.c.
References addr, b, n, rz_buf_fread(), rz_buf_seek(), RZ_BUF_SET, rz_buf_tell(), rz_return_val_if_fail, st64, and autogen_x86imm::tmp.
Referenced by art_header_load(), bin_pe_dotnet_init_metadata(), carve_deps_at_address(), check_buffer(), create_cache_bins(), entries(), estimate_slide(), get_rebase_info(), get_rebase_infos(), header(), init_items(), lmf_header_load(), load_buffer(), parse_chained_fixups(), parse_thread(), populate_cache_maps(), read_cache_accel(), read_cache_header(), read_cache_images(), read_cache_imgextra(), rz_axml_decode(), rz_bin_coff_init_hdr(), rz_bin_coff_init_opt_hdr(), rz_bin_coff_init_scn_hdr(), rz_bin_coff_init_symtable(), rz_coresym_cache_element_header_new(), rz_dyld_locsym_new(), rz_dyldcache_symbols_from_locsym(), sections(), and sep64_xtr_ctx_new().
Free all internal data hold by the buffer and the buffer.
b | ... |
...
Definition at line 1253 of file buf.c.
References b, free(), and rz_buf_fini().
Referenced by __close(), __open(), ar_close(), ar_open_all(), ar_open_file(), basefind_create_array_of_addresses(), bin_pe_dotnet_destroy_clr(), buf_ref_fini(), buf_sparse_fini(), build(), classes(), cmd_search_bin(), create(), destroy(), egg_patch_free(), extract(), get_gnu_debugdata_elf_symbols(), get_virtual_files(), gprobe_debugoff(), gprobe_debugon(), gprobe_getdeviceid(), gprobe_getinformation(), gprobe_read(), gprobe_reset(), gprobe_runcode(), gprobe_write(), handle_tmp_desc(), mach0_free(), msf_stream_directory_free(), msf_stream_free(), nso_free(), oneshot_buffer(), parse_classes(), rabin_do_operation(), rz_analysis_il_vm_free(), rz_analysis_il_vm_new(), rz_analysis_reflines_str(), rz_asm_massemble(), rz_asm_pseudo_incbin(), rz_axml_decode(), rz_bflt_free(), rz_bin_coff_free(), rz_bin_dex_free(), rz_bin_dmp64_free(), rz_bin_elf_free(), rz_bin_fatmach0_free(), rz_bin_file_compute_hashes(), rz_bin_file_free(), rz_bin_file_set_bytes(), rz_bin_mdmp_free(), rz_bin_mdmp_init_pe_bins(), rz_bin_mz_free(), rz_bin_open_io(), rz_bin_pdb_free(), rz_bin_pdb_parse_from_file(), rz_bin_pe_free(), rz_bin_pemixed_free(), rz_bin_pemixed_init_native(), rz_bin_te_free(), rz_bin_virtual_file_free(), rz_bin_wasm_destroy(), rz_bin_xtrdata_free(), rz_bin_zimg_new_buf(), rz_buf_fread(), rz_buf_fwrite(), rz_cf_value_data_free(), rz_cmd_debug(), rz_core_bin_whole_strings(), rz_core_fini(), rz_core_flirt_convert_file(), rz_core_flirt_create_file(), rz_core_flirt_dump_file(), rz_debug_dmp_init(), rz_dyldcache_free(), rz_egg_encode(), rz_egg_finalize(), rz_egg_free(), rz_egg_reset(), rz_file_deflate(), rz_file_inflate(), rz_il_mem_free(), rz_io_def_mmap_free(), rz_io_zip_free_zipfileobj(), rz_kernel_cache_free(), rz_main_rz_bin(), rz_sign_flirt_apply(), rz_sign_flirt_parse_compressed_pattern_from_buffer(), rz_sign_flirt_write_compressed_pattern_to_buffer(), sep64_xtr_ctx_get_slice(), sigdb_signature_resolve_details(), socket_http_answer(), virtual_files(), and xnu_generate_corefile().
RZ_API ut64 rz_buf_fwd_scan | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | start, | ||
ut64 | amount, | ||
RZ_NONNULL RzBufferFwdScan | fwd_scan, | ||
RZ_NULLABLE void * | user | ||
) |
Scans buffer linearly in chunks calling fwd_scan
for each chunk.
b | RzBuffer to read |
start | Start address |
amount | Amount of bytes to read |
fwd_scan | Function to call for each chunk |
user | User data to pass to fwd_scan |
Definition at line 1303 of file buf.c.
References addr, b, buf_size, test_evm::end, free(), malloc(), read(), rz_buf_read_at(), rz_buf_size(), RZ_MIN, rz_return_val_if_fail, start, ut64(), UT64_ADD_OVFCHK, and UT64_MAX.
Referenced by bin_pe_compute_authentihash(), bin_pe_get_actual_checksum(), find_go_build_info(), and rz_bin_file_compute_hashes().
RZ_API st64 rz_buf_fwrite | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const ut8 * | buf, | ||
RZ_NONNULL const char * | fmt, | ||
int | n | ||
) |
...
b | ... |
addr | ... |
buf | ... |
fmt | ... |
n | ... |
...
Definition at line 1033 of file buf.c.
References b, buf_format(), n, rz_buf_free(), rz_buf_new_with_pointers(), rz_return_val_if_fail, src, st64, and UT64_MAX.
Referenced by rz_buf_fwrite_at().
RZ_API st64 rz_buf_fwrite_at | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | addr, | ||
RZ_NONNULL const ut8 * | buf, | ||
RZ_NONNULL const char * | fmt, | ||
int | n | ||
) |
...
b | ... |
addr | ... |
buf | ... |
fmt | ... |
n | ... |
...
Definition at line 1056 of file buf.c.
References addr, b, n, rz_buf_fwrite(), rz_buf_seek(), RZ_BUF_SET, rz_buf_tell(), rz_return_val_if_fail, st64, and autogen_x86imm::tmp.
Get a string with a max length from the buffer.
b | RzBuffer pointer |
addr | The address of the string |
size | The max length authorized |
Return an heap-allocated string read from the RzBuffer b at address addr. The length depends on the first '\0' found and the arguments size in the buffer. If there is no '\0' in the buffer, there is no string, thus NULL is returned.
Definition at line 585 of file buf.c.
References addr, b, count, GET_STRING_BUFFER_SIZE, NULL, r, rz_buf_read_at(), rz_return_val_if_fail, rz_str_nlen(), rz_strbuf_append_n(), rz_strbuf_drain(), rz_strbuf_free(), rz_strbuf_new(), st64, and autogen_x86imm::tmp.
Referenced by parse_note_file(), and rz_buf_get_string().
RZ_API RZ_OWN char* rz_buf_get_string | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | addr | ||
) |
Get a string from the buffer.
b | RzBuffer pointer |
addr | The address of the string |
Return an heap-allocated string read from the RzBuffer b at address addr. The length depends on the first '\0' found in the buffer. If there is no '\0' in the buffer, there is no string, thus NULL is returned.
Definition at line 628 of file buf.c.
References addr, b, NULL, rz_buf_get_nstring(), rz_buf_size(), and rz_return_val_if_fail.
Referenced by mach_headerfields(), parse_dbi_stream_ex_header(), parse_gdata_global(), rz_bin_pe_get_clr_symbols(), and rz_dyldcache_symbols_from_locsym().
RZ_API st64 rz_buf_insert_bytes | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | addr, | ||
RZ_NONNULL const ut8 * | buf, | ||
ut64 | length | ||
) |
Insert an array of bytes in the buffer.
b | A buffer with write permission. |
addr | ... |
buf | ... |
length | ... |
...
Definition at line 1087 of file buf.c.
References addr, b, buf_move_back(), length, rz_buf_write_at(), rz_return_val_if_fail, and st64.
Referenced by rz_buf_prepend_bytes().
Creates a new empty buffer with a predefined size;.
len | The length in byte of the new buffer. |
The function creates a new buffer of the specified length in memory, filled with \0.
Definition at line 285 of file buf.c.
References buf_bytes_user::data_steal, free(), len, buf_bytes_user::length, new_buffer(), NULL, RZ_BUFFER_BYTES, RZ_NEWS0, and buf_bytes_user::steal.
Referenced by get_gnu_debugdata_elf_symbols(), get_virtual_files(), rz_sign_flirt_write_compressed_pattern_to_buffer(), and virtual_files().
Creates a new buffer from a file.
file | The filename used to create the new buffer. |
perm | Same meaning than the symbolic constants defined in sys/stat.h. |
mode | Same meaning than the symbolic constants use with open (fcntl.h). |
The function creates a new buffer synchronized with the file content, opening it with rz_sys_open and using regular read/write operations to change its content.
Definition at line 317 of file buf.c.
References file, buf_file_user::file, buf_file_user::mode, new_buffer(), buf_file_user::perm, and RZ_BUFFER_FILE.
Referenced by ar_open_all(), ar_open_file(), rz_bin_open_io(), rz_cmd_debug(), rz_core_flirt_convert_file(), rz_core_flirt_create_file(), rz_file_deflate(), rz_file_inflate(), rz_io_def_mmap_create_new_file(), and sigdb_signature_resolve_details().
Creates a new buffer from a file using rz_file_mmap.
file | The filename used to create the new buffer. |
perm | Same meaning than the symbolic constants defined in sys/stat.h. |
mode | Same meaning than the symbolic constants use with open (fcntl.h). |
The function creates a new buffer synchronized with the file content, using mmap to access the file.
Definition at line 339 of file buf.c.
References buf_mmap_user::filename, buf_mmap_user::mode, new_buffer(), NULL, buf_mmap_user::perm, RZ_BUFFER_MMAP, and rz_return_val_if_fail.
Referenced by rz_io_def_mmap_create_new_file().
Creates a new buffer from a slice of another buffer.
b | The source buffer used to create the sub buffer. |
offset | The starting offset in the source buffer. |
size | The number of bytes that will be extract from the source buffer. |
The function creates a new buffer which shows just a slice of another one, passed as argument. The allocated buffer will reference the source buffer. So both buffer are synchronized.
Definition at line 364 of file buf.c.
References b, new_buffer(), buf_ref_user::offset, buf_ref_user::parent, RZ_BUFFER_REF, and buf_ref_user::size.
Referenced by bin_pe_dotnet_init_metadata(), cmd_search_bin(), get_gnu_debugdata_elf_symbols(), rz_bin_fatmach0_extract(), rz_bin_open_io(), and sep64_xtr_ctx_get_slice().
Creates a new buffer from a file.
file | The filename used to create the new buffer. |
The function creates a new buffer in memory, initializing it with the whole content of the specified file.
Definition at line 384 of file buf.c.
References buf_bytes_user::data_steal, len, buf_bytes_user::length, new_buffer(), NULL, RZ_BUFFER_BYTES, rz_file_slurp(), buf_bytes_user::steal, autogen_x86imm::tmp, and ut64().
Referenced by rz_bin_pdb_parse_from_file(), rz_core_flirt_convert_file(), rz_core_flirt_dump_file(), and rz_sign_flirt_apply().
Creates a sparse buffer.
Oxff | The byte used to fill unpopulated bytes. |
The function creates a new allocated buffer using the RZ_BUFFER_SPARSE back end. Creates a new sparse RzBuffer where unpopulated bytes are filled with Oxff parameter.
Definition at line 408 of file buf.c.
References b, new_buffer(), NULL, and RZ_BUFFER_SPARSE.
Referenced by __open().
RZ_API RZ_OWN RzBuffer* rz_buf_new_sparse_overlay | ( | RzBuffer * | b, |
RzBufferSparseWriteMode | write_mode | ||
) |
Creates a sparse buffer from a already populated buffer.
b | The source buffer used to create the sub buffer. |
write_mode | Defined how byte are written to the buffer. |
The function creates a new allocated buffer using the RZ_BUFFER_SPARSE back end. Creates a new sparse RzBuffer where unpopulated bytes are taken as-is from b
Definition at line 426 of file buf.c.
References b, sparse_init_config_t::base, new_buffer(), NULL, RZ_BUFFER_SPARSE, and rz_return_val_if_fail.
Referenced by bflt_patch_relocs(), patch_relocs(), and rz_coff_get_patched_buf().
Creates a new buffer from a source buffer.
b | The source buffer used to create the sub buffer. |
The function creates a new allocated buffer using the RZ_BUFFER_BYTES back end. WARNING: this function doesn't use reference counting, this can lead to a lot of memory overhead.
Definition at line 448 of file buf.c.
References b, get_whole_buf(), rz_buf_new_with_bytes(), autogen_x86imm::tmp, and ut64().
Referenced by rabin_do_operation(), rz_bin_mz_new_buf(), rz_bin_pemixed_init_native(), and rz_bin_te_new_buf().
Creates a new buffer with a bytes array.
bytes | The bytes array used to initialized the buffer. |
len | The length of the bytes array. |
The function creates a new buffer in memory, initializing it with the bytes passed as argument. The bytes parameter can be NULL, but the length should be set to 0.
Definition at line 465 of file buf.c.
References bytes, buf_bytes_user::data, len, buf_bytes_user::length, new_buffer(), NULL, RZ_BUFFER_BYTES, and rz_return_val_if_fail.
Referenced by build(), create(), dex_create_relocations(), gprobe_debugoff(), gprobe_debugon(), gprobe_getdeviceid(), gprobe_getinformation(), gprobe_read(), gprobe_reset(), gprobe_runcode(), gprobe_write(), handle_tmp_desc(), rz_analysis_reflines_str(), rz_bin_fatmach0_from_bytes_new(), rz_bin_fatmach0_new(), rz_bin_file_set_bytes(), rz_bin_mdmp_init_pe_bins(), rz_bin_mz_new(), rz_bin_pemixed_from_bytes_new(), rz_bin_pemixed_init_dos(), rz_bin_te_new(), rz_buf_new_with_buf(), rz_buf_new_with_string(), rz_core_cmd_subst_i(), rz_core_init(), rz_egg_finalize(), rz_egg_new(), rz_egg_patch(), rz_egg_reset(), rz_io_zip_create_new_file(), rz_io_zip_slurp_file(), rz_main_rz_gg(), socket_http_answer(), and xnu_generate_corefile().
RZ_API RZ_OWN RzBuffer* rz_buf_new_with_io | ( | RZ_NONNULL void * | iob | ) |
Creates a new buffer wrapping the memory map exposed by RzIOBind.
iob | Pointer to RzIOBind structure. |
This buffer will use rz_io_read_at()
/rz_io_write_at()
as implemented by the RzIOBind given.
Definition at line 509 of file buf.c.
References buf_io_fd_user::iob, new_buffer(), NULL, RZ_BUFFER_IO, and rz_return_val_if_fail.
Referenced by rz_analysis_il_vm_new(), and rz_debug_dmp_init().
RZ_API RZ_OWN RzBuffer* rz_buf_new_with_io_fd | ( | RZ_NONNULL void * | iob, |
int | fd | ||
) |
Creates a new buffer wrapping a file descriptor accessed through RzIOBind.
iob | Pointer to RzIOBind structure. |
fd | File descriptor to wrap in the buffer. |
The function creates a new buffer wrapping access to a file descriptor through the RzIOBind methods specified in librz/io.
Definition at line 490 of file buf.c.
References fd, buf_io_fd_user::fd, buf_io_fd_user::iob, new_buffer(), NULL, RZ_BUFFER_IO_FD, and rz_return_val_if_fail.
Referenced by basefind_new_bin_file(), cmd_search_bin(), rz_bin_file_compute_hashes(), rz_bin_open_io(), and rz_core_bin_whole_strings().
RZ_API RZ_OWN RzBuffer* rz_buf_new_with_methods | ( | RZ_NONNULL const RzBufferMethods * | methods, |
void * | init_user | ||
) |
Creates a new buffer with a specific back end.
methods | A struct holding the list of methods to use. |
init_user | Some implementation specific information. |
The function creates a new allocated buffer using a custom back end. This function should only be used when no other back end are appropriate.
Definition at line 525 of file buf.c.
References b, buf_init(), free(), NULL, and RZ_NEW0.
Referenced by new_buffer(), new_rebasing_and_stripping_buf(), rz_dyldcache_new_rebasing_buf(), and rz_xnu_kernelcache_new_rebasing_buf().
Creates a new buffer with a bytes array.
bytes | The bytes array used to initialized the buffer. |
len | The length of the bytes array. |
steal | If the boolean is true the function take the ownership of the data. |
The function creates a new buffer in memory. The argument bytes
is used as the memory backend if steal
is true, otherwise a new buffer is allocated and its content is initialized with the one from bytes
.
Definition at line 552 of file buf.c.
References bytes, buf_bytes_user::data_steal, len, buf_bytes_user::length, new_buffer(), RZ_BUFFER_BYTES, and buf_bytes_user::steal.
Referenced by extract_slice(), load_buffer(), pdb7_extract_msf_stream_directory(), pdb7_extract_streams(), rz_axml_decode(), rz_bin_file_set_bytes(), rz_buf_fread(), rz_buf_fwrite(), rz_cf_value_data_new(), and rz_sign_flirt_parse_compressed_pattern_from_buffer().
RZ_API RZ_OWN RzBuffer* rz_buf_new_with_string | ( | RZ_NONNULL const char * | msg | ) |
Creates a new buffer from a string.
msg | The source string used to create the buffer. |
The function creates a new buffer in memory, initializing it with the string passed as argument.
Definition at line 570 of file buf.c.
References msg, rz_buf_new_with_bytes(), and ut64().
Referenced by rz_asm_pseudo_incbin().
RZ_API bool rz_buf_prepend_bytes | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const ut8 * | buf, | ||
ut64 | length | ||
) |
Prepend an array of bytes to the buffer.
b | A buffer with write permission. |
buf | ... |
length | ... |
...
Definition at line 846 of file buf.c.
References b, length, rz_buf_insert_bytes(), and rz_return_val_if_fail.
Referenced by gprobe_frame_sp(), rz_egg_prepend_bytes(), and rz_egg_raw_prepend().
RZ_API st64 rz_buf_read | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL RZ_OUT ut8 * | buf, | ||
ut64 | len | ||
) |
Referenced by ar_check_magic(), ar_parse_header(), bin_pe_dotnet_read_method_header(), constant_pool_copy_from_buffer(), consume_r(), consume_str_r(), dex_parse(), dex_string_new(), flirt_parse_version(), get_bytes(), get_complex_object(), get_float_object(), get_ut8(), make_string(), parse_code_entry(), parse_image_header(), parse_pdb_stream(), parse_type_string(), parse_type_vtshape(), parse_v5_header(), pdb7_extract_msf_stream_directory(), pdb7_extract_streams(), read_byte(), read_image_clr_header(), read_image_debug_directory_entry(), read_image_delay_import_directory(), read_image_export_directory(), read_image_import_directory(), read_image_metadata_tilde_header(), read_image_resource_data_entry(), rz_bin_dmp64_init_triage(), rz_bin_dmp64_init_triage_drivers(), rz_bin_pdb_parse_from_buf(), rz_egg_compile(), rz_io_def_mmap_read(), rz_sign_flirt_parse_compressed_pattern_from_buffer(), rz_sign_flirt_parse_header_compressed_pattern_from_buffer(), and rz_sign_flirt_parse_string_pattern_from_buffer().
RZ_API bool rz_buf_read8 | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL RZ_OUT ut8 * | result | ||
) |
Read a byte at the cursor in the buffer.
b | ... |
result | ... |
...
Definition at line 860 of file buf.c.
References b, rz_buf_read(), rz_return_val_if_fail, and ut8.
Referenced by bin_pe_dotnet_read_method_header(), consume_init_expr_r(), consumeBuffer(), has_non_padding(), java_attribute_set_code(), java_constant_pool_new(), parse_gdata_global(), parse_type_bitfield(), parse_type_mfunction(), parse_type_numeric(), parse_type_procedure(), parse_type_string(), showBuffer(), and skip_padding().
Read a byte at the specified address in the buffer.
b | ... |
addr | ... |
result | ... |
Definition at line 876 of file buf.c.
References addr, b, rz_buf_read_at(), rz_return_val_if_fail, and ut8.
Referenced by __read_nonnull_str_at(), bin_pe_get_actual_checksum(), bin_pe_read_metadata_string(), build(), check_buffer(), check_pe32_buf(), check_pe64_buf(), jmp(), jmp_dest(), le_read_nonnull_str_at(), lua_parse_body_53(), lua_parse_body_54(), lua_parse_const_entry(), lua_parse_debug(), lua_parse_header_53(), lua_parse_header_54(), lua_parse_string(), lua_parse_szint(), lua_parse_upvalue_entry(), mach_headerfields(), rjmp(), rjmp_dest(), rz_bin_le_get_relocs(), rz_bin_ne_get_imports(), rz_bin_ne_get_symbols(), rz_core_meta_pascal_string_add(), and rz_core_yank_as_string().
RZ_API st64 rz_buf_read_at | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | addr, | ||
RZ_NONNULL RZ_OUT ut8 * | buf, | ||
ut64 | len | ||
) |
Read len bytes of the buffer at the specified address.
b | ... |
addr | ... |
buf | ... |
len | ... |
...
Definition at line 1136 of file buf.c.
References addr, b, len, rz_buf_read(), rz_buf_seek(), RZ_BUF_SET, rz_buf_tell(), rz_return_val_if_fail, st64, and autogen_x86imm::tmp.
Referenced by __dumpSections(), __ne_get_resources(), __read(), __read_nonnull_str_at(), _parse_resource_directory(), ar_read_at(), bflt_init_hdr(), bin_pe_dotnet_init_metadata(), bin_pe_get_actual_checksum(), bin_pe_init_security(), bin_pe_parse_imports(), binsym(), bootimg_header_load(), buf_move_back(), buf_read(), buf_ref_read(), buf_sparse_read(), carve_deps_at_address(), carve_kexts(), check_buffer(), check_mingw(), check_msvcseh(), check_pe32_buf(), check_pe64_buf(), check_unknow(), checkEntrypointBuffer(), checkHeader(), classes(), create_cache_bins(), create_path_to_index(), decompress(), entries(), extract_binobj(), extract_slice(), get_category_t(), get_class_name(), get_class_ro_t(), get_class_t(), get_entrypoint(), get_filetype(), get_import_addr_mips(), get_ivar_list_t(), get_lib_name(), get_main(), get_main_offset_mips(), get_main_offset_x86_pie(), get_method_list_t(), get_objc_property_list(), get_protocol_list_t(), get_rebase_info(), get_relocs(), get_section_bytes(), get_whole_buf(), gprobe_read(), header(), info(), init_hdr(), init_items(), io_read_va_at(), is_compressed_pdb(), iterate_rebase_list(), kexts_from_load_commands(), knownHeaderBuffer(), le_get_entries(), le_init_header(), le_read_nonnull_str_at(), load_buffer(), lua_load_block(), lua_parse_string(), mach0_info_new(), mach_headerfields(), parse_classes(), parse_dylib(), parse_dysymtab(), parse_function_starts(), parse_go_build_info(), parse_note_prstatus(), parse_relocation_info(), parse_segments(), parse_signature(), parse_symbol_table(), parse_symtab(), parse_thread(), parseCodeDirectory(), parseDragons(), parseHeader(), parseMetadata(), Pe_r_bin_pe_parse_string(), Pe_r_bin_pe_parse_string_file_info(), Pe_r_bin_pe_parse_string_table(), Pe_r_bin_pe_parse_var(), Pe_r_bin_pe_parse_var_file_info(), Pe_r_bin_pe_parse_version_info(), process_constructors(), process_kmod_init_term(), rabin_dump_symbols(), read_and_follow_jump(), read_elf_intrp(), read_image_section_header(), read_le_header_aux(), read_n_bits(), read_ptr_pa(), read_str(), read_xbe_header(), read_xbe_lib(), read_xbe_section(), readString(), rebase_buffer(), reconstruct_chained_fixup(), resolve_mig_subsystem(), resolve_syscalls(), rz_axml_decode(), rz_bin_dmp64_init_bmp_header(), rz_bin_dmp64_init_header(), rz_bin_dmp64_init_memory_runs(), rz_bin_elf_get_compiler(), rz_bin_elf_get_ehdr(), rz_bin_elf_get_main_offset(), rz_bin_elf_strtab_new(), rz_bin_fatmach0_init(), rz_bin_le_get_relocs(), rz_bin_mdmp_init_directory_entry(), rz_bin_mdmp_init_pe_bins(), rz_bin_mz_get_main_vaddr(), rz_bin_mz_init_hdr(), rz_bin_ne_buf_init(), rz_bin_ne_get_imports(), rz_bin_ne_get_relocs(), rz_bin_ne_get_symbols(), rz_bin_pe_get_debug_data(), rz_bin_pe_get_exports(), rz_bin_pe_get_imports(), rz_bin_pe_get_libs(), rz_bin_pe_get_sections(), rz_bin_pemixed_init_dos(), rz_bin_te_get_main_paddr(), rz_bin_te_init_sections(), rz_bin_zimg_new_buf(), rz_buf_append_buf_slice(), rz_buf_fwd_scan(), rz_buf_get_nstring(), rz_buf_read8_at(), rz_buf_to_string(), rz_cf_value_dict_parse(), rz_coff_symbol_name(), rz_core_yank_paste(), rz_core_yank_print(), rz_core_yank_print_hexdump(), rz_core_yank_print_string(), rz_coresym_cache_element_new(), rz_il_mem_load(), rz_io_zip_read(), rz_rebase_info_new_from_mach0(), rz_scan_strings(), sections(), shared_data_read_at(), size(), socket_http_answer(), string_scan_range_cfstring(), symbols(), symbols_from_stubs(), trycatch(), vf_read(), and walk_exports().
Increment the reference count of the buffer.
b | RzBuffer to reference |
b
The function increment the reference count of the buffer
Definition at line 668 of file buf.c.
References b.
Referenced by buf_ref_init(), buf_sparse_init(), load_buffer(), rz_bflt_init(), rz_bin_coff_init(), rz_bin_dmp64_new_buf(), rz_bin_elf_new_buf(), rz_bin_fatmach0_from_buffer_new(), rz_bin_file_new_from_buffer(), rz_bin_file_object_new_from_xtr_data(), rz_bin_mdmp_new_buf(), rz_bin_pe_new_buf(), rz_bin_wasm_init(), rz_bin_xtrdata_new(), rz_bin_zimg_new_buf(), rz_dyldcache_new_buf(), and rz_il_mem_new().
RZ_API bool rz_buf_resize | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | newsize | ||
) |
Resize the buffer size.
b | ... |
newsize | ... |
...
Definition at line 890 of file buf.c.
References b, buf_resize(), and rz_return_val_if_fail.
Referenced by __resize(), buf_bytes_write(), buf_move_back(), buf_resize(), rz_buf_append_nbytes(), rz_buf_set_bytes(), rz_io_def_mmap_truncate(), rz_io_zip_realloc_buf(), rz_io_zip_truncate_buf(), and vf_resize().
Modify the current cursor position in the buffer.
b | ... |
addr | ... |
whence | The relative position of the address. |
...
Definition at line 1166 of file buf.c.
References addr, b, buf_seek(), and rz_return_val_if_fail.
Referenced by __lseek(), __read(), __write(), ar_parse_header(), bin_pe_dotnet_read_method_header(), consume_r(), consumeBuffer(), dex_class_def_new(), dex_parse(), entries(), get_entries_from_section(), get_entrypoint(), has_non_padding(), java_attribute_set_code(), java_attribute_set_unknown(), java_constant_pool_new(), parse_code_entry(), parse_data_entry(), parse_dbi_stream(), parse_dbi_stream_ex_header(), parse_gdata_global(), parse_gdata_stream(), parse_type_string(), parse_v5_header(), pdb7_extract_msf_stream_directory(), pdb7_extract_streams(), read_desc(), read_entry(), read_hdr(), read_image_clr_header(), read_image_debug_directory_entry(), read_image_delay_import_directory(), read_image_export_directory(), read_image_import_directory(), read_image_metadata_tilde_header(), read_image_resource_data_entry(), read_image_resource_directory(), read_image_resource_directory_entry(), read_memory64_list(), read_module(), read_tls_directory(), rz_bin_dmp64_init_triage(), rz_bin_dmp64_init_triage_datablocks(), rz_bin_dmp64_init_triage_drivers(), rz_bin_reload(), rz_bin_wasm_get_custom_name_entries(), rz_bin_wasm_get_sections(), rz_bin_wasm_get_start(), rz_buf_append_bytes(), rz_buf_fread_at(), rz_buf_fwrite_at(), rz_buf_read_at(), rz_buf_set_bytes(), rz_buf_sleb128_at(), rz_buf_tell(), rz_buf_uleb128_at(), rz_buf_write_at(), rz_egg_compile(), rz_io_def_mmap_seek(), rz_io_zip_lseek(), rz_io_zip_read(), rz_io_zip_write(), rz_main_rz_gg(), showBuffer(), skip_padding(), and symbols().
RZ_API bool rz_buf_set_bytes | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const ut8 * | buf, | ||
ut64 | length | ||
) |
Replace the content of the buffer with the bytes array.
b | A buffer with write permission. |
buf | ... |
length | ... |
...
Definition at line 905 of file buf.c.
References b, length, rz_buf_append_bytes(), rz_buf_resize(), rz_buf_seek(), RZ_BUF_SET, and rz_return_val_if_fail.
Referenced by build(), rz_bin_fatmach0_from_bytes_new(), rz_bin_fatmach0_new(), rz_bin_mz_new(), rz_bin_te_new(), rz_core_yank_set(), and rz_io_zip_slurp_file().
RZ_API void rz_buf_set_overflow_byte | ( | RZ_NONNULL RzBuffer * | b, |
ut8 | Oxff | ||
) |
Change the overflow byte used in the RZ_BUFFER_SPARSE.
b | ... |
Oxff | The new byte filling value. |
Set the content that bytes read outside the buffer bounds should have.
Definition at line 1272 of file buf.c.
References b, and rz_return_if_fail.
RZ_API ut64 rz_buf_size | ( | RZ_NONNULL RzBuffer * | b | ) |
Return the size of the buffer.
b | ... |
...
Definition at line 1225 of file buf.c.
References b, buf_get_size(), and rz_return_val_if_fail.
Referenced by __dumpSections(), ar_open_all(), ar_open_file(), art_header_load(), bin_pe_compute_authentihash(), bin_pe_dotnet_init_metadata(), bin_pe_init_imports(), bootimg_header_load(), buf_get_size(), buf_move_back(), buf_ref_init(), buf_ref_resize(), buf_seek(), buf_sparse_size(), build(), check_buffer(), check_buffer_jmp(), check_buffer_rjmp(), checkEntrypointBuffer(), checkHeader(), consume_init_expr_r(), consume_limits_r(), consume_locals_r(), consume_r(), consume_str_r(), consumeBuffer(), create(), dex_parse(), entries(), get_elf_intrp(), get_entries_from_section(), get_main_offset_arm_glibc_thumb(), get_section(), get_whole_buf(), gprobe_read(), handle_tmp_desc(), is_eob(), java_class_parse(), kexts_from_load_commands(), knownHeaderBuffer(), lmf_header_load(), load_buffer(), MACH0_(), mach_headerfields(), make_string(), maps(), parse_header(), parse_omap_stream(), parse_pe_stream(), parse_signature(), parseDragons(), rz_asm_massemble(), rz_bflt_init(), rz_bin_coff_init(), rz_bin_dmp64_init_triage(), rz_bin_dmp64_new_buf(), rz_bin_elf_new_buf(), rz_bin_fatmach0_from_buffer_new(), rz_bin_file_compute_hashes(), rz_bin_file_new_from_buffer(), rz_bin_file_xtr_load_buffer(), rz_bin_mdmp_init_directory_entry(), rz_bin_mdmp_new_buf(), rz_bin_mz_get_segments(), rz_bin_mz_new_buf(), rz_bin_ne_get_relocs(), rz_bin_object_new(), rz_bin_open_io(), rz_bin_pdb_parse_from_buf(), rz_bin_pe_get_debug_data(), rz_bin_pe_new_buf(), rz_bin_te_new_buf(), rz_bin_wasm_get_custom_name_entries(), rz_bin_wasm_get_sections(), rz_bin_wasm_get_start(), rz_bin_wasm_init(), rz_bin_zimg_new_buf(), rz_buf_append_nbytes(), rz_buf_fwd_scan(), rz_buf_get_string(), rz_buf_to_string(), rz_core_cmd_subst_i(), rz_core_yank_as_string(), rz_core_yank_dump(), rz_core_yank_paste(), rz_core_yank_print(), rz_core_yank_print_hexdump(), rz_core_yank_print_string(), rz_coresym_cache_element_new(), rz_egg_finalize(), rz_io_open_buffer(), rz_io_zip_lseek(), rz_io_zip_read(), rz_io_zip_write(), rz_sign_flirt_parse_compressed_pattern_from_buffer(), rz_xnu_kernelcache_buf_is_kernelcache(), sections(), sep64_xtr_ctx_get_slice(), showBuffer(), size(), trycatch(), and vf_lseek().
RZ_API st64 rz_buf_sleb128 | ( | RZ_NONNULL RzBuffer * | buffer, |
RZ_NONNULL st64 * | value | ||
) |
Decodes SLEB128 from RzBuffer.
buffer | Buffer used to decode the SLEB128. |
value | Decoded value. |
Definition at line 1384 of file buf.c.
References rz_buf_read(), rz_return_val_if_fail, shift(), st64, ut64(), and value.
Referenced by rz_buf_sleb128_at().
Definition at line 146 of file rz_buf.h.
References addr, b, rz_buf_seek(), RZ_BUF_SET, rz_buf_sleb128(), and v.
RZ_API const RzBufferSparseChunk* rz_buf_sparse_get_chunks | ( | RzBuffer * | b, |
RZ_NONNULL size_t * | count | ||
) |
Only for sparse RzBuffers, get all sparse data chunks currently populated.
Definition at line 313 of file buf_sparse.c.
References b, buffer_sparse_methods, buf_sparse_priv::chunks, count, get_priv_sparse(), NULL, rz_return_val_if_fail, rz_vector_index_ptr(), and rz_vector_len().
Referenced by __write(), and ihex_write().
from | inclusive |
to | inclusive |
Definition at line 339 of file buf_sparse.c.
References b, buffer_sparse_methods, c, chunk_index_in(), buf_sparse_priv::chunks, from, get_priv_sparse(), rz_return_val_if_fail, rz_vector_index_ptr(), and to.
Referenced by rz_bin_relocs_patch_maps().
RZ_API void rz_buf_sparse_set_write_mode | ( | RzBuffer * | b, |
RzBufferSparseWriteMode | mode | ||
) |
Only for sparse RzBuffers.
Definition at line 325 of file buf_sparse.c.
References b, buffer_sparse_methods, get_priv_sparse(), rz_return_if_fail, and buf_sparse_priv::write_mode.
Referenced by bflt_patch_relocs(), patch_relocs(), and rz_coff_get_patched_buf().
RZ_API ut64 rz_buf_tell | ( | RZ_NONNULL RzBuffer * | b | ) |
Return the current cursor position.
b | ... |
...
Definition at line 1238 of file buf.c.
References b, RZ_BUF_CUR, rz_buf_seek(), and rz_return_val_if_fail.
Referenced by ar_parse_header(), consume_init_expr_r(), consume_limits_r(), consume_locals_r(), consume_r(), consume_str_r(), dex_new_encoded_field(), dex_new_encoded_method(), dex_parse(), get_code_object(), get_entries_from_section(), is_eob(), java_class_parse(), java_field_new(), java_method_new(), parse_code_entry(), parse_data_entry(), parse_dbi_stream_ex_header(), parse_element_entry(), parse_gdata_global(), parse_gdata_stream(), parse_type_entry(), rz_bin_wasm_get_custom_name_entries(), rz_bin_wasm_get_sections(), rz_bin_wasm_get_start(), rz_buf_fread_at(), rz_buf_fwrite_at(), rz_buf_read_at(), rz_buf_write_at(), rz_io_zip_lseek(), rz_io_zip_realloc_buf(), rz_io_zip_write(), and rz_sign_flirt_parse_compressed_pattern_from_buffer().
RZ_API RZ_OWN char* rz_buf_to_string | ( | RZ_NONNULL RzBuffer * | b | ) |
Stringify the buffer.
b | RzBuffer pointer |
The string is guaranteed to be NULL terminated even if the buffer doesn't have any NULL bytes.
Definition at line 642 of file buf.c.
References b, free(), NULL, rz_buf_read_at(), rz_buf_size(), RZ_NEWS, rz_return_val_if_fail, and ut64().
Referenced by gprobe_getdeviceid(), rz_analysis_reflines_str(), rz_asm_massemble(), rz_egg_assemble_asm(), rz_egg_get_assembly(), rz_egg_get_source(), and rz_egg_to_string().
RZ_API st64 rz_buf_uleb128 | ( | RZ_NONNULL RzBuffer * | buffer, |
RZ_NONNULL ut64 * | value | ||
) |
Decodes ULEB128 from RzBuffer.
buffer | Buffer used to decode the ULEB128. |
value | Decoded value. |
Definition at line 1353 of file buf.c.
References rz_buf_read(), rz_return_val_if_fail, shift(), ut64(), and value.
Referenced by dex_class_def_new(), dex_new_encoded_field(), dex_new_encoded_method(), dex_string_new(), and rz_buf_uleb128_at().
Definition at line 142 of file rz_buf.h.
References addr, b, rz_buf_seek(), RZ_BUF_SET, rz_buf_uleb128(), and v.
RZ_API st64 rz_buf_write | ( | RZ_NONNULL RzBuffer * | b, |
RZ_NONNULL const ut8 * | buf, | ||
ut64 | len | ||
) |
Write len bytes of the buffer at the cursor.
b | A buffer with write permission. |
buf | ... |
len | ... |
...
Definition at line 1181 of file buf.c.
References b, buf_write(), len, and rz_return_val_if_fail.
Referenced by buf_format(), rz_buf_append_bytes(), rz_buf_write8(), rz_buf_write_at(), and rz_io_def_mmap_write().
RZ_API bool rz_buf_write8 | ( | RZ_NONNULL RzBuffer * | b, |
ut8 | value | ||
) |
Write a byte at the cursor in the buffer.
b | ... |
result | ... |
...
Definition at line 931 of file buf.c.
References b, rz_buf_write(), rz_return_val_if_fail, ut8, and value.
Write a byte at the specified address in the buffer.
b | ... |
addr | ... |
value | ... |
...
Definition at line 948 of file buf.c.
References addr, b, rz_buf_write_at(), rz_return_val_if_fail, ut8, and value.
RZ_API st64 rz_buf_write_at | ( | RZ_NONNULL RzBuffer * | b, |
ut64 | addr, | ||
RZ_NONNULL const ut8 * | buf, | ||
ut64 | len | ||
) |
Write len bytes of the buffer at the specified address.
b | A buffer with write permission. |
addr | ... |
buf | ... |
len | ... |
...
Definition at line 1197 of file buf.c.
References addr, b, len, rz_buf_seek(), RZ_BUF_SET, rz_buf_tell(), rz_buf_write(), rz_return_val_if_fail, st64, and autogen_x86imm::tmp.
Referenced by __open(), __write(), _patch_reloc(), ar_write_at(), buf_move_back(), buf_sparse_write(), buf_write(), build(), fill_level(), ihex_parse(), patch_reloc_cb(), rz_analysis_reflines_str(), rz_bin_pemixed_init_native(), rz_buf_insert_bytes(), rz_buf_write8_at(), rz_core_bin_whole_strings(), rz_core_yank_set_str(), rz_egg_finalize(), rz_il_mem_store(), rz_io_zip_write(), srecord_parse(), vf_write(), write_image_section_header(), and write_n_bits().
RZ_API bool rz_deflate_buf | ( | RZ_NONNULL RzBuffer * | src, |
RZ_NONNULL RzBuffer * | dst, | ||
ut64 | block_size, | ||
ut8 * | src_consumed | ||
) |
deflate uncompressed data in RzBbuffer to zlib or gzipped, use MAX_WBITS as the window size logarithm.
Definition at line 350 of file compression.c.
References dst, MAX_WBITS, rz_deflatew_buf(), rz_return_val_if_fail, and src.
Referenced by rz_file_deflate().
RZ_API bool rz_deflatew_buf | ( | RZ_NONNULL RzBuffer * | src, |
RZ_NONNULL RzBuffer * | dst, | ||
ut64 | block_size, | ||
ut8 * | src_consumed, | ||
int | wbits | ||
) |
Definition at line 327 of file compression.c.
Referenced by rz_deflate_buf(), and rz_sign_flirt_write_compressed_pattern_to_buffer().
RZ_API bool rz_inflate_buf | ( | RZ_NONNULL RzBuffer * | src, |
RZ_NONNULL RzBuffer * | dst, | ||
ut64 | block_size, | ||
ut8 * | src_consumed | ||
) |
inflate compressed data in RzBbuffer, use MAX_WBITS as the window size logarithm.
Definition at line 360 of file compression.c.
References dst, MAX_WBITS, rz_inflatew_buf(), rz_return_val_if_fail, and src.
Referenced by rz_file_inflate().
RZ_API bool rz_inflatew_buf | ( | RZ_NONNULL RzBuffer * | src, |
RZ_NONNULL RzBuffer * | dst, | ||
ut64 | block_size, | ||
ut8 * | src_consumed, | ||
int | wbits | ||
) |
Definition at line 331 of file compression.c.
Referenced by rz_inflate_buf().
RZ_API bool rz_lzma_dec_buf | ( | RZ_NONNULL RzBuffer * | src, |
RZ_NONNULL RzBuffer * | dst, | ||
ut64 | block_size, | ||
ut8 * | src_consumed | ||
) |
Decompress the src
buffer with LZMA algorithm and put the decompressed data in dst
.
src | Where to read the compressed data from |
dst | Where to write the decompressed data to |
block_size | Decompression can happen block after block. Specify the size of the block here. |
Definition at line 462 of file compression.c.
References dst, lzma_action_buf(), and src.
Referenced by get_gnu_debugdata_elf_symbols().
RZ_API bool rz_lzma_enc_buf | ( | RZ_NONNULL RzBuffer * | src, |
RZ_NONNULL RzBuffer * | dst, | ||
ut64 | block_size, | ||
ut8 * | src_consumed | ||
) |
Compress the src
buffer with LZMA algorithm and put the compressed data in dst
.
src | Where to read the decompressed data from |
dst | Where to write the compressed data to |
block_size | Compression can happen block after block. Specify the size of the block here. |
Definition at line 474 of file compression.c.
References dst, lzma_action_buf(), and src.
change cur according to addr and whence (RZ_BUF_SET/RZ_BUF_CUR/RZ_BUF_END)
Definition at line 67 of file rz_buf.h.
References addr, length, RZ_BUF_CUR, RZ_BUF_END, RZ_BUF_SET, rz_warn_if_reached, and ut64().
Referenced by buf_bytes_seek(), buf_io_seek(), and buf_seek().