2,640
社区成员
发帖
与我相关
我的任务
分享
const int SE_SHUTDOWN_PRIVILEGE = 0x13;
typedef int (__stdcall *PFN_RtlAdjustPrivilege)( INT, BOOL, BOOL, INT*);
typedef int (__stdcall *PFN_ZwShutdownSystem)(INT);
HMODULE hModule = ::LoadLibrary(_T("ntdll.dll"));
if( hModule != NULL)
{
PFN_RtlAdjustPrivilege pfnRtl = (PFN_RtlAdjustPrivilege)GetProcAddress( hModule, "RtlAdjustPrivilege");
PFN_ZwShutdownSystem pfnShutdown = (PFN_ZwShutdownSystem)GetProcAddress( hModule,"ZwShutdownSystem");
if( pfnRtl != NULL &&
pfnShutdown != NULL )
{
int en = 0;
int nRet= pfnRtl( SE_SHUTDOWN_PRIVILEGE, TRUE, TRUE, &en);
if( nRet == 0x0C000007C )
nRet = pfnRtl(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, &en);
const int POWEROFF = 2;
nRet = pfnShutdown(POWEROFF);
}
}