153 #define DEFINE_RZ_BUF_READ_BLE(size) \
154 static inline bool rz_buf_read_ble##size(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \
155 rz_return_val_if_fail(b &&result, false); \
157 ut8 tmp[sizeof(ut##size)]; \
158 if (rz_buf_read(b, tmp, sizeof(tmp)) != sizeof(tmp)) { \
162 *result = rz_read_ble##size(tmp, big_endian); \
166 static inline bool rz_buf_read_ble##size##_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \
167 rz_return_val_if_fail(b &&result, false); \
169 ut8 tmp[sizeof(ut##size)]; \
170 if (rz_buf_read_at(b, addr, tmp, sizeof(tmp)) != sizeof(tmp)) { \
174 *result = rz_read_ble##size(tmp, big_endian); \
178 #define DEFINE_RZ_BUF_WRITE_BLE(size) \
179 static inline bool rz_buf_write_ble##size(RZ_NONNULL RzBuffer *b, ut##size value, bool big_endian) { \
180 ut8 tmp[sizeof(ut##size)]; \
181 rz_write_ble##size(tmp, value, big_endian); \
183 return rz_buf_write(b, tmp, sizeof(tmp)) == sizeof(tmp); \
186 static inline bool rz_buf_write_ble##size##_at(RZ_NONNULL RzBuffer *b, ut64 addr, ut##size value, bool big_endian) { \
187 ut8 tmp[sizeof(ut##size)]; \
188 rz_write_ble##size(tmp, value, big_endian); \
190 return rz_buf_write_at(b, addr, tmp, sizeof(tmp)) == sizeof(tmp); \
217 #define DEFINE_RZ_BUF_READ_OFFSET_BLE(size) \
218 static inline bool rz_buf_read_ble##size##_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \
219 rz_return_val_if_fail(b &&offset &&result, false); \
220 if (!rz_buf_read_ble##size##_at(b, *offset, result, big_endian)) { \
223 *offset += sizeof(*result); \
227 #define DEFINE_RZ_BUF_WRITE_OFFSET_BLE(size) \
228 static inline bool rz_buf_write_ble##size##_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, ut##size value, bool big_endian) { \
229 rz_return_val_if_fail(b &&offset, false); \
230 if (!rz_buf_write_ble##size##_at(b, *offset, value, big_endian)) { \
233 *offset += sizeof(value); \
237 #define rz_buf_read_ble8_at(b, addr, result, endian) rz_buf_read8_at(b, addr, result)
238 #define rz_buf_write_ble8_at(b, addr, value, endian) rz_buf_write8_at(b, addr, value)
266 #define rz_buf_read_le16(b, result) rz_buf_read_ble16(b, result, false)
267 #define rz_buf_read_le32(b, result) rz_buf_read_ble32(b, result, false)
268 #define rz_buf_read_le64(b, result) rz_buf_read_ble64(b, result, false)
270 #define rz_buf_read_le16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, false)
271 #define rz_buf_read_le32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, false)
272 #define rz_buf_read_le64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, false)
274 #define rz_buf_read8_offset(b, offset, result) rz_buf_read_ble8_offset(b, offset, result, false)
276 #define rz_buf_read_le16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, false)
277 #define rz_buf_read_le32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, false)
278 #define rz_buf_read_le64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, false)
280 #define rz_buf_read_be16(b, result) rz_buf_read_ble16(b, result, true)
281 #define rz_buf_read_be32(b, result) rz_buf_read_ble32(b, result, true)
282 #define rz_buf_read_be64(b, result) rz_buf_read_ble64(b, result, true)
284 #define rz_buf_read_be16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, true)
285 #define rz_buf_read_be32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, true)
286 #define rz_buf_read_be64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, true)
288 #define rz_buf_read_be16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, true)
289 #define rz_buf_read_be32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, true)
290 #define rz_buf_read_be64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, true)
292 #define rz_buf_write_le16(b, value) rz_buf_write_ble16(b, value, false)
293 #define rz_buf_write_le32(b, value) rz_buf_write_ble32(b, value, false)
294 #define rz_buf_write_le64(b, value) rz_buf_write_ble64(b, value, false)
296 #define rz_buf_write_le16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, false)
297 #define rz_buf_write_le32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, false)
298 #define rz_buf_write_le64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, false)
300 #define rz_buf_write8_offset(b, offset, value) rz_buf_write_ble8_offset(b, offset, value, false)
302 #define rz_buf_write_le16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, false)
303 #define rz_buf_write_le32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, false)
304 #define rz_buf_write_le64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, false)
306 #define rz_buf_write_be16(b, value) rz_buf_write_ble16(b, value, true)
307 #define rz_buf_write_be32(b, value) rz_buf_write_ble32(b, value, true)
308 #define rz_buf_write_be64(b, value) rz_buf_write_ble64(b, value, true)
310 #define rz_buf_write_be16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, true)
311 #define rz_buf_write_be32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, true)
312 #define rz_buf_write_be64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, true)
314 #define rz_buf_write_be16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, true)
315 #define rz_buf_write_be32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, true)
316 #define rz_buf_write_be64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, true)
318 #undef DEFINE_RZ_BUF_READ_BLE
319 #undef DEFINE_RZ_BUF_WRITE_BLE
320 #undef DEFINE_RZ_BUF_READ_OFFSET_BLE
321 #undef DEFINE_RZ_BUF_WRITE_OFFSET_BLE
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
#define rz_warn_if_reached()
RZ_API bool rz_buf_sparse_populated_in(RzBuffer *b, ut64 from, ut64 to)
RZ_API bool rz_buf_prepend_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Prepend an array of bytes to the 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.
RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b)
Return the current cursor position.
RZ_API void rz_buf_sparse_set_write_mode(RzBuffer *b, RzBufferSparseWriteMode mode)
Only for sparse RzBuffers.
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.
ut64(* RzBufferFwdScan)(RZ_BORROW RZ_NONNULL const ut8 *buf, ut64 len, RZ_NULLABLE void *user)
RZ_API RZ_OWN char * rz_buf_get_nstring(RZ_NONNULL RzBuffer *b, ut64 addr, size_t size)
Get a string with a max length from the buffer.
ut64(* RzBufferGetSize)(RzBuffer *b)
RZ_API bool rz_buf_resize(RZ_NONNULL RzBuffer *b, ut64 newsize)
Resize the buffer size.
#define DEFINE_RZ_BUF_WRITE_OFFSET_BLE(size)
RZ_API bool rz_buf_append_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Append an array of bytes to the buffer.
RZ_API bool rz_buf_append_nbytes(RZ_NONNULL RzBuffer *b, ut64 len)
Extend the size of the buffer.
RZ_API bool rz_buf_append_ut32(RZ_NONNULL RzBuffer *b, ut32 n)
Add a ut32 number at the end of the buffer.
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)
...
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
RZ_API st64 rz_buf_fread(RZ_NONNULL RzBuffer *b, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n)
...
RZ_API bool rz_buf_append_ut64(RZ_NONNULL RzBuffer *b, ut64 n)
Add a ut64 number at the end of the buffer.
RZ_API RZ_OWN char * rz_buf_get_string(RZ_NONNULL RzBuffer *b, ut64 addr)
Get a string from the buffer.
bool(* RzBufferResize)(RzBuffer *b, ut64 newsize)
st64(* RzBufferSeek)(RzBuffer *b, st64 addr, int whence)
static ut64 rz_seek_offset(ut64 cur, ut64 length, st64 addr, int whence)
change cur according to addr and whence (RZ_BUF_SET/RZ_BUF_CUR/RZ_BUF_END)
RZ_API st64 rz_buf_fwrite(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, RZ_NONNULL const char *fmt, int n)
...
RZ_API bool rz_buf_fini(RzBuffer *b)
Free all internal data hold by the buffer.
st64(* RzBufferWrite)(RzBuffer *b, const ut8 *buf, ut64 len)
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.
RZ_API RzBuffer * rz_buf_ref(RzBuffer *b)
Increment the reference count of the buffer.
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.
st64(* RzBufferRead)(RzBuffer *b, ut8 *buf, ut64 len)
struct rz_buf_sparse_chunk_t RzBufferSparseChunk
RZ_API RZ_OWN RzBuffer * rz_buf_new_mmap(const char *file, int flags, int mode)
Creates a new buffer from a file using rz_file_mmap.
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...
RZ_API bool rz_buf_read8_at(RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *result)
Read a byte at the specified address in the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_slurp(const char *file)
Creates a new buffer from a file.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_buf(RzBuffer *b)
Creates a new buffer from a source buffer.
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.
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.
#define DEFINE_RZ_BUF_WRITE_BLE(size)
RZ_API st64 rz_buf_uleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL ut64 *value)
Decodes ULEB128 from RzBuffer.
static st64 rz_buf_uleb128_at(RzBuffer *b, ut64 addr, ut64 *v)
#define DEFINE_RZ_BUF_READ_BLE(size)
RZ_API st64 rz_buf_append_string(RZ_NONNULL RzBuffer *b, RZ_NONNULL const char *str)
Append a string to the 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.
#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 buffe...
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_pointers(const ut8 *bytes, ut64 len, bool steal)
Creates a new buffer with a bytes array.
RZ_API st64 rz_buf_fread_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n)
...
RZ_API bool rz_buf_write8_at(RZ_NONNULL RzBuffer *b, ut64 addr, ut8 value)
Write a byte at the specified address in the buffer.
void(* RzBufferFreeWholeBuf)(RzBuffer *b)
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.
RZ_API st64 rz_buf_insert_bytes(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len)
Insert an array of bytes in the buffer.
@ 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
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.
RZ_API bool rz_buf_write8(RZ_NONNULL RzBuffer *b, ut8 value)
Write a byte at the cursor in the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_string(RZ_NONNULL const char *msg)
Creates a new buffer from a string.
RZ_API bool rz_buf_dump(RZ_NONNULL RzBuffer *buf, RZ_NONNULL const char *file)
Dump the content of the buffer to a file.
bool(* RzBufferFini)(RzBuffer *b)
ut8 *(* RzBufferGetWholeBuf)(RzBuffer *b, ut64 *sz)
RZ_API bool rz_buf_append_ut16(RZ_NONNULL RzBuffer *b, ut16 n)
Add a ut16 number at the end of the buffer.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API bool rz_inflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits)
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.
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.
RZ_API RZ_OWN RzBuffer * rz_buf_new_empty(ut64 len)
Creates a new empty buffer with a predefined size;.
RZ_API RZ_OWN RzBuffer * rz_buf_new_slice(RzBuffer *b, ut64 offset, ut64 size)
Creates a new buffer from a slice of another buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_sparse(ut8 Oxff)
Creates a sparse buffer.
RZ_API bool rz_buf_set_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Replace the content of the buffer with the bytes array.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
bool(* RzBufferInit)(RzBuffer *b, const void *user)
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.
RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
struct rz_buffer_methods_t RzBufferMethods
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.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_file(const char *file, int perm, int mode)
Creates a new buffer from a 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.
static st64 rz_buf_sleb128_at(RzBuffer *b, ut64 addr, st64 *v)
RZ_API bool rz_deflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits)
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.
RZ_API RZ_OWN char * rz_buf_to_string(RZ_NONNULL RzBuffer *b)
Stringify the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_sparse_overlay(RzBuffer *b, RzBufferSparseWriteMode write_mode)
Creates a sparse buffer from a already populated buffer.
RZ_API st64 rz_buf_sleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL st64 *value)
Decodes SLEB128 from RzBuffer.
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.
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
static struct sockaddr static addrlen static backlog const void static flags void flags
static struct sockaddr static addrlen static backlog const void msg
ut8 * data
size == to - from + 1
ut64 to
inclusive, there can't be chunks with size == 0
const RzBufferMethods * methods
RzBufferFreeWholeBuf free_whole_buf
RzBufferGetWholeBuf get_whole_buf
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]