typedef int (*FuncPtr)(); // Create a function: char testFunc[] = { 0x90, // NOP (not really necessary...) 0xB8, 0x10, 0x00, 0x00, 0x00, // MOVL $16,%eax 0xC3 }; // RET int main () { // Make a copy on the heap, OS doesn't like executing the stack: FuncPtr testFuncPtr = (FuncPtr) malloc(7); memmove( (void*) testFuncPtr, testFunc, 7 ); printf("Before function.\n"); int result = (*testFuncPtr)(); printf("Result %d\n", result); system("PAUSE"); return 0; }