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 


Doubt function assembly

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Wed Feb 08, 2017 2:41 pm    Post subject: Doubt function assembly Reply with quote

Look at this script:
Code:

push 10
call script2

I believe this script will pass 10 as parameter. If I am right, it tells me how script2 would get this argument.

_________________
...
Back to top
View user's profile Send private message
mgostIH
Expert Cheater
Reputation: 3

Joined: 01 Jan 2016
Posts: 159

PostPosted: Wed Feb 08, 2017 3:02 pm    Post subject: Re: Doubt function assembly Reply with quote

Filipe_Br wrote:
Look at this script:
Code:

push 10
call script2

I believe this script will pass 10 as parameter. If I am right, it tells me how script2 would get this argument.


And the question is?

_________________
Do you need to ask me something? Feel free to join my discord server at: https://discord.gg/At4VZXA or ask me something in my YouTube channel: https://www.youtube.com/c/mgostIH
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4710

PostPosted: Wed Feb 08, 2017 3:13 pm    Post subject: Reply with quote

Code:
script2:
  push ebp
  mov ebp,esp
  mov eax,[ebp+8]

  // eax is now 0x10 (16 in dec); do whatever with it
 
  mov esp,ebp
  pop ebp
  ret

If you're smart enough to keep track of the stack yourself, establishing a stack frame isn't necessary.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Wed Feb 08, 2017 3:42 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
script2:
  push ebp
  mov ebp,esp
  mov eax,[ebp+8]

  // eax is now 0x10 (16 in dec); do whatever with it
 
  mov esp,ebp
  pop ebp
  ret

If you're smart enough to keep track of the stack yourself, establishing a stack frame isn't necessary.

There is always an error in the application. I've tried several script variations, most of the error in the application.

_________________
...
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4710

PostPosted: Wed Feb 08, 2017 3:50 pm    Post subject: Reply with quote

I don't know what you mean by that. If you're trying to test this and it's crashing, make sure you're removing the argument from the stack.

If it still crashes, post your code so we can tell you what's wrong.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
SunBeam
I post too much
Reputation: 65

Joined: 25 Feb 2005
Posts: 4023
Location: Romania

PostPosted: Wed Feb 08, 2017 3:56 pm    Post subject: Reply with quote

I guess he gave up on DirectX coding/hooking Smile

Keep in mind the second script you posted is in stdcall calling convention. If you somehow need to use cdecl, you'll need to "add esp,X" after the call:

Code:
push 10
call myfunc
add esp,4

BR,
Sun
Back to top
View user's profile Send private message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Wed Feb 08, 2017 4:10 pm    Post subject: Reply with quote

SunBeam wrote:
I guess he gave up on DirectX coding/hooking Smile

Keep in mind the second script you posted is in stdcall calling convention. If you somehow need to use cdecl, you'll need to "add esp,X" after the call:

Code:
push 10
call myfunc
add esp,4

BR,
Sun

I'm going to leave directX more ahead, first I'll finish reading my C programming book.
"add esp,4" worked Smile

_________________
...
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Feb 08, 2017 6:22 pm    Post subject: Reply with quote

No one wanted to point out that it is actually passing 16 as a parameter? Wink
Back to top
View user's profile Send private message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Wed Feb 08, 2017 7:20 pm    Post subject: Reply with quote

Zanzer wrote:
No one wanted to point out that it is actually passing 16 as a parameter? Wink
At the time of writing this example I ended up using "push 10" instead of "push #10".
_________________
...
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Thu Feb 09, 2017 1:45 am    Post subject: Reply with quote

ParkourPenguin did point it out. Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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