executing code on the stack - works Revision 376564326131 (Sun Jun 18 2017 at 21:07) - Diff Link to this snippet: https://friendpaste.com/2B2NA1UyI8TDn0wXXCXEGH Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 12345678910111213141516171819202122232425262728293031323334353637383940#include <iostream>#include <cstdio>using namespace std;void tFunc(int (*_printf)(const char*,...)){ _printf("You got here!");}int main(int argc, char* argv[]){ unsigned int fsize; unsigned int mv, tv; mv = reinterpret_cast<unsigned int>(main); tv = reinterpret_cast<unsigned int>(tFunc); fsize = mv - tv; int (*_printf)(const char*, ...); void (*_tFunc)(int (*)(const char*, ...)); _printf = printf; unsigned char buff[256]; unsigned char* cpy = (unsigned char*) tFunc; for(unsigned int i = 0; i < fsize; i++) { buff[i] = cpy[i]; } _tFunc = (void(*)(int(*)(const char*, ...))) buff; _tFunc(_printf); //tFunc(_printf); return 0;}