本文整理汇总了C++中r_list_new函数的典型用法代码示例。如果您正苦于以下问题:C++ r_list_new函数的具体用法?C++ r_list_new怎么用?C++ r_list_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_list_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_r_list_values
bool test_r_list_values(void) {
RList* list = r_list_new ();
intptr_t test1 = 0x12345;
intptr_t test2 = 0x88888;
r_list_append (list, (void*)test1);
r_list_append (list, (void*)test2);
int top1 = (intptr_t)r_list_pop (list);
int top2 = (intptr_t)r_list_pop (list);
mu_assert_eq(top1, 0x88888, "first value not 0x88888");
mu_assert_eq(top2, 0x12345, "first value not 0x12345");
r_list_free (list);
mu_end;
}
示例2: entries
static RList* entries(RBinArch *arch) {
RList* ret = r_list_new ();;
RBinAddr *ptr = NULL;
if (!ret) return NULL;
ret->free = free;
if (!memcmp (arch->buf+0x30, "\x00\x00\x00\x00\x20\x73\x74\x64\x6f\x75\x74\x20\x21\x55\x0c\xcd", 16)) {
if ((ptr = R_NEW (RBinAddr))) {
ptr->rva = ptr->offset = 0x9a;
r_list_append (ret, ptr);
}
}
return ret;
}
示例3: sections
static RList* sections(RBinFile *arch) {
RBinSection *ptr = NULL;
RList *ret = NULL;
int rc;
if (!(ret = r_list_new ()))
return NULL;
ret->free = free;
rc = r_buf_fread_at (arch->buf, 0, (ut8*)&sb, "10i", 1);
if (!rc) return false;
// add text segment
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strncpy (ptr->name, "text", R_BIN_SIZEOF_STRINGS);
ptr->size = sb.psize;
ptr->vsize = sb.psize;
ptr->paddr = sb.paddr + 40;
ptr->vaddr = sb.vaddr;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
ptr->add = true;
ptr->has_strings = true;
r_list_append (ret, ptr);
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strncpy (ptr->name, "sign", R_BIN_SIZEOF_STRINGS);
ptr->size = sb.sign_sz;
ptr->vsize = sb.sign_sz;
ptr->paddr = sb.sign_va - sb.vaddr;
ptr->vaddr = sb.sign_va;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_MAP; // r--
ptr->has_strings = true;
ptr->add = true;
r_list_append (ret, ptr);
if (sb.cert_sz && sb.cert_va > sb.vaddr) {
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strncpy (ptr->name, "cert", R_BIN_SIZEOF_STRINGS);
ptr->size = sb.cert_sz;
ptr->vsize = sb.cert_sz;
ptr->paddr = sb.cert_va - sb.vaddr;
ptr->vaddr = sb.cert_va;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_MAP; // r--
ptr->has_strings = true;
ptr->add = true;
r_list_append (ret, ptr);
}
return ret;
}
示例4: r_reg_get_value
// XXX: Do this work correctly?
static RList *backtrace_x86_64_anal(RDebug *dbg, ut64 at) {
int i;
ut8 buf[8];
RDebugFrame *frame;
ut64 ptr, ebp2 = UT64_MAX;
ut64 _rip, _rbp;
RList *list;
RReg *reg = dbg->reg;
RIOBind *bio = &dbg->iob;
RAnalFunction *fcn;
_rip = r_reg_get_value (reg, r_reg_get (reg, "rip", R_REG_TYPE_GPR));
if (at == UT64_MAX) {
//_rsp = r_reg_get_value (reg, r_reg_get (reg, "rsp", R_REG_TYPE_GPR));
_rbp = r_reg_get_value (reg, r_reg_get (reg, "rbp", R_REG_TYPE_GPR));
} else {
_rbp = at;
}
list = r_list_new ();
list->free = free;
bio->read_at (bio->io, _rip, (ut8*)&buf, 8);
// TODO : frame->size by using esil to emulate first instructions
fcn = r_anal_get_fcn_in (dbg->anal, _rip, R_ANAL_FCN_TYPE_NULL);
if (fcn) {
frame = R_NEW0 (RDebugFrame);
frame->addr = _rip;
frame->size = 0;
r_list_append (list, frame);
}
for (i=1; i<dbg->btdepth; i++) {
// TODO: make those two reads in a shot
bio->read_at (bio->io, _rbp, (ut8*)&ebp2, 8);
if (ebp2 == UT64_MAX)
break;
bio->read_at (bio->io, _rbp+8, (ut8*)&ptr, 8);
if (!ptr || !_rbp)
break;
//fcn = r_anal_get_fcn_in (dbg->anal, ptr, R_ANAL_FCN_TYPE_NULL);
frame = R_NEW0 (RDebugFrame);
frame->addr = ptr;
frame->size = 0;
//frame->name = (fcn && fcn->name) ? strdup (fcn->name) : NULL;
r_list_append (list, frame);
_rbp = ebp2;
}
return list;
}
示例5: if
static RList *sections(RBinFile *bf) {
RList *ret = NULL;
RBinSection *sections[4] = {
NULL, NULL, NULL, NULL
};
int i, corrupt = false;
if (!(ret = r_list_new ())) {
return NULL;
}
/* FIRM has always 4 sections, normally the 4th section is not used */
for (i = 0; i < 4; i++) {
/* Check if section is used */
if (loaded_header.sections[i].size) {
sections[i] = R_NEW0 (RBinSection);
/* Firmware Type ('0'=ARM9/'1'=ARM11) */
if (loaded_header.sections[i].type == 0x0) {
strncpy (sections[i]->name, "arm9", 4);
} else if (loaded_header.sections[i].type == 0x1) {
strncpy (sections[i]->name, "arm11", 5);
} else {
corrupt = true;
break;
}
sections[i]->size = loaded_header.sections[i].size;
sections[i]->vsize = loaded_header.sections[i].size;
sections[i]->paddr = loaded_header.sections[i].offset;
sections[i]->vaddr = loaded_header.sections[i].address;
sections[i]->srwx = r_str_rwx ("mrwx");
sections[i]->add = true;
}
}
/* Append sections or free them if file is corrupt to avoid memory leaks */
for (i = 0; i < 4; i++) {
if (sections[i]) {
if (corrupt) {
free (sections[i]);
} else {
r_list_append (ret, sections[i]);
}
}
}
if (corrupt) {
r_list_free (ret);
return NULL;
}
return ret;
}
示例6: sections
static RList* sections(RBinFile *arch) {
int i;
RList *ret;
RBinSection *s;
DolHeader *dol;
if (!arch || !arch->o || !arch->o->bin_obj)
return NULL;
dol = arch->o->bin_obj;
if (!(ret = r_list_new ())) {
return NULL;
}
/* text sections */
for (i=0; i<N_TEXT; i++) {
if (!dol->text_paddr[i] || !dol->text_vaddr[i])
continue;
s = R_NEW0 (RBinSection);
snprintf (s->name, sizeof (s->name), "text_%d", i);
s->paddr = dol->text_paddr[i];
s->vaddr = dol->text_vaddr[i];
s->size = dol->text_size[i];
s->vsize = s->size;
s->srwx = r_str_rwx ("mr-x");
r_list_append (ret, s);
}
/* data sections */
for (i=0; i<N_DATA; i++) {
if (!dol->data_paddr[i] || !dol->data_vaddr[i])
continue;
s = R_NEW0 (RBinSection);
snprintf (s->name, sizeof (s->name), "data_%d", i);
s->paddr = dol->data_paddr[i];
s->vaddr = dol->data_vaddr[i];
s->size = dol->data_size[i];
s->vsize = s->size;
s->srwx = r_str_rwx ("mr--");
r_list_append (ret, s);
}
/* bss section */
s = R_NEW0 (RBinSection);
strcpy (s->name, "bss");
s->paddr = 0;
s->vaddr = dol->bss_addr;
s->size = dol->bss_size;
s->vsize = s->size;
s->srwx = r_str_rwx ("-rw-");
r_list_append (ret, s);
return ret;
}
示例7: r_list_new
// (in,out)[code,data]
R_API RList *r_anal_xrefs_get (RAnal *anal, ut64 addr) {
RList *list = r_list_new ();
list->free = NULL; // XXX
r_anal_xrefs_from (anal, list, "xref", "code", addr);
r_anal_xrefs_from (anal, list, "xref", "data", addr);
r_anal_xrefs_from (anal, list, "ref", "code", addr);
r_anal_xrefs_from (anal, list, "ref", "data", addr);
if (r_list_length (list)<1) {
r_list_free (list);
list = NULL;
}
return list;
}
示例8: lines
static RList* lines(RBinArch *arch) {
int i;
char *file = strdup (arch->file);
RList *list = r_list_new ();
RBinJavaObj *b = arch->bin_obj;
file = r_str_replace (file, ".class", ".java", 0);
for (i=0; i<b->lines.count; i++) {
RBinDwarfRow *row = R_NEW (RBinDwarfRow);
r_bin_dwarf_line_new (row, b->lines.addr[i], file, b->lines.line[i]);
r_list_append (list, row);
}
free (file);
return list;
}
示例9: r_io_vread
/* Idea: At first, get all sections in vrange, meanwhile record all unsectioned area and store it via RIORange in a list,
read all sections via mread, resolve maps for unsectioned areas and fill the gaps. last point must always prefere using io->desc*/
R_API int r_io_vread (RIO *io, ut64 vaddr, ut8 *buf, int len) {
int tmp_len = len;
ut8 *tmp_buf = buf;
ut64 vendaddr, maddr, tmp_vaddr = vaddr;
RIOMap *map;
RIOSection *section;
RIORange *range;
RList *sections, *ranges = NULL, *maps;
RListIter *iter, *ator;
if (!io->desc) {
eprintf ("r_io_vread: desc is NULL, WTF!\n");
return R_ERROR;
}
if (len < 0) {
eprintf ("r_io_vread: wrong usage; len is smaller than 0. len: %i\n", len);
return R_FAIL;
}
sections = r_io_section_get_in_vaddr_range (io, vaddr, vaddr+len);
if (!r_list_empty (sections)) { //check if there is any section
ranges = r_list_new();
ranges->free = free;
r_list_foreach (sections, iter, section) {
if (section->vaddr==0)
continue;
if (section->vaddr > tmp_vaddr) {
range = r_io_range_new(); //create a new range
range->from = tmp_vaddr; //record unsectioned area
range->to = section->vaddr;
r_list_append (ranges, range); //store the range
tmp_vaddr = section->vaddr; //prepare for resolving the maddr
tmp_len -= (tmp_vaddr - vaddr);
tmp_buf += (tmp_vaddr - vaddr); //adjust buffer
}
vendaddr = tmp_vaddr + tmp_len; //calculate the virtual end address
if (vendaddr > (section->vaddr + section->vsize)) //check if the virual end address is in the section too
vendaddr = section->vaddr + section->vsize; //if not, size it down
maddr = tmp_vaddr - section->vaddr + section->offset; //calculate the map address (address inside the map)
if (maddr > ( section->offset + section->size)) { //check if the maddr is inside the physical section, if not, skip some things
} else {
if ((vendaddr - section->vaddr + section->offset) > (section->offset + section->size)) { //check if the virtual part of the section fits into the physical part
r_io_mread (io, section->fd, maddr, tmp_buf, (section->offset + section->size) - maddr);//if not, read as far as possible
} else {
r_io_mread (io, section->fd, maddr, tmp_buf, vendaddr - tmp_vaddr); //read from the sections fd
}
}
tmp_buf += (vendaddr - tmp_vaddr); //adjust buffer
tmp_len -= (vendaddr - tmp_vaddr); //adjust length
tmp_vaddr = vendaddr; //adjust address
}
}
示例10: entries
static RList* entries(RBinFile *arch) {
RList* ret;
RBinAddr *ptr = NULL;
if (!(ret = r_list_new ()))
return NULL;
ret->free = free;
if ((ptr = R_NEW0 (RBinAddr))) {
ptr->paddr = 40 + sb.code_pa;
ptr->vaddr = 40 + sb.code_pa + sb.vaddr;
r_list_append (ret, ptr);
}
return ret;
}
示例11: r_list_new
static RList *sections(RBinFile *arch) {
RList *shared = r_list_new ();
if (!shared) {
return NULL;
}
RList *cobjs = r_list_new ();
if (!cobjs) {
return NULL;
}
interned_table = r_list_new ();
if (!interned_table) {
return NULL;
}
r_list_append (shared, cobjs);
r_list_append (shared, interned_table);
arch->o->bin_obj = shared;
RList *sections = r_list_new ();
if (!sections) {
return NULL;
}
pyc_get_sections (sections, cobjs, arch->buf, version.magic);
return sections;
}
示例12: entries
static RList* entries(RBinFile *bf) {
RList *ret;
RBinAddr *ptr = NULL;
if (!(ret = r_list_new ())) {
return NULL;
}
if (!(ptr = R_NEW0 (RBinAddr))) {
return ret;
}
ptr->paddr = RAM_START_ADDRESS;
ptr->vaddr = 0;
r_list_append (ret, ptr);
return ret;
}
示例13: entries
static RList* entries(RBinFile *arch) {
RList* ret;
RBinAddr *ptr = NULL;
if (!(ret = r_list_new ()))
return NULL;
ret->free = free;
if ((ptr = R_NEW (RBinAddr))) {
ptr->paddr = 8*4;
ptr->vaddr = 8*4;// + baddr (arch);
r_list_append (ret, ptr);
}
return ret;
}
示例14: init_pdb_parser
bool init_pdb_parser(R_PDB *pdb, const char *filename) {
char *signature = NULL;
int bytes_read = 0;
if (!pdb) {
eprintf ("struct R_PDB is not correct\n");
goto error;
}
if (!pdb->cb_printf) {
pdb->cb_printf = (PrintfCallback)printf;
}
pdb->buf = r_buf_new_slurp (filename);
// pdb->fp = r_sandbox_fopen (filename, "rb");
// if (!pdb->fp) {
// eprintf ("file %s can not be open\n", filename);
// goto error;
// }
signature = (char *)calloc (1, PDB7_SIGNATURE_LEN);
if (!signature) {
eprintf ("memory allocation error\n");
goto error;
}
bytes_read = r_buf_read(pdb->buf, (ut8 *)signature, PDB7_SIGNATURE_LEN);
if (bytes_read != PDB7_SIGNATURE_LEN) {
eprintf ("file reading error\n");
goto error;
}
r_buf_seek (pdb->buf, 0, 0);
if (!memcmp (signature, PDB7_SIGNATURE, PDB7_SIGNATURE_LEN)) {
pdb->pdb_parse = pdb7_parse;
} else {
goto error;
}
R_FREE (signature);
pdb->pdb_streams = r_list_new ();
pdb->stream_map = 0;
pdb->finish_pdb_parse = finish_pdb_parse;
pdb->print_types = print_types;
pdb->print_gvars = print_gvars;
// printf("init_pdb_parser() finish with success\n");
return true;
error:
R_FREE (signature);
return false;
}
示例15: baddr
static RList *entries(RBinFile *bf) {
RList *ret;
RBinAddr *ptr = NULL;
if (!(ret = r_list_new ())) {
return NULL;
}
ret->free = free;
if ((ptr = R_NEW0 (RBinAddr))) {
ptr->paddr = 0x80;
ptr->vaddr = ptr->paddr + baddr (bf);
r_list_append (ret, ptr);
}
return ret;
}