-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSystemSecureBootInformation.ahk
51 lines (40 loc) · 2.07 KB
/
SystemSecureBootInformation.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; =============================================================================================================================================================
; Author ........: jNizM
; Released ......: 2021-12-22
; Modified ......: 2023-01-13
; Tested with....: AutoHotkey v2.0.2 (x64)
; Tested on .....: Windows 11 - 22H2 (x64)
; Function ......: SystemSecureBootInformation()
;
; Parameter(s)...: No parameters used
;
; Return ........: Returns a SYSTEM_SECUREBOOT_INFORMATION structure from the NtQuerySystemInformation function.
; =============================================================================================================================================================
#Requires AutoHotkey v2.0
SystemSecureBootInformation()
{
#DllLoad "ntdll.dll"
static STATUS_SUCCESS := 0x00000000
static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004
static STATUS_BUFFER_TOO_SMALL := 0xC0000023
static SYSTEM_SECUREBOOT_INFORMATION := 0x00000091
Buf := Buffer(0x0002)
NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_SECUREBOOT_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt")
while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL)
{
Buf := Buffer(Size)
NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_SECUREBOOT_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt")
}
if (NT_STATUS = STATUS_SUCCESS)
{
SECUREBOOT_INFORMATION := Map()
SECUREBOOT_INFORMATION["SecureBootEnabled"] := NumGet(Buf, 0x0000, "UChar")
SECUREBOOT_INFORMATION["SecureBootCapable"] := NumGet(Buf, 0x0001, "UChar")
return SECUREBOOT_INFORMATION
}
throw OSError()
}
; =============================================================================================================================================================
; Example
; =============================================================================================================================================================
MsgBox SystemSecureBootInformation()["SecureBootEnabled"]