Implement BlGetEfiVariable() and BlSetEfiVariable() routines
所有检测均成功
Builds / ExectOS (i686) (push) Successful in 33s
Builds / ExectOS (amd64) (push) Successful in 33s

这个提交包含在:
Rafal Kupiec 2024-03-18 17:04:58 +01:00
父节点 713f826387
当前提交 ee23cd90cb
签署人:: belliash
GPG 密钥 ID: 4E829243E0CFE6B4
共有 2 个文件被更改,包括 94 次插入0 次删除

查看文件

@ -103,6 +103,54 @@ BlGetConfigurationTable(IN PEFI_GUID TableGuid,
return STATUS_EFI_NOT_FOUND;
}
/**
* Gets the value of the EFI variable.
*
* @param Vendor
* Supplies a pointer to the unique vendor GUID.
*
* @param VariableName
* Supplies a pointer to tge NULL-terminated string containing the variable name.
*
* @param VariableValue
* Supplies a pointer to the buffer, where the variable value will be stored.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlGetEfiVariable(IN PEFI_GUID Vendor,
IN PWCHAR VariableName,
OUT PVOID *VariableValue)
{
EFI_STATUS Status;
PVOID Buffer;
UINT_PTR Size;
/* Allocate a buffer for storing a variable's value */
Size = EFI_MAXIMUM_VARIABLE_SIZE * sizeof(PWCHAR);
Status = BlAllocateMemoryPool(Size, (PVOID*)&Buffer);
if(Status != STATUS_EFI_SUCCESS)
{
/* Memory allocation failure */
return Status;
}
/* Attempt to get variable value */
Status = EfiSystemTable->RuntimeServices->GetVariable(VariableName, Vendor, NULL, &Size, Buffer);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to get variable, probably not found such one */
return Status;
}
/* Get variable value and return success */
*VariableValue = Buffer;
return STATUS_EFI_SUCCESS;
}
/**
* Returns a random value based on the initialized RNG buffer.
*
@ -250,6 +298,39 @@ BlRebootSystem()
return EfiSystemTable->RuntimeServices->ResetSystem(EfiResetCold, STATUS_EFI_SUCCESS, 0, NULL);
}
/**
* Sets a value of an EFI variable.
*
* @param Vendor
* Supplies a pointer to the unique vendor GUID.
*
* @param VariableName
* Supplies a pointer to tge NULL-terminated string containing the variable name.
*
* @param VariableValue
* Supplies the contents of the variable.
*
* @param Size
* Supplies the size of the variable data buffer.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlSetEfiVariable(IN PEFI_GUID Vendor,
IN PWCHAR VariableName,
IN PVOID VariableValue,
IN UINT_PTR Size)
{
ULONG Attributes;
/* Set EFI variable */
Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
return EfiSystemTable->RuntimeServices->SetVariable(VariableName, Vendor, Attributes, Size, VariableValue);
}
/**
* Shuts down the machine.
*

查看文件

@ -137,6 +137,12 @@ EFI_STATUS
BlGetEfiPath(IN PWCHAR SystemPath,
OUT PWCHAR *EfiPath);
XTCDECL
EFI_STATUS
BlGetEfiVariable(IN PEFI_GUID Vendor,
IN PWCHAR VariableName,
OUT PVOID *VariableValue);
XTCDECL
VOID
BlGetMappingsCount(IN PXTBL_PAGE_MAPPING PageMap,
@ -327,6 +333,13 @@ VOID
BlSetCursorPosition(IN ULONGLONG PosX,
IN ULONGLONG PosY);
XTCDECL
EFI_STATUS
BlSetEfiVariable(IN PEFI_GUID Vendor,
IN PWCHAR VariableName,
IN PVOID VariableValue,
IN UINT_PTR Size);
XTCDECL
EFI_STATUS
BlShutdownSystem();