tags:

views:

104

answers:

2

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");
}
A: 

Thanks. I can run now with gcc.

Do not know why g++ compiling get error

To add additional information to your question, simply edit your question, rather than 'answering' your question with more information.That is, unless, you really have figured out the answer to your own question and wish to answer it.
Tim Post
+1  A: 

Just fyi. Check the man setjmp and man longjmp.

Dummy00001