判断系统到底运行在哪个模式有几种方法,这里我就列出一个用户态和驱动层的判断....
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");
}