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 CE sort Processes in order?

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

Joined: 13 Aug 2015
Posts: 60

PostPosted: Tue Jan 30, 2018 5:35 pm    Post subject: How CE sort Processes in order? Reply with quote

Darkbyte, i'd like to know how can i sort same way as CE do with process list to attach.

Imo, is sorting for creation timestamp or something. I'd like to sort them out the same in Delphi.

How can i do it?

Thanks
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue Jan 30, 2018 7:19 pm    Post subject: This post has 2 review(s) Reply with quote

I think this is must be on lua section, but here is a sample :

Code:
---------------------------------------
--- GET PROCESS LIST
---------------------------------------
function GetTheProcessList()
 local T = {}
 local SL=createStringlist()
 getProcesslist(SL)
 for i=0,strings_getCount(SL)-1 do
  T[i] = strings_getString(SL,i)
 -- print(T[i])   -- Output
 end
 SL = nil
 return T
end

---------------------------------------
--- SORT PROCESS LIST BY PID
---------------------------------------
function SortByPID(sender)
 PIDsort = {}
 for x = 1, #sender do
  PIDsort[x] = sender[x]
 end
 table.sort(PIDsort)
 return PIDsort   --- retunr new table preserving old table
end

---------------------------------------
--- SORT PROCESS NAME
---------------------------------------
function SortByName(sender)   --sorts table by name with incremental PID's
 local A = SortByPID(sender)
 local NameSort = {}
 local FinalSort = {}
  for x = 1,#A do
    NameSort[x] = string.sub(A[x],10)..'-'..string.sub(A[x],0,8)
   end
 table.sort(NameSort)    --- table with names first then PID
  for x=1, #NameSort do            --- FLIP PIDs and Name
   FinalSort[x] = string.sub(NameSort[x],-8).."-"..string.sub(NameSort[x],0,-10)
 end
 A = nil
 NameSort = nil
 return FinalSort
end

---------------------------------------
--- REVERSE SORT DESCENDING TO ASCENDING AND VV
---------------------------------------
function ReverseOrder(sender)
 local RevTable = {}
   for x = #sender, 1,-1 do
    RevTable[#RevTable+1] = sender[x]
    end
 return RevTable
end

--------------------------------------------------
------------    Usage Examples -------------------
--------------------------------------------------
PID = GetTheProcessList()      --- A is returned table from GetTheProcessList()
Sort = SortByPID(PID)       ---- call function with sender (A = table)
NamePid = SortByName(GetTheProcessList())
Rev = ReverseOrder(NamePid)

for x = 1,#PID do
print(PID[x])    ---- prints system table
end

for x = 1,#Sort do
print(Sort[x])    ---- prints system table by PIDs
end

for x = 1,#NamePid do
print(NamePid[x])    ---- prints system table by Soted PID's and Name
end

for x = 1,#Rev do
print(Rev[x])    ---- prints table in Reverse Order
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Jan 30, 2018 7:49 pm    Post subject: Re: How CE sort Processes in order? Reply with quote

broly7 wrote:
I'd like to sort them out the same in Delphi
then you might want to look at the source https://github.com/cheat-engine/cheat-engine/blob/5b16776c15b52fab44b2c111d8ee7741ac2ed32f/Cheat%20Engine/processlist.pas
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Wed Jan 31, 2018 2:40 am    Post subject: Reply with quote

toolhelp32snapshot returns it in that order
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
broly7
Advanced Cheater
Reputation: 0

Joined: 13 Aug 2015
Posts: 60

PostPosted: Wed Jan 31, 2018 6:22 am    Post subject: Reply with quote

Dark Byte wrote:
toolhelp32snapshot returns it in that order

I was thinking on that possibility, thanks.
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