Rizin
unix-like reverse engineering framework and cli tools
libqnxr.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2016 madprogrammer
2 // SPDX-License-Identifier: GPL-2.0-only
3 
5 #ifndef LIBQNXR_H
6 #define LIBQNXR_H
7 
8 #include <stdint.h>
9 #ifdef _MSC_VER
10 typedef int pid_t;
11 #else
12 #include <unistd.h>
13 #endif
14 
15 #include "arch.h"
16 #include "rz_types_base.h"
17 #include "rz_socket.h"
18 #include "dsmsgs.h"
19 
20 #define MSG_OK 0
21 #define MSG_NOT_SUPPORTED -1
22 #define MSG_ERROR_1 -2
23 
24 #define X86_64 ARCH_X86_64
25 #define X86_32 ARCH_X86_32
26 #define ARM_32 ARCH_ARM_32
27 #define ARM_64 ARCH_ARM_64
28 
29 typedef struct
30 {
33 } ptid_t;
34 
39 typedef struct libqnxr_t {
40  char *read_buff;
41  char *send_buff;
46  char host[256];
47  int port;
48  int connected;
50  union {
53  } tran, recv;
57  int channelrd;
58  int channelwr;
64  int signal;
68 
69 typedef void(pidlist_cb_t)(void *ctx, pid_t pid, char *name);
70 
71 int qnxr_init(libqnxr_t *g);
72 int qnxr_set_architecture(libqnxr_t *g, ut8 architecture);
74 int qnxr_connect(libqnxr_t *g, const char *server, int port);
76 void qnxr_pidlist(libqnxr_t *g, void *ctx, pidlist_cb_t *cb);
77 int qnxr_select(libqnxr_t *g, pid_t pid, int tid);
78 ptid_t qnxr_run(libqnxr_t *g, const char *file, char **args, char **env);
81 int qnxr_stop(libqnxr_t *g);
82 
83 // Commands
84 int qnxr_continue(libqnxr_t *g, int thread_id);
85 int qnxr_step(libqnxr_t *g, int thread_id);
87 
88 int qnxr_write_reg(libqnxr_t *g, const char *name, char *value, int len);
89 int qnxr_write_register(libqnxr_t *g, int index, char *value, int len);
90 int qnxr_read_memory(libqnxr_t *g, ut64 address, ut8 *data, ut64 len);
91 int qnxr_write_memory(libqnxr_t *g, ut64 address, const ut8 *data, ut64 len);
92 
93 int qnxr_set_bp(libqnxr_t *g, ut64 address, const char *conditions);
94 int qnxr_set_hwbp(libqnxr_t *g, ut64 address, const char *conditions);
95 int qnxr_remove_bp(libqnxr_t *g, ut64 address);
96 int qnxr_remove_hwbp(libqnxr_t *g, ut64 address);
97 
98 // ptid
99 extern ptid_t null_ptid;
100 int ptid_equal(ptid_t ptid1, ptid_t ptid2);
101 
102 #endif
size_t len
Definition: 6502dis.c:15
static int value
Definition: cmd_api.c:93
uint32_t ut32
#define DS_DATA_MAX_SIZE
Definition: dsmsgs.h:102
struct @667 g
uint8_t ut8
Definition: lh5801.h:11
int qnxr_remove_hwbp(libqnxr_t *g, ut64 address)
Definition: core.c:611
int qnxr_set_bp(libqnxr_t *g, ut64 address, const char *conditions)
Definition: core.c:599
int qnxr_connect(libqnxr_t *g, const char *server, int port)
Definition: core.c:147
int qnxr_write_memory(libqnxr_t *g, ut64 address, const ut8 *data, ut64 len)
Definition: core.c:395
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
Definition: utils.c:309
int qnxr_read_registers(libqnxr_t *g)
Definition: core.c:323
int qnxr_select(libqnxr_t *g, pid_t pid, int tid)
Definition: core.c:445
int qnxr_remove_bp(libqnxr_t *g, ut64 address)
Definition: core.c:607
void() pidlist_cb_t(void *ctx, pid_t pid, char *name)
Definition: libqnxr.h:69
int qnxr_set_hwbp(libqnxr_t *g, ut64 address, const char *conditions)
Definition: core.c:603
int qnxr_continue(libqnxr_t *g, int thread_id)
Definition: core.c:470
int qnxr_cleanup(libqnxr_t *g)
Definition: core.c:138
int qnxr_disconnect(libqnxr_t *g)
Definition: core.c:206
ptid_t qnxr_attach(libqnxr_t *g, pid_t pid)
Definition: core.c:223
void qnxr_pidlist(libqnxr_t *g, void *ctx, pidlist_cb_t *cb)
Definition: core.c:417
ptid_t qnxr_wait(libqnxr_t *g, pid_t pid)
Definition: core.c:542
int qnxr_set_architecture(libqnxr_t *g, ut8 architecture)
Definition: core.c:121
int qnxr_read_memory(libqnxr_t *g, ut64 address, ut8 *data, ut64 len)
Definition: core.c:365
ptid_t qnxr_run(libqnxr_t *g, const char *file, char **args, char **env)
Definition: core.c:248
int qnxr_stop(libqnxr_t *g)
Definition: core.c:528
struct libqnxr_t libqnxr_t
int qnxr_init(libqnxr_t *g)
Definition: core.c:104
int qnxr_write_reg(libqnxr_t *g, const char *name, char *value, int len)
Definition: core.c:496
ptid_t null_ptid
Definition: core.c:18
int qnxr_write_register(libqnxr_t *g, int index, char *value, int len)
Definition: core.c:474
int qnxr_step(libqnxr_t *g, int thread_id)
Definition: core.c:466
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
Definition: sflib.h:64
int args
Definition: mipsasm.c:18
const char * name
Definition: op.c:541
static const char * conditions[]
#define st64
Definition: rz_types_base.h:10
#define st32
Definition: rz_types_base.h:12
int pid_t
Definition: sftypes.h:38
int ssize_t
Definition: sftypes.h:39
Definition: gzappend.c:170
ssize_t send_len
Definition: libqnxr.h:42
int port
Definition: libqnxr.h:47
ut32 stop_pc
Definition: libqnxr.h:63
DSMsg_union_t pkt
Definition: libqnxr.h:52
char host[256]
Definition: libqnxr.h:46
ut8 data[DS_DATA_MAX_SIZE]
Definition: libqnxr.h:51
char * read_buff
Definition: libqnxr.h:40
char * send_buff
Definition: libqnxr.h:41
int waiting_for_stop
Definition: libqnxr.h:66
union libqnxr_t::@603 tran
int channelwr
Definition: libqnxr.h:58
ut8 mid
Definition: libqnxr.h:49
int target_proto_major
Definition: libqnxr.h:60
ssize_t data_len
Definition: libqnxr.h:54
int channelrd
Definition: libqnxr.h:57
int stop_flags
Definition: libqnxr.h:61
ut8 architecture
Definition: libqnxr.h:55
ssize_t read_len
Definition: libqnxr.h:43
int connected
Definition: libqnxr.h:48
ssize_t read_ptr
Definition: libqnxr.h:44
int target_proto_minor
Definition: libqnxr.h:59
ut8 notify_type
Definition: libqnxr.h:62
registers_t * registers
Definition: libqnxr.h:56
RzSocket * sock
Definition: libqnxr.h:45
union libqnxr_t::@603 recv
ptid_t inferior_ptid
Definition: libqnxr.h:65
int signal
Definition: libqnxr.h:64
Definition: z80asm.h:102
Definition: libqnxr.h:30
st32 pid
Definition: libqnxr.h:31
st64 tid
Definition: libqnxr.h:32
static char ** env
Definition: sys.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const char * cb[]
Definition: z80_tab.h:176