#include <windows.h>
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
{
int SE_SHUTDOWN_PRIVILEGE = 0x13;
typedef int (WINAPI *PFNRtlAdjustPrivilege)( INT, BOOL, BOOL, BOOL* );
typedef int (WINAPI *PFNZwShutdownSystem)( INT );
HMODULE hModule = LoadLibrary( TEXT("ntdll.dll") );
if( hModule != NULL)
{
PFNRtlAdjustPrivilege pfnRtlAdjustPrivilege = (PFNRtlAdjustPrivilege)GetProcAddress( hModule, "RtlAdjustPrivilege" );
PFNZwShutdownSystem pfnZwShutdownSystem = (PFNZwShutdownSystem)GetProcAddress( hModule, "ZwShutdownSystem" );
if( pfnRtlAdjustPrivilege != NULL &&
pfnZwShutdownSystem != NULL )
{
BOOL bEnabled = 0;
int nResult = pfnRtlAdjustPrivilege( SE_SHUTDOWN_PRIVILEGE,
TRUE, TRUE, &bEnabled );
if( nResult == 0xC000007C )
nResult = pfnRtlAdjustPrivilege( SE_SHUTDOWN_PRIVILEGE,
TRUE, FALSE, &bEnabled );
nResult = pfnZwShutdownSystem( 0 );
//快速关闭系统 = 0;
//快速重启 = 1;
//快速关机 = 2;
}
}
}