哪里错了?如何为eip赋值以改变程序中运行的位置?
请帮助!!!!
错误:无法在分配中将'mcontext_t *'转换为'sigcontext *'
struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
sigset_t uc_sigmask; /* mask last for extensibility */
};
#include <stdio.h>
#include <signal.h>
#include <asm/ucontext.h>
void handler(int signum, siginfo_t *siginfo, void *uc0){
struct ucontext *uc;
struct sigcontext *sc;
uc = (struct ucontext *)uc0;
sc = &uc->uc_mcontext;
sc->eip = target;
//uc->uc_mcontext.gregs[REG_EIP]
}
int main (int argc, char** argv){
struct sigaction act;
act.sa_sigaction = handler;
act.sa_flags = SA_SIGINFO;
sigaction(SIGTRAP, &act, NULL);
asm("movl $skipped, %0" : : "m" (target));
asm("int3"); // cause SIGTRAP
printf("to be skipped.\n");
asm("skipped:");
printf("Done.\n");
}
答案 0 :(得分:1)
只是fyi。查看man setjmp
和man longjmp
。