I was wondering if it's possible to run direct machine code using inline assembly.
#include <iostream>
void code() {
__asm (
".byte 0xB8, 0x01, 0x00, 0x00, 0x00" // mov eax,0x1
);
}
int main() {
code();
return 0;
}
This code works fine but the problem is, I need to input the machine code as a string like this but it doesn't work.
std::string code = ".byte 0xB8, 0x0C, 0x00, 0x00, 0x00";
__asm (
code
);
What am I doing wrong? Is this even possible? Thanks in advance.