mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 07:00:30 +00:00
Fix msvc warnings (#19827)
This commit is contained in:
parent
43a2ee3686
commit
4bed905d8a
@ -7,6 +7,10 @@ if "%*" == "asan" (
|
||||
set MESON_FLAGS=%MESON_FLAGS% -Dwasan=true
|
||||
)
|
||||
|
||||
if "%*" == "static" (
|
||||
set MESON_FLAGS=%MESON_FLAGS% -Dstatic_runtime=true -Dblob=true
|
||||
)
|
||||
|
||||
set PATH=%CD%\prefix\bin;%PATH%
|
||||
set WORKS=0
|
||||
if EXIST vs (
|
||||
|
@ -2128,7 +2128,7 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
|
||||
{
|
||||
int disp = (int)MEMDISP64 (2);
|
||||
char sign = disp>=0?'+':'-';
|
||||
ut64 abs = disp>=0? MEMDISP64 (2): -MEMDISP64 (2);
|
||||
ut64 abs = disp>=0? MEMDISP64 (2): (ut64)(-MEMDISP64 (2));
|
||||
int size = REGSIZE64 (0);
|
||||
// Pre-index case
|
||||
// x2,x8,32,+,=[8],x3,x8,32,+,8,+,=[8]
|
||||
@ -2737,7 +2737,7 @@ r6,r5,r4,3,sp,[*],12,sp,+=
|
||||
}
|
||||
if (OPCOUNT() == 2) {
|
||||
if (ISMEM(1) && !HASMEMINDEX(1)) {
|
||||
int disp = MEMDISP(1);
|
||||
int disp = MEMDISP (1);
|
||||
char sign = disp>=0?'+':'-';
|
||||
disp = disp>=0?disp:-disp;
|
||||
r_strbuf_appendf (&op->esil, "%s,0x%x,%s,%c,0xffffffff,&,=[%d]",
|
||||
@ -4034,7 +4034,7 @@ jmp $$ + 4 + ( [delta] * 2 )
|
||||
if (REGBASE(1) == ARM_REG_FP) {
|
||||
op->stackop = R_ANAL_STACK_SET;
|
||||
op->stackptr = 0;
|
||||
op->ptr = -MEMDISP(1);
|
||||
op->ptr = (ut64)-MEMDISP (1);
|
||||
}
|
||||
break;
|
||||
case ARM_INS_SXTB:
|
||||
@ -4082,15 +4082,15 @@ jmp $$ + 4 + ( [delta] * 2 )
|
||||
if (REGBASE(1) == ARM_REG_FP) {
|
||||
op->stackop = R_ANAL_STACK_GET;
|
||||
op->stackptr = 0;
|
||||
op->ptr = -MEMDISP(1);
|
||||
op->ptr = -MEMDISP (1);
|
||||
} else if (REGBASE(1) == ARM_REG_PC) {
|
||||
op->ptr = (addr & ~3LL) + (thumb? 4: 8) + MEMDISP(1);
|
||||
op->ptr = (addr & ~3LL) + (thumb? 4: 8) + MEMDISP (1);
|
||||
op->refptr = 4;
|
||||
if (REGID(0) == ARM_REG_PC && insn->detail->arm.cc != ARM_CC_AL) {
|
||||
//op->type = R_ANAL_OP_TYPE_MCJMP;
|
||||
op->type = R_ANAL_OP_TYPE_UCJMP;
|
||||
op->fail = addr+op->size;
|
||||
op->jump = ((addr & ~3LL) + (thumb? 4: 8) + MEMDISP(1)) & UT64_MAX;
|
||||
op->jump = ((addr & ~3LL) + (thumb? 4: 8) + MEMDISP (1)) & UT64_MAX;
|
||||
op->ireg = r_str_getf (cs_reg_name (handle, INSOP (1).mem.index));
|
||||
break;
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ static int init_phdr(ELFOBJ *bin) {
|
||||
}
|
||||
ut64 phnum = Elf_(r_bin_elf_get_phnum) (bin);
|
||||
if (!(bin->phdr = R_NEWS0 (Elf_(Phdr), phnum))) {
|
||||
perror ("malloc (phdr)");
|
||||
r_sys_perror ("malloc (phdr)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -387,7 +387,7 @@ static int init_shdr(ELFOBJ *bin) {
|
||||
return false;
|
||||
}
|
||||
if (!(bin->shdr = R_NEWS0 (Elf_(Shdr), bin->ehdr.e_shnum))) {
|
||||
perror ("malloc (shdr)");
|
||||
r_sys_perror ("malloc (shdr)");
|
||||
return false;
|
||||
}
|
||||
sdb_num_set (bin->kv, "elf_shdr.offset", bin->ehdr.e_shoff, 0);
|
||||
@ -472,7 +472,7 @@ static int init_strtab(ELFOBJ *bin) {
|
||||
}
|
||||
|
||||
if (!(bin->shstrtab = calloc (1, bin->shstrtab_size + 1))) {
|
||||
perror ("malloc");
|
||||
r_sys_perror ("malloc");
|
||||
bin->shstrtab = NULL;
|
||||
return false;
|
||||
}
|
||||
@ -2927,7 +2927,7 @@ RBinElfLib* Elf_(r_bin_elf_get_libs)(ELFOBJ *bin) {
|
||||
|
||||
RBinElfLib *r = realloc (ret, (k + 1) * sizeof (RBinElfLib));
|
||||
if (!r) {
|
||||
perror ("realloc (libs)");
|
||||
r_sys_perror ("realloc (libs)");
|
||||
free (ret);
|
||||
return NULL;
|
||||
}
|
||||
@ -2946,7 +2946,7 @@ RBinElfLib* Elf_(r_bin_elf_get_libs)(ELFOBJ *bin) {
|
||||
|
||||
RBinElfLib *r = realloc (ret, (k + 1) * sizeof (RBinElfLib));
|
||||
if (!r) {
|
||||
perror ("realloc (libs)");
|
||||
r_sys_perror ("realloc (libs)");
|
||||
free (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
Elf_(Rel) *rel, *relp;
|
||||
rel = (Elf_(Rel) *)malloc (1+shdrp->sh_size);
|
||||
if (!rel) {
|
||||
perror ("malloc");
|
||||
r_sys_perror ("malloc");
|
||||
return 0;
|
||||
}
|
||||
if (r_buf_read_at (bin->b, shdrp->sh_offset, (ut8*)rel, shdrp->sh_size) == -1) {
|
||||
perror("read (rel)");
|
||||
r_sys_perror("read (rel)");
|
||||
}
|
||||
for (j = 0, relp = rel; j < shdrp->sh_size; j += sizeof(Elf_(Rel)), relp++) {
|
||||
/* rewrite relp->r_offset */
|
||||
@ -77,7 +77,7 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
relp->r_offset+=delta;
|
||||
off = shdrp->sh_offset + j;
|
||||
if (r_buf_write_at (bin->b, off, (ut8*)relp, sizeof (Elf_(Rel))) == -1) {
|
||||
perror("write (imports)");
|
||||
r_sys_perror("write (imports)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,11 +87,11 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
Elf_(Rela) *rel, *relp;
|
||||
rel = (Elf_(Rela) *)malloc (shdrp->sh_size + 1);
|
||||
if (!rel) {
|
||||
perror("malloc");
|
||||
r_sys_perror("malloc");
|
||||
return 0;
|
||||
}
|
||||
if (r_buf_read_at (bin->b, shdrp->sh_offset, (ut8*)rel, shdrp->sh_size) == -1) {
|
||||
perror("read (rel)");
|
||||
r_sys_perror("read (rel)");
|
||||
}
|
||||
for (j = 0, relp = rel; j < shdrp->sh_size; j += sizeof(Elf_(Rela)), relp++) {
|
||||
/* rewrite relp->r_offset */
|
||||
@ -99,7 +99,7 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
relp->r_offset+=delta;
|
||||
off = shdrp->sh_offset + j;
|
||||
if (r_buf_write_at (bin->b, off, (ut8*)relp, sizeof (Elf_(Rela))) == -1) {
|
||||
perror("write (imports)");
|
||||
r_sys_perror("write (imports)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
}
|
||||
off = ehdr->e_shoff + i * sizeof (Elf_(Shdr));
|
||||
if (r_buf_write_at (bin->b, off, (ut8*)shdrp, sizeof (Elf_(Shdr))) == -1) {
|
||||
perror ("write (shdr)");
|
||||
r_sys_perror ("write (shdr)");
|
||||
}
|
||||
printf ("-> elf section (%s)\n", &strtab[shdrp->sh_name]);
|
||||
}
|
||||
@ -148,7 +148,7 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
}
|
||||
off = ehdr->e_phoff + i * sizeof (Elf_(Phdr));
|
||||
if (r_buf_write_at (bin->b, off, (ut8 *)phdrp, sizeof (Elf_ (Phdr))) == -1) {
|
||||
perror ("write (phdr)");
|
||||
r_sys_perror ("write (phdr)");
|
||||
}
|
||||
printf ("-> program header (0x%08"PFMT64x")\n", (ut64) phdrp->p_offset);
|
||||
}
|
||||
@ -164,7 +164,7 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) {
|
||||
ehdr->e_shoff += delta;
|
||||
}
|
||||
if (r_buf_write_at (bin->b, 0, (ut8*)ehdr, sizeof (Elf_(Ehdr))) == -1) {
|
||||
perror ("write (ehdr)");
|
||||
r_sys_perror ("write (ehdr)");
|
||||
}
|
||||
|
||||
/* inverse order to write bodies .. avoid overlapping here */
|
||||
@ -201,7 +201,7 @@ bool Elf_(r_bin_elf_del_rpath)(RBinFile *bf) {
|
||||
continue;
|
||||
}
|
||||
if (!(dyn = malloc (bin->phdr[i].p_filesz + 1))) {
|
||||
perror ("malloc (dyn)");
|
||||
r_sys_perror ("malloc (dyn)");
|
||||
return false;
|
||||
}
|
||||
if (r_buf_read_at (bin->b, bin->phdr[i].p_offset, (ut8*)dyn, bin->phdr[i].p_filesz) == -1) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
static int r_bin_dyldcache_init(struct r_bin_dyldcache_obj_t* bin) {
|
||||
int len = r_buf_fread_at (bin->b, 0, (ut8*)&bin->hdr, "16c4i7l", 1);
|
||||
if (len == -1) {
|
||||
perror ("read (cache_header)");
|
||||
r_sys_perror ("read (cache_header)");
|
||||
return false;
|
||||
}
|
||||
bin->nlibs = bin->hdr.numlibs;
|
||||
|
@ -11,7 +11,7 @@ static int r_bin_fatmach0_init(struct r_bin_fatmach0_obj_t* bin) {
|
||||
ut8 hdrbytes[sizeof (struct fat_header)] = {0};
|
||||
int len = r_buf_read_at (bin->b, 0, &hdrbytes[0], sizeof (struct fat_header));
|
||||
if (len != sizeof (struct fat_header)) {
|
||||
perror ("read (fat_header)");
|
||||
r_sys_perror ("read (fat_header)");
|
||||
return false;
|
||||
}
|
||||
bin->hdr.magic = r_read_be32 (&hdrbytes[0]);
|
||||
@ -30,14 +30,14 @@ static int r_bin_fatmach0_init(struct r_bin_fatmach0_obj_t* bin) {
|
||||
return false;
|
||||
}
|
||||
if (!(bin->archs = malloc (size))) {
|
||||
perror ("malloc (fat_arch)");
|
||||
r_sys_perror ("malloc (fat_arch)");
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < bin->nfat_arch; i++) {
|
||||
ut8 archbytes[sizeof (struct fat_arch)] = {0};
|
||||
len = r_buf_read_at (bin->b, 8 + i * sizeof (struct fat_arch), &archbytes[0], sizeof (struct fat_arch));
|
||||
if (len != sizeof (struct fat_arch)) {
|
||||
perror ("read (fat_arch)");
|
||||
r_sys_perror ("read (fat_arch)");
|
||||
R_FREE (bin->archs);
|
||||
return false;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ static bool parse_segments(struct MACH0_(obj_t) *bin, ut64 off) {
|
||||
return false;
|
||||
}
|
||||
if (!(bin->segs = realloc (bin->segs, bin->nsegs * sizeof(struct MACH0_(segment_command))))) {
|
||||
perror ("realloc (seg)");
|
||||
r_sys_perror ("realloc (seg)");
|
||||
return false;
|
||||
}
|
||||
j = bin->nsegs - 1;
|
||||
@ -384,7 +384,7 @@ static bool parse_segments(struct MACH0_(obj_t) *bin, ut64 off) {
|
||||
}
|
||||
|
||||
if (!(bin->sects = realloc (bin->sects, bin->nsects * sizeof (struct MACH0_(section))))) {
|
||||
perror ("realloc (sects)");
|
||||
r_sys_perror ("realloc (sects)");
|
||||
bin->nsects = sect;
|
||||
return false;
|
||||
}
|
||||
@ -570,7 +570,7 @@ static bool parse_dysymtab(struct MACH0_(obj_t) *bin, ut64 off) {
|
||||
bin->ntoc = bin->dysymtab.ntoc;
|
||||
if (bin->ntoc > 0) {
|
||||
if (!(bin->toc = calloc (bin->ntoc, sizeof (struct dylib_table_of_contents)))) {
|
||||
perror ("calloc (toc)");
|
||||
r_sys_perror ("calloc (toc)");
|
||||
return false;
|
||||
}
|
||||
if (!UT32_MUL (&size_tab, bin->ntoc, sizeof (struct dylib_table_of_contents))){
|
||||
@ -602,7 +602,7 @@ static bool parse_dysymtab(struct MACH0_(obj_t) *bin, ut64 off) {
|
||||
ut64 max_nmodtab = (bin->size - bin->dysymtab.modtaboff) / sizeof (struct MACH0_(dylib_module));
|
||||
if (bin->nmodtab > 0 && bin->nmodtab <= max_nmodtab) {
|
||||
if (!(bin->modtab = calloc (bin->nmodtab, sizeof (struct MACH0_(dylib_module))))) {
|
||||
perror ("calloc (modtab)");
|
||||
r_sys_perror ("calloc (modtab)");
|
||||
return false;
|
||||
}
|
||||
if (!UT32_MUL (&size_tab, bin->nmodtab, sizeof (struct MACH0_(dylib_module)))){
|
||||
@ -651,7 +651,7 @@ static bool parse_dysymtab(struct MACH0_(obj_t) *bin, ut64 off) {
|
||||
bin->nindirectsyms = bin->dysymtab.nindirectsyms;
|
||||
if (bin->nindirectsyms > 0) {
|
||||
if (!(bin->indirectsyms = calloc (bin->nindirectsyms, sizeof (ut32)))) {
|
||||
perror ("calloc (indirectsyms)");
|
||||
r_sys_perror ("calloc (indirectsyms)");
|
||||
return false;
|
||||
}
|
||||
if (!UT32_MUL (&size_tab, bin->nindirectsyms, sizeof (ut32))){
|
||||
@ -1213,7 +1213,7 @@ static int parse_dylib(struct MACH0_(obj_t) *bin, ut64 off) {
|
||||
|
||||
void *relibs = realloc (bin->libs, bin->nlibs * R_BIN_MACH0_STRING_LENGTH);
|
||||
if (!relibs) {
|
||||
perror ("realloc (libs)");
|
||||
r_sys_perror ("realloc (libs)");
|
||||
return false;
|
||||
}
|
||||
bin->libs = relibs;
|
||||
|
@ -110,7 +110,7 @@ static int r_bin_te_init_sections(struct r_bin_te_obj_t* bin) {
|
||||
return false;
|
||||
}
|
||||
if (!(bin->section_header = malloc (sections_size))) {
|
||||
perror ("malloc (sections headers)");
|
||||
r_sys_perror ("malloc (sections headers)");
|
||||
return false;
|
||||
}
|
||||
if (r_buf_read_at (bin->b, sizeof(TE_image_file_header),
|
||||
@ -181,7 +181,7 @@ RBinAddr* r_bin_te_get_entrypoint(struct r_bin_te_obj_t* bin) {
|
||||
return NULL;
|
||||
}
|
||||
if (!(entry = malloc (sizeof (RBinAddr)))) {
|
||||
perror("malloc (entrypoint)");
|
||||
r_sys_perror("malloc (entrypoint)");
|
||||
return NULL;
|
||||
}
|
||||
entry->vaddr = bin->header->AddressOfEntryPoint - r_bin_te_get_stripped_delta (bin);
|
||||
@ -341,7 +341,7 @@ struct r_bin_te_section_t* r_bin_te_get_sections(struct r_bin_te_obj_t* bin) {
|
||||
sections_count = bin->header->NumberOfSections;
|
||||
|
||||
if (!(sections = calloc ((sections_count + 1), sizeof (struct r_bin_te_section_t)))) {
|
||||
perror ("malloc (sections)");
|
||||
r_sys_perror ("malloc (sections)");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < sections_count; i++) {
|
||||
|
@ -4981,7 +4981,7 @@ static void getpcfromstack(RCore *core, RAnalEsil *esil) {
|
||||
|
||||
buf = malloc (size + 2);
|
||||
if (!buf) {
|
||||
perror ("malloc");
|
||||
r_sys_perror ("malloc");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5230,7 +5230,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
|
||||
}
|
||||
buf = malloc ((size_t)iend + 2);
|
||||
if (!buf) {
|
||||
perror ("malloc");
|
||||
r_sys_perror ("malloc");
|
||||
return;
|
||||
}
|
||||
esilbreak_last_read = UT64_MAX;
|
||||
|
@ -3043,7 +3043,7 @@ static void r_w32_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
|
||||
}
|
||||
fd_out = _open_osfhandle ((intptr_t)pipe[1], _O_WRONLY|_O_TEXT);
|
||||
if (fd_out == -1) {
|
||||
perror ("_open_osfhandle");
|
||||
r_sys_perror ("_open_osfhandle");
|
||||
goto err_r_w32_cmd_pipe;
|
||||
}
|
||||
cons_out = dup (1);
|
||||
|
@ -1167,7 +1167,7 @@ R_API int r_cmd_macro_call(RCmdMacro *mac, const char *name) {
|
||||
|
||||
str = strdup (name);
|
||||
if (!str) {
|
||||
perror ("strdup");
|
||||
r_sys_perror ("strdup");
|
||||
return false;
|
||||
}
|
||||
ptr = strchr (str, ')');
|
||||
|
@ -914,7 +914,7 @@ R_API void r_core_rtr_event(RCore *core, const char *input) {
|
||||
errmsg_tmpfile = strdup (f);
|
||||
int e = mkfifo (f, 0644);
|
||||
if (e == -1) {
|
||||
perror ("mkfifo");
|
||||
r_sys_perror ("mkfifo");
|
||||
} else {
|
||||
int ff = open (f, O_RDWR);
|
||||
if (ff != -1) {
|
||||
|
@ -74,7 +74,7 @@ static void apply_IP(ut32 in[DW_BY_BLOCK], ut32 out[DW_BY_BLOCK]) {
|
||||
int i;
|
||||
for (i = 0; i < DW_BY_BLOCK * 32; i++) {
|
||||
index = IPTable[i];
|
||||
out[i / 32] ^= (-(ut32)get_bit (index % 32, in[index / 32]) ^ out[i / 32])
|
||||
out[i / 32] ^= (ut32)(-(ut32)get_bit (index % 32, in[index / 32]) ^ out[i / 32])
|
||||
& (1 << (i & 0x1f));
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ static void apply_FP(ut32 in[DW_BY_BLOCK], ut32 out[DW_BY_BLOCK]) {
|
||||
int i;
|
||||
for (i = 0; i < DW_BY_BLOCK * 32; i++) {
|
||||
index = FPTable[i];
|
||||
out[i / 32] ^= (-(ut32)get_bit (index % 32, in[index / 32]) ^ out[i / 32])
|
||||
out[i / 32] ^= (ut32)(-(ut32)get_bit (index % 32, in[index / 32]) ^ out[i / 32])
|
||||
& (1 << (i & 0x1f));
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ static bool r_debug_native_step(RDebug *dbg) {
|
||||
#elif __BSD__
|
||||
int ret = ptrace (PT_STEP, dbg->pid, (caddr_t)1, 0);
|
||||
if (ret != 0) {
|
||||
perror ("native-singlestep");
|
||||
r_sys_perror ("native-singlestep");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -146,14 +146,14 @@ static bool r_debug_native_attach(RDebug *dbg, int pid) {
|
||||
return linux_attach (dbg, pid);
|
||||
#elif __KFBSD__
|
||||
if (ptrace (PT_ATTACH, pid, 0, 0) != -1) {
|
||||
perror ("ptrace (PT_ATTACH)");
|
||||
r_sys_perror ("ptrace (PT_ATTACH)");
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
int ret = ptrace (PTRACE_ATTACH, pid, 0, 0);
|
||||
if (ret != -1) {
|
||||
eprintf ("Trying to attach to %d\n", pid);
|
||||
perror ("ptrace (PT_ATTACH)");
|
||||
r_sys_perror ("ptrace (PT_ATTACH)");
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
@ -1035,7 +1035,7 @@ static RList *r_debug_native_map_get(RDebug *dbg) {
|
||||
fd = r_sandbox_fopen (path, "r");
|
||||
if (!fd) {
|
||||
char *errstr = r_str_newf ("Cannot open '%s'", path);
|
||||
perror (errstr);
|
||||
r_sys_perror (errstr);
|
||||
free (errstr);
|
||||
return NULL;
|
||||
}
|
||||
@ -1489,7 +1489,7 @@ static RList *xnu_desc_list(int pid) {
|
||||
continue;
|
||||
}
|
||||
if (nb < sizeof (vi)) {
|
||||
perror ("too few bytes");
|
||||
r_sys_perror ("too few bytes");
|
||||
break;
|
||||
}
|
||||
//printf ("FD %d RWX %x ", i, vi.pfi.fi_openflags);
|
||||
|
@ -51,22 +51,22 @@ static bool __is_target_kernel(DbgEngContext *idbg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int windbg_init(RDebug *dbg) {
|
||||
static bool windbg_init(RDebug *dbg) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
if (!idbg || !idbg->initialized) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int windbg_step(RDebug *dbg) {
|
||||
static bool windbg_step(RDebug *dbg) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, 0);
|
||||
idbg->lastExecutionStatus = DEBUG_STATUS_STEP_INTO;
|
||||
return SUCCEEDED (ITHISCALL (dbgCtrl, SetExecutionStatus, DEBUG_STATUS_STEP_INTO));
|
||||
}
|
||||
|
||||
static int windbg_select(RDebug *dbg, int pid, int tid) {
|
||||
static bool windbg_select(RDebug *dbg, int pid, int tid) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, 0);
|
||||
ULONG Id = tid;
|
||||
@ -79,12 +79,12 @@ static int windbg_select(RDebug *dbg, int pid, int tid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int windbg_continue(RDebug *dbg, int pid, int tid, int sig) {
|
||||
static bool windbg_continue(RDebug *dbg, int pid, int tid, int sig) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, 0);
|
||||
idbg->lastExecutionStatus = DEBUG_STATUS_GO;
|
||||
ITHISCALL (dbgCtrl, SetExecutionStatus, DEBUG_STATUS_GO);
|
||||
return tid;
|
||||
return true; // tid?
|
||||
}
|
||||
|
||||
// nicked from windows_debug.c
|
||||
@ -131,7 +131,7 @@ static void __break(void *user) {
|
||||
do_break = true;
|
||||
}
|
||||
|
||||
static int windbg_wait(RDebug *dbg, int pid) {
|
||||
static RDebugReasonType windbg_wait(RDebug *dbg, int pid) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, 0);
|
||||
ULONG Type, ProcessId, ThreadId;
|
||||
@ -158,7 +158,7 @@ static int windbg_wait(RDebug *dbg, int pid) {
|
||||
dbg->pid = ProcessId;
|
||||
dbg->tid = ThreadId;
|
||||
}
|
||||
int ret;
|
||||
RDebugReasonType ret;
|
||||
switch (Type) {
|
||||
case 0:
|
||||
// I dont really get why Type is zero here
|
||||
@ -196,14 +196,14 @@ static int windbg_wait(RDebug *dbg, int pid) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int windbg_step_over(RDebug *dbg) {
|
||||
static bool windbg_step_over(RDebug *dbg) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, 0);
|
||||
idbg->lastExecutionStatus = DEBUG_STATUS_STEP_OVER;
|
||||
if (SUCCEEDED (ITHISCALL (dbgCtrl, SetExecutionStatus, DEBUG_STATUS_STEP_OVER))) {
|
||||
return windbg_wait (dbg, dbg->pid) != R_DEBUG_REASON_ERROR;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int windbg_breakpoint(RBreakpoint *bp, RBreakpointItem *b, bool set) {
|
||||
@ -471,7 +471,7 @@ static RList *windbg_map_get(RDebug *dbg) {
|
||||
return map_list;
|
||||
}
|
||||
|
||||
static int windbg_attach(RDebug *dbg, int pid) {
|
||||
static bool windbg_attach(RDebug *dbg, int pid) {
|
||||
ULONG Id = 0;
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, -1);
|
||||
@ -481,12 +481,12 @@ static int windbg_attach(RDebug *dbg, int pid) {
|
||||
}
|
||||
}
|
||||
if (SUCCEEDED (ITHISCALL (dbgClient, AttachProcess, idbg->server, pid, DEBUG_ATTACH_DEFAULT))) {
|
||||
return windbg_wait (dbg, pid);
|
||||
return windbg_wait (dbg, pid) != R_DEBUG_REASON_ERROR;
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int windbg_detach(RDebug *dbg, int pid) {
|
||||
static bool windbg_detach(RDebug *dbg, int pid) {
|
||||
DbgEngContext *idbg = dbg->user;
|
||||
r_return_val_if_fail (idbg && idbg->initialized, 0);
|
||||
return SUCCEEDED (ITHISCALL (dbgClient, DetachProcesses));
|
||||
|
@ -231,7 +231,7 @@ static prstatus_t *linux_get_prstatus(RDebug *dbg, int pid, int tid, proc_conten
|
||||
p->pr_cstime.tv_usec = (proc_data->per_thread->cstime % 1000) / 1000;
|
||||
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETREGS, tid, NULL, ®s) < 0) {
|
||||
perror ("PTRACE_GETREGS");
|
||||
r_sys_perror ("PTRACE_GETREGS");
|
||||
R_FREE (proc_data->per_thread);
|
||||
free (p);
|
||||
return NULL;
|
||||
@ -245,7 +245,7 @@ static elf_fpregset_t *linux_get_fp_regset(RDebug *dbg, int pid) {
|
||||
elf_fpregset_t *p = R_NEW0 (elf_fpregset_t);
|
||||
if (p) {
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETFPREGS, pid, NULL, p) < 0) {
|
||||
perror ("PTRACE_GETFPREGS");
|
||||
r_sys_perror ("PTRACE_GETFPREGS");
|
||||
free (p);
|
||||
return NULL;
|
||||
}
|
||||
@ -261,7 +261,7 @@ static siginfo_t *linux_get_siginfo(RDebug *dbg, int pid) {
|
||||
}
|
||||
int ret = r_debug_ptrace (dbg, PTRACE_GETSIGINFO, pid, 0, (r_ptrace_data_t)(size_t)siginfo);
|
||||
if (ret == -1 || !siginfo->si_signo) {
|
||||
perror ("PTRACE_GETSIGINFO");
|
||||
r_sys_perror ("PTRACE_GETSIGINFO");
|
||||
free (siginfo);
|
||||
return NULL;
|
||||
}
|
||||
@ -918,7 +918,7 @@ static elf_fpxregset_t *linux_get_fpx_regset(RDebug *dbg, int tid) {
|
||||
transfer.iov_base = fpxregset;
|
||||
transfer.iov_len = sizeof (elf_fpxregset_t);
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETREGSET, tid, (void *)NT_PRXFPREG, &transfer) < 0) {
|
||||
perror ("linux_get_fpx_regset");
|
||||
r_sys_perror ("linux_get_fpx_regset");
|
||||
R_FREE (fpxregset);
|
||||
}
|
||||
}
|
||||
@ -940,7 +940,7 @@ void *linux_get_xsave_data (RDebug *dbg, int tid, ut32 size) {
|
||||
transfer.iov_base = xsave_data;
|
||||
transfer.iov_len = size;
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETREGSET, tid, (void *)NT_X86_XSTATE, &transfer) < 0) {
|
||||
perror ("linux_get_xsave_data");
|
||||
r_sys_perror ("linux_get_xsave_data");
|
||||
free (xsave_data);
|
||||
return NULL;
|
||||
}
|
||||
@ -960,7 +960,7 @@ void *linux_get_arm_vfp_data (RDebug *dbg, int tid) {
|
||||
}
|
||||
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETVFPREGS, tid, 0, vfp_data) < 0) {
|
||||
perror ("linux_get_arm_vfp_data");
|
||||
r_sys_perror ("linux_get_arm_vfp_data");
|
||||
free (vfp_data);
|
||||
return NULL;
|
||||
}
|
||||
@ -1067,7 +1067,7 @@ static int *get_unique_thread_id(RDebug *dbg, int n_threads) {
|
||||
/* The main thread is already being traced */
|
||||
if (th->pid != dbg->pid) {
|
||||
if (r_debug_ptrace (dbg, PTRACE_ATTACH, thread_id[i], 0, 0) < 0) {
|
||||
perror ("Could not attach to thread");
|
||||
r_sys_perror ("Could not attach to thread");
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@ -1085,7 +1085,7 @@ void detach_threads (RDebug *dbg, int *thread_id, int n_threads) {
|
||||
for(i = 0; i < n_threads ; i++) {
|
||||
if (dbg->pid != thread_id[i]) {
|
||||
if (r_debug_ptrace (dbg, PTRACE_DETACH, thread_id[i], 0, 0) < 0) {
|
||||
perror ("PTRACE_DETACH");
|
||||
r_sys_perror ("PTRACE_DETACH");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1350,7 +1350,7 @@ static int get_xsave_size(RDebug *dbg, int pid) {
|
||||
local.iov_base = xstate_hdr;
|
||||
local.iov_len = sizeof (xstate_hdr);
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETREGSET, pid, (void *)NT_X86_XSTATE, &local) < 0) {
|
||||
perror ("NT_X86_XSTATE");
|
||||
r_sys_perror ("NT_X86_XSTATE");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2021 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2022 - pancake */
|
||||
|
||||
#include <r_userconf.h>
|
||||
|
||||
@ -240,7 +240,7 @@ RDebugReasonType linux_ptrace_event (RDebug *dbg, int ptid, int status, bool dow
|
||||
// The new child has a pending SIGSTOP. We can't affect it until it
|
||||
// hits the SIGSTOP, but we're already attached. */
|
||||
if (waitpid ((int)data, &status, 0) == -1) {
|
||||
perror ("waitpid");
|
||||
r_sys_perror ("waitpid");
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ RDebugReasonType linux_ptrace_event (RDebug *dbg, int ptid, int status, bool dow
|
||||
// The new child has a pending SIGSTOP. We can't affect it until it
|
||||
// hits the SIGSTOP, but we're already attached. */
|
||||
if (waitpid (dbg->forked_pid, &status, 0) == -1) {
|
||||
perror ("waitpid");
|
||||
r_sys_perror ("waitpid");
|
||||
}
|
||||
}
|
||||
eprintf ("(%d) Created process %d\n", ptid, (int)data);
|
||||
@ -271,7 +271,7 @@ RDebugReasonType linux_ptrace_event (RDebug *dbg, int ptid, int status, bool dow
|
||||
// breakpoints are inherited from the parent
|
||||
linux_remove_fork_bps (dbg);
|
||||
if (r_debug_ptrace (dbg, PTRACE_DETACH, dbg->forked_pid, NULL, (r_ptrace_data_t)(size_t)NULL) == -1) {
|
||||
perror ("PTRACE_DETACH");
|
||||
r_sys_perror ("PTRACE_DETACH");
|
||||
}
|
||||
}
|
||||
return R_DEBUG_REASON_NEW_PID;
|
||||
@ -349,7 +349,7 @@ int linux_step(RDebug *dbg) {
|
||||
ret = r_debug_ptrace (dbg, PTRACE_SINGLESTEP, pid, 0, 0);
|
||||
//XXX(jjd): why?? //linux_handle_signals (dbg);
|
||||
if (ret == -1) {
|
||||
perror ("native-singlestep");
|
||||
r_sys_perror ("native-singlestep");
|
||||
ret = false;
|
||||
} else {
|
||||
ret = true;
|
||||
@ -392,7 +392,7 @@ static void linux_detach_all(RDebug *dbg) {
|
||||
r_list_foreach (th_list, it, th) {
|
||||
if (th->pid != dbg->main_pid) {
|
||||
if (r_debug_ptrace (dbg, PTRACE_DETACH, th->pid, NULL, (r_ptrace_data_t)(size_t)NULL) == -1) {
|
||||
perror ("PTRACE_DETACH");
|
||||
r_sys_perror ("PTRACE_DETACH");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -400,7 +400,7 @@ static void linux_detach_all(RDebug *dbg) {
|
||||
|
||||
// Detaching from main proc
|
||||
if (r_debug_ptrace (dbg, PTRACE_DETACH, dbg->main_pid, NULL, (r_ptrace_data_t)(size_t)NULL) == -1) {
|
||||
perror ("PTRACE_DETACH");
|
||||
r_sys_perror ("PTRACE_DETACH");
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ RDebugReasonType linux_dbg_wait(RDebug *dbg, int pid) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
perror ("waitpid");
|
||||
r_sys_perror ("waitpid");
|
||||
break;
|
||||
} else if (ret == 0) {
|
||||
// Unset WNOHANG to call next waitpid in blocking mode.
|
||||
@ -607,7 +607,7 @@ static bool linux_kill_thread(int tid, int signo) {
|
||||
int ret = syscall (__NR_tkill, tid, signo);
|
||||
|
||||
if (ret == -1) {
|
||||
perror ("tkill");
|
||||
r_sys_perror ("tkill");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -627,7 +627,7 @@ static bool linux_stop_thread(RDebug *dbg, int tid) {
|
||||
|
||||
if (linux_kill_thread (tid, SIGSTOP)) {
|
||||
if ((ret = waitpid (tid, &status, 0)) == -1) {
|
||||
perror ("waitpid");
|
||||
r_sys_perror ("waitpid");
|
||||
}
|
||||
return ret == tid;
|
||||
}
|
||||
@ -664,7 +664,7 @@ static bool linux_attach_single_pid(RDebug *dbg, int pid) {
|
||||
if (r_debug_ptrace (dbg, PTRACE_GETSIGINFO, pid, NULL,
|
||||
(r_ptrace_data_t)&sig) == -1) {
|
||||
if (r_debug_ptrace (dbg, PTRACE_ATTACH, pid, NULL, NULL) == -1) {
|
||||
perror ("ptrace (PT_ATTACH)");
|
||||
r_sys_perror ("ptrace (PT_ATTACH)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ static int set_mod_inf(HANDLE h_proc, RDebugMap *map, RWinModInfo *mod) {
|
||||
memcpy (mod->sect_hdr, sect_hdr, sizeof (IMAGE_SECTION_HEADER) * mod->sect_count);
|
||||
mod_inf_fill = 0;
|
||||
} else {
|
||||
perror ("malloc set_mod_inf()");
|
||||
r_sys_perror ("malloc set_mod_inf()");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ static void proc_mem_img(HANDLE h_proc, RList *map_list, RList *mod_list, RWinMo
|
||||
if (sect_found) {
|
||||
char *map_name = r_str_newf ("%s | %.8s", mod->map->name, sect_hdr->Name);
|
||||
if (!map_name) {
|
||||
perror ("r_str_newf");
|
||||
r_sys_perror ("r_str_newf");
|
||||
return;
|
||||
}
|
||||
if (sect_found == 1) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2021 - pancake, xvilka, gustavo */
|
||||
/* radare - LGPL - Copyright 2010-2022 - pancake, xvilka, gustavo */
|
||||
|
||||
#include "w32.h"
|
||||
|
||||
@ -812,7 +812,7 @@ static void w32_info_user(RDebug *dbg, RDebugInfo *rdi) {
|
||||
}
|
||||
tok_usr = (PTOKEN_USER)malloc (tok_len);
|
||||
if (!tok_usr) {
|
||||
perror ("w32_info_user/malloc tok_usr");
|
||||
r_sys_perror ("w32_info_user/malloc tok_usr");
|
||||
goto err_w32_info_user;
|
||||
}
|
||||
if (!GetTokenInformation (h_tok, TokenUser, (LPVOID)tok_usr, tok_len, &tok_len)) {
|
||||
@ -821,13 +821,13 @@ static void w32_info_user(RDebug *dbg, RDebugInfo *rdi) {
|
||||
}
|
||||
usr = (LPTSTR)malloc (usr_len);
|
||||
if (!usr) {
|
||||
perror ("w32_info_user/malloc usr");
|
||||
r_sys_perror ("w32_info_user/malloc usr");
|
||||
goto err_w32_info_user;
|
||||
}
|
||||
*usr = '\0';
|
||||
usr_dom = (LPTSTR)malloc (usr_dom_len);
|
||||
if (!usr_dom) {
|
||||
perror ("w32_info_user/malloc usr_dom");
|
||||
r_sys_perror ("w32_info_user/malloc usr_dom");
|
||||
goto err_w32_info_user;
|
||||
}
|
||||
*usr_dom = '\0';
|
||||
@ -860,7 +860,7 @@ static void w32_info_exe(RDebug *dbg, RDebugInfo *rdi) {
|
||||
}
|
||||
LPTSTR path = (LPTSTR)malloc (MAX_PATH + 1);
|
||||
if (!path) {
|
||||
perror ("w32_info_exe/malloc path");
|
||||
r_sys_perror ("w32_info_exe/malloc path");
|
||||
goto err_w32_info_exe;
|
||||
}
|
||||
DWORD len = MAX_PATH;
|
||||
|
@ -1185,7 +1185,7 @@ static void __w32_info_user(RDebug *dbg, RDebugInfo *rdi) {
|
||||
}
|
||||
tok_usr = (PTOKEN_USER)malloc (tok_len);
|
||||
if (!tok_usr) {
|
||||
perror ("__w32_info_user/malloc tok_usr");
|
||||
r_sys_perror ("__w32_info_user/malloc tok_usr");
|
||||
goto err___w32_info_user;
|
||||
}
|
||||
if (!GetTokenInformation (h_tok, TokenUser, (LPVOID)tok_usr, tok_len, &tok_len)) {
|
||||
@ -1194,13 +1194,13 @@ static void __w32_info_user(RDebug *dbg, RDebugInfo *rdi) {
|
||||
}
|
||||
usr = (LPTSTR)calloc (usr_len, sizeof (TCHAR));
|
||||
if (!usr) {
|
||||
perror ("__w32_info_user/malloc usr");
|
||||
r_sys_perror ("__w32_info_user/malloc usr");
|
||||
goto err___w32_info_user;
|
||||
}
|
||||
*usr = '\0';
|
||||
usr_dom = (LPTSTR)calloc (usr_dom_len, sizeof (TCHAR));
|
||||
if (!usr_dom) {
|
||||
perror ("__w32_info_user/malloc usr_dom");
|
||||
r_sys_perror ("__w32_info_user/malloc usr_dom");
|
||||
goto err___w32_info_user;
|
||||
}
|
||||
*usr_dom = '\0';
|
||||
|
@ -10,7 +10,7 @@ static bool ios_hwstep_enable64(RDebug *dbg, bool enable) {
|
||||
|
||||
mach_msg_type_number_t count = ARM_DEBUG_STATE64_COUNT;
|
||||
if (thread_get_state (th, ARM_DEBUG_STATE64, (thread_state_t)&ds, &count)) {
|
||||
perror ("thread-get-state");
|
||||
r_sys_perror ("thread-get-state");
|
||||
return false;
|
||||
}
|
||||
// The use of __arm64__ here is not ideal. If debugserver is running on
|
||||
@ -25,7 +25,7 @@ static bool ios_hwstep_enable64(RDebug *dbg, bool enable) {
|
||||
ds.mdscr_el1 &= ~(1ULL);
|
||||
}
|
||||
if (thread_set_state (th, ARM_DEBUG_STATE64, (thread_state_t)&ds, count)) {
|
||||
perror ("thread-set-state");
|
||||
r_sys_perror ("thread-set-state");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -41,13 +41,13 @@ static bool ios_hwstep_enable32(RDebug *dbg, bool enable) {
|
||||
count = ARM_DEBUG_STATE32_COUNT;
|
||||
ret = thread_get_state (th, ARM_DEBUG_STATE32, (thread_state_t)&ds, &count);
|
||||
if (ret != KERN_SUCCESS) {
|
||||
perror ("thread_get_state(debug)");
|
||||
r_sys_perror ("thread_get_state(debug)");
|
||||
}
|
||||
|
||||
count = ARM_UNIFIED_THREAD_STATE_COUNT;
|
||||
ret = thread_get_state (th, ARM_UNIFIED_THREAD_STATE, (thread_state_t)&state, &count);
|
||||
if (ret != KERN_SUCCESS) {
|
||||
perror ("thread_get_state(unified)");
|
||||
r_sys_perror ("thread_get_state(unified)");
|
||||
}
|
||||
//eprintf ("PC = 0x%08x\n", state.ts_32.__pc);
|
||||
if (enable) {
|
||||
@ -80,7 +80,7 @@ static bool ios_hwstep_enable32(RDebug *dbg, bool enable) {
|
||||
}
|
||||
}
|
||||
if (thread_set_state (th, ARM_DEBUG_STATE32, (thread_state_t)&ds, ARM_DEBUG_STATE32_COUNT)) {
|
||||
perror ("ios_hwstep_enable32");
|
||||
r_sys_perror ("ios_hwstep_enable32");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -171,7 +171,7 @@ bool xnu_step(RDebug *dbg) {
|
||||
#if XNU_USE_PTRACE
|
||||
int ret = r_debug_ptrace (dbg, PT_STEP, dbg->pid, (caddr_t)1, 0) == 0; //SIGINT
|
||||
if (!ret) {
|
||||
perror ("ptrace-step");
|
||||
r_sys_perror ("ptrace-step");
|
||||
eprintf ("mach-error: %d, %s\n", ret, MACH_ERROR_STRING (ret));
|
||||
}
|
||||
return ret;
|
||||
@ -205,7 +205,7 @@ bool xnu_attach(RDebug *dbg, int pid) {
|
||||
# define MY_ATTACH PT_ATTACH
|
||||
# endif
|
||||
if (r_debug_ptrace (dbg, MY_ATTACH, pid, 0, 0) == -1) {
|
||||
perror ("ptrace (PT_ATTACH)");
|
||||
r_sys_perror ("ptrace (PT_ATTACH)");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
@ -446,7 +446,7 @@ int xnu_map_dealloc (RDebug *dbg, ut64 addr, int size) {
|
||||
}
|
||||
int ret = vm_deallocate (th->port, (vm_address_t)addr, (vm_size_t)size);
|
||||
if (ret != KERN_SUCCESS) {
|
||||
perror ("vm_deallocate");
|
||||
r_sys_perror ("vm_deallocate");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -459,7 +459,7 @@ static int xnu_get_kinfo_proc(int pid, struct kinfo_proc *kp) {
|
||||
|
||||
mib[3] = pid;
|
||||
if (sysctl (mib, len, kp, &kpl, NULL, 0) == -1) {
|
||||
perror ("sysctl");
|
||||
r_sys_perror ("sysctl");
|
||||
return -1;
|
||||
}
|
||||
if (kpl < 1) {
|
||||
@ -566,7 +566,7 @@ int xnu_map_protect (RDebug *dbg, ut64 addr, int size, int perms) {
|
||||
int xnu_perms = xwr2rwx (perms);
|
||||
ret = mach_vm_protect (task, (vm_address_t)addr, (vm_size_t)size, (boolean_t)0, xnu_perms); //VM_PROT_COPY | perms);
|
||||
if (ret != KERN_SUCCESS) {
|
||||
perror ("vm_protect");
|
||||
r_sys_perror ("vm_protect");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -682,12 +682,12 @@ static cpu_type_t xnu_get_cpu_type(pid_t pid) {
|
||||
size_t cpu_type_len = sizeof (cpu_type_t);
|
||||
|
||||
if (sysctlnametomib ("sysctl.proc_cputype", mib, &len) == -1) {
|
||||
perror ("sysctlnametomib");
|
||||
r_sys_perror ("sysctlnametomib");
|
||||
return -1;
|
||||
}
|
||||
mib[len++] = pid;
|
||||
if (sysctl (mib, len, &cpu_type, &cpu_type_len, NULL, 0) == -1) {
|
||||
perror ("sysctl");
|
||||
r_sys_perror ("sysctl");
|
||||
return -1;
|
||||
}
|
||||
if (cpu_type_len > 0) return cpu_type;
|
||||
@ -739,7 +739,7 @@ static int xnu_dealloc_threads(RList *threads) {
|
||||
|
||||
kr = task_threads (task_dbg, &thread_list, &thread_count);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
perror ("task_threads");
|
||||
r_sys_perror ("task_threads");
|
||||
} else {
|
||||
r_list_foreach_safe (threads, iter, iter2, thread) {
|
||||
mach_port_deallocate (mach_task_self (), thread->port);
|
||||
@ -977,7 +977,7 @@ bool xnu_generate_corefile (RDebug *dbg, RBuffer *dest) {
|
||||
r_list_length (threads_list), command_size, dbg->pid);
|
||||
|
||||
if (!dbg->maps) {
|
||||
perror ("There are not loaded maps");
|
||||
r_sys_perror ("There are not loaded maps");
|
||||
}
|
||||
if (xnu_write_mem_maps_to_buffer (mem_maps_buffer, dbg->maps, round_page (header_size),
|
||||
header, mach_header_sz, segment_command_sz, &hoffset) < 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2019 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2022 - pancake */
|
||||
|
||||
#include <r_userconf.h>
|
||||
#if DEBUGGER
|
||||
@ -60,7 +60,7 @@ static bool xnu_thread_get_drx(RDebug *dbg, xnu_thread_t *thread) {
|
||||
rc = KERN_FAILURE;
|
||||
#endif
|
||||
if (rc != KERN_SUCCESS) {
|
||||
perror (__FUNCTION__);
|
||||
r_sys_perror (__FUNCTION__);
|
||||
thread->count = 0;
|
||||
return false;
|
||||
}
|
||||
@ -120,7 +120,7 @@ static bool xnu_thread_set_drx(RDebug *dbg, xnu_thread_t *thread) {
|
||||
thread->count = 0;
|
||||
#endif
|
||||
if (rc != KERN_SUCCESS) {
|
||||
perror (__FUNCTION__);
|
||||
r_sys_perror (__FUNCTION__);
|
||||
thread->count = 0;
|
||||
return false;
|
||||
}
|
||||
@ -174,7 +174,7 @@ static bool xnu_thread_set_gpr(RDebug *dbg, xnu_thread_t *thread) {
|
||||
rc = thread_set_state (thread->port, thread->flavor,
|
||||
(thread_state_t)regs, thread->count);
|
||||
if (rc != KERN_SUCCESS) {
|
||||
perror (__FUNCTION__);
|
||||
r_sys_perror (__FUNCTION__);
|
||||
thread->count = 0;
|
||||
return false;
|
||||
}
|
||||
@ -218,7 +218,7 @@ static bool xnu_thread_get_gpr(RDebug *dbg, xnu_thread_t *thread) {
|
||||
rc = thread_get_state (thread->port, thread->flavor,
|
||||
(thread_state_t)regs, &thread->count);
|
||||
if (rc != KERN_SUCCESS) {
|
||||
perror (__FUNCTION__);
|
||||
r_sys_perror (__FUNCTION__);
|
||||
thread->count = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ static void handle_posix_error(int err) {
|
||||
break;
|
||||
default:
|
||||
eprintf ("posix_spawnp: unknown error %d\n", err);
|
||||
perror ("posix_spawnp");
|
||||
r_sys_perror ("posix_spawnp");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -398,12 +398,12 @@ static int fork_and_ptraceme_for_unix(RIO *io, int bits, const char *cmd) {
|
||||
child_data.cmd = cmd;
|
||||
child_pid = r_io_ptrace_fork (io, fork_child_callback, &child_data);
|
||||
if (child_pid == -1 || child_pid == 0) {
|
||||
perror ("fork_and_ptraceme");
|
||||
r_sys_perror ("fork_and_ptraceme");
|
||||
return -1;
|
||||
} do {
|
||||
ret = waitpid (child_pid, &status, WNOHANG);
|
||||
if (ret == -1) {
|
||||
perror ("waitpid");
|
||||
r_sys_perror ("waitpid");
|
||||
return -1;
|
||||
}
|
||||
bed = r_cons_sleep_begin ();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2021 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2022 - pancake */
|
||||
|
||||
#include <r_userconf.h>
|
||||
|
||||
@ -309,7 +309,7 @@ static bool tsk_setperm(RIO *io, task_t task, vm_address_t addr, int len, int pe
|
||||
kern_return_t kr;
|
||||
kr = vm_protect (task, addr, len, 0, perm);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
perror ("tsk_setperm");
|
||||
r_sys_perror ("tsk_setperm");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -411,7 +411,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
eprintf ("Operation not permitted\n");
|
||||
break;
|
||||
case EINVAL:
|
||||
perror ("ptrace: Cannot attach");
|
||||
r_sys_perror ("ptrace: Cannot attach");
|
||||
eprintf ("Possibly unsigned r2. Please see doc/macos.md\n");
|
||||
eprintf ("ERRNO: %d (EINVAL)\n", errno);
|
||||
break;
|
||||
@ -478,14 +478,15 @@ static bool __close(RIODesc *fd) {
|
||||
task_t task = pid_to_task (fd, iodd->pid);
|
||||
kern_return_t kr = mach_port_deallocate (mach_task_self (), task);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
perror ("__close io_mach");
|
||||
r_sys_perror ("__close io_mach");
|
||||
}
|
||||
R_FREE (fd->data);
|
||||
return kr == KERN_SUCCESS;
|
||||
}
|
||||
|
||||
static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
if (!io || !fd || !cmd || !fd->data) {
|
||||
r_return_val_if_fail (io && fd, NULL);
|
||||
if (!cmd || !fd->data) {
|
||||
return NULL;
|
||||
}
|
||||
RIOMachData *iodd = fd->data;
|
||||
|
@ -67,7 +67,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
eprintf ("Operation not permitted\n");
|
||||
break;
|
||||
case EINVAL:
|
||||
perror ("ptrace: Cannot attach");
|
||||
r_sys_perror ("ptrace: Cannot attach");
|
||||
eprintf ("ERRNO: %d (EINVAL)\n", errno);
|
||||
break;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
eprintf ("ptrace_attach: Operation not permitted\n");
|
||||
break;
|
||||
case EINVAL:
|
||||
perror ("ptrace: Cannot attach");
|
||||
r_sys_perror ("ptrace: Cannot attach");
|
||||
eprintf ("ERRNO: %d (EINVAL)\n", errno);
|
||||
break;
|
||||
default:
|
||||
|
@ -156,7 +156,7 @@ static bool lang_pipe_run(RLang *lang, const char *code, int len) {
|
||||
child = r_sys_fork ();
|
||||
if (child == -1) {
|
||||
/* error */
|
||||
perror ("pipe run");
|
||||
r_sys_perror ("pipe run");
|
||||
} else if (!child) {
|
||||
/* children */
|
||||
r_sandbox_system (code, 1);
|
||||
|
@ -657,7 +657,7 @@ static int apprentice_load(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, c
|
||||
if (stat (subfn, &st) == 0 && S_ISREG (st.st_mode)) {
|
||||
load_1 (ms, action, subfn, &errs, &marray, &marraycount);
|
||||
}
|
||||
//else perror (subfn);
|
||||
//else r_sys_perror (subfn);
|
||||
}
|
||||
closedir (dir);
|
||||
} else {
|
||||
|
@ -158,7 +158,7 @@ R_API int r_main_r2agent(int argc, const char **argv) {
|
||||
char *cmd;
|
||||
|
||||
if (!(cmd = malloc (cmd_len))) {
|
||||
perror ("malloc");
|
||||
r_sys_perror ("malloc");
|
||||
return 1;
|
||||
}
|
||||
snprintf (cmd, cmd_len, "r2 -q %s-e http.port=%d -c=h \"%s\"",
|
||||
@ -171,7 +171,7 @@ R_API int r_main_r2agent(int argc, const char **argv) {
|
||||
free (escaped_filename);
|
||||
result = result_heap = malloc (1024 + escaped_len);
|
||||
if (!result) {
|
||||
perror ("malloc");
|
||||
r_sys_perror ("malloc");
|
||||
free (pfile);
|
||||
r_list_free (so.authtokens);
|
||||
return 1;
|
||||
|
@ -323,7 +323,7 @@ R_API R2Pipe *r2pipe_open(const char *cmd) {
|
||||
R_API char *r2pipe_cmd(R2Pipe *r2p, const char *str) {
|
||||
r_return_val_if_fail (r2p && str, NULL);
|
||||
if (!*str || !r2pipe_write (r2p, str)) {
|
||||
perror ("r2pipe_write");
|
||||
r_sys_perror ("r2pipe_write");
|
||||
return NULL;
|
||||
}
|
||||
return r2pipe_read (r2p);
|
||||
|
@ -698,7 +698,7 @@ static int fd_forward(int in_fd, int out_fd, char **buff) {
|
||||
int size = 0;
|
||||
|
||||
if (ioctl (in_fd, FIONREAD, &size) == -1) {
|
||||
perror ("ioctl");
|
||||
r_sys_perror ("ioctl");
|
||||
return -1;
|
||||
}
|
||||
if (!size) { // child process exited or socket is closed
|
||||
@ -712,11 +712,11 @@ static int fd_forward(int in_fd, int out_fd, char **buff) {
|
||||
}
|
||||
*buff = new_buff;
|
||||
if (read (in_fd, *buff, size) != size) {
|
||||
perror ("read");
|
||||
r_sys_perror ("read");
|
||||
return -1;
|
||||
}
|
||||
if (write (out_fd, *buff, size) != size) {
|
||||
perror ("write");
|
||||
r_sys_perror ("write");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -750,7 +750,7 @@ static int redirect_socket_to_pty(RSocket *sock) {
|
||||
int fdm = -1, fds = -1;
|
||||
|
||||
if (dyn_openpty && dyn_openpty (&fdm, &fds, NULL, NULL, NULL) == -1) {
|
||||
perror ("opening pty");
|
||||
r_sys_perror ("opening pty");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -782,7 +782,7 @@ static int redirect_socket_to_pty(RSocket *sock) {
|
||||
FD_SET (sockfd, &readfds);
|
||||
|
||||
if (select (max_fd + 1, &readfds, NULL, NULL, NULL) == -1) {
|
||||
perror ("select error");
|
||||
r_sys_perror ("select error");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1171,7 +1171,7 @@ R_API int r_run_start(RRunProfile *p) {
|
||||
break;
|
||||
default:
|
||||
eprintf ("posix_spawnp: unknown error %d\n", ret);
|
||||
perror ("posix_spawnp");
|
||||
r_sys_perror ("posix_spawnp");
|
||||
break;
|
||||
}
|
||||
exit (ret);
|
||||
@ -1188,7 +1188,7 @@ R_API int r_run_start(RRunProfile *p) {
|
||||
#else
|
||||
pid_t child = r_sys_fork ();
|
||||
if (child == -1) {
|
||||
perror ("fork");
|
||||
r_sys_perror ("fork");
|
||||
exit (1);
|
||||
}
|
||||
if (child) {
|
||||
@ -1306,7 +1306,7 @@ R_API int r_run_start(RRunProfile *p) {
|
||||
#else
|
||||
pid_t child = r_sys_fork ();
|
||||
if (child == -1) {
|
||||
perror ("fork");
|
||||
r_sys_perror ("fork");
|
||||
exit (1);
|
||||
}
|
||||
if (child) {
|
||||
|
@ -113,7 +113,7 @@ R_API bool r_socket_is_connected(RSocket *s) {
|
||||
socklen_t len = sizeof (error);
|
||||
int ret = getsockopt (s->fd, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||
if (ret != 0) {
|
||||
perror ("getsockopt");
|
||||
r_sys_perror ("getsockopt");
|
||||
return false;
|
||||
}
|
||||
return (error == 0);
|
||||
@ -358,7 +358,7 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int
|
||||
|
||||
s->fd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||
if (s->fd == -1) {
|
||||
perror ("socket");
|
||||
r_sys_perror ("socket");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int
|
||||
case R_SOCKET_PROTO_TCP:
|
||||
ret = setsockopt (s->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof (flag));
|
||||
if (ret < 0) {
|
||||
perror ("setsockopt");
|
||||
r_sys_perror ("setsockopt");
|
||||
close (s->fd);
|
||||
s->fd = -1;
|
||||
continue;
|
||||
@ -416,7 +416,7 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int
|
||||
goto success;
|
||||
}
|
||||
} else {
|
||||
perror ("connect");
|
||||
r_sys_perror ("connect");
|
||||
}
|
||||
}
|
||||
r_socket_close (s);
|
||||
@ -703,7 +703,7 @@ R_API RSocket *r_socket_accept_timeout(RSocket *s, unsigned int timeout) {
|
||||
|
||||
int r = select (s->fd + 1, &read_fds, NULL, &except_fds, &t);
|
||||
if(r < 0) {
|
||||
perror ("select");
|
||||
r_sys_perror ("select");
|
||||
} else if (r > 0 && FD_ISSET (s->fd, &read_fds)) {
|
||||
return r_socket_accept (s);
|
||||
}
|
||||
@ -780,7 +780,7 @@ R_API char *r_socket_to_string(RSocket *s) {
|
||||
a[0], a[1], a[2], a[3], ntohs (sain->sin_port));
|
||||
}
|
||||
} else {
|
||||
eprintf ("getperrname: failed\n"); //r_sys_perror ("getpeername");
|
||||
r_sys_perror ("getpeername");
|
||||
}
|
||||
return str;
|
||||
#else
|
||||
|
@ -27,7 +27,7 @@ R_API struct r_socket_proc_t *r_socket_proc_open(char* const argv[]) {
|
||||
}
|
||||
|
||||
if (pipe (sp->fd0)==-1) {
|
||||
perror ("pipe");
|
||||
r_sys_perror ("pipe");
|
||||
goto error;
|
||||
}
|
||||
if (fcntl (sp->fd0[0], flags) < 0) {
|
||||
@ -38,7 +38,7 @@ R_API struct r_socket_proc_t *r_socket_proc_open(char* const argv[]) {
|
||||
}
|
||||
|
||||
if (pipe (sp->fd1)==-1) {
|
||||
perror ("pipe");
|
||||
r_sys_perror ("pipe");
|
||||
goto error;
|
||||
}
|
||||
if (fcntl (sp->fd1[0], flags) < 0) {
|
||||
@ -59,7 +59,7 @@ R_API struct r_socket_proc_t *r_socket_proc_open(char* const argv[]) {
|
||||
exit (1);
|
||||
break;
|
||||
case -1:
|
||||
perror ("fork");
|
||||
r_sys_perror ("fork");
|
||||
r_socket_proc_close (sp);
|
||||
goto error;
|
||||
//r_socket_block_time (sp, false, 0);
|
||||
|
@ -295,7 +295,7 @@ R_API int r_sandbox_system(const char *x, int n) {
|
||||
#endif
|
||||
char *bin_sh = r_file_binsh ();
|
||||
if (execl (bin_sh, "sh", "-c", x, (const char*)NULL) == -1) {
|
||||
perror ("execl");
|
||||
r_sys_perror ("execl");
|
||||
}
|
||||
free (bin_sh);
|
||||
exit (1);
|
||||
|
@ -1246,7 +1246,7 @@ R_API char *r_sys_whoami(void) {
|
||||
#if __WINDOWS__
|
||||
char buf[256];
|
||||
DWORD buf_sz = sizeof (buf);
|
||||
if (!GetUserName ((LPWSTR)buf, (LPDWORD)&buf_sz) ) {
|
||||
if (!GetUserName ((LPSTR)buf, (LPDWORD)&buf_sz) ) {
|
||||
return strdup ("?");
|
||||
}
|
||||
return strdup (buf);
|
||||
@ -1274,7 +1274,7 @@ R_API int r_sys_uid(void) {
|
||||
char buf[32];
|
||||
DWORD buf_sz = sizeof (buf);
|
||||
// TODO
|
||||
if (!GetUserName ((LPWSTR)buf, (LPDWORD)&buf_sz) ) {
|
||||
if (!GetUserName ((LPSTR)buf, (LPDWORD)&buf_sz) ) {
|
||||
return 1; //
|
||||
}
|
||||
return 0;
|
||||
|
@ -48,7 +48,6 @@ bool bochs_cmd_stop(libbochs_t * b) {
|
||||
#if __WINDOWS__
|
||||
HMODULE hKernel;
|
||||
unsigned int ExitCode;
|
||||
DWORD apiOffset = 0;
|
||||
char buffer[] = {
|
||||
0x68, 0x00, 0x00, 0x00, 0x00, //push 0
|
||||
0x68, 0x00, 0x00, 0x00, 0x00, //push 0
|
||||
@ -60,7 +59,7 @@ bool bochs_cmd_stop(libbochs_t * b) {
|
||||
0xeb, 0xfe //jmp $
|
||||
};
|
||||
hKernel = GetModuleHandle (TEXT ("kernel32"));
|
||||
apiOffset = (DWORD)GetProcAddress (hKernel, "GenerateConsoleCtrlEvent");
|
||||
FARPROC apiOffset = (FARPROC)GetProcAddress (hKernel, "GenerateConsoleCtrlEvent");
|
||||
*((DWORD *)&buffer[20]) = apiOffset;
|
||||
ExitCode = RunRemoteThread_(b, (const ut8*)&buffer, 0x1Eu, 0, &ExitCode) && ExitCode;
|
||||
return ExitCode;
|
||||
|
Loading…
Reference in New Issue
Block a user