Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++]AA to ASM

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Lothrik
Newbie cheater
Reputation: 0

Joined: 18 Mar 2009
Posts: 18

PostPosted: Wed Mar 31, 2010 7:21 pm    Post subject: [C++]AA to ASM Reply with quote

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 Smile

One other question:

Source AA:
Code:
je 00458b11


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
View user's profile Send private message MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Apr 01, 2010 6:27 am    Post subject: Reply with quote

Try:
Code:
je [ItemVacMemTarget1]
Back to top
View user's profile Send private message
Lothrik
Newbie cheater
Reputation: 0

Joined: 18 Mar 2009
Posts: 18

PostPosted: Thu Apr 01, 2010 12:14 pm    Post subject: Reply with quote

Slugsnack wrote:
Try:
Code:
je [ItemVacMemTarget1]


Already tried that many hours ago, and it didn't work.
Back to top
View user's profile Send private message MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Apr 01, 2010 6:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
WaffleMaster
Grandmaster Cheater Supreme
Reputation: 0

Joined: 19 Oct 2006
Posts: 1237

PostPosted: Tue Apr 13, 2010 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Apr 14, 2010 6:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites