how to assign value to EIP with C language in ubuntu
- by user353573
where is wrong? how to assign value to eip to change the location of running in program?
Please help !!!!
error: cannot convert ‘mcontext_t*’ to ‘sigcontext*’ in assignment
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");
}