UEFI GetNextVariableName returns bad string
Posted: Fri Nov 24, 2023 7:24 pm
Hello. I am trying to write a very minimal UEFI OS/Application. Everything has been going mostly smooth so far but im running into an issue where UEFI->RT->GetNextVariableName() returns a string with null terminators placed in the middle. I cant find literally anything online about why this might be happening.
So far its been confirmed on QEMU (EDK II, Rev 2.7) and baremetal (HP Laptop).
Here is the return values im getting inside of QEMU
Here is how im calling UEFI->RT->GetNextVariableName()
Create a blank name buffer (768 bytes wide) and empty GUID field for first function call.
Function call returns the variable name, vendor GUID, and variable name size without issue.
Pass in the previous name (all trailing null terminators are stripped before appending a singular null terminator to terminate the string) returned with the provided GUID
Function call returns garbage data but the size is correct.
Repeat with the returned names and GUID.
Reading the variable returned by GetNextVariableName() did not affect the output before/after getting the next variable. Code is attached for review (rustlang)
Thanks for the help and feedback
So far its been confirmed on QEMU (EDK II, Rev 2.7) and baremetal (HP Laptop).
Here is the return values im getting inside of QEMU
Has anyone else encountered this yet or are all of my machines bugged out? Just need to verify im not crazy[INFO]: Vendor: "EDK II" EFI_Firmware_Revision: 0x10000(65536)
[INFO]: EFI_System_Table_Version: EFI_SYS_TABLE_VERSION_2_70 Table_Revision: 0x20046(131142)
[INFO]: EFI_Boot_Services_Revision: 0x20046(131142)
[INFO]: EFI_Runtime_Services_Revision: 0x20046(131142)
[DEBUG]: UEFI Fn() VarName: [4F, 73, 49, 6E, 64, 69, 63, 61, 74, 69, 6F, 6E, 73, 53, 75, 70, 70, 6F, 72, 74, 65, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[INFO]: VarName: "ConOutDev\0covery0000"
Here is how im calling UEFI->RT->GetNextVariableName()
Create a blank name buffer (768 bytes wide) and empty GUID field for first function call.
Function call returns the variable name, vendor GUID, and variable name size without issue.
Pass in the previous name (all trailing null terminators are stripped before appending a singular null terminator to terminate the string) returned with the provided GUID
Function call returns garbage data but the size is correct.
Repeat with the returned names and GUID.
Reading the variable returned by GetNextVariableName() did not affect the output before/after getting the next variable. Code is attached for review (rustlang)
Thanks for the help and feedback