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 


How do I call a method using cheat engine or C#?

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

Joined: 19 Nov 2022
Posts: 4

PostPosted: Mon Nov 28, 2022 3:01 am    Post subject: How do I call a method using cheat engine or C#? Reply with quote

Hello, I have found the full class of an object and I want to call methods withing the object.

I have the full source code of the program so I know exactly what the methods name is and the parameters required but how do I actually do it?

Example:

void Game::processCloseContainer(int containerId)
{
ContainerPtr container = getContainer(containerId);
if(!container) {
return;
}

m_containers[containerId] = nullptr;
container->onClose();
}

can i inject a dll and just call the methods from there?
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Mon Nov 28, 2022 8:29 am    Post subject: Reply with quote

you want to call it from Cheat Engine?
if yes then use executeCodeEx, example:
Code:
executeCodeEx(DECLARATION, nil, 0x746050, ContainerId) --where declaration is convention of __cdecl or __stdcall calls
--ContainerId - your container id

Alternative:
https://github.com/cheat-engine/cheat-engine/blob/847088ee0c6dd93c5d5a0833434e8670d094a203/Cheat%20Engine/bin/celua.txt#L465

and how to know call convention?
Look at the function with disassembler, find the end of that function(must be ret)
if there's any bytes after ret then it means that it has stdcall if not - cdecl
in C++ it would look like this(calling it from injected DLL, in most cases DLL are written in C++):
Code:
void cSlowRateManager_SetSlowRate(SlowRateType SlowType, float SlowTime) noexcept
{
   DWORD address = base + 0x532020; // base is game module address
   ((void(__cdecl*)(SlowRateType, float))address)(SlowType, SlowTime);
}

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
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