Sign in to follow this  
Followers 0
Stevnhoved

UEFI or BIOS boot? - DllCall help.

3 posts in this topic

Hi.

Thank you for a nice forum. It has often been a real lifesaver.

Now I have to figure out if a system is booted via UEFI or legacy BIOS.

I have found an example in Delpha that someone has rewritten in WinBach, which looks a lot like AutoIt.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DllCall~Information+Booted~UEFI~or~BIOS.txt

However, I cannot figure out to translate it to AutoIt. I think have not enough experience with the DllCall function.

Can anyone help me, or guide me in some direction?

Many thanks in advance: D 

 

Best Regards,

Martin Stevnhoved

 

Share this post


Link to post
Share on other sites



Untested:

Func _WinAPI_GetFirmwareEnvironmentVariable($sName, $sGUID)
    
    If Not StringLen($sName) Then
        ; variable cannot be null
        Return SetError(1, 0, 0)
    EndIf
    
    Local $aRet = DllCall("Kernel32.dll", "dword", _
        "GetFirmwareEnvironmentVariableW", "wstr", $sName, _
        "wstr", $sGUID, "wstr", "", "dword", 4096)
    
    If @error Or Not $aRet[0] Then
        Return SetError(1, 0, 0)
    EndIf
    
    Return $aRet[3] ; pBuffer
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#include <WinAPI.au3>

MsgBox(0,_WinAPI_GetFirmwareEnvironmentVariable(),0)

Func _WinAPI_GetFirmwareEnvironmentVariable()

    Local $sName = ""
    Local $sGUID = "{00000000-0000-0000-0000-000000000000}"

    Local $aRet = DllCall("Kernel32.dll", "dword", _
        "GetFirmwareEnvironmentVariableW", "wstr", $sName, _
        "wstr", $sGUID, "wstr", "", "dword", 4096)

    ; ERROR_INVALID_FUNCTION 1 (0x1)
    ; ERROR_NOACCESS 998 (0x3E6)
    Local $LastError = _WinAPI_GetLastError()

    If $LastError == 1 Then
        Return "Legacy"
    ElseIf $LastError == 998 Then
        Return "UEFI"
    Else
        Return "Unknown"
    EndIf

EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0