title: Shutting down Windows from kernel mode?
body: <p>I'm trying to create a driver that will intercept a certain key sequence and perform a reboot from kernel mode in Windows, similarly to the <a href="http://kember.net/articles/reisub-the-gentle-linux-restart/" rel="noreferrer">REISUB</a> key sequence in Linux.</p>
  <p>I've created a keyboard hook just like <a href="http://technet.microsoft.com/en-us/sysinternals/bb897578" rel="noreferrer">Ctrl2Cap</a> does, and I've tried calling <a href="http://social.technet.microsoft.com/Forums/en/winservergen/thread/b2df4a2a-a083-4d26-abcd-ac59bdcfe407" rel="noreferrer"><code>NtShutdownSystem</code></a> to reboot the system.</p>
  <p>The handler <em>does</em> detect the key press, but the problem is that when it actually calls <code>NtShutdownSystem</code>, I get a BSOD with the <a href="http://msdn.microsoft.com/en-us/library/ff560140(v=vs.85).aspx" rel="noreferrer"><code>ATTEMPTED_SWITCH_FROM_DPC</code></a> error code.</p>
  <p>I'm assuming this is because I can't shut down the system from an executing <a href="http://en.wikipedia.org/wiki/Deferred_Procedure_Call" rel="noreferrer">DPC</a>, so I probably need to execute my code from somewhere else.
  But I don't know where.</p>
  <p>So the question is:</p>
  <h3>How <em>can</em> I shut down the system upon detecting the key sequence in kernel mode?</h3>