Process Explorer has a nice feature Replace Task Manager
I just wondered how Mark Russinovich implements this.
What trick is used for implementing this?
You can use ProcMon to find out how it's done...
To save you the bother, ProcExp is defined as the debugger of taskmgr.exe in Image File Execution Options
on the registry. This means ProcExp is launched before taskmgr starts to run, no matter how taskmgr was launched. Then, ProcExp can easily close task manager and show itself.