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 


Timer - get Thread ID / NoBreak

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

Joined: 14 Jan 2019
Posts: 84

PostPosted: Thu Dec 16, 2021 5:50 pm    Post subject: Timer - get Thread ID / NoBreak Reply with quote

https://www.cheatengine.org/forum/viewtopic.php?t=609388
https://wiki.cheatengine.org/index.php?title=Help_File:Script_engine#debug_addThreadToNoBreakList

Is there any way to get the thread ID of a timer (using createTimer) and/or add that timer to the NoBreakList?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Fri Dec 17, 2021 4:15 pm    Post subject: Reply with quote

Timers don't run on separate threads. They are done using the window message system which raises a 'WM_TIMER' event when a timers interval has passed.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 84

PostPosted: Sat Dec 18, 2021 6:46 am    Post subject: Reply with quote

https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.ExtCtrls.TTimer

Hmmm ... but ... i mean I don't have any knowledge in that field but doesn't the Windows API then run in an own thread? How to capture that?

Else would it even make sense to implement a own thread for timers? (because CE Timers should ideally always be excluded from CE debugging) Ideas:

https://www.programmerall.com/article/3272205759/
https://codereview.stackexchange.com/questions/153819/ttimerthread-threaded-timer-class
https://www.lazarusforum.de/viewtopic.php?f=29&t=10433
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: Sat Dec 18, 2021 1:14 pm    Post subject: Reply with quote

salumor wrote:
https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.ExtCtrls.TTimer

Hmmm ... but ... i mean I don't have any knowledge in that field but doesn't the Windows API then run in an own thread? How to capture that?

Else would it even make sense to implement a own thread for timers? (because CE Timers should ideally always be excluded from CE debugging) Ideas:

https://www.programmerall.com/article/3272205759/
https://codereview.stackexchange.com/questions/153819/ttimerthread-threaded-timer-class
https://www.lazarusforum.de/viewtopic.php?f=29&t=10433

You don't need to create new threads and create timers in them,you can create lot of timers instead of creating new thread and creating timer in it

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 84

PostPosted: Sat Dec 18, 2021 1:35 pm    Post subject: Reply with quote

Frouk wrote:
You don't need to create new threads and create timers in them,you can create lot of timers instead of creating new thread and creating timer in it
? In what way would a lot of timers help me if one is enough to break the debugger? Why would I even need a lot of timers? Are you sure you did understand the topic or are you trolling me?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sat Dec 18, 2021 2:15 pm    Post subject: Reply with quote

Timers aren't run on separate threads. The Lua code run by OnTimer is run by the main thread IIRC.

debug_addThreadToNoBreakList operates on the target process. When CE handles a debug event (in TDebugThreadHandler.DispatchBreakpoint), it checks to see if the thread that triggered the breakpoint is in the noBreakList, and if so, it exits the breakpoint handling routine early and continues execution.

createTimer can't break the debugger unless you do something really weird in the OnTimer function.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Sat Dec 18, 2021 2:56 pm    Post subject: Reply with quote

salumor wrote:
https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.ExtCtrls.TTimer

Hmmm ... but ... i mean I don't have any knowledge in that field but doesn't the Windows API then run in an own thread? How to capture that?

Else would it even make sense to implement a own thread for timers? (because CE Timers should ideally always be excluded from CE debugging) Ideas:

https://www.programmerall.com/article/3272205759/
https://codereview.stackexchange.com/questions/153819/ttimerthread-threaded-timer-class
https://www.lazarusforum.de/viewtopic.php?f=29&t=10433


You are also missing the fact that when you create a timer, it is not running in the remote process. The timer is local to CE's process itself. So CE's process is what will be handling that timer and receiving the WM_TIMER message when the interval is expired each time.

If you need to do something similar in the remote process, then you need to create a remote thread instead. (By this I do not mean using CE's Lua function 'createThread', as that is just a local thread inside of CE's own process as well. You'll need to inject a thread, such as with the auto-assembler, into the remote process. CE's Lua also has 'createRemoteThread' but you'll have to have injected code already to be invoked with this as it expects an address. So you can instead just do it all from an auto-assembler script.)

For example, this is an old script of mine that force respawns the player of a certain game:

Code:

[ENABLE]
alloc(threadGame,1024,"Game.dll")
registersymbol(threadGame)

createthread(threadGame)
threadGame:
    mov ecx, [playerPointer]
    mov [ecx+00000D60], 4
    ret

[DISABLE]
dealloc(threadGame)
unregistersymbol(threadGame)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 84

PostPosted: Sat Dec 18, 2021 4:09 pm    Post subject: Reply with quote

ParkourPenguin wrote:
createTimer can't break the debugger unless you do something really weird in the OnTimer function.
OOOkay so did test beforehand also simplifying the the script (only autoattach). I know the table/debugging works. I know the timer did what I wanted just breaking the debugger and found the thread in 1. post mentioning threads breaking the debugger. Hence my conclusion.

But I did miss some mistake leading to the timer always running "openProcess" "breaking" (of course) the debugger ... And now there is no problem. Damn. Embarassed

@atom0s yes, that would have been more of a feature request in CE anyway. (I mean still could be if needed. If you check those threads TTimer is not rly reliable in higher Intervals. But except that nonexistent problem I don't know if there would be any need?)
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 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