本文整理汇总了C++中r_buf_read_at函数的典型用法代码示例。如果您正苦于以下问题:C++ r_buf_read_at函数的具体用法?C++ r_buf_read_at怎么用?C++ r_buf_read_at使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_buf_read_at函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sections
static RList* sections(RBinFile *arch) {
xbe_section *sect;
r_bin_xbe_obj_t *obj;
RList *ret;
int i;
if (!arch || !arch->o)
return NULL;
obj = arch->o->bin_obj;
if (obj->header->sections < 1)
return NULL;
ret = r_list_new ();
if (!ret)
return NULL;
if (!arch->buf) {
free (ret);
return NULL;
}
ret->free = free;
sect = calloc (obj->header->sections, sizeof (xbe_section));
r_buf_read_at (arch->buf, obj->header->sechdr_addr - obj->header->base,
(ut8 *)sect, sizeof (xbe_section)*obj->header->sections);
for (i = 0; i < obj->header->sections; i++) {
RBinSection *item = R_NEW0(RBinSection);
char tmp[0x100];
r_buf_read_at (arch->buf, sect[i].name_addr - obj->header->base, (ut8 *)tmp, sizeof(tmp));
snprintf(item->name, R_BIN_SIZEOF_STRINGS, "%s.%i", tmp, i);
item->paddr = sect[i].offset;
item->vaddr = sect[i].vaddr;
item->size = sect[i].size;
item->vsize = sect[i].vsize;
item->srwx |= 4;
if (sect[i].flags & SECT_FLAG_X)
item->srwx |= 1;
if (sect[i].flags & SECT_FLAG_W)
item->srwx |= 2;
r_list_append (ret, item);
}
free (sect);
return ret;
}
开发者ID:DePierre,项目名称:radare2,代码行数:52,代码来源:bin_xbe.c
示例2: libs
static RList* libs(RBinFile *arch) {
r_bin_xbe_obj_t *obj;
int i, off, libs, r;
xbe_lib lib;
RList *ret;
char *s;
if (!arch || !arch->o)
return NULL;
obj = arch->o->bin_obj;
ret = r_list_new ();
if (!ret) return NULL;
ret->free = free;
if ( obj->header->kernel_lib_addr < obj->header->base) {
off = 0;
} else {
off = obj->header->kernel_lib_addr - obj->header->base;
}
r = r_buf_read_at (arch->buf, off, (ut8 *)&lib, sizeof(xbe_lib));
if (r == 0 || r == -1) return NULL;
s = r_str_newf ("%s %i.%i.%i", lib.name, lib.major, lib.minor, lib.build);
if (s) r_list_append (ret, s);
if (obj->header->xapi_lib_addr < obj->header->base) {
off = 0;
} else {
off = obj->header->xapi_lib_addr - obj->header->base;
}
r = r_buf_read_at (arch->buf, off, (ut8 *)&lib, sizeof(xbe_lib));
if (r == 0 || r == -1) return NULL;
s = r_str_newf ("%s %i.%i.%i", lib.name, lib.major, lib.minor, lib.build);
if (s) r_list_append (ret, s);
libs = obj->header->lib_versions;
if (libs<1) libs = 0;
for (i = 0; i < libs; i++) {
r = r_buf_read_at (arch->buf, obj->header->lib_versions_addr - \
obj->header->base + (i * sizeof (xbe_lib)),
(ut8 *)&lib, sizeof (xbe_lib));
if (r == 0 || r == -1) continue;
s = r_str_newf ("%s %i.%i.%i", lib.name,
lib.major, lib.minor, lib.build);
if (s) r_list_append(ret, s);
}
return ret;
}
开发者ID:13572293130,项目名称:radare2,代码行数:48,代码来源:bin_xbe.c
示例3: r_bin_mz_get_main_vaddr
ut64 r_bin_mz_get_main_vaddr(struct r_bin_mz_obj_t *bin) {
int entry;
int n;
ut8 b[512];
if (!bin || !bin->b) {
return 0LL;
}
entry = r_bin_mz_get_entrypoint (bin);
ZERO_FILL (b);
if (r_buf_read_at (bin->b, entry, b, sizeof (b)) < 0) {
eprintf ("Warning: Cannot read entry at 0x%08"PFMT32x "\n", (ut32) entry);
return 0LL;
}
// MSVC
if (b[0] == 0xb4 && b[1] == 0x30) {
// ff 36 XX XX push XXXX
// ff 36 XX XX push argv
// ff 36 XX XX push argc
// 9a XX XX XX XX lcall _main
// 50 push ax
for (n = 0; n < sizeof (b) - 18; n++) {
if (b[n] == 0xff && b[n + 4] == 0xff && b[n + 8] == 0xff && b[n + 12] == 0x9a && b[n + 17] == 0x50) {
const ut16 call_addr = r_read_ble16 (b + n + 13, 0);;
const ut16 call_seg = r_read_ble16 (b + n + 15, 0);;
const ut64 call_dst = r_bin_mz_seg_to_paddr (bin, call_seg) + call_addr;
return call_dst;
}
}
}
return 0LL;
}
开发者ID:agatti,项目名称:radare2,代码行数:32,代码来源:mz.c
示例4: rabin_dump_sections
static int rabin_dump_sections(char *scnname) {
RList *sections;
RListIter *iter;
RBinSection *section;
ut8 *buf;
char *ret;
if ((sections = r_bin_get_sections (bin)) == NULL)
return R_FALSE;
r_list_foreach (sections, iter, section) {
if (!strcmp (scnname, section->name)) {
if (!(buf = malloc (section->size)))
return R_FALSE;
if (!(ret = malloc (section->size*2+1))) {
free (buf);
return R_FALSE;
}
r_buf_read_at (bin->cur->buf, section->paddr, buf, section->size);
if (output) {
r_file_dump (output, buf, section->size);
} else {
r_hex_bin2str (buf, section->size, ret);
printf ("%s\n", ret);
}
free (buf);
free (ret);
break;
}
}
return R_TRUE;
}
开发者ID:KarjamP,项目名称:radare2,代码行数:33,代码来源:rabin2.c
示例5: check
static int check(RBinFile *arch) {
ut8 lict[48];
if (!arch || !arch->buf)
return 0;
r_buf_read_at (arch->buf, 0x104, lict,48);
return (!memcmp (lict, lic, 48))? 1: 0;
}
开发者ID:17twenty,项目名称:radare2,代码行数:7,代码来源:bin_ningb.c
示例6: calloc
static RList *parseSegments(RBuffer *buf, int off, int count) {
ut8 *b = calloc (count, 32);
(void)r_buf_read_at (buf, off, b, count * 32);
int x = off;
int X = 0;
int i;
RList *segments = r_list_newf ((RListFree)r_bin_section_free);
if (!segments) {
return NULL;
}
// eprintf ("Segments: %d\n", count);
for (i = 0; i < count; i++) {
int A = r_read_le32 (b + X + 16);
int B = r_read_le32 (b + X + 16 + 8);
// eprintf ("0x%08x segment 0x%08x 0x%08x %s\n",
// x, A, A + B, b + X);
const char *cname = (const char *)(b + X);
char *name = r_str_ndup (cname, r_str_nlen (cname, 16));
RBinSection *section = newSection (name, A, A + B, true);
free (name);
r_list_append (segments, section);
x += 32;
X += 32;
}
return segments;
}
开发者ID:aronsky,项目名称:radare2,代码行数:26,代码来源:bin_symbols.c
示例7: info
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
PebbleAppInfo pai;
memset (&pai, 0, sizeof (pai));
int reat = r_buf_read_at (arch->buf, 0, (ut8*)&pai, sizeof (pai));
if (reat != sizeof (pai)) {
eprintf ("Truncated Header\n");
return NULL;
}
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->lang = NULL;
ret->file = strdup (arch->file);
ret->type = strdup ("pebble");
ret->bclass = r_str_ndup (pai.name, 32);
ret->rclass = r_str_ndup (pai.company, 32);
ret->os = strdup ("rtos");
ret->subsystem = strdup ("pebble");
ret->machine = strdup ("watch");
ret->arch = strdup ("arm"); // thumb only
ret->has_va = 1;
ret->bits = 16;
ret->big_endian = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:13572293130,项目名称:radare2,代码行数:26,代码来源:bin_pebble.c
示例8: R_NEW0
static RBinInfo *info(RBinFile *arch) {
ut8 rom_info[16];
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret) {
return NULL;
}
if (!arch || !arch->buf) {
free (ret);
return NULL;
}
ret->lang = NULL;
r_buf_read_at (arch->buf, 0xa0, rom_info, 16);
ret->file = r_str_ndup ((const char *) rom_info, 12);
ret->type = r_str_ndup ((char *) &rom_info[12], 4);
ret->machine = strdup ("GameBoy Advance");
ret->os = strdup ("any");
ret->arch = strdup ("arm");
ret->has_va = 1;
ret->bits = 32;
ret->big_endian = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:P4N74,项目名称:radare2,代码行数:26,代码来源:bin_ningba.c
示例9: info
static RBinInfo* info(RBinFile *arch) {
ut8 rom_info[16];
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret)
return NULL;
if (!arch || !arch->buf) {
free (ret);
return NULL;
}
ret->lang = NULL;
r_buf_read_at (arch->buf, 0xa0, rom_info, 16);
strncpy (ret->file, (char *) rom_info, 12);
strncpy (ret->type, (char *) &rom_info[12], 4);
strncpy (ret->machine, "Gameboy Advanced", sizeof (ret->machine)-1);
strncpy (ret->os, "any", sizeof (ret->os)-1);
strcpy (ret->arch, "arm");
ret->has_va = 1;
ret->bits = 32;
ret->big_endian = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:DePierre,项目名称:radare2,代码行数:25,代码来源:bin_ningba.c
示例10: R_NEW0
static RBinInfo *info(RBinFile *bf) {
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret) {
return NULL;
}
ut8 magic[4];
r_buf_read_at (bf->buf, NRO_OFF (magic), magic, sizeof (magic));
const char *ft = fileType (magic);
if (!ft) {
ft = "nro";
}
ret->file = strdup (bf->file);
ret->rclass = strdup (ft);
ret->os = strdup ("switch");
ret->arch = strdup ("arm");
ret->machine = strdup ("Nintendo Switch");
ret->subsystem = strdup (ft);
if (!strncmp (ft, "nrr", 3)) {
ret->bclass = strdup ("program");
ret->type = strdup ("EXEC (executable file)");
} else if (!strncmp (ft, "nro", 3)) {
ret->bclass = strdup ("object");
ret->type = strdup ("OBJECT (executable code)");
} else { // mod
ret->bclass = strdup ("library");
ret->type = strdup ("MOD (executable library)");
}
ret->bits = 64;
ret->has_va = true;
ret->has_lit = true;
ret->big_endian = false;
ret->dbg_info = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:radare,项目名称:radare2,代码行数:35,代码来源:bin_nro.c
示例11: info
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
PebbleAppInfo pai;
if (!r_buf_read_at (arch->buf, 0, (ut8*)&pai, sizeof (pai))) {
eprintf ("Truncated Header\n");
return NULL;
}
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->lang = NULL;
strncpy (ret->file, arch->file, R_BIN_SIZEOF_STRINGS-1);
strncpy (ret->rpath, "NONE", R_BIN_SIZEOF_STRINGS-1);
strncpy (ret->type, "pebble", sizeof (ret->type)-1); // asm.arch
strncpy (ret->bclass, pai.name, sizeof (ret->bclass)-1);
strncpy (ret->rclass, pai.company, sizeof (ret->rclass)-1); // file.type
strncpy (ret->os, "rtos", sizeof (ret->os)-1);
strncpy (ret->subsystem, "pebble", sizeof (ret->subsystem)-1);
strncpy (ret->machine, "watch", sizeof (ret->machine)-1);
strcpy (ret->arch, "arm"); // ARM THUMB ONLY
ret->has_va = 1;
ret->bits = 16;
ret->big_endian = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:commiebstrd,项目名称:radare2,代码行数:25,代码来源:bin_pebble.c
示例12: rabin_dump_symbols
static int rabin_dump_symbols(int len) {
RList *symbols;
RListIter *iter;
RBinSymbol *symbol;
ut8 *buf;
char *ret;
int olen = len;
if ((symbols = r_bin_get_symbols (bin)) == NULL)
return R_FALSE;
r_list_foreach (symbols, iter, symbol) {
if (symbol->size != 0 && (olen > symbol->size || olen == 0))
len = symbol->size;
else if (symbol->size == 0 && olen == 0)
len = 32;
else len = olen;
if (!(buf = malloc (len))) {
return R_FALSE;
}
if (!(ret = malloc (len*2+1))) {
free (buf);
return R_FALSE;
}
r_buf_read_at (bin->cur->buf, symbol->paddr, buf, len);
r_hex_bin2str (buf, len, ret);
printf ("%s %s\n", symbol->name, ret);
free (buf);
free (ret);
}
return R_TRUE;
}
开发者ID:KarjamP,项目名称:radare2,代码行数:32,代码来源:rabin2.c
示例13: R_NEW0
static RBinInfo *info(RBinFile *bf) {
r_bin_xbe_obj_t *obj;
RBinInfo *ret;
ut8 dbg_name[256];
if (!bf || !bf->buf) {
return NULL;
}
ret = R_NEW0 (RBinInfo);
if (!ret) {
return NULL;
}
obj = bf->o->bin_obj;
memset (dbg_name, 0, sizeof (dbg_name));
r_buf_read_at (bf->buf, obj->header->debug_name_addr -\
obj->header->base, dbg_name, sizeof (dbg_name));
dbg_name[sizeof(dbg_name) - 1] = 0;
ret->file = strdup ((char *) dbg_name);
ret->bclass = strdup ("program");
ret->machine = strdup ("Microsoft Xbox");
ret->os = strdup ("xbox");
ret->type = strdup ("Microsoft Xbox executable");
ret->arch = strdup ("x86");
ret->has_va = 1;
ret->bits = 32;
ret->big_endian = 0;
ret->dbg_info = 0;
ret->lang = NULL;
return ret;
}
开发者ID:montekki,项目名称:radare2,代码行数:33,代码来源:bin_xbe.c
示例14: sections
static RList* sections(RBinFile *bf) {
RList *ret = NULL;
RBinSection *ptr = NULL;
spc_hdr spchdr;
memset (&spchdr, 0, SPC_HDR_SIZE);
int reat = r_buf_read_at (bf->buf, 0, (ut8*)&spchdr, SPC_HDR_SIZE);
if (reat != SPC_HDR_SIZE) {
eprintf ("Truncated Header\n");
return NULL;
}
if (!(ret = r_list_new ())) {
return NULL;
}
if (!(ptr = R_NEW0 (RBinSection))) {
r_list_free (ret);
return NULL;
}
strcpy (ptr->name, "RAM");
ptr->paddr = RAM_START_ADDRESS;
ptr->size = RAM_SIZE;
ptr->vaddr = 0x0;
ptr->vsize = RAM_SIZE;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_MAP;
ptr->add = true;
r_list_append (ret, ptr);
return ret;
}
开发者ID:leberus,项目名称:radare2,代码行数:27,代码来源:bin_spc700.c
示例15: info
static RBinInfo* info(RBinFile *arch) {
ut8 rom_header[76];
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret)
return NULL;
if (!arch || !arch->buf) {
free (ret);
return NULL;
}
ret->lang = NULL;
r_buf_read_at (arch->buf,0x104,rom_header,76);
strncpy (ret->file, (const char*)&rom_header[48], 16);
gb_get_gbtype (ret->type,rom_header[66],rom_header[63]);
gb_add_cardtype (ret->type,rom_header[67]); // XXX
strncpy (ret->machine, "Gameboy", sizeof (ret->machine)-1);
strncpy (ret->os, "any", sizeof (ret->os)-1);
strcpy (ret->arch, "gb");
ret->has_va = 1;
ret->bits = 8;
ret->big_endian = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:DePierre,项目名称:radare2,代码行数:26,代码来源:bin_ningb.c
示例16: info
static RBinInfo* info(RBinFile *arch) {
ut8 rom_header[76];
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret)
return NULL;
if (!arch || !arch->buf) {
free (ret);
return NULL;
}
r_buf_read_at (arch->buf, 0x104, rom_header, 76);
ret->file = calloc (1, 17);
strncpy (ret->file, (const char*)&rom_header[48], 16);
ret->type = malloc (128);
ret->type[0] = 0;
gb_get_gbtype (ret->type, rom_header[66], rom_header[63]);
gb_add_cardtype (ret->type, rom_header[67]); // XXX
ret->machine = strdup ("Gameboy");
ret->os = strdup ("any");
ret->arch = strdup ("gb");
ret->has_va = 1;
ret->bits = 16;
ret->big_endian = 0;
ret->dbg_info = 0;
return ret;
}
开发者ID:Kakkoroid,项目名称:radare2,代码行数:28,代码来源:bin_ningb.c
示例17: bootimg_header_load
static int bootimg_header_load(BootImage *bi, RBuffer *buf, Sdb *db) {
char *n;
int i;
if (r_buf_size (buf) < sizeof (BootImage)) {
return false;
}
// TODO make it endian-safe (void)r_buf_fread_at (buf, 0, (ut8*)bi, "IIiiiiiiiiiiii", 1);
(void)r_buf_read_at (buf, 0, (ut8*)bi, sizeof (BootImage));
if ((n = r_str_ndup ((char*)bi->name, BOOT_NAME_SIZE))) {
sdb_set (db, "name", n, 0);
free (n);
}
if ((n = r_str_ndup ((char*)bi->cmdline, BOOT_ARGS_SIZE))) {
sdb_set (db, "cmdline", n, 0);
free (n);
}
for (i=0; i<8; i++) {
sdb_num_set (db, "id", (ut64)bi->id[i], 0);
}
if ((n = r_str_ndup ((char*)bi->extra_cmdline, BOOT_EXTRA_ARGS_SIZE))) {
sdb_set (db, "extra_cmdline", n, 0);
free (n);
}
return true;
}
开发者ID:13572293130,项目名称:radare2,代码行数:25,代码来源:bin_bootimg.c
示例18: info
static RBinInfo* info(RBinFile *arch) {
r_bin_xbe_obj_t *obj;
RBinInfo *ret;
ut8 dbg_name[256];
if (!arch || !arch->buf)
return NULL;
ret = R_NEW0 (RBinInfo);
if (!ret)
return NULL;
obj = arch->o->bin_obj;
r_buf_read_at (arch->buf, obj->header->debug_name_addr - \
obj->header->base, dbg_name, sizeof(dbg_name));
strncpy (ret->file, (const char*)dbg_name, R_BIN_SIZEOF_STRINGS);
strncpy (ret->bclass, "program", R_BIN_SIZEOF_STRINGS);
strncpy (ret->machine, "Microsoft Xbox", R_BIN_SIZEOF_STRINGS);
strncpy (ret->os, "xbox", R_BIN_SIZEOF_STRINGS);
strncpy (ret->type, "Microsoft Xbox executable", R_BIN_SIZEOF_STRINGS);
strncpy (ret->arch, "x86", R_BIN_SIZEOF_STRINGS);
ret->has_va = 1;
ret->bits = 32;
ret->big_endian = 0;
ret->dbg_info = 0;
ret->lang = NULL;
return ret;
}
开发者ID:DePierre,项目名称:radare2,代码行数:30,代码来源:bin_xbe.c
示例19: r_bin_dex_get_version
char* r_bin_dex_get_version(RBinDexObj *bin) {
if (bin) {
ut8* version = calloc (1, 8);
r_buf_read_at (bin->b, 4, version, 3);
return (char *)version;
}
return NULL;
}
开发者ID:P4N74,项目名称:radare2,代码行数:8,代码来源:dex.c
示例20: sections
static RList* sections(RBinFile *bf){
ut8 bank;
int i;
RList *ret;
if (!bf) {
return NULL;
}
ret = r_list_new();
if (!ret) {
return NULL;
}
r_buf_read_at (bf->buf, 0x148, &bank, 1);
bank = gb_get_rombanks(bank);
#ifdef _MSC_VER
RBinSection **rombank = (RBinSection**) malloc (sizeof (RBinSection*) * bank);
#else
RBinSection *rombank[bank];
#endif
if (!bf->buf) {
free (ret);
#ifdef _MSC_VER
free (rombank);
#endif
return NULL;
}
ret->free = free;
rombank[0] = R_NEW0 (RBinSection);
rombank[0]->name = strdup ("rombank00");
rombank[0]->paddr = 0;
rombank[0]->size = 0x4000;
rombank[0]->vsize = 0x4000;
rombank[0]->vaddr = 0;
rombank[0]->perm = r_str_rwx ("rx");
rombank[0]->add = true;
r_list_append (ret, rombank[0]);
for (i = 1; i < bank; i++) {
rombank[i] = R_NEW0 (RBinSection);
rombank[i]->name = r_str_newf ("rombank%02x", i);
rombank[i]->paddr = i*0x4000;
rombank[i]->vaddr = i*0x10000-0xc000; //spaaaaaaaaaaaaaaaace!!!
rombank[i]->size = rombank[i]->vsize = 0x4000;
rombank[i]->perm = r_str_rwx ("rx");
rombank[i]->add = true;
r_list_append (ret,rombank[i]);
}
#ifdef _MSC_VER
free (rombank);
#endif
return ret;
}
开发者ID:radare,项目名称:radare2,代码行数:58,代码来源:bin_ningb.c
注:本文中的r_buf_read_at函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论