我在下面编写了代码并包含了asm/ptrace.h
,在linux中使用GCC编译了代码,编译器告诉
'struct pt_regs'没有名为'ARM_sp'的成员
我该怎么做才能解决这个问题?
#include <asm/ptrace.h>
extern struct pt_regs saved_regs;
//...
uint32_t * inject_so_of(pid_t pid,const char *so_path)
{
struct pt_regs regs;
memcpy(®s,&saved_regs,sizeof(regs));
ptrace_readdata(pid,(void *)regs.ARM_sp,(void *)sbuf, sizeof(sbuf));
ptrace_writedata(pid,(void *)regs.ARM_sp,(void *)so_path,strlen(so_path));
uint32_t parameters[2];
parameters[0] = regs.ARM_sp;
parameters[1] = RTLD_NOW;
if(ptrace_call(pid,find_dlopen_addr(pid),parameters,2,®s) == -1)
{
DPRINTF("dlopen_error");
}
ptrace_getregs(pid,®s);
uint32_t r0 = regs.ARM_r0;
DPRINTF("[+2]\t");
ptrace_setregs(pid,&saved_regs);
ptrace_writedata(pid,(uint8_t *)saved_regs.ARM_sp,(uint8_t *) sbuf,sizeof(sbuf));
ptrace_detach(pid);
return (uint32_t *) r0;
}
//...
pt_regs
中asm/ptrace.h
的定义是:
struct pt_regs
{
long uregs[18];
};
#define ARM_cpsr uregs[16]
#define ARM_pc uregs[15]
#define ARM_lr uregs[14]
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ARM_sp uregs[13]
#define ARM_ip uregs[12]
#define ARM_fp uregs[11]
#define ARM_r10 uregs[10]
我收到以下错误:
AndroidInjectSo.c:149:38: error: ‘struct pt_regs’ has no member named ‘ARM_sp’
ptrace_writedata(pid,(void *)regs.ARM_sp,(void *)so_path,strlen(so_path));
^
AndroidInjectSo.c:151:25: error: ‘struct pt_regs’ has no member named ‘ARM_sp’
parameters[0] = regs.ARM_sp;
^
AndroidInjectSo.c:158:23: error: ‘struct pt_regs’ has no member named ‘ARM_r0’
uint32_t r0 = regs.ARM_r0;
^
AndroidInjectSo.c:161:47: error: ‘struct pt_regs’ has no member named ‘ARM_sp’
ptrace_writedata(pid,(uint8_t *)saved_regs.ARM_sp,(uint8_t *) sbuf,sizeof(sbuf));