Come rendere un’applicazione non “killabile”

Questo tema è spesso oggetto di discussioni e ricerche, perchè ci sono situazioni in cui si vorrebbe creare un’applicazione che non possa essere chiusa. Per contro però un utente vorrebbe poter chiudere ogni applicazione soprattutto se questa manifesta problemi.

A riguardo Raymond Chen ha pubblicato nel 2004 un post dal titolo The arms race between programs and users dove viene dibattuta la questione:

“Eventually you have to decide which side wins, and Windows has decided to keep users in control of their own programs and data, and keep administrators in control of their own computer. So users can kill any process they want (given sufficient privileges), they can stop any program from stealing focus, and they can delete any file they want (again, given sufficient privileges). Programs can try to make themselves more difficult to kill (deny PROCESS_TERMINATE access, deny PROCESS_CREATE_THREAD access so people can’t CreateRemoteThread(EndProcess), deny PROCESS_VM_WRITE so people can’t scribble into your stack and make you doublefault, deny PROCESS_SUSPEND_RESUME so they can’t suspend you), but eventually you just can’t stop them from, say, elevating to Debug privilege, debugging your process, and moving EIP to “ExitProcess”. Notice that you can kill CSRSS.EXE and WINLOGON.EXE if you like. Your computer will get very angry at you, but you can do it. (Save you work first!)”

 

“Another useful question to ask yourself: “What’s to prevent a virus from doing the same thing?” If there were a way to do these things, then a virus could take advantage of them and make itself invisible to Task Manager, undeletable, and unkillable. Clearly you don’t want that, do you?”

Quindi la conclusione è che non c’è un modo applicativo in Windows per cui un’applicazione possa bloccare il kill di se stessa se l’utente ha i privilegi necessari per avviare il kill della stessa. Quindi l’unico modo che il sistema ammette per rendere un’applicazione non “Killabile” è quello di far si che l’utente non abbia i privilegi necessari per chiuderla. Come giustamente fa notare Raymond Chen se vi fosse un modo per far si che un’applicazione possa impedire di essere chiusa potrebbe essere sfruttato anche da virus e malware che potrebbero impedire ad antivirus e antimalware di bloccarli.