Note: I’ve asked this question in a similiar format on superuser but it seems like it may fit here on SO better.
It definitely also is about programming as it concerns parts of the Win32 API, Windows in general and process management.
So there are these processes that can’t be terminated with taskkill – system processes in general. But there also is, for example my Anti Virus program that makes itself “unterminateable”.
-
How can I access and mainly terminate system processes under windows? (kill.exe by Microsoft doesn’t work)
-
How do processes like anti-virus programs protect themselves? How can you turn them off again, then?
You will need API hooking to guard your process against termination. API hooking is not easy, as it requires either system-wide dll injection and memory editing or a device driver. Read this to get an idea.
Luckily, there are existing libraries out there, like this one, which I think is shareware now unfortunately. I also found this, and you can probably find more freeware stuff on google.
To answer your first question, terminating system processes is fairly easy. In C# using the Process.Kill method you can terminate system processes and cause a blue screen if doing it from a windows system service, at least on Windows 7 (I learned this the hard way…). Doing it using the TerminateProcess() function from outside a service will only work if you enable certain permissions: http://www.codase.com/search/call?name=AdjustTokenPrivileges – if I’m not mistaken you need to enable SE_DEBUG_NAME.
To turn off your antivirus, well, they usually have a menu for that :). To forcefully terminate them, you’ll have to use a termination method that they don’t hook. This page describes a lot.
Here’s a sample that can terminate the processes you want, supposing the used API functions aren’t hooked. DO NOT RUN THIS UNLESS YOU KNOW WHAT YOU’RE DOING AS IT CAN CAUSE A BLUE SCREEN!