22 r->dbg->main_pid =
pid;
34 if (!strcmp(bep,
"loader")) {
36 }
else if (!strcmp(bep,
"entry")) {
71 eprintf(
"Cannot alloc %d byte(s)\n", bs);
76 for (
i = 0;
i <
size;
i += bs) {
80 if ((
i + bs) >
size) {
84 if (fwrite(
buf, bs, 1,
fd) < 1) {
99 const char *archval =
NULL;
112 bitsval =
s->bits * 8;
124 if (
bits && bitsval) {
127 if (
arch && archval) {
199 ut64 fend = 0, fstart = 0, bstart = 0, file_sz = 0;
203 if (!core->
io || !core->
file) {
207 if (b_size == 0 || b_size == (
ut64)-1) {
215 fstart = file_sz - fend;
216 b_size = fend > bstart ? fend - bstart : 0;
219 if ((
st64)b_size < 1) {
222 shift_buf =
calloc(b_size, 1);
224 eprintf(
"Cannot allocated %d byte(s)\n", (
int)b_size);
228 if (
addr + dist < fstart) {
230 }
else if ((
addr) + dist > fend) {
244 if (core && core->
block) {
252 eprintf(
"rz_core_is_valid_offset: core is NULL\n");
276 RZ_LOG_ERROR(
"Could not convert hexpair '%s' to bin data\n", pairs);
337 if (acode->
len <= 0) {
375 if (acode->
len <= 0) {
385 if (
op.size < acode->
len) {
415 switch (
state->mode) {
430 rz_list_foreach (plist, piter, uri) {
650 for (
int i = 0;
i <
len;
i++) {
704 size_t str_len = strlen(
s) + 1;
749 size_t str_len = strlen(
s) + 1;
783 for (
int i = 0;
i <
len;
i++) {
807 switch (
state->mode) {
810 for (
i = 0;
i < dataSize;
i++) {
814 for (
i = 0;
i < dataSize;
i++) {
835 for (
i = 0;
i < dataSize;
i++) {
840 for (
i = 0;
i < dataSize;
i++) {
865 rz_list_foreach (caches,
iter,
c) {
869 switch (
state->mode) {
873 for (
i = 1;
i < cacheSize;
i++) {
877 for (
i = 1;
i < cacheSize;
i++) {
884 for (
i = 1;
i < cacheSize;
i++) {
966 for (
int i = 0, j = 0;
i <
len;
i++, j = (j + 1) % (hexlen ? hexlen : 1)) {
1071 rz_return_val_if_fail(value_size == 1 || value_size == 2 || value_size == 4 || value_size == 8,
false);
1072 ut64 max_val = (1ULL << (8 * value_size));
RZ_API void * rz_asm_code_free(RzAsmCode *acode)
RZ_API int rz_asm_set_pc(RzAsm *a, ut64 pc)
RZ_API RzAsmCode * rz_asm_massemble(RzAsm *a, const char *assembly)
static const AvrInstruction instructions[]
RZ_API RzBinObject * rz_bin_cur_object(RzBin *bin)
RZ_API RZ_BORROW RzBinSection * rz_bin_get_section_at(RzBinObject *o, ut64 off, int va)
Find the binary section at offset off.
int bits(struct state *s, int need)
RZ_API bool rz_core_debug_continue_until(RzCore *core, ut64 addr, ut64 to)
RZ_IPI void rz_core_debug_attach(RzCore *core, int pid)
RZ_API int rz_core_setup_debugger(RzCore *r, const char *debugbackend, bool attach)
RZ_API bool rz_core_write_block_op_at(RzCore *core, ut64 addr, RzCoreWriteOp op, ut8 *hex, int hexlen)
Write a full block of data according to the operation op and the hexvalue hex.
RZ_API bool rz_core_write_string_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given string s at the specified addr.
RZ_API bool rz_core_extend_at(RzCore *core, ut64 addr, ut64 size)
Extend the file at current offset by inserting size 0 bytes at addr.
RZ_API bool rz_core_write_string_wide_at(RzCore *core, ut64 addr, const char *s)
Write a given string s as a wide string at the specified addr.
RZ_API int rz_core_write_hexpair(RzCore *core, ut64 addr, const char *pairs)
RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size)
RZ_API bool rz_core_shift_block(RzCore *core, ut64 addr, ut64 b_size, st64 dist)
Shift a block of data from addr of size b_size left or right based on dist.
RZ_API RzCmdStatus rz_core_io_pcache_print(RzCore *core, RzIODesc *desc, RzCmdStateOutput *state)
RZ_API RzCmdStatus rz_core_io_cache_print(RzCore *core, RzCmdStateOutput *state)
RZ_API void rz_core_arch_bits_at(RzCore *core, ut64 addr, RZ_OUT RZ_NULLABLE int *bits, RZ_OUT RZ_BORROW RZ_NULLABLE const char **arch)
RZ_API RzCmdStatus rz_core_io_plugin_print(RzIOPlugin *plugin, RzCmdStateOutput *state)
Print an IO plugin according to state.
RZ_API void rz_core_seek_arch_bits(RzCore *core, ut64 addr)
RZ_API bool rz_core_write_block(RzCore *core, ut64 addr, ut8 *data, size_t len)
RZ_API bool rz_core_write_string_zero_at(RzCore *core, ut64 addr, const char *s)
Write a given string s, followed by the zero terminator, at the specified addr.
RZ_API int rz_core_write_assembly(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions)
Assembles instructions and writes the resulting data at the given offset.
RZ_API int rz_core_block_read(RzCore *core)
RZ_API bool rz_core_write_base64d_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given base64 string s at the specified addr, decoded.
RZ_API bool rz_core_write_value_inc_at(RzCore *core, ut64 addr, st64 value, int sz)
Write at addr the current value + value passed as argument.
RZ_API bool rz_core_write_length_string_at(RzCore *core, ut64 addr, const char *s)
Write at the specified addr the length of the string in one byte, followed by the given string s.
RZ_API bool rz_core_dump(RzCore *core, const char *file, ut64 addr, ut64 size, int append)
RZ_API int rz_core_is_valid_offset(RzCore *core, ut64 offset)
RZ_API bool rz_core_write_seq_at(RzCore *core, ut64 addr, ut64 from, ut64 to, ut64 step, int value_size)
Write a full block of data with a sequence.
RZ_API bool rz_core_write_base64_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given string s at the specified addr encoded as base64.
RZ_API bool rz_core_write_random_at(RzCore *core, ut64 addr, size_t len)
Write len random bytes at address addr.
RZ_API int rz_core_write_assembly_fill(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions)
Assemble instructions and write the resulting data inside the current instruction.
RZ_API RzCmdStatus rz_core_io_plugins_print(RzIO *io, RzCmdStateOutput *state)
Print the registered IO plugins according to state.
RZ_API bool rz_core_write_duplicate_at(RzCore *core, ut64 addr, ut64 from, int len)
Copy len bytes from from to addr.
RZ_API bool rz_core_write_value_at(RzCore *core, ut64 addr, ut64 value, int sz)
Write a given value at the specified address, using sz bytes.
RZ_API RZ_OWN ut8 * rz_core_transform_op(RzCore *core, ut64 addr, RzCoreWriteOp op, ut8 *hex, int hexlen, int *buflen)
Transform a block of data at addr according to the operation op and the hexvalue hex.
RZ_API void rz_cmd_state_output_set_columnsf(RzCmdStateOutput *state, const char *fmt,...)
Specify the columns of the command output.
RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state)
Mark the start of an array of elements in the output.
RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state)
Mark the end of an array of elements in the output.
RZ_IPI bool rz_core_seek_to_register(RzCore *core, const char *regname, bool is_silent)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API void rz_cons_break_pop(void)
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API bool rz_cons_is_breaked(void)
RZ_API void rz_core_reg_update_flags(RzCore *core)
Update or create flags for all registers where it makes sense.
static states step(struct re_guts *, sopno, sopno, states, int, states)
size_t map(int syms, int left, int len)
RZ_API bool rz_core_hack(RzCore *core, const char *op)
Write/Modify instructions at current offset based on op.
RZ_API int rz_analysis_hint_bits_at(RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr)
RZ_API RZ_NULLABLE RZ_BORROW const char * rz_analysis_hint_arch_at(RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API bool rz_debug_select(RzDebug *dbg, int pid, int tid)
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
static const char hex[16]
@ RZ_ANALYSIS_OP_MASK_BASIC
#define rz_warn_if_reached()
#define rz_return_val_if_fail(expr, val)
RZ_API size_t rz_base64_encode(char *bout, const ut8 *bin, size_t sz)
RZ_API int rz_base64_decode(ut8 *bout, const char *bin, int len)
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
@ RZ_CMD_STATUS_NONEXISTINGCMD
command does not exist
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
@ RZ_CORE_WRITE_OP_BYTESWAP8
Swap the endianess of 8-bytes values.
@ RZ_CORE_WRITE_OP_SHIFT_LEFT
Write the shift left of existing byte by argument value.
@ RZ_CORE_WRITE_OP_AND
Write the bitwise-and of existing byte and argument value.
@ RZ_CORE_WRITE_OP_SHIFT_RIGHT
Write the shift right of existing byte and argument value.
@ RZ_CORE_WRITE_OP_BYTESWAP2
Swap the endianess of 2-bytes values.
@ RZ_CORE_WRITE_OP_OR
Write the bitwise-or of existing byte and argument value.
@ RZ_CORE_WRITE_OP_ADD
Write the addition of existing byte and argument value.
@ RZ_CORE_WRITE_OP_MUL
Write the multiplication of existing byte and argument value.
@ RZ_CORE_WRITE_OP_DIV
Write the division of existing byte and argument value.
@ RZ_CORE_WRITE_OP_BYTESWAP4
Swap the endianess of 4-bytes values.
@ RZ_CORE_WRITE_OP_XOR
Write the bitwise-xor of existing byte and argument value.
@ RZ_CORE_WRITE_OP_SUB
Write the subtraction of existing byte and argument value.
static ut64 rz_read_ble64(const void *src, bool big_endian)
static ut8 rz_read_ble8(const void *src)
static void rz_write_be16(void *dest, ut16 val)
static void rz_write_ble8(void *dest, ut8 val)
static ut16 rz_read_le16(const void *src)
static void rz_write_be64(void *dest, ut64 val)
static void rz_write_ble(void *dst, ut64 val, bool big_endian, int size)
static ut32 rz_read_le32(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)
static void rz_write_ble32(void *dest, ut32 val, bool big_endian)
static void rz_write_ble64(void *dest, ut64 val, bool big_endian)
static void rz_write_ble16(void *dest, ut16 val, bool big_endian)
static ut64 rz_read_le64(const void *src)
static void rz_write_be32(void *dest, ut32 val)
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
RZ_API char * rz_hex_bin2strdup(const ut8 *in, int len)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API bool rz_io_extend_at(RzIO *io, ut64 addr, ut64 size)
Extend the RzIODesc at addr by inserting size 0 bytes.
RZ_API ut64 rz_io_size(RzIO *io)
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
RZ_API RzList * rz_io_desc_cache_list(RzIODesc *desc)
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
RZ_API int rz_io_desc_get_pid(RzIODesc *desc)
RZ_API bool rz_io_read_at_mapped(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API bool rz_io_is_valid_offset(RzIO *io, ut64 offset, int hasperm)
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
RZ_API bool rz_io_use_fd(RzIO *io, int fd)
RZ_API int rz_io_nread_at(RzIO *io, ut64 addr, ut8 *buf, int len)
static ut64 rz_itv_begin(RzInterval itv)
static ut64 rz_itv_size(RzInterval itv)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API void rz_mem_copyloop(ut8 *dest, const ut8 *orig, int dsize, int osize)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API int rz_num_rand(int max)
RZ_API void rz_num_irand(void)
RZ_API PJ * pj_kb(PJ *j, const char *k, bool v)
RZ_API PJ * pj_k(PJ *j, const char *k)
RZ_API PJ * pj_end(PJ *j)
RZ_API PJ * pj_s(PJ *j, const char *k)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
RZ_API RzList * rz_str_split_list(char *str, const char *c, int n)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API int rz_str_unescape(char *buf)
RZ_API char RZ_API void rz_sys_backtrace(void)
Print the backtrace at the point this function is called from.
RZ_API int rz_sys_truncate(const char *file, int sz)
RZ_API FILE * rz_sys_fopen(const char *path, const char *mode)
RZ_API void rz_table_add_rowf(RzTable *t, const char *fmt,...)
RZ_API void rz_table_set_columnsf(RzTable *t, const char *fmt,...)
Specify the types and names of the referenced table.
@ RZ_OUTPUT_MODE_STANDARD
#define rz_pvector_foreach(vec, it)
RZ_API bool rz_core_seek_delta(RzCore *core, st64 delta, bool save)
Seek relative to current offset and optionally save the current offset in seek history.
RZ_API bool rz_core_seek(RzCore *core, ut64 addr, bool rb)
Seek to addr.
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
Represent the output state of a command handler.
int(* write)(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]