From 113a46ef102371b3e02ee28df32d20ac65188c4c Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Fri, 22 Dec 2023 23:36:09 +0100 Subject: [PATCH] Fix XTLDR configuration --- xtldr2/config.c | 39 ++++++++++++++++++--------------------- xtldr2/efiutils.c | 2 +- xtldr2/globals.c | 2 +- xtldr2/includes/globals.h | 2 +- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/xtldr2/config.c b/xtldr2/config.c index c6c8958..b03c91a 100644 --- a/xtldr2/config.c +++ b/xtldr2/config.c @@ -30,26 +30,22 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName) /* Get config entry name length */ Length = RtlWideStringLength(ConfigName, 0); - /* Make sure config list is not empty */ - if(BlpConfig != NULL) + /* Iterate through config entries */ + ConfigListEntry = BlpConfig.Flink; + while(ConfigListEntry != &BlpConfig) { - /* Iterate through config entries */ - ConfigListEntry = BlpConfig->Flink; - while(ConfigListEntry != BlpConfig) + /* Get config entry */ + ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink); + + /* Check if requested configuration found */ + if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0) { - /* Get config entry */ - ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink); - - /* Check if requested configuration found */ - if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0) - { - /* Return config value */ - return ConfigEntry->Value; - } - - /* Move to the next config entry */ - ConfigListEntry = ConfigListEntry->Flink; + /* Return config value */ + return ConfigEntry->Value; } + + /* Move to the next config entry */ + ConfigListEntry = ConfigListEntry->Flink; } /* Config entry not found, return NULL */ @@ -82,8 +78,8 @@ BlSetConfigValue(IN CONST PWCHAR ConfigName, Length = RtlWideStringLength(ConfigName, 0); /* Iterate through config entries */ - ConfigListEntry = BlpConfig->Flink; - while(ConfigListEntry != BlpConfig) + ConfigListEntry = BlpConfig.Flink; + while(ConfigListEntry != &BlpConfig) { /* Get config entry */ ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink); @@ -564,8 +560,9 @@ BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig) /* Make sure config entry does not exist yet */ if(BlGetConfigValue(ConfigEntry->Name) == NULL) { - /* Put new config entry into global config list */ - RtlInsertTailList(BlpConfig, &ConfigEntry->Flink); + /* Remove new config entry from input list and put it into global config list */ + RtlRemoveEntryList(&ConfigEntry->Flink); + RtlInsertTailList(&BlpConfig, &ConfigEntry->Flink); } /* Move to the next new config entry */ diff --git a/xtldr2/efiutils.c b/xtldr2/efiutils.c index c61b606..411cdcb 100644 --- a/xtldr2/efiutils.c +++ b/xtldr2/efiutils.c @@ -144,7 +144,7 @@ BlpInitializeEfiBootLoader() BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION); /* Initialize XTLDR configuration list */ - RtlInitializeListHead(BlpConfig); + RtlInitializeListHead(&BlpConfig); /* Check if debug is enabled */ if(DEBUG) diff --git a/xtldr2/globals.c b/xtldr2/globals.c index 7292295..4b2a3b9 100644 --- a/xtldr2/globals.c +++ b/xtldr2/globals.c @@ -10,7 +10,7 @@ /* XT Boot Loader configuration list */ -PLIST_ENTRY BlpConfig; +LIST_ENTRY BlpConfig; /* XT Boot Loader loaded configuration */ LIST_ENTRY BlpConfigSections; diff --git a/xtldr2/includes/globals.h b/xtldr2/includes/globals.h index b913e9e..dcdc804 100644 --- a/xtldr2/includes/globals.h +++ b/xtldr2/includes/globals.h @@ -13,7 +13,7 @@ /* XT Boot Loader configuration list */ -EXTERN PLIST_ENTRY BlpConfig; +EXTERN LIST_ENTRY BlpConfig; /* XT Boot Loader loaded configuration */ EXTERN LIST_ENTRY BlpConfigSections;