27 #define GET_STRING_BUFFER_SIZE 32
31 if (
b->methods->get_whole_buf) {
32 if (
b->methods->free_whole_buf) {
33 b->methods->free_whole_buf(
b);
43 return b->methods->init ?
b->methods->init(
b, user) :
true;
49 return b->methods->fini ?
b->methods->fini(
b) :
true;
55 return b->methods->get_size ?
b->methods->get_size(
b) : 0;
61 return b->methods->read ?
b->methods->read(
b,
buf,
len) : -1;
69 return b->methods->write ?
b->methods->write(
b,
buf,
len) : -1;
75 return b->methods->seek ?
b->methods->seek(
b,
addr, whence) : -1;
81 return b->methods->resize ?
b->methods->resize(
b, newsize) :
false;
87 for (
int i = 0;
i <
n;
i++) {
90 bool bigendian =
true;
92 for (
int j = 0; fmt[j]; j++) {
139 for (
int k = 0;
k <
m;
k++) {
196 if (tmp_length < 0) {
219 if (
b->methods->get_whole_buf) {
220 return b->methods->get_whole_buf(
b,
size);
431 .write_mode = write_mode
531 b->methods = methods;
1275 b->Oxff_priv = Oxff;
1308 if (
b->methods->get_whole_buf) {
1310 const ut8 *
buf =
b->methods->get_whole_buf(
b, &sz);
1356 ut64 sum = 0, used = 0, slice;
1365 slice =
byte & 0x7f;
1366 if ((
shift >= 64 && slice != 0) || ((slice <<
shift) >>
shift) != slice) {
1370 sum += slice <<
shift;
1372 }
while (
byte >= 128);
1387 ut64 used = 0, slice;
1397 slice =
byte & 0x7f;
1398 if ((
shift >= 64 && slice != (sum < 0 ? 0x7f : 0x00)) ||
1399 (
shift == 63 && slice != 0 && slice != 0x7f)) {
1403 sum |= slice <<
shift;
1405 }
while (
byte >= 128);
1407 if (
shift < 64 && (
byte & 0x40)) {
1409 sum |= (-1ull) <<
shift;
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
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.
RZ_API bool rz_buf_append_nbytes(RZ_NONNULL RzBuffer *b, ut64 length)
Extend the size of the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_mmap(const char *filename, int perm, int mode)
Creates a new buffer from a file using rz_file_mmap.
RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b)
Return the current cursor position.
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.
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.
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.
RZ_API bool rz_buf_resize(RZ_NONNULL RzBuffer *b, ut64 newsize)
Resize the buffer size.
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.
#define GET_STRING_BUFFER_SIZE
static ut64 buf_get_size(RzBuffer *b)
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)
...
static bool buf_move_back(RZ_NONNULL RzBuffer *b, ut64 addr, ut64 length)
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 bool rz_buf_dump(RZ_NONNULL RzBuffer *b, RZ_NONNULL const char *file)
Dump the content of the buffer to a file.
RZ_API RZ_OWN char * rz_buf_get_string(RZ_NONNULL RzBuffer *b, ut64 addr)
Get a string from the buffer.
static st64 buf_format(RzBuffer *dst, RzBuffer *src, const char *fmt, int n)
static ut8 * get_whole_buf(RzBuffer *b, ut64 *size)
static st64 buf_seek(RzBuffer *b, st64 addr, int whence)
RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL ut8 RZ_OUT *buf, ut64 len)
Read len bytes of the buffer at the cursor.
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.
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.
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_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.
static st64 buf_read(RzBuffer *b, ut8 *buf, size_t len)
static bool buf_fini(RzBuffer *b)
RZ_API st64 rz_buf_uleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL ut64 *value)
Decodes ULEB128 from RzBuffer.
static RzBuffer * new_buffer(RzBufferType type, void *user)
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.
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.
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 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_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 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 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.
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.
static bool buf_resize(RzBuffer *b, ut64 newsize)
static bool buf_init(RzBuffer *b, const void *user)
static st64 buf_write(RzBuffer *b, const ut8 *buf, size_t len)
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.
static void buf_whole_buf_free(RzBuffer *b)
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.
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 const RzBufferMethods buffer_bytes_methods
static const RzBufferMethods buffer_file_methods
static const RzBufferMethods buffer_io_methods
static const RzBufferMethods buffer_io_fd_methods
static const RzBufferMethods buffer_mmap_methods
static const RzBufferMethods buffer_ref_methods
static const RzBufferMethods buffer_sparse_methods
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
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
void * malloc(size_t size)
#define rz_warn_if_reached()
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
ut64(* RzBufferFwdScan)(RZ_BORROW RZ_NONNULL const ut8 *buf, ut64 len, RZ_NULLABLE void *user)
static ut64 rz_read_ble64(const void *src, bool big_endian)
static ut8 rz_read_ble8(const void *src)
static ut32 rz_read_ble32(const void *src, bool big_endian)
static ut16 rz_read_ble16(const void *src, bool big_endian)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
RZ_API size_t rz_str_nlen(const char *s, size_t n)
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API void rz_strbuf_free(RzStrBuf *sb)
RZ_API bool rz_strbuf_append_n(RzStrBuf *sb, const char *s, size_t l)
#define UT64_ADD_OVFCHK(x, y)
static struct sockaddr static addrlen static backlog const void msg
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)