int main(int argc, char **argv)
{
int (*func)();
func = (int (*)()) code;
(int)(*func)();
}
the variable code has some shellcode in it
int main(int argc, char **argv)
{
int (*func)();
func = (int (*)()) code;
(int)(*func)();
}
the variable code has some shellcode in it
Function pointers. This code snippet should help you understand.
#include <stdio.h>
int Hello();
int code();
int main(int argc, char **argv)
{
int (*func)(); //pointer to function that takes no arguments quivalent to: int (*func)(void);
func =&Hello;
int x = func();
printf("%d\n", x);
func = (int (*)()) code; // Assigns the pointer from the code function to the func pointer
x = code();
printf("%d", x);
}
int code()
{
printf("code returns: ");
return 500;
}
int Hello()
{
printf("hello returns: ");
return 1;
}
code
probably is a variable that correspond to the address of some machine code in memory. Then a pointer to function that takes no parameter and returns an int is set to that address and the function is called. int f()
is the prototype for a function with no param and int as return value, then int (*pf)()
is a pointer to such a function.