Since the introduction of Windows 2000, many driver developers have asked if there is a way to determine whether or not the system is running in Safe Mode, and if it is, exactly what type of Safe Mode it is in. Well, a recent KB article entitled "How to determine whether the system is running in Safe Mode from a device driver" found at http://support.microsoft.com/default.aspx?scid=kb;EN-US;837643 explains it all.
Essentially the way it works is that your driver must import the InitSafeBootMode variable using the following declaration:
extern PULONG InitSafeBootMode;
This variable has 4 possible values:
- 0 - The system is not in safe mode
- 1 - SAFEBOOT_MINIMAL
- 2 - SAFEBOOT_NETWORK
- 3 - SAFEBOOT_DSREPAIR (for Windows Domain Controllers Only)
Anyway, this KB article applies to all Windows 2000,XP, and Server 2003 system.