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 


About the process filter in to-do list.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Alice0725
Expert Cheater
Reputation: 11

Joined: 24 Jul 2012
Posts: 145

PostPosted: Fri Apr 19, 2013 9:56 pm    Post subject: About the process filter in to-do list. Reply with quote

@Dark Byte:
I've noticed it still in to-do list:Add filter to the processlist to exclude system processes. So I assume it just not finished yet.

I've searched something about it and found a solution.
When open 'Windows Task Manager',we can see that a column of "User name", so processes from 'System','Local Service' and 'Network Service' are system processes. Normally, CE cannot open these processes and can only open processes from current user. Then, we can add an option:Only show processes from current user.

Here's how I do it,only affect 3 units.

1.CEFUNCPROC.PAS:
(1)Add a variable:ProcessesCurrentUserOnly:Boolean.
(2)Add a function GetUserNameFromPID(),
Code:

function GetUserNameFromPID(ProcessId: DWORD; out User, Domain: string): boolean;
type
  PTOKEN_USER = ^TOKEN_USER;
var
  hToken: THandle;
  cbBuf: cardinal;
  pUser: PTOKEN_USER=nil;
  snu: SID_NAME_USE;
  ProcessHandle: THandle;
  UserSize: DWORD=0;
  DomainSize: DWORD=0;
  bSuccess: boolean;
begin
  Result := False;
  ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId);
  if ProcessHandle <> 0 then
  begin
    if OpenProcessToken(ProcessHandle, TOKEN_QUERY, hToken) then
    begin
      bSuccess := GetTokenInformation(hToken, TokenUser, nil, 0, cbBuf);
      while (not bSuccess) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) do
      begin
        ReallocMem(pUser, cbBuf);
        bSuccess := GetTokenInformation(hToken, TokenUser, pUser, cbBuf, cbBuf);
      end;
      CloseHandle(hToken);
      if not bSuccess then Exit;

      LookupAccountSid(nil, pUser^.User.Sid, nil, UserSize, nil, DomainSize, snu);
      if (UserSize <> 0) and (DomainSize <> 0) then
      begin
        SetLength(User, UserSize);
        SetLength(Domain, DomainSize);
        if LookupAccountSid(nil, pUser^.User.Sid, PChar(User), UserSize,
          PChar(Domain), DomainSize, snu) then
        begin
          Result := True;
          User := StrPas(PChar(User));
          Domain := StrPas(PChar(Domain));
        end;
      end;

      if bSuccess then FreeMem(pUser);

    end;
    CloseHandle(ProcessHandle);
  end;
end;


(3)Edit function GetProcessList():
Code:

...
    CEFuncProc.GetUserNameFromPID(GetCurrentProcessID(),curuser,domain);

    Check:=Process32First(SnapHandle,ProcessEntry);
    while check do
    begin

      if ProcessesCurrentUserOnly then
      begin
        CEFuncProc.GetUserNameFromPID(ProcessEntry.th32ProcessID,username,domain);
        if username<>curuser then
        begin
          check:=Process32Next(SnapHandle,ProcessEntry);
          continue;
        end;
      end;
...



2.Add 3 lines in MainUnit2.pas
Code:

if reg.ValueExists('Only show processes of current user')then
   cbProcessesCurrentUserOnly.Checked:=reg.ReadBool('Only show processes of current user');
ProcessesCurrentUserOnly := cbProcessesCurrentUserOnly.Checked;



3.Add 2 lines in formseetingsuinit and drag a ctrl TCheckBox.(name cbProcessesCurrentUserOnly)
Code:

reg.WriteBool('Only show processes of current user',cbProcessesCurrentUserOnly.Checked);
ProcessesCurrentUserOnly:=cbProcessesCurrentUserOnly.Checked;



Capture.PNG
 Description:
 Filesize:  117.37 KB
 Viewed:  3064 Time(s)

Capture.PNG



_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sat Apr 20, 2013 5:14 am    Post subject: Re: About the process filter in to-do list. Reply with quote

Thanks. I'll add it to ce (and a rightclick menu to the processlist)

Alice0725 wrote:
Normally, CE cannot open these processes and can only open processes from current user.

That's because you aren't running cheat engine as administrator.

_________________
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
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