Advertisement
Guest User

Untitled

a guest
Mar 28th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <signal.h>
  2. #include <sys/types.h>
  3. #include <ucontext.h>
  4. #include <stdio.h>
  5. #include <unistd.h>
  6.  
  7. void handler (int sig, siginfo_t *si, ucontext_t *ctx)
  8. {
  9.     stack_t st = ctx->uc_stack;
  10.     size_t *retp = ctx->uc_mcontext.mc_rsp;
  11.     printf ("%p\n", ctx->uc_mcontext.mc_rip);
  12.     int i;
  13.     for (i=0; i<30; i++)
  14.     {
  15.         printf ("%p\n", *(retp+i));
  16.     }
  17. }
  18.  
  19. void lol () {kill (getpid(), SIGINT);}
  20.  
  21. int main()
  22. {
  23.     printf ("%i\n", sizeof (size_t));
  24.     struct sigaction sa;
  25.     sigemptyset (&sa.sa_mask);
  26.     sa.sa_flags = SA_RESETHAND | SA_SIGINFO;
  27.     sa.sa_sigaction = handler;
  28.     sigaction (SIGINT, &sa, NULL);
  29.  
  30.     lol();
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement