pthreads - Modifying PC in jmp_buf to go to another function -
I have written this: I am trying to modify the function in jmp_buf by setting the function to that function address for which i try to jump I am getting a division mistake, I am unable to understand what should I do. Can I also revise the SP? Any help would be greatly appreciated.
jmp_buf env; Zero print (zero) {printf ("\ nHello World!"); } Fixed int ptr_mangle (int p) {unsigned int ret; Asm ("movl% 1, %% eax; \ n" "xorl %% gs: 0x18, %% eax;" $ 0x 9 roll, %% eax; "" movl %% eax,% 0; ":" = R "(ret):" r "(p):"% eax "); Return return;} int main () {int i = setjmp (env); env [0] .__ jmpbuf [5] = ptr_mangle Print); long jump (nv, 2); return 0;}
what do you do Trying to do? Are not you checking the return value of setjmp
? I do not think you are doing it correctly. Take a look at the sample code to see that What will be the output:
#include & lt; stdio.h & gt; #include & lt; setjmp.h & gt; # Include & lt; stdlib.h & gt; Zero suburban (jmp_buf) ; Int main (zero) {int value; Jmp_buf jumper; Value = set jumper; If (value! = 0) {printf (long jump, value with "value% d \ n"); Exit (value); } Printf ("About calling subtitles ... \ n"); Subroutine (jumper); Return 0; } Zero suburban (jmp_buf jumper) {longjmp (jumper, 1); }
The output will be: about to call substrin ... Longjmp with the value of 1.
Which question asks - Why are you trying to modify the IP? It looks like you have overwritten a few things or the code 'jump' in the jungle and something is chopped and back with a hard landing. Segfault
variable env
is typically a structure, do not use an array membership as you did. I doubt that this is the reason why you got a sygft ...
Hope it helps, best wishes, Tom.
Comments
Post a Comment