Prevent process from being closed in task manager

后端 未结 1 1513
说谎
说谎 2021-01-03 05:45

Hi guys I am programming a little program for becoming more productive. It should disconnect the user from the Internet or shut your computer down after a preset number of m

相关标签:
1条回答
  • 2021-01-03 06:11

    This functionality is, deliberately, unsupported and actively made intractable:

    Why can't you trap TerminateProcess?

    If a user fires up Task Manager and clicks the End Task button on the Applications tab, Windows first tries to shut down your program nicely, by sending WM_CLOSE messages to GUI programs and CTRL_CLOSE_EVENT events to console programs. But you don't get a chance to intercept TerminateProcess. Why not?

    TerminateProcess is the low-level process-killing function. It bypasses DLL_PROCESS_DETACH and anything else in the process. When you kill with TerminateProcess, no more user-mode code will run in that process. It's gone. Do not pass go. Do not collect $200.

    If you could intercept TerminateProcess, you would be escalating the arms race between programs and users. Suppose you could intercept it. Well, then if you wanted to make your program unkillable, you would just hand in your TerminateProcess handler! And then people would ask for "a way to kill a process that is refusing to be killed with TerminateProcess," and we'd be back to where we started.

    In practice, programs attempting to evade detection and task kill try to rename themselves to near isoforms of the Windows system processes. Don't do this. It guarantees your program will be submitted as malware and will kill your credibility dead.

    0 讨论(0)
提交回复
热议问题