When programming in Win32, one can execute data as follows:
#include <iostream>
using namespace std;
typedef double(*func)(void);
int main()
{
// The sample program to display the PI number
uint8_t code[] = { 0xD9,0xEB,0xC3 }; // fldpi; ret
uint8_t* p = code;
func f = reinterpret_cast<func>(p);
cout << f() << endl;
return 0;
}
This trick allows to speed up some numeric calculations when the expression to calculate is initially unknown.
The only thing you need to do this in Win32 is to disable data execution protection by using the /NXCOMPAT:NO
Visual Studio Option.
But how to do this in Win64? Is this even possible?