The following code is really simple. It restricts access to the current process. In this way no other process can open the process handle and for example terminate this process.
var
SD : TJwSecurityDescriptor;
hProcess : TJwProcessHandle;
begin
JwInitWellKnownSIDs;
hProcess := OpenProcess(READ_CONTROL or WRITE_DAC, false, GetCurrentProcessId());
if hProcess <> 0 then
try
SD := TJwSecureGeneralObject.GetSecurityInfo(hProcess,SE_KERNEL_OBJECT, [siDaclSecurityInformation]);
try
SD.DACL.Clear;
SD.DACL.Add(TJwDiscretionaryAccessControlEntryAllow.Create(nil, [], GENERIC_ALL, JwLocalSystemSID));
//allow read access to the current user
SD.DACL.Add(TJwDiscretionaryAccessControlEntryAllow.Create(nil, [], GENERIC_READ, JwSecurityProcessUserSID));
TJwSecureGeneralObject.SetSecurityInfo(hProcess, SE_KERNEL_OBJECT, [siDaclSecurityInformation], SD);
finally
SD.Free;
end;
finally
CloseHandle(hProcess);
end;
end;
However there are some problems:
The only way to prevent a restricted user from terminating the application is to run the process with a foreign account (e.g. CreateProcessAsUser) and make sure that the user is not listed in the DACL. However if this user gets the DEBUG privilege the game is over.
6 Responses
Pablo
25|Nov|2008 1Hi Christian, may you post something about running a process as foreign account and make sure he is not int the DACL? (Like you propose in this article)
Im working in a application for Cyber-Cafes and would be great if my service can’t be stopped/killed (like Anti Virus does)
Thanks in advance.
Christian Wimmer
28|Nov|2008 2Comments are only for questions and remarks about the article.
You should ask this question in an expert forum or contact us directly. For professionals we host a service that you can use to get support. Consider that JEDI API&WSCL are free but our support is not!
misko
26|Jan|2011 3It seems that this is not working on WinXP, i try to test this code , but it was no problem to kill them with Task-Manager
Christian Wimmer
26|Jan|2011 4Hi misko,
did you read the problems at the end of the article?
Carlos
24|Nov|2011 5Hello Christian, about the support, can you write me an email and explain how to get support with you about this or others things?
regards
Christian Wimmer
24|Nov|2011 6I can be contacted through the “about fame” page.
Leave a reply
You must be logged in to post a comment.
Search
Paypal donation (EUR)
Download Win 7 Search Provider
Categories
Archives
Tags
Recent Posts
Recent Comments
Blogroll
JEDI Sites
Pages
A design creation of Design Disease
Copyright © 2007 - JEDI Windows API - is proudly powered by WordPress
InSense 1.0 Theme by Design Disease brought to you by HostGator Web Hosting.