12 #include <sys/ptrace.h>
13 #include <sys/types.h>
22 #define RzIOPROCPID_PID(x) (((RzIOProcpid *)(x)->data)->pid)
23 #define RzIOPROCPID_FD(x) (((RzIOProcpid *)(x)->data)->fd)
25 static int __waitpid(
int pid) {
27 return (waitpid(
pid, &st, 0) != -1);
30 static int debug_os_read_at(
int fdn,
void *
buf,
int sz,
ut64 addr) {
39 return debug_os_read_at(RzIOPROCPID_FD(
fd),
buf,
len, io->
off);
50 return procpid_write_at(RzIOPROCPID_FD(
fd),
buf,
len, io->
off);
54 return (!strncmp(
file,
"procpid://", 10));
67 eprintf(
"Operation not permitted\n");
70 perror(
"ptrace: Cannot attach");
71 eprintf(
"ERRNO: %d (EINVAL)\n", errno);
74 }
else if (!__waitpid(
pid)) {
78 snprintf(procpidpath,
sizeof(procpidpath),
"/proc/%d/mem",
pid);
81 RzIOProcpid *riop =
RZ_NEW0(RzIOProcpid);
93 eprintf(
"Cannot open /proc/%d/mem of already attached process\n",
pid);
110 RzIOProcpid *iop = (RzIOProcpid *)
fd->data;
111 if (!strncmp(
cmd,
"pid", 3)) {
125 .desc =
"Open /proc/[pid]/mem io",
127 .uris =
"procpid://",
143 #ifndef RZ_PLUGIN_INCORE
static static fork const void static count close
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 cmd
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 lseek
static int __read(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
static bool __plugin_open(RzIO *io, const char *pathname, bool many)
static RzIODesc * __open(RzIO *io, const char *pathname, int rw, int mode)
static int __write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
static ut64 __lseek(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
static int __close(RzIODesc *fd)
static char * __system(RzIO *io, RzIODesc *fd, const char *cmd)
RzIOPlugin rz_io_plugin_procpid
RZ_API RzLibStruct rizin_plugin
return memset(p, 0, total)
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
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid ptrace
RZ_API RzIODesc * rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
RZ_API int rz_sys_open(const char *path, int perm, int mode)
RZ_API char * rz_sys_pid_to_path(int pid)
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)