Revision 376564326131 () - Diff

Link to this snippet: https://friendpaste.com/2B2NA1UyI8TDn0wXXCXEGH
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#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;
}