 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
mingylord How do I cheat?
Reputation: 0
Joined: 19 Nov 2022 Posts: 4
|
Posted: Mon Nov 28, 2022 3:01 am Post subject: How do I call a method using cheat engine or C#? |
|
|
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 |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 510
|
Posted: Mon Nov 28, 2022 8:29 am Post subject: |
|
|
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);
} |
|
|
Back to top |
|
 |
|
|
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
|
|