How to make my app unremovable from taskmanager in Win2k/NT

Started by
35 comments, last by T2k 21 years, 10 months ago
it does, if you recieve a specified message return 0 to stop shutdown, and 1 to continue ...


T2k
Advertisement
quote:Original post by T2k
it does, if you recieve a specified message return 0 to stop shutdown, and 1 to continue ...


Are you talking about system shutdown? Like if you go Start->Shutdown? In that case, you''re right. Just intercept the WM_QUERYENDSESSION message and return 0. Or are you talking about WM_CLOSE - i.e. when you click on the X in the top-right? If you return 0 from that, then the application isn''t closed.

However, none of these things stop you from killing the process from the task manager. When you do that, no messages are sent to the application, it''s just terminated.

codeka.com - Just click it.
i spoke about the WM_QUERYENDSESSION message, ive also tried to get some messages by killing process, but no way...
but i dont want to disable the taskmanager, because of crashes etc ...


T2k
Actually messages are sent, at least in win98 and if there is no response, it kills the process.
After that message is sent, if your app returns 0 (whatever indicates that you don''t want to end the process) or if there is no response, the user is presented with the ''end process'' dialog box, giving them the option to kill it in which case the app doesn''t get a say in the matter.
but returning 0 means message handled (and eaten) and not that the program dont respond, so nothing will appear, and it dont appear in my app, i do something like:

/blablabla
case WM_QUERYENDSESSION:
//do some stuff, but dont waste time, because the end process dialog will appear in a few clicks...
if(dont_shutdown){
PostMessage(WM_USER+1,0,0);
return 0;
}
break;
case WM_USER+1:
//do what you want here, the end process dialog will not appear
break;
//here you will normaly see a command which takes the message again to do some stuff ...
//blablabla


T2k
All of us could kill any user mode process, because you could debug it, and kill it butt-good. This would prevent any launch-another-copy shenanigans, as the process would be paused.
And if you boot in debug mode, and hook up wnddbg I think you can kill everything.

quote:
However, none of these things stop you from killing the process from the task manager. When you do that, no messages are sent to the application, it''s just terminated.

Are you sure? The behavior I''ve witnessed indicates that a quit or close or some-such WM_YOU_A_GONNA_DIE message is sent.

If you really want it kill-proof, I think you need to make it a system service or a device driver. The new mcafee virus scanner appears to be a special system service, and taskman won''t kill it.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement