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 


Re-use void in game with Cheat Engine[solved]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Sun Oct 10, 2021 2:18 am    Post subject: Re-use void in game with Cheat Engine[solved] Reply with quote

Is it possible to re-use void? Let's say that in my game i have void that toggles police, but when it's called bool value isn't changing(i've wanted to find the value but it's unknown,tried all value types)

Last edited by Frouk on Tue Oct 12, 2021 9:37 am; edited 1 time in total
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Sun Oct 10, 2021 1:01 pm    Post subject: Reply with quote

If you mean a function that returns void then it can't return a boolean value since it's a void function i.e. return nothing.
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Mon Oct 11, 2021 2:40 am    Post subject: Reply with quote

Like in c++ i can use
Code:
void(*Game_SetCopsEnabled)(bool AreCopsEnabled) = (void(*)(bool))0x6513E0;

But idk how to use it Cheat Engine
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Oct 11, 2021 3:19 am    Post subject: Reply with quote

With 7.3 you can do it with the new C compiler tags. Something like this. This is for the old school Minesweeper as just a simple/straight-forward example. This will call the 'ResetGame' function that resets the game board, flags and timer.

Code:

{ Game   : winmine.exe
  Version: Old/Windows XP
  Author : atom0s

  Cheat Engine 7.3 C compiler tag example to cast to and call a game function.
  Creates a cave and invokes it as a thread. (Keep this in mind as it is not
  designed to be threadsafe as-is!)
}

[ENABLE]
alloc(cave,1024)
createthread(cave)

cave:
{$ccode temp=eax}
  // Create the typedef and cast the known function address..
  typedef int (__cdecl *fResetGame)(void);
  fResetGame ResetGame = (fResetGame)0x100367A;

  // Call the ResetGame function..
  ResetGame();

{$asm}
  ret

[DISABLE]
dealloc(cave)


You can ignore the temp=eax tag for now, this is a bug in the current parser of the current 7.3 release. CE requires at least one register is used in 'ccode' tags at the moment which I believe will be fixed in the next update.

As mentioned in the comment tag, this is not considered threadsafe. Calling game functions from a new thread like this is prone to crashing if you are not careful, do not handle proper locking as needed, and so on. Be sure to handle any thread safety requirements accordingly.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Mon Oct 11, 2021 3:39 am    Post subject: Reply with quote

atom0s wrote:
With 7.3 you can do it with the new C compiler tags. Something like this. This is for the old school Minesweeper as just a simple/straight-forward example. This will call the 'ResetGame' function that resets the game board, flags and timer.

Code:

{ Game   : winmine.exe
  Version: Old/Windows XP
  Author : atom0s

  Cheat Engine 7.3 C compiler tag example to cast to and call a game function.
  Creates a cave and invokes it as a thread. (Keep this in mind as it is not
  designed to be threadsafe as-is!)
}

[ENABLE]
alloc(cave,1024)
createthread(cave)

cave:
{$ccode temp=eax}
  // Create the typedef and cast the known function address..
  typedef int (__cdecl *fResetGame)(void);
  fResetGame ResetGame = (fResetGame)0x100367A;

  // Call the ResetGame function..
  ResetGame();

{$asm}
  ret

[DISABLE]
dealloc(cave)


You can ignore the temp=eax tag for now, this is a bug in the current parser of the current 7.3 release. CE requires at least one register is used in 'ccode' tags at the moment which I believe will be fixed in the next update.

As mentioned in the comment tag, this is not considered threadsafe. Calling game functions from a new thread like this is prone to crashing if you are not careful, do not handle proper locking as needed, and so on. Be sure to handle any thread safety requirements accordingly.


Making bool in the function same as c++?

EDIT:

How to create one with bool?
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Tue Oct 12, 2021 1:41 am    Post subject: Reply with quote

any1?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Tue Oct 12, 2021 4:08 am    Post subject: Reply with quote

DB pointed out on the other forum you posted in that you can add them to the typedef parameters.

If bool won't work use int and define true as 1 or 0xffffffff and false as 0.

Credit: DB, not my suggestion.
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