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 


How do I get thread count of every process named "xxxxx

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
el_beta
How do I cheat?
Reputation: 0

Joined: 05 Apr 2019
Posts: 9

PostPosted: Wed Apr 17, 2019 5:26 am    Post subject: How do I get thread count of every process named "xxxxx Reply with quote

As of now, my radar hack requires manually attaching CE to the target process. There's multiple processes with the same name. I get the process ID of the one with the highest thread count (also consuming the highest system resources) using Process Hacker and then attach CE to that process. The process takes some time, although small.

I wanted to make this process automated. What are the possible ways?

----------------------------------------------------------------------------------

Edit: I came up with this solution. I guess there can be some room for some improvement. There may even be a better method that I'm unaware of.

Code:

function attachToTarget()
    local procList       = getProcesslist()
    local targetPID    = nil

    local maxThreadCount = 0
    local threadlist = createStringlist()
    for pid, name in pairs(procList) do
       if name == "xxxxxx" then
           openProcess(pid)
           getThreadlist(threadlist)
           if threadlist.Count >= maxThreadCount then
              maxThreadCount = threadlist.Count
              targetPID = pid
           end
        end
    end
    openProcess(targetPID)
    return targetPID
end

print(attachToTarget())
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