VC中利用INT 0X2E中断实现关机

VC中利用INT 0X2E中断实现关机


#include"windows.h"



extern "C" __declspec(dllexport) void ShutdownWindow(void)
{
 const int SE_SHUTDOWN_PRIVILEGE=0x13;
 typedef int (*RtlAdjustPrivilege)(int,bool, bool,int*);
 int en = 0;
 HMODULE module = LoadLibrary("ntdll.dll");
 RtlAdjustPrivilege rtl = (RtlAdjustPrivilege)GetProcAddress(module, "RtlAdjustPrivilege");
    int nRet=rtl(SE_SHUTDOWN_PRIVILEGE,TRUE,TRUE,&en);
    if(nRet==0x0C000007C)
        nRet = rtl(SE_SHUTDOWN_PRIVILEGE,TRUE,FALSE,&en);
}


void main()
{
ShutdownWindow();// 取得权限
_asm //XP系统
{
push 2
mov eax,0xf9
mov edx,esp
int 0x2e
add esp,4
}


_asm //2000系统
{
push 2
mov eax,0xd9
mov edx,esp
int 0x2e
add esp,4
}
}

你可能感兴趣的:(汇编编程学习,Windows编程)