本文整理汇总了C++中R_NEW0函数的典型用法代码示例。如果您正苦于以下问题:C++ R_NEW0函数的具体用法?C++ R_NEW0怎么用?C++ R_NEW0使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_NEW0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r_anal_state_new
R_API RAnalState * r_anal_state_new(ut64 start, ut8* buffer, ut64 len) {
RAnalState *state = R_NEW0 (RAnalState);
if (!state) {
return NULL;
}
state->start = start;
state->end = start + len;
state->buffer = buffer;
state->len = len;
state->current_op = NULL;
state->current_bb = NULL;
state->current_fcn = NULL;
state->ht = r_hashtable64_new();
state->ht->free = (RHashFree)r_anal_bb_free;
state->ht_sz = 512;
state->bbs = r_list_newf ((RListFree)r_anal_bb_free);
state->max_depth = 50;
state->current_depth = 0;
return state;
}
示例2: R_NEW0
R_API RThread *r_th_new(R_TH_FUNCTION(fun), void *user, int delay) {
RThread *th = R_NEW0 (RThread);
if (th) {
th->lock = r_th_lock_new (false);
th->running = false;
th->fun = fun;
th->user = user;
th->delay = delay;
th->breaked = false;
th->ready = false;
#if HAVE_PTHREAD
pthread_cond_init (&th->_cond, NULL);
pthread_mutex_init (&th->_mutex, NULL);
pthread_create (&th->tid, NULL, _r_th_launcher, th);
#elif __WINDOWS__ && !defined(__CYGWIN__)
th->tid = CreateThread (NULL, 0, _r_th_launcher, th, 0, 0);
#endif
}
return th;
}
示例3: r_list_new
static RList *sections(RBinFile *bf) {
RList /*<RBinSection>*/ *ret = r_list_new ();
if (!ret) {
return NULL;
}
RBinSection *text = R_NEW0 (RBinSection);
if (!text) {
r_list_free (ret);
return NULL;
}
strncpy (text->name, "text", R_BIN_SIZEOF_STRINGS);
text->size = bf->buf->length - N64_ROM_START;
text->vsize = text->size;
text->paddr = N64_ROM_START;
text->vaddr = baddr (bf);
text->perm = R_PERM_RX;
text->add = true;
r_list_append (ret, text);
return ret;
}
示例4: info
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
ines_hdr ihdr;
memset (&ihdr, 0, INES_HDR_SIZE);
int reat = r_buf_read_at (arch->buf, 0, (ut8*)&ihdr, INES_HDR_SIZE);
if (reat != INES_HDR_SIZE) {
eprintf ("Truncated Header\n");
return NULL;
}
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->file = strdup (arch->file);
ret->type = strdup ("ROM");
ret->machine = strdup ("Nintendo NES");
ret->os = strdup ("nes");
ret->arch = strdup ("6502");
ret->bits = 8;
ret->has_va = 1;
return ret;
}
示例5:
static RList *entries(RBinFile *bf) {
BootImageObj *bio = bf->o->bin_obj;
RBinAddr *ptr = NULL;
if (!bio) {
return NULL;
}
BootImage *bi = &bio->bi;
RList *ret;
if (!(ret = r_list_newf (free))) {
return NULL;
}
if (!(ptr = R_NEW0 (RBinAddr))) {
return ret;
}
ptr->paddr = bi->page_size;
ptr->vaddr = bi->kernel_addr;
r_list_append (ret, ptr);
return ret;
}
示例6: sections
static RList* sections(RBinFile *arch) {
RList *ret = NULL;
RBinSection *ptr = NULL;
if (!(ret = r_list_new ()))
return NULL;
ret->free = free;
// program headers is another section
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strcpy (ptr->name, "bootblk");
ptr->vsize = ptr->size = 0x10000;
//printf ("SIZE %d\n", ptr->size);
ptr->paddr = arch->buf->length - ptr->size;
ptr->vaddr = 0xf0000;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_WRITABLE |
R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP;
r_list_append (ret, ptr);
return ret;
}
示例7: strdup
static RBinInfo *info(RBinFile *arch) {
RBinInfo *ret;
if(!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->file = strdup (arch->file);
ret->bclass = strdup ("OMF");
ret->rclass = strdup ("omf");
// the "E" is here to made rva return the same value for 16 bit en 32 bits files
ret->type = strdup ("E OMF (Relocatable Object Module Format)");
ret->os = strdup ("any");
ret->machine = strdup ("i386");
ret->arch = strdup ("x86");
ret->big_endian = false;
ret->has_va = true;
ret->bits = r_bin_omf_get_bits (arch->o->bin_obj);
ret->dbg_info = 0;
ret->has_nx = false;
return ret;
}
示例8: R_NEW0
static RList *sections(RBinFile *arch) {
RList *ret = NULL;
RBinSection *s = R_NEW0 (RBinSection);
ut64 sz = r_buf_size (arch->buf);
if (!(ret = r_list_new ())) {
free (s);
return NULL;
}
strcpy (s->name, "ROM");
s->paddr = 0;
s->vaddr = 0x8000000;
s->size = sz;
s->vsize = 0x2000000;
s->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP;
s->add = true;
r_list_append (ret, s);
return ret;
}
示例9: R_NEW0
static RList *entries(RBinFile *bf) {
const r_bin_xbe_obj_t *obj;
RList *ret;
RBinAddr *ptr = R_NEW0 (RBinAddr);
if (!bf || !bf->buf || !bf->o->bin_obj || !ptr) {
free (ptr);
return NULL;
}
ret = r_list_new ();
if (!ret) {
free (ptr);
return NULL;
}
ret->free = free;
obj = bf->o->bin_obj;
ptr->vaddr = obj->header->ep ^ obj->ep_key;
ptr->paddr = ptr->vaddr - obj->header->base;
r_list_append (ret, ptr);
return ret;
}
示例10: info
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
bool big_endian = 0;
if ((ret = R_NEW0 (RBinInfo)) == NULL)
return NULL;
ret->file = strdup (arch->file);
ret->bclass = strdup ("dyldcache");
ret->rclass = strdup ("ios");
ret->os = strdup ("iOS");
ret->arch = strdup ("arm");
ret->machine = strdup (ret->arch);
ret->subsystem = strdup ("xnu");
ret->type = strdup ("LIBRARY CACHE");
ret->bits = dyld64? 64: 32;
ret->has_va = true;
ret->big_endian = big_endian;
ret->dbg_info = 0;
ret->dbg_info = 0;
return ret;
}
示例11: info
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
_3DSX_hdr _3dsxhdr;
memset (&_3dsxhdr, 0, _3DSX_HDR_SIZE);
int reat = r_buf_read_at (arch->buf, 0, (ut8*)&_3dsxhdr, _3DSX_HDR_SIZE);
if (reat != _3DSX_HDR_SIZE) {
eprintf ("Truncated Header\n");
return NULL;
}
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->file = strdup (arch->file);
ret->type = strdup ("Sound File Data");
ret->machine = strdup ("3DSX");
ret->os = strdup ("3DS");
ret->arch = strdup ("arm");
ret->bits = 32;
ret->has_va = 1;
return ret;
}
示例12: R_NEW0
/* Try to get a valid entrypoint using the methods outlined in
* http://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_mono/ld.html#SEC24 */
RBinAddr *r_coff_get_entry(struct r_bin_coff_obj *obj) {
RBinAddr *addr = R_NEW0 (RBinAddr);
int i;
if (!addr) return -1;
/* Simplest case, the header provides the entrypoint address */
if (obj->hdr.f_opthdr) {
addr->paddr = obj->opt_hdr.entry;
return addr;
}
/* No help from the header eh? Use the address of the symbols '_start'
* or 'main' if present */
if (obj->symbols)
for (i = 0; i < obj->hdr.f_nsyms; i++) {
if ((!strcmp (obj->symbols[i].n_name, "_start") ||
!strcmp (obj->symbols[i].n_name, "start")) &&
r_coff_rebase_sym (obj, addr, &obj->symbols[i]))
return addr;
}
if (obj->symbols)
for (i = 0; i < obj->hdr.f_nsyms; i++) {
if ((!strcmp (obj->symbols[i].n_name, "_main") ||
!strcmp (obj->symbols[i].n_name, "main")) &&
r_coff_rebase_sym (obj, addr, &obj->symbols[i]))
return addr;
}
/* Still clueless ? Let's just use the address of .text */
if (obj->scn_hdrs)
for (i = 0; i < obj->hdr.f_nscns; i++) {
if (!strcmp (obj->scn_hdrs[i].s_name, ".text")) {
addr->paddr = obj->scn_hdrs[i].s_scnptr;
return addr;
}
}
return addr;
}
示例13: R_NEW0
R_API R2Pipe *r2p_open(const char *cmd) {
R2Pipe *r2p = R_NEW0 (R2Pipe);
r2p->magic = R2P_MAGIC;
if (!cmd) {
r2p->child = -1;
return r2p_open_spawn (r2p, cmd);
}
#if __WINDOWS__ && !defined(__CYGWIN__)
w32_createPipe (r2p, cmd);
r2p->child = (int)(r2p->pipe);
#else
pipe (r2p->input);
pipe (r2p->output);
r2p->child = fork ();
if (r2p->child == -1) {
r2p_close (r2p);
return NULL;
}
env ("R2PIPE_IN", r2p->input[0]);
env ("R2PIPE_OUT", r2p->output[1]);
if (r2p->child) {
eprintf ("Child is %d\n", r2p->child);
char ch;
read (r2p->output[0], &ch, 1);
} else {
int rc = 0;
if (cmd && *cmd) {
close (0);
close (1);
dup2 (r2p->input[0], 0);
dup2 (r2p->output[1], 1);
rc = r_sandbox_system (cmd, 0);
}
r2p_close (r2p);
exit (rc);
return NULL;
}
#endif
return r2p;
}
示例14: R_NEW0
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
if (__plugin_open (io, file, 0)) {
char *pidpath;
RIODesc *ret;
RIOW32Dbg *dbg = R_NEW0 (RIOW32Dbg);
if (!dbg) {
return NULL;
}
dbg->pid = atoi (file + 9);
if (__open_proc (dbg, !strncmp (file, "attach://", 9)) == -1) {
free (dbg);
return NULL;
}
pidpath = r_sys_pid_to_path (dbg->pid);
ret = r_io_desc_new (io, &r_io_plugin_w32dbg,
file, rw | R_PERM_X, mode, dbg);
ret->name = pidpath;
return ret;
}
return NULL;
}
示例15: R_NEW0
RIOMMapFileObj *r_io_def_mmap_create_new_file(RIO *io, const char *filename, int mode, int flags) {
RIOMMapFileObj *mmo = NULL;
if (!io)
return NULL;
mmo = R_NEW0 (RIOMMapFileObj);
if (!mmo)
return NULL;
mmo->filename = strdup (filename);
mmo->fd = r_num_rand (0xFFFF); // XXX: Use r_io_fd api
mmo->mode = mode;
mmo->flags = flags;
mmo->io_backref = io;
if (!r_io_def_mmap_refresh_def_mmap_buf (mmo)) {
r_io_def_mmap_free (mmo);
mmo = NULL;
}
return mmo;
}