How would I inline this in C++ function.
0041F84E . 7B 02 JPO SHORT Unmodifi.0041F852
0041F850 B8 DB B8
0041F851 00 DB 00
0041F852 . 8B46 38 MOV EAX,DWORD PTR DS:[ESI+38]
0041F855 . 8B56 24 MOV EDX,DWORD PTR DS:[ESI+24]
0041F858 . 8B4E 10 MOV ECX,DWORD PTR DS:[ESI+10]
0041F85B . 81EA 8B4B8636 SUB EDX,36864B8B
How would I put
DB B8
DB 00
void test() {
__asm {
...
JPO label_0041F852
__emit 0xB8
__emit 00
label_0041F852:
MOV EAX,DWORD PTR DS:[ESI+0x38]
MOV EDX,DWORD PTR DS:[ESI+0x24]
MOV ECX,DWORD PTR DS:[ESI+0x10]
SUB EDX,0x36864B8B
...
}
}
error C2400: inline assembler syntax error in 'opcode'; found 'constant' Error executing cl.exe.
I don't think I can put this in the .data
section, I've read thats all I can do to include bytes like this.
This is an answer-length comment to reply to SSpoke's request for an example. A long time ago, when emulating Turing machines was a cool thing to do, I wrote a Turing machine emulator program to search for busy beavers on a DEC Vax minicomputer. When the program decided which Turing machine to try next, it compiled the machine code for the Turing machine into an array, and called the array as if it was a function. (All this was written in C
.)
That's self-modifying code. To run it, you need an area of memory that is simultaneously writable and executable.
Your code is not self-modifying -- you don't write to it at all. So you can run it in a read-only program segment.