Print the return address using a format string

Do I need to print the return address stored on the stack for a function? The format that I have to execute to print it,

void function() 
{
      int *RetPtr = 0;
      printf("Return address 0x%08x\n",
                 (unsigned int *)(&RetPtr+Return_addr_Offset));
      /*Code goes here*/

}

Can anybody help! I should not use the built-in function. How can i do this?

+3
source share
2 answers

It smells of homework if you can't use the built-in features.

In any case, there is nothing magical in that it is a pointer; you just need to print the hex number.

Not knowing what features, if any, you can use. Basically you need to work out eight hexadecimal digits and then output them.

0
source

, Return_addr_Offset. RetPtr , , RetPtr, , , . , , , , .

0

Source: https://habr.com/ru/post/1792964/


All Articles