Return a copy of config value, so that it won't get altered
This commit is contained in:
parent
a674d2eb1b
commit
cb4bd3db8b
@ -25,10 +25,12 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
|
|||||||
{
|
{
|
||||||
PXTBL_CONFIG_ENTRY ConfigEntry;
|
PXTBL_CONFIG_ENTRY ConfigEntry;
|
||||||
PLIST_ENTRY ConfigListEntry;
|
PLIST_ENTRY ConfigListEntry;
|
||||||
SIZE_T Length;
|
SIZE_T KeyLength, ValueLength;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
PWCHAR Value;
|
||||||
|
|
||||||
/* Get config entry name length */
|
/* Get config entry name length */
|
||||||
Length = RtlWideStringLength(ConfigName, 0);
|
KeyLength = RtlWideStringLength(ConfigName, 0);
|
||||||
|
|
||||||
/* Iterate through config entries */
|
/* Iterate through config entries */
|
||||||
ConfigListEntry = BlpConfig.Flink;
|
ConfigListEntry = BlpConfig.Flink;
|
||||||
@ -38,10 +40,24 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
|
|||||||
ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink);
|
ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink);
|
||||||
|
|
||||||
/* Check if requested configuration found */
|
/* Check if requested configuration found */
|
||||||
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0)
|
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, KeyLength) == 0)
|
||||||
{
|
{
|
||||||
/* Return config value */
|
/* Get value length */
|
||||||
return ConfigEntry->Value;
|
ValueLength = RtlWideStringLength(ConfigEntry->Value, 0);
|
||||||
|
|
||||||
|
/* Allocate memory for value */
|
||||||
|
Status = BlMemoryAllocatePool(ValueLength * sizeof(WCHAR), (PVOID *)&Value);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Memory allocation failure, return NULL */
|
||||||
|
BlDebugPrint(L"ERROR: Memory allocation failure (Status Code: 0x%lx)\n", Status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy value and return it */
|
||||||
|
RtlCopyMemory(Value, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
|
||||||
|
Value[ValueLength] = 0;
|
||||||
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the next config entry */
|
/* Move to the next config entry */
|
||||||
|
Loading…
Reference in New Issue
Block a user