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 


Show the number of executions per second?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DaviFN
Cheater
Reputation: 0

Joined: 23 Oct 2016
Posts: 32

PostPosted: Tue May 01, 2018 3:42 pm    Post subject: Show the number of executions per second? Reply with quote

Hello everyone!

Is there a way to make a lua script to show the number of executions of a particular line of assembly code per second?

I mean, suppose I disassemble a program and I see an instruction that appears to be in a loop, e.g. xor eax,eax. But there may be something limiting the number of executions of that loop, such as a sleep().

I have the idea. Set a breakpoint on the address of the instruction and increase an integer variable each time the breakpoint is hit (but letting the program flow, "unbreakpointing" it as soon as possible), and then, when another "thread" of lua tells us 1 second has passed, we simply print the value of the variable, effectively printing the number of executions per second.

However, I have no knowledge of lua whatsoever. Where do I begin?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 360

Joined: 09 May 2003
Posts: 21035
Location: The netherlands

PostPosted: Tue May 01, 2018 4:01 pm    Post subject: Reply with quote

instead of breakpoints you can do a code injection that increases the value.
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
DaviFN
Cheater
Reputation: 0

Joined: 23 Oct 2016
Posts: 32

PostPosted: Tue May 01, 2018 4:07 pm    Post subject: Reply with quote

Could you give me an example, Dark Byte?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 360

Joined: 09 May 2003
Posts: 21035
Location: The netherlands

PostPosted: Tue May 01, 2018 4:16 pm    Post subject: Reply with quote

i can't post a full script atm as i'm on a phone, but in short:

record the current time (getTickCount())
do a normal codeinjection where you allocate a counter, register the countersymbol and each time the injection runs increase the counter
then in lua start a timer to take the current time and read out the counter. then count/timedifference is executions per ms

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
DaviFN
Cheater
Reputation: 0

Joined: 23 Oct 2016
Posts: 32

PostPosted: Tue May 01, 2018 4:21 pm    Post subject: Reply with quote

I just need a quick solution... I'm trying to do it via threads right now, but, as my lua script has an infinite loop, it executes "forever", and I have to reopen Cheat Engine in order to make it stop...

How do I stop a lua script execution?

(p.s. this per second thing is an useful thing and I think you should consider, in future editions of Cheat Engine, adding such a functionality)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 360

Joined: 09 May 2003
Posts: 21035
Location: The netherlands

PostPosted: Tue May 01, 2018 4:34 pm    Post subject: Reply with quote

in your lua thread check for a variable you define that says it should terminate or not. (timers are a lot easier and safer, since you can't just access gui objects in threads without crashing unless you encapsule them using synchronize.)

once your thread returns it exits

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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