I'm generating machine code for buffer overflow execution and wanted a quick and easy method to plug the bytecode into a program and see how it runs on my host machine.
I looked for ways to dynamically generate functions in C++ and came across this question with this very interesting answer. It has been upvoted quite a bit and there doesn't seem to be anyone challenging what they said.
However, when trying to implement what they wrote in my own program I get the error "Expression cannot be used as a function".
Here's my code:
int main()
{
uint8_t machinecode[] = {0x90, 0x0F, 0x01};
*reinterpret_cast<void**>(&machinecode)();
return 0;
}