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++] Pointers in inline asm

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Thu Dec 04, 2008 4:52 pm    Post subject: [C++] Pointers in inline asm Reply with quote

When i'm trying to put a script from CE to a inline asm in C++ it's working perfectly unless the script contains pointers. I take an example script I'm trying to use:

Code:
_declspec(naked) void UnlimitedAttack()
{
   __asm
   {
      push ebx
      push eax
      mov eax,[0x00804FD4]
      mov ebx,[eax+0x5F4]
      inc ebx
      mov eax,[eax+0x14B4]
      cmp eax, 0x50
      pop eax
      cmovge eax,ebx
      pop ebx
      mov [ebx],eax
      mov edi,[ebp+0x10]
      jmp dwUnlimitedAttackRet
   }
}
When this work properly it will move my char when the attack counter is at 80 (50 in hex) and then back again. But all this does when I activate it is to move me instantly and its like that until I turn it off. It gets like CSEAX X for those who played Maple. This script is working perfectly in CE but not here and I dont understand why :S. This only happens when there are pointers involved. My question is how to use pointers in inline asm, Any help is appreciated.
Back to top
View user's profile Send private message
Fronzel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Feb 2008
Posts: 1099
Location: Nexons backyard

PostPosted: Thu Dec 04, 2008 5:11 pm    Post subject: Reply with quote

My assembler isnt that good, but I am quite sure you need to define dwUnlimitedAttackRet before you can use it.

Not sure about c++ inline, but i would try to define it like this



Code:
_dwUnlimitedAttackRet:
 push blah blah
 mov your code here blah blah

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

Joined: 05 Apr 2008
Posts: 94

PostPosted: Thu Dec 04, 2008 5:17 pm    Post subject: Reply with quote

Fronzel wrote:
My assembler isnt that good, but I am quite sure you need to define dwUnlimitedAttackRet before you can use it.

Not sure about c++ inline, but i would try to define it like this



Code:
_dwUnlimitedAttackRet:
 push blah blah
 mov your code here blah blah


Here already has the DWORD define (DWORD dwUnlimitedAttackRet = . . .) or else it would give an error.
Back to top
View user's profile Send private message
Fronzel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Feb 2008
Posts: 1099
Location: Nexons backyard

PostPosted: Thu Dec 04, 2008 5:23 pm    Post subject: Reply with quote

Then the jump should work as its unconditional as far as i can see... =/
_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Thu Dec 04, 2008 5:32 pm    Post subject: Re: [C++] Pointers in inline asm Reply with quote

TraxMate wrote:
When i'm trying to put a script from CE to a inline asm in C++ it's working perfectly unless the script contains pointers. I take an example script I'm trying to use:

Code:
_declspec(naked) void UnlimitedAttack()
{
   __asm
   {
      push ebx
      push eax
      mov eax,[0x00804FD4]
      mov ebx,[eax+0x5F4]
      inc ebx
      mov eax,[eax+0x14B4]
      cmp eax, 0x50
      pop eax
      cmovge eax,ebx
      pop ebx
      mov [ebx],eax
      mov edi,[ebp+0x10]
      jmp dwUnlimitedAttackRet
   }
}
When this work properly it will move my char when the attack counter is at 80 (50 in hex) and then back again. But all this does when I activate it is to move me instantly and its like that until I turn it off. It gets like CSEAX X for those who played Maple. This script is working perfectly in CE but not here and I dont understand why :S. This only happens when there are pointers involved. My question is how to use pointers in inline asm, Any help is appreciated.


C++ is a bit different than asm.

Code:
      
mov eax,[0x00804FD4]
mov eax,[eax]
mov ebx,[eax+0x5F4]


will wwork.

_________________
Back to top
View user's profile Send private message Send e-mail
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Thu Dec 04, 2008 6:14 pm    Post subject: Re: [C++] Pointers in inline asm Reply with quote

kitterz wrote:
TraxMate wrote:
When i'm trying to put a script from CE to a inline asm in C++ it's working perfectly unless the script contains pointers. I take an example script I'm trying to use:

Code:
_declspec(naked) void UnlimitedAttack()
{
   __asm
   {
      push ebx
      push eax
      mov eax,[0x00804FD4]
      mov ebx,[eax+0x5F4]
      inc ebx
      mov eax,[eax+0x14B4]
      cmp eax, 0x50
      pop eax
      cmovge eax,ebx
      pop ebx
      mov [ebx],eax
      mov edi,[ebp+0x10]
      jmp dwUnlimitedAttackRet
   }
}
When this work properly it will move my char when the attack counter is at 80 (50 in hex) and then back again. But all this does when I activate it is to move me instantly and its like that until I turn it off. It gets like CSEAX X for those who played Maple. This script is working perfectly in CE but not here and I dont understand why :S. This only happens when there are pointers involved. My question is how to use pointers in inline asm, Any help is appreciated.


C++ is a bit different than asm.

Code:
      
mov eax,[0x00804FD4]
mov eax,[eax]
mov ebx,[eax+0x5F4]


will wwork.


Or just do
Code:
mov eax,dword ptr ds:[0x00804FD4]
mov ebx,[eax+0x5F4]
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Dec 05, 2008 8:03 am    Post subject: Re: [C++] Pointers in inline asm Reply with quote

kitterz wrote:
C++ is a bit different than asm.

Code:
      
mov eax,[0x00804FD4]
mov eax,[eax]
mov ebx,[eax+0x5F4]


will wwork.

C++ is diffrent than ASM. Razz
The inline asm isn't. Rolling Eyes
When you don't specify the size, the compiler ignores the brackets, it treats the opcode "mov reg32,val32" instead of "mov reg32,size seg:[val32]".

CE simply treat the value as the size of the register you're using, eax is a 32-bit register so it treats the value as a DWORD, you can simply write: "mov eax,dword ptr ds:[Address]", like smartz said.
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Fri Dec 05, 2008 8:07 am    Post subject: Reply with quote

Nvm was something else this time.. but fixed it.

Last edited by TraxMate on Fri Dec 05, 2008 8:22 am; edited 2 times in total
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Fri Dec 05, 2008 8:13 am    Post subject: Re: [C++] Pointers in inline asm Reply with quote

Symbol wrote:
kitterz wrote:
C++ is a bit different than asm.

Code:
      
mov eax,[0x00804FD4]
mov eax,[eax]
mov ebx,[eax+0x5F4]


will wwork.

C++ is diffrent than ASM. Razz
The inline asm isn't. Rolling Eyes
When you don't specify the size, the compiler ignores the brackets, it treats the opcode "mov reg32,val32" instead of "mov reg32,size seg:[val32]".

CE simply treat the value as the size of the register you're using, eax is a 32-bit register so it treats the value as a DWORD, you can simply write: "mov eax,dword ptr ds:[Address]", like smartz said.


i see Razz Razz

_________________
Back to top
View user's profile Send private message Send e-mail
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Fri Dec 05, 2008 8:24 am    Post subject: Reply with quote

It's working now Thx kitterz and smartz. And Symbol for giving that usefull information Smile .
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