系统运行模式判断

判断系统到底运行在哪个模式有几种方法,这里我就列出一个用户态和驱动层的判断....

1 用户态的:

#include<windows.h>
#include<stdio.h>
main()
{
int mode;
mode=GetSystemMetrics(SM_CLEANBOOT);
if(mode==0)
   printf("系统运行于正常模式");
if(mode==1)
   printf("系统运行于安全模式");
else if(mode==2)
   printf("系统运行于网络环境下的安全模式");

}


2 驱动层的:

挺简单的,,只要利用一个导出的变量InitSafeBootMode,,ddk说明如下:

The Microsoft Windows operating system kernel exports a pointer to a ULONG variable that is namedInitSafeBootMode. The InitSafeBootMode variable contains the Safe Mode settings that are currently in effect. A device driver can examine InitSafeBootMode to determine whether the operating system is running in Safe Mode.

The following table lists the modes for values of the InitSafeBootMode variable.

Value Mode
0 The operating system is not in Safe Mode.
1 SAFEBOOT_MINIMAL
2 SAFEBOOT_NETWORK
3* SAFEBOOT_DSREPAIR

程序就这两三句:

extern PULONG InitSafeBootMode;

if (*InitSafeBootMode == 0) 
{
       DbgPrint("this is running in Normalmode");

}

if (*InitSafeBootMode ==1) 
{
       DbgPrint("this is running in safemode");

}

else if (*InitSafeBootMode ==2) 
{
       DbgPrint("this is running in safe and network mode");

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值