| View previous topic :: View next topic |
| Author |
Message |
Lothrik Newbie cheater
Reputation: 0
Joined: 18 Mar 2009 Posts: 18
|
Posted: Wed Mar 31, 2010 7:21 pm Post subject: [C++]AA to ASM |
|
|
Snippets from my C++ project:
void *ItemVacPacket = VirtualAlloc(NULL, 32, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
__declspec(naked) void ItemVacNewMem()
{
__asm
{
push eax
push ecx
mov ax,word ptr ds:[ItemVacMemTarget2]
mov [ItemVacPacket],ax
mov eax,[ItemVacPlayerBasePointer]
mov ecx,[eax+0xf4]
mov [ItemVacPacket+0x2],cl
mov ecx,[eax+0xfc]
mov [ItemVacPacket+0x3],cl
push ebx
push ecx
...
The error I'm encountering: C2443: operand size conflict: "The instruction requires operands to be the same size."
The lines the error is occurring on:
mov [ItemVacPacket],ax
...
mov [ItemVacPacket+0x2],cl
...
mov [ItemVacPacket+0x3],cl
The source AA went something like:
alloc(packet,32)
...
mov [packet],ax
...
mov [packet+0x2],cl
...
mov [packet+0x3],cl
I suspect I've done something wrong in my use of VirtualAlloc, but I'm not sure what. The source AA script works perfectly fine (it's 197 lines long though, and increasingly confusing to convert to ASM/C++).
Edit:
Err, not sure why sponge deleted his post.. but anyways, he said to add "word ptr ds:" and "byte ptr ds:" before "[ItemVacPacket]"
..
Thanks sponge, makes sense and it works
One other question:
Source AA:
Result C++:
| Code: |
DWORD ItemVacMemTarget1 = 0x00458b11;
...
__asm
{
...
je ItemVacMemTarget1
...
} |
Error: C2415: improper operand type: "The opcode does not use operands of this type."
I know I could just use
| Code: | | #define ItemVacMemTarget1 0x00458b11 |
but that wouldn't allow me to change the address when I need to =/
Seriously, if you have ANY IDEA what I'm doing wrong in that code, tell me! It DOES compile if I replace the "je" with "jmp" which seems really strange to me.
Edit: Figured it out. Can't do conditional jumps >256 bytes.
Solution:
JNE JumpOver
JMP ItemVacMemTarget1
JumpOver:
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Apr 01, 2010 6:27 am Post subject: |
|
|
Try:
| Code: | | je [ItemVacMemTarget1] |
|
|
| Back to top |
|
 |
Lothrik Newbie cheater
Reputation: 0
Joined: 18 Mar 2009 Posts: 18
|
Posted: Thu Apr 01, 2010 12:14 pm Post subject: |
|
|
| Slugsnack wrote: | Try:
| Code: | | je [ItemVacMemTarget1] |
|
Already tried that many hours ago, and it didn't work.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Apr 01, 2010 6:34 pm Post subject: |
|
|
| Lothrik wrote: | | Slugsnack wrote: | Try:
| Code: | | je [ItemVacMemTarget1] |
|
Already tried that many hours ago, and it didn't work. |
That works fine for me so how about you post your errors
|
|
| Back to top |
|
 |
WaffleMaster Grandmaster Cheater Supreme
Reputation: 0
Joined: 19 Oct 2006 Posts: 1237
|
Posted: Tue Apr 13, 2010 10:00 pm Post subject: |
|
|
| Lothrik wrote: | | Slugsnack wrote: | Try:
| Code: | | je [ItemVacMemTarget1] |
|
Already tried that many hours ago, and it didn't work. |
Maybe it's your ide; I know that c++ builder doesn't allow that. Try
| Code: | | je dword ptr [ItemVacMemTarget1] |
_________________
Problem, CEF?
Buying zhelms/leech in Windia. PM me. |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Apr 14, 2010 6:53 am Post subject: |
|
|
| WaffleMaster wrote: | | Lothrik wrote: | | Slugsnack wrote: | Try:
| Code: | | je [ItemVacMemTarget1] |
|
Already tried that many hours ago, and it didn't work. |
Maybe it's your ide; I know that c++ builder doesn't allow that. Try
| Code: | | je dword ptr [ItemVacMemTarget1] |
|
That shouldn't be necessary. Writing the size is only needed when it can not be determined implicitly from the context it is applied in. In this case, any type of jump is always to a 32 bit address.
|
|
| Back to top |
|
 |
|