Home > Back-end >  C# app which cannot be terminable by a user from task manager or taskkill
C# app which cannot be terminable by a user from task manager or taskkill

Time:07-17

I would like to create an application in C# which cannot be terminable by a user from task manager or taskkill. I found some methods on the internet. but what would you recommend? What's the best practices method for this?

  • RegisterServiceProcess
  • Procected Services
  • Keep-alive processes

and so on.

Thanks,

CodePudding user response:

Task manager is OS supplied way to stop/kick nonresponsive applications. You cannot bypass task manager. For that matter, you cannot bypass any tool whatsoever. Operating system is custodian of system's resources and is responsible for controlling its execution, managing resources etc.

OS provisions certain ways for its users so that they can view/interrupt running processes, allocate more memory, view other relevant parameters. Any sane OS (windows or not) never exposes interface whereby user can run amok through the system creating destroying whatever he or she wants. If it does, it will simply lose control over system internals - something only it can control and not the user.

If you are trying to develop something that works like antivirus, take a look at here - https://docs.microsoft.com/en-us/windows/win32/services/protecting-anti-malware-services- . This is vendor specific way provided by MS to create a process that stays around even if other processes try to kill it. Useful in scenarios like anti-malware defence.

There is a way to deal with this in Linux - https://unix.stackexchange.com/questions/227459/make-a-process-unkillable-on-linux . Note that root user can kill any process that it wants to.

CodePudding user response:

The task needs to run under R0 privileges which sits above an elevated administrator. Our antivirus and several other security packages do this so it absolutely is possible. I'm a domain admin and cannot kill the task via task manager.

  •  Tags:  
  • c#
  • Related