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 


aa to c++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
gawron25
How do I cheat?
Reputation: 0

Joined: 04 Jun 2011
Posts: 3

PostPosted: Sun Nov 25, 2012 3:51 pm    Post subject: aa to c++ Reply with quote

Hey

Can any one tell me how to convert this

Code:
[ENABLE]
alloc(blah,2024)
alloc(blah3,2024)
label(blah2)

008D265E:
JMP blah

blah:
jmp blah2

blah2:
MOV BX,WORD PTR DS:[EDI+10]
->MOV EAX,blah3<-
MOV DWORD PTR DS:[EAX],E7395B84



MOV EAX,blah3
Back to top
View user's profile Send private message
SteveAndrew
Master Cheater
Reputation: 30

Joined: 02 Sep 2012
Posts: 323

PostPosted: Tue Nov 27, 2012 12:23 am    Post subject: Reply with quote

Well I think I see what your having trouble with...

In CE's auto assembler not including brackets in your instruction '[' and ']' means to use the address of the variable rather than the value of it.

In C++ inline assembler it doesn't matter whether you include them or not it gets interpreted the same exact way. (also MASM and likely other assemblers as well)

example:

Code:

mov eax,[blah3]


Is the same exact thing as

Code:

mov eax,blah3


In inline assembler...

In CE's autoassembler they are different!


So what you can do is either use 'lea' (load effective address) instead of 'mov' or use a pointer to blah3.

So something like this: (Does blah3 really need to be 2024 bytes? or what is it?) Also make sure to put an 0x before a hex number as it defaults to decimal when not writing a CE auto assembler script [like inline assembler instead])
Code:

BYTE blah3[2024];

void __declspec(naked) blah2()
{
        __asm
       {
           mov bx,[edi+0x10]
           lea eax,blah3
           mov [eax],0xE7395B84
       }
}

//OR

BYTE blah3[2024];
BYTE *blah3pointer = &blah3;

void __declspec(naked) blah2()
{
        __asm
       {
           mov bx,[edi+0x10]
           mov eax,blah3pointer
           mov [eax],0xE7395B84
       }
}



the instruction 'lea eax,blah3' is the same as 'lea eax,[blah3]' here. brackets or not when dealing with variables in inline assembler it always will have brackets [ ] whether you put them or not. That's only variables though registers can have them or not have them normally as shown even just this little code.


If you had allocated the memory for blah3 dynamically you probably wouldn't have encountered this problem, as blah3 would have already been a pointer: (Then you could've kept the mov)

Code:

BYTE *blah3 = new BYTE[2024]

void __declspec(naked) blah2()
{
        __asm
       {
           mov bx,[edi+0x10]
           mov eax,blah3
           mov [eax],0xE7395B84
       }
}


Any memory you allocate though make sure to keep track of it until you free it, no one likes memory leaks! And in C you have to manually manage your memory!

_________________
Back to top
View user's profile Send private message
n0 m3rcY
Cheater
Reputation: 0

Joined: 18 Jun 2012
Posts: 42

PostPosted: Tue Nov 27, 2012 8:22 pm    Post subject: Reply with quote

In masm syntax mov eax, esi+10 gives the value of esi+10 wheres mov eax, [esi+10] gives you the address (effectively lea).

Of course, this is just what I remember about masm being reverse fasm in the bracket-access of pointers, so...
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