Alice0725 Expert Cheater
Reputation: 11
Joined: 24 Jul 2012 Posts: 145
|
Posted: Fri Apr 19, 2013 9:56 pm Post subject: About the process filter in to-do list. |
|
|
@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;
|
Description: |
|
Filesize: |
117.37 KB |
Viewed: |
3064 Time(s) |

|
_________________
|
|