Reputation: 5836
I have the following
struct john {
int oldA;
int A;
} myJohn;
DWORD gotoAddressBack = 0x00401000;
void __declspec( naked ) test(void) {
__asm {
MOV myJohn.oldA, DWORD PTR DS:[ESI+0x77C]
MOV DWORD PTR DS:[ESI+0x77C], myJohn.A
JMP gotoAddressBack
}
}
You can tell that both MOV's generate the error C2415: improper operand type.
As you can see what I want to do is store [ESI+0x77C]'s value into myJohn.oldA
Then I want to replace the same [ESI+0x77C]'s value with myJohn.A
Upvotes: 0
Views: 1499
Reputation: 1371
There is no memory/memory operand for MOV
instruction. You should use a register for such usages. This is something like that:
void __declspec( naked ) test(void) {
__asm {
MOV EAX, DWORD PTR [ESI+0x77C]
MOV myJohn.oldA, EAX
MOV EAX, myJohn.A
MOV DWORD PTR [ESI+0x77C], EAX
JMP gotoAddressBack
}
}
BTW, I really suspect that you really have to deal with segment registers under modern OSes (due to virtual memory, i.e. you can use direct addresses). You should check your code after above changes.
Upvotes: 3