a | b | |
---|
| 0 | + | #include <iostream> |
---|
| 0 | + | #include <cstdio> |
---|
| 0 | + | |
---|
| 0 | + | using namespace std; |
---|
| 0 | + | |
---|
| 0 | + | void tFunc(int (*_printf)(const char*,...)) |
---|
| 0 | + | { |
---|
| 0 | + | _printf("You got here!"); |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | int main(int argc, char* argv[]) |
---|
| 0 | + | { |
---|
| 0 | + | unsigned int fsize; |
---|
| 0 | + | |
---|
| 0 | + | unsigned int mv, tv; |
---|
| 0 | + | |
---|
| 0 | + | mv = reinterpret_cast<unsigned int>(main); |
---|
| 0 | + | tv = reinterpret_cast<unsigned int>(tFunc); |
---|
| 0 | + | |
---|
| 0 | + | fsize = mv - tv; |
---|
| 0 | + | |
---|
| 0 | + | int (*_printf)(const char*, ...); |
---|
| 0 | + | void (*_tFunc)(int (*)(const char*, ...)); |
---|
| 0 | + | _printf = printf; |
---|
| 0 | + | |
---|
| 0 | + | unsigned char buff[256]; |
---|
| 0 | + | unsigned char* cpy = (unsigned char*) tFunc; |
---|
| 0 | + | |
---|
| 0 | + | for(unsigned int i = 0; i < fsize; i++) |
---|
| 0 | + | { |
---|
| 0 | + | buff[i] = cpy[i]; |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | _tFunc = (void(*)(int(*)(const char*, ...))) buff; |
---|
| 0 | + | |
---|
| 0 | + | _tFunc(_printf); |
---|
| 0 | + | //tFunc(_printf); |
---|
| 0 | + | |
---|
| 0 | + | return 0; |
---|
| 0 | + | } |
---|
... | |
---|