Set process as critical on Windows in C++

In Windows, there exists an obscure ZwAPI/NTAPI feature that lets you set a process as critical/system. A critical process will bugcheck (BSOD) the computer with a 0x000000F4 (CRITICAL_OBJECT_TERMINATION) bugcheck. This requires at least Windows XP to function.

Example code:


 * nt_types.h:


 * ntapi.h:


 * ntapi.cc:
 * main.cc:

Three things to note:
 * This requires Administrator privileges in order to work, so, if you have Windows Vista and up with UAC enabled, you'll need to run it as Administrator (Right click > Run as Administrator)
 * If your process gets killed or returns/dies normally, the computer that it is running on WILL bugcheck (BSOD).
 * If you want to make sure the computer can reboot normally, listen for shutdown/reboot and call ntapi::SetCritical(0).