本文整理汇总了C++中r_io_desc_new函数的典型用法代码示例。如果您正苦于以下问题:C++ r_io_desc_new函数的具体用法?C++ r_io_desc_new怎么用?C++ r_io_desc_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_io_desc_new函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: R_NEW0
static RIODesc *r2k__open(RIO *io, const char *pathname, int rw, int mode) {
if (!strncmp (pathname, "r2k://", 6)) {
rw |= R_IO_WRITE;
rw |= R_IO_EXEC;
#if __WINDOWS__
RIOW32 *w32 = R_NEW0 (RIOW32);
if (Init (&pathname[6]) == FALSE) {
eprintf ("r2k__open: Error cant init driver: %s\n", &pathname[6]);
free (w32);
return NULL;
}
//return r_io_desc_new (&r_io_plugin_r2k, -1, pathname, rw, mode, w32);
return r_io_desc_new (io, &r_io_plugin_r2k, pathname, rw, mode, w32);
#elif defined (__linux__) && !defined (__GNU__)
int fd = open ("/dev/r2k", O_RDONLY);
if (fd == -1) {
io->cb_printf ("r2k__open: Error in opening /dev/r2k.");
return NULL;
}
r2k_struct.beid = 0;
r2k_struct.pid = 0;
r2k_struct.wp = 1;
return r_io_desc_new (io, &r_io_plugin_r2k, pathname, rw, mode, (void *)(size_t)fd);
#else
io->cb_printf ("Not supported on this platform\n");
#endif
}
return NULL;
}
开发者ID:agatti,项目名称:radare2,代码行数:30,代码来源:io_r2k.c
示例2: getpid
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
int pid = getpid ();
self_sections_count = 0;
#if __APPLE__
mach_port_t task;
kern_return_t rc;
rc = task_for_pid (mach_task_self(),pid, &task);
if (rc) {
eprintf ("task_for_pid failed\n");
return NULL;
}
macosx_debug_regions (task, (void*)(size_t)1, 1000);
io->va = R_TRUE; // nop
return r_io_desc_new (&r_io_plugin_self,
pid, file, rw, mode, NULL);
#elif __linux__
char *pos_c;
char null[64];
char path[1024], line[1024];
char region[100], region2[100], perms[5];
snprintf (path, sizeof (path)-1, "/proc/%d/maps", pid);
FILE *fd = fopen (file, "r");
if (!fd)
return NULL;
while (!feof (fd)) {
line[0]='\0';
fgets (line, sizeof (line)-1, fd);
if (line[0]=='\0')
break;
path[0]='\0';
sscanf (line, "%s %s %s %s %s %s",
®ion[2], perms, null, null, null, path);
pos_c = strchr (®ion[2], '-');
if (pos_c) strncpy (path, pos_c, sizeof (path)-1);
else path[0] = 0;
int i, perm = 0;
for (i = 0; perms[i] && i < 4; i++)
switch (perms[i]) {
case 'r': perm |= R_IO_READ; break;
case 'w': perm |= R_IO_WRITE; break;
case 'x': perm |= R_IO_EXEC; break;
}
self_sections[self_sections_count].from = r_num_get (NULL, region);
self_sections[self_sections_count].to = r_num_get (NULL, region2);
self_sections[self_sections_count].perm = perm;
self_sections_count++;
r_num_get (NULL, region2);
if (!pos_c)
continue;
}
return r_io_desc_new (&r_io_plugin_self,
pid, file, rw, mode, NULL);
#else
#warning not yet implemented for this platform
#endif
return NULL;
}
开发者ID:johansenj,项目名称:radare2,代码行数:58,代码来源:io_self.c
示例3: r_io_def_mmap_create_new_file
static RIODesc *r_io_def_mmap_open(RIO *io, const char *file, int flags, int mode) {
RIOMMapFileObj *mmo = r_io_def_mmap_create_new_file (io, file, mode, flags);
if (!mmo) {
return NULL;
}
return r_io_desc_new (io, &r_io_plugin_default, mmo->filename, flags, mode, mmo);
}
开发者ID:agatti,项目名称:radare2,代码行数:7,代码来源:io_default.c
示例4: R_NEW0
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
if (__plugin_open (io, pathname,0)) {
RIOSparse *mal = R_NEW0 (RIOSparse);
int size = (int)r_num_math (NULL, pathname + 9);
mal->buf = r_buf_new_sparse (io->Oxff);
if (!mal->buf) {
free (mal);
return NULL;
}
if (size > 0) {
ut8 *data = malloc (size);
if (!data) {
eprintf ("Cannot allocate (%s) %d byte(s)\n",
pathname+9, size);
mal->offset = 0;
} else {
memset (data, 0x00, size);
r_buf_write_at (mal->buf, 0, data, size);
free (data);
}
}
if (mal->buf) {
return r_io_desc_new (io, &r_io_plugin_sparse,
pathname, rw, mode, mal);
}
r_buf_free (mal->buf);
free (mal);
}
return NULL;
}
开发者ID:aronsky,项目名称:radare2,代码行数:30,代码来源:io_sparse.c
示例5: atoi
static RIODesc *__open(struct r_io_t *io, const char *file, int rw, int mode) {
RIOMach *riom;
int pid;
task_t task;
if (!__plugin_open (io, file))
return NULL;
pid = atoi (file+(file[0]=='a'?9:7));
if (pid<1)
return NULL;
task = debug_attach (pid);
if ((int)task == -1) {
switch (errno) {
case EPERM:
eprintf ("Operation not permitted\n");
break;
case EINVAL:
perror ("ptrace: Cannot attach");
eprintf ("ERRNO: %d (EINVAL)\n", errno);
break;
default:
eprintf ("unknown error in debug_attach\n");
break;
}
return NULL;
}
riom = R_NEW (RIOMach);
riom->pid = pid;
riom->task = task;
return r_io_desc_new (&r_io_plugin_mach, riom->pid, file, 1, mode, riom);
}
开发者ID:DJHartley,项目名称:radare2,代码行数:30,代码来源:io_mach.c
示例6: strncpy
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
char host[128], *port, *p;
if (!__plugin_open (io, file, 0))
return NULL;
RIOGdb *riog;
strncpy (host, file+6, sizeof (host)-1);
port = strchr (host , ':');
if (!port) {
eprintf ("Port not specified. Please use gdb://[host]:[port]\n");
return NULL;
}
*port = '\0';
port++;
p = strchr (port, '/');
if (p) *p=0;
if (r_sandbox_enable (0)) {
eprintf ("sandbox: Cannot use network\n");
return NULL;
}
riog = R_NEW (RIOGdb);
gdbr_init(&riog->desc);
int i_port = atoi(port);
if (gdbr_connect(&riog->desc, host, i_port) == 0) {
desc = &riog->desc;
return r_io_desc_new (&r_io_plugin_gdb, riog->desc.fd, file, rw, mode, riog);
}
eprintf ("gdb.io.open: Cannot connect to host.\n");
free (riog);
return NULL;
}
开发者ID:KarjamP,项目名称:radare2,代码行数:31,代码来源:io_gdb.c
示例7: r_socket_http_get
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
char *out;
int rlen, code;
if (__plugin_open (io, pathname, 0)) {
out = r_socket_http_get (pathname, &code, &rlen);
if (out && rlen>0) {
RIOMalloc *mal = R_NEW0 (RIOMalloc);
if (!mal) return NULL;
mal->size = rlen;
mal->buf = malloc (mal->size+1);
if (!mal->buf) {
free (mal);
return NULL;
}
if (mal->buf != NULL) {
mal->fd = getmalfd (mal);
memcpy (mal->buf, out, mal->size);
free (out);
return r_io_desc_new (io, &r_io_plugin_http,
pathname, rw, mode, mal);
}
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size);
free (mal);
}
free (out);
}
return NULL;
}
开发者ID:PankajKataria,项目名称:radare2,代码行数:28,代码来源:io_http.c
示例8: R_NEW0
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
char *out;
int rlen;
if (__plugin_open (io, pathname, 0)) {
RIOBind iob;
RIOBfdbg *mal = R_NEW0 (RIOBfdbg);
r_io_bind (io, &iob);
mal->fd = getmalfd (mal);
mal->bfvm = bfvm_new (&iob);
out = r_file_slurp (pathname+8, &rlen);
if (!out || rlen < 1) {
free (mal);
free (out);
return NULL;
}
mal->size = rlen;
mal->buf = malloc (mal->size+1);
if (mal->buf != NULL) {
memcpy (mal->buf, out, rlen);
free (out);
return r_io_desc_new (&r_io_plugin_bfdbg,
mal->fd, pathname, rw, mode, mal);
}
eprintf ("Cannot allocate (%s) %d bytes\n",
pathname+9, mal->size);
free (mal);
free (out);
}
return NULL;
}
开发者ID:8500616886,项目名称:radare2,代码行数:30,代码来源:io_bfdbg.c
示例9: atoi
static RIODesc *__open(struct r_io_t *io, const char *file, int rw, int mode) {
int ret = -1;
if (__plugin_open (io, file)) {
int pid = atoi (file+9);
ret = ptrace (PTRACE_ATTACH, pid, 0, 0);
if (file[0]=='p') //ptrace
ret = 0;
else
if (ret == -1) {
#ifdef __ANDROID__
eprintf ("ptrace_attach: Operation not permitted\n");
#else
switch (errno) {
case EPERM:
ret = pid;
eprintf ("ptrace_attach: Operation not permitted\n");
break;
case EINVAL:
perror ("ptrace: Cannot attach");
eprintf ("ERRNO: %d (EINVAL)\n", errno);
break;
}
#endif
} else
if (__waitpid (pid))
ret = pid;
else eprintf ("Error in waitpid\n");
if (ret != -1) {
RIOPtrace *riop = R_NEW (RIOPtrace);
riop->pid = riop->tid = pid;
return r_io_desc_new (&r_io_plugin_ptrace, -1, file, R_TRUE, 0, riop);
}
}
return NULL;
}
开发者ID:pixilla,项目名称:radare2,代码行数:35,代码来源:io_ptrace.c
示例10: eprintf
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
void *io_ctx;
WindCtx *ctx;
if (!__plugin_open (io, file, 0))
return NULL;
if (!iob_select ("pipe")) {
eprintf("Could not initialize the IO backend\n");
return NULL;
}
io_ctx = iob_open (file + 9);
if (!io_ctx) {
eprintf ("Could not open the pipe\n");
return NULL;
}
ctx = wind_ctx_new (io_ctx);
if (!ctx)
return NULL;
return r_io_desc_new (&r_io_plugin_windbg, -1, file, R_TRUE, mode, ctx);
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:25,代码来源:io_windbg.c
示例11: R_NEW
static RIODesc *__open(struct r_io_t *io, const char *pathname, int rw, int mode) {
if (__plugin_open (io, pathname)) {
RIOMalloc *mal = R_NEW (RIOMalloc);
mal->fd = -1; /* causes r_io_desc_new() to set the correct fd */
if (!memcmp (pathname, "hex://", 6)) {
mal->size = strlen (pathname);
mal->buf = malloc (mal->size);
memset (mal->buf, 0, mal->size);
mal->size = r_hex_str2bin (pathname+6, mal->buf);
} else {
mal->size = r_num_math (NULL, pathname+9);
if ((mal->size)>0) {
mal->buf = malloc (mal->size);
memset (mal->buf, '\0', mal->size);
} else {
eprintf ("Cannot allocate (%s) 0 bytes\n", pathname+9);
return NULL;
}
}
if (mal->buf != NULL)
return r_io_desc_new (&r_io_plugin_malloc, mal->fd, pathname, rw, mode, mal);
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size);
free (mal);
}
return NULL;
}
开发者ID:Missuniverse110,项目名称:radare2,代码行数:26,代码来源:io_malloc.c
示例12: strncpy
static RIODesc *haret__open(struct r_io_t *io, const char *pathname, int rw, int mode) {
char *port, *ptr, buf[1024];
RSocket *s;
strncpy (buf, pathname, sizeof (buf)-1);
if (haret__plugin_open (io, pathname)) {
ptr = buf + 8;
if (!(port = strchr (ptr, ':'))) {
eprintf ("haret: wrong url\n");
return NULL;
}
if (!r_sandbox_enable (0)) {
eprintf ("sandbox: cannot use network\n");
return NULL;
}
*port++ = 0;
if ((s = r_socket_new (R_FALSE)) == NULL) {
eprintf ("Cannot create new socket\n");
return NULL;
}
if (!r_socket_connect_tcp (s, ptr, port, 30)) {
eprintf ("Cannot connect to '%s' (%s)\n", ptr, port);
return NULL;
} else eprintf ("Connected to: %s at port %s\n", ptr, port);
haret_wait_until_prompt (s);
return r_io_desc_new (&r_io_plugin_haret, s->fd, pathname, rw, mode, (void*)s);
}
return NULL;
}
开发者ID:DJHartley,项目名称:radare2,代码行数:29,代码来源:io_haret.c
示例13: R_NEW0
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
char *out;
int rlen, code;
if (__plugin_open (io, pathname, 0)) {
RIOR2Web *mal = R_NEW0 (RIOR2Web);
if (!mal) return NULL;
char *url = r_str_newf ("http://%s/?V", pathname+8);
//eprintf ("URL:(%s)\n", url);
out = r_socket_http_get (url, &code, &rlen);
//eprintf ("RES %d %d\n", code, rlen);
//eprintf ("OUT(%s)\n", out);
if (out && rlen>0) {
mal->fd = getmalfd (mal);
mal->url = r_str_newf ("http://%s", pathname+8);
free (out);
free (url);
return r_io_desc_new (&r_io_plugin_r2web,
mal->fd, pathname, rw, mode, mal);
}
free (url);
free (mal);
free (out);
}
return NULL;
}
开发者ID:Darredevil,项目名称:radare2,代码行数:25,代码来源:io_r2web.c
示例14: r2p_open
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
R2Pipe *r2p = NULL;
if (__check (io, pathname, 0)) {
r2p = r2p_open (pathname + 9);
}
return r2p? r_io_desc_new (io, &r_io_plugin_r2pipe,
pathname, rw, mode, r2p): NULL;
}
开发者ID:montekki,项目名称:radare2,代码行数:8,代码来源:io_r2pipe.c
示例15: strdup
// Below this line are the r_io_zip plugin APIs
static RList *r_io_zip_open_many(RIO *io, const char *file, int rw, int mode) {
RList *list_fds = NULL;
RListIter *iter;
RList *filenames = NULL;
RIODesc *res = NULL;
RIOZipFileObj *zfo = NULL;
char *filename_in_zipfile, *zip_filename = NULL, *zip_uri;
if (!r_io_zip_plugin_open (io, file, true)) {
return NULL;
}
zip_uri = strdup (file);
if (!zip_uri) {
return NULL;
}
// 1) Tokenize to the '//' and find the base file directory ('/')
zip_filename = strstr(zip_uri, "//");
if (zip_filename && zip_filename[2]) {
if (zip_filename[0] && zip_filename[0] == '/' &&
zip_filename[1] && zip_filename[1] == '/' ) {
*zip_filename++ = 0;
}
*zip_filename++ = 0;
} else {
free (zip_uri);
return NULL;
}
filenames = r_io_zip_get_files(zip_filename, 0, mode, rw );
if (!filenames) {
free (zip_uri);
return NULL;
}
list_fds = r_list_new ();
r_list_foreach (filenames, iter, filename_in_zipfile) {
size_t v = strlen (filename_in_zipfile);
if (filename_in_zipfile[v - 1] == '/') {
continue;
}
zfo = r_io_zip_alloc_zipfileobj (zip_filename,
filename_in_zipfile, ZIP_CREATE, mode, rw);
if (zfo && zfo->entry == -1) {
eprintf ("Warning: File did not exist, creating a new one.\n");
}
if (zfo) {
zfo->io_backref = io;
res = r_io_desc_new (io, &r_io_plugin_zip,
zfo->name, rw, mode, zfo);
}
r_list_append (list_fds, res);
}
开发者ID:csarn,项目名称:radare2,代码行数:59,代码来源:io_zip.c
示例16: r_io_def_mmap_create_new_file
static RIODesc *r_io_def_mmap_open(RIO *io, const char *file, int flags, int mode) {
const char* name = NULL;
RIOMMapFileObj *mmo;
name = file;
mmo = r_io_def_mmap_create_new_file (io, name, mode, flags);
if (!mmo) return NULL;
return r_io_desc_new (&r_io_plugin_default, mmo->fd,
mmo->filename, flags, mode, mmo);
}
开发者ID:kuduka,项目名称:radare2,代码行数:11,代码来源:io_default.c
示例17: r_io_mmap_create_new_file
static RIODesc *r_io_mmap_open(RIO *io, const char *file, int flags, int mode) {
const char* name = NULL;
RIOMMapFileObj *mmo;
name = !strncmp (file, "mmap://", 7) ? file+7 : file;
mmo = r_io_mmap_create_new_file (io, name, mode, flags);
if (!mmo) return NULL;
return r_io_desc_new (&r_io_plugin_mmap, mmo->fd,
mmo->filename, flags, mode, mmo);
}
开发者ID:8500616886,项目名称:radare2,代码行数:11,代码来源:io_mmap.c
示例18: getpid
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
int ret, pid = getpid ();
if (r_sandbox_enable (0))
return NULL;
io->va = R_TRUE; // nop
ret = update_self_regions (pid);
if (ret) {
return r_io_desc_new (&r_io_plugin_self,
pid, file, rw, mode, NULL);
}
return NULL;
}
开发者ID:AnwarMohamed,项目名称:radare2,代码行数:12,代码来源:io_self.c
示例19: __open
static RIODesc* __open(RIO* io, const char* pathname, int rw, int mode) {
RIONull* null;
if (__plugin_open (io, pathname,0)) {
if (!strncmp (pathname, "null://", 7) && strlen (pathname + 7)) {
null = R_NEW0 (RIONull);
null->size = r_num_math (NULL, pathname + 7) + 1; //???
null->offset = 0LL;
return r_io_desc_new (io, &r_io_plugin_null, pathname, rw, mode, null);
}
}
return NULL;
}
开发者ID:aronsky,项目名称:radare2,代码行数:12,代码来源:io_null.c
示例20: pid_to_task
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
RIODesc *ret = NULL;
RIOMach *riom;
const char *pidfile;
char *pidpath, *endptr;
int pid;
task_t task;
if (!__plugin_open (io, file, 0)) {
return NULL;
}
pidfile = file + (file[0] == 'a' ? 9 : 7);
pid = (int)strtol (pidfile, &endptr, 10);
if (endptr == pidfile || pid < 0) {
return NULL;
}
task = pid_to_task (pid);
if (task == -1) {
return NULL;
}
if (!task) {
if (pid > 0 && io->referer && !strncmp (io->referer, "dbg://", 6)) {
eprintf ("Child killed\n");
kill (pid, 9);
}
switch (errno) {
case EPERM:
eprintf ("Operation not permitted\n");
break;
case EINVAL:
perror ("ptrace: Cannot attach");
eprintf ("Possibly unsigned r2. Please see doc/osx.md\n");
eprintf ("ERRNO: %d (EINVAL)\n", errno);
break;
default:
eprintf ("unknown error in debug_attach\n");
break;
}
return NULL;
}
riom = R_NEW0 (RIOMach);
riom->pid = pid;
riom->task = task;
// sleep 1s to get proper path (program name instead of ls) (racy)
pidpath = pid
? r_sys_pid_to_path (pid)
: strdup ("kernel");
ret = r_io_desc_new (&r_io_plugin_mach, riom->pid,
pidpath, rw | R_IO_EXEC, mode, riom);
free (pidpath);
return ret;
}
开发者ID:ghostbar,项目名称:radare2.deb,代码行数:51,代码来源:io_mach.c
注:本文中的r_io_desc_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论