diff --git a/xtldr/config.c b/xtldr/config.c index c0d29a4..68d7e61 100644 --- a/xtldr/config.c +++ b/xtldr/config.c @@ -9,6 +9,39 @@ #include +/** + * Returns a boolean value of the specified configuration key. + * + * @param ConfigName + * Specifies the configuration key to return its boolean representation. + * + * @return This routine returns a boolean representation of the configuration value. + * + * @since XT 1.0 + */ +XTCDECL +BOOLEAN +BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName) +{ + PWCHAR Value; + + /* Get config value */ + Value = BlGetConfigValue(ConfigName); + + /* Check if option is enabled */ + if(RtlCompareWideStringInsensitive(Value, L"ENABLED", 0) == 0 || + RtlCompareWideStringInsensitive(Value, L"ON", 0) == 0 || + RtlCompareWideStringInsensitive(Value, L"TRUE", 0) == 0 || + RtlCompareWideStringInsensitive(Value, L"YES", 0) == 0) + { + /* This option is enabled */ + return TRUE; + } + + /* Return FALSE by default */ + return FALSE; +} + /** * Returns a value of the specified configuration key. * diff --git a/xtldr/includes/xtldr.h b/xtldr/includes/xtldr.h index b456305..7225470 100644 --- a/xtldr/includes/xtldr.h +++ b/xtldr/includes/xtldr.h @@ -123,6 +123,10 @@ XTCDECL EFI_STATUS BlFreeMemoryPool(IN PVOID Memory); +XTCDECL +BOOLEAN +BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName); + XTCDECL PWCHAR BlGetConfigValue(IN CONST PWCHAR ConfigName); diff --git a/xtldr/xtldr.c b/xtldr/xtldr.c index bb58a1c..e24862b 100644 --- a/xtldr/xtldr.c +++ b/xtldr/xtldr.c @@ -112,7 +112,7 @@ BlInitializeBootMenuList(OUT PXTBL_BOOTMENU_ITEM MenuEntries, DefaultMenuEntry = BlGetConfigValue(L"DEFAULT"); /* Check if configuration allows to use last booted OS */ - if(RtlCompareWideStringInsensitive(BlGetConfigValue(L"KEEPLASTBOOT"), L"TRUE", 0) == 0) + if(BlGetConfigBooleanValue(L"KEEPLASTBOOT")) { /* Attempt to get last booted Operating System from NVRAM */ Status = BlGetEfiVariable(&VendorGuid, L"XtLdrLastBootOS", (PVOID*)&LastBooted); @@ -312,7 +312,7 @@ BlInvokeBootProtocol(IN PWCHAR ShortName, } /* Check if chosen operating system should be saved */ - if(RtlCompareWideStringInsensitive(BlGetConfigValue(L"KEEPLASTBOOT"), L"TRUE", 0) == 0) + if(BlGetConfigBooleanValue(L"KEEPLASTBOOT")) { /* Save chosen operating system in NVRAM */ Status = BlSetEfiVariable(&VendorGuid, L"XtLdrLastBootOS", (PVOID)ShortName, RtlWideStringLength(ShortName, 0) * sizeof(WCHAR));