Archive: how to detect safe mode


how to detect safe mode
Is there a way of detecting if Windows (2k/XP/2003) is running in safe mode or NOT ?


Use the GetSystemMetrics API.


- code -
!define SM_CLEANBOOT 67
.
.
.

System::Call 'user32.dll::GetSystemMetrics(i) i (${SM_CLEANBOOT})'
- code -

What am I missing something ?

How to get the return value, in this case 0 or 1 or 2 (depending on bootmode)


just to be clear :)
Hi...I went through the "system.dll" help and I am still just as confused. :(

I know what the GetSystemMetrics API does. I just want to know how to get the RETURN value of any called API with the help of the system.dll


This should do it (untested)

System::Call 'user32::GetSystemMetrics(i${SM_CLEANBOOT}) ir0'
; $0 will now have the return value


upon eccles code:


!define NAME "SafeMode"
!define SM_CLEANBOOT 67

Name "${NAME}"
Caption "${NAME}"
OutFile "${NAME}.exe"
ShowInstDetails show

Section "-boo"
System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
DetailPrint "Returning values:"
DetailPrint "0 - Normal boot"
DetailPrint "1 - Fail-safe boot"
DetailPrint "2 - Fail-safe with network boot"
DetailPrint "You PC started as: $0"
SectionEnd

You can learn more about SystemMetrics.

right !, thanks, got it !

I was missing the ".r0" at the end of the statement.

Thanks again !