Yes, this is a test.
This only works on 64bit, replace 8 with 4 for 32bit.
Code:#include <stdio.h> #include <string.h> int main() { void *old_sp, *p = main; printf("int main()\n"); asm("mov %0, rsp#" : "m="(old_sp)); old_sp -= 8; memcpy(old_sp, &p, sizeof(p)); printf("after memcpy"); return 0; }