You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the init() function, you create a thread, which runs runChecks this function, in turn, calls checkAtoms, checkFiles, and checkRegistry in sequence.
so checkAtoms, checkFiles, and checkRegistry are called from both init() (within runChecks) and license (as individual threads).
now you will get Multiple threads running the same functions, you are calling the same functions (checkAtoms, checkFiles, and checkRegistry) twice in parallel
once from runChecks (which is called in init()) and once from license(), this leads to multiple threads working on the same task, potentially doing redundant
work and introducing unnecessary complexity and overhead. it will consume more system resources (CPU, memory) than necessary.
One more thing when you call runChecks from the init() function, it first calls checkAtoms, then checkFiles, and finally checkRegistry.
the key point here is that runChecks doesn't return until checkAtoms finishes its work, since checkAtoms has an infinite loop (while(true))
it will never return control to runChecks, you are checking only for GlobalFindAtomA, which mean GetFileAttributesA and RegOpenKeyExA will never be called until you return from checkAtoms.
One solution would be to move each of the checkAtoms, checkFiles, and checkRegistry functions into separate threads so they run concurrently,
instead of running one after the other in runChecks, and no need to call them again in License() function since they gonna keep working till the program exit
I Added a simple mechanism to interrupt the sleep if the user logs in before the 45 seconds have passed, the function waits in a loop, checking every second
if the user has logged in, if the user logs in before the 45s timeout, the loop breaks, and the checks begin.
if the user hasn’t logged in by the time the 45s pass, it simply proceeds with the checks.
0 commit comments