Kill.exe and EnableDebugPriv()

The last few days, I have been looking into a solution to kill a process in c/c++ – but not just any process, a ScreenSaver running while the computer is locked. Most examples on MSDN and such terminiate processes by sending close messages to them, and 99% of the time that works. It even works for ScreenSavers that are running while the computer is locked. Thing is, I didnt want to bundle kill.exe that comes on the Windows NT Resource kit. Off to search google, pskill by sysinternals works too, but again with the bundling. Search the net some more, I found a link to the kill.exe source code from MSDN. The big difference in this code compared to all other kill examples, is this

That opened the door for the kill.exe to stop a process when the computer was locked 100% of the time. Im sure there is some long explination dealing with user mode and kernel mode code, maybe someone can comment on and shed some more light on the subject. I have attached the source code that I found here just in case the site it was on goes down. Well, in the end, we ended up getting the program to kill the process while the computer was locked, so it worked out well :)

Hmm, well, depending on the version of the OS, not quite so weird. The screensaver runs on its own desktop, so I think you have to do something special in that case. But you’ve got a working solution, which is a good deal (though I don’t think I want to know what it is you’re trying to accomplish).

Do you use this script to kill screensavers running on remote machines?
I have been looking for a way to do so without having to list the PID and then kill it via the pstools. The screensaver can vary as well but they are all .scr