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 


Is there a way to call windows API from your trainer ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Mohsen
Advanced Cheater
Reputation: 1

Joined: 04 Apr 2013
Posts: 69
Location: PE

PostPosted: Fri Apr 05, 2013 9:14 am    Post subject: Is there a way to call windows API from your trainer ? Reply with quote

How to call windows API or any dll which is inside your trainer folder functions.

For example I want to use GetTickCount64 inside kernel32.dll in my AA.
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 340
Location: Somewhere....

PostPosted: Fri Apr 05, 2013 10:51 am    Post subject: Reply with quote

Code:

Alloc(Mem,1000)

[Enable]
Label(MyTickCount)

Mem:
call GetTickCount64
Mov dword [MyTickCount],eax
ret

MyTickCount:
add [eax],al      //empty value (0)
add [eax],al


CreateThread(Mem)


[DISABLE]
Mem:
ret
Back to top
View user's profile Send private message
Mohsen
Advanced Cheater
Reputation: 1

Joined: 04 Apr 2013
Posts: 69
Location: PE

PostPosted: Fri Apr 05, 2013 11:06 am    Post subject: Subject Reply with quote

Thanks however I didn't mean only GetTickCount..
I want the general way to call exported functions from any dll.

Anyway good point. Thanks for shedding some light Smile
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 340
Location: Somewhere....

PostPosted: Fri Apr 05, 2013 12:03 pm    Post subject: Reply with quote

as you see in the script, allocate a memory, push the function parameters to the stack, then call the function name, if the dll is not loaded in the process, you can add LOADLIBRARY command to the script (so Cheat Engine will load the dll for you).

Code:

LOADLIBRARY(YOUR DLL PATH HERE-->Example: C\TEST\MyDLL.dll)

[ENABLE]
//Your cheat code here
//.
//.
//.
//.
pushad //Copy original registers
pushfd  //-------
push eax     //the function first parameter
push ebx    //another paramter
push 100   //another parameter
Call MyDLL.MyFunction   //Call the 'MyFunction' procedure
popfd //restore original registers
popad//-----

//continue your cheat code
//.
//.
//.



or instead, use LoadLibraryA and GetProcAddress functions first, then use call dword [The Address Returned from GetProcAddress],

either you then run that into a separate thread (Using Createthread command), or adding the call to your cheat code.
Back to top
View user's profile Send private message
Mohsen
Advanced Cheater
Reputation: 1

Joined: 04 Apr 2013
Posts: 69
Location: PE

PostPosted: Fri Apr 05, 2013 1:17 pm    Post subject: nosubje Reply with quote

Simple, Complete.
Thanks for your brilliant answer Smile
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Fri Apr 05, 2013 1:31 pm    Post subject: Reply with quote

@TsTg:
TsTg wrote:
Code:

MyTickCount:
add [eax],al      //empty value (0)
add [eax],al

You can use "dd 0" (Data Dword) instead of 2*add [eax],al to store 0 over a 32 bit int. dd will store a dword with the specified value, db a byte, dq a qword, and dw a word. Strings are best stored with "db 'Blah',0" .

Aside that GetTickCount64 returns a 64bit value, in edx:eax. But since we usually make comparisons over short periods of time (less than 1190 hours), the edx part isn't always useful. Wink
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 340
Location: Somewhere....

PostPosted: Fri Apr 05, 2013 2:44 pm    Post subject: Reply with quote

@Mohsen:

Mohsen wrote:
Simple, Complete.
Thanks for your brilliant answer Smile


You're welcome Smile



@Gniarf:

Gniarf wrote:

You can use "dd 0" (Data Dword) instead of 2*add [eax],al to store 0 over a 32 bit int. dd will store a dword with the specified value, db a byte, dq a qword, and dw a word. Strings are best stored with "db 'Blah',0" .

Aside that GetTickCount64 returns a 64bit value, in edx:eax. But since we usually make comparisons over short periods of time (less than 1190 hours), the edx part isn't always useful. Wink


thanks for those info 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 -> 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