OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 1:36 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: UEFI GetNextVariableName returns bad string
PostPosted: Fri Nov 24, 2023 7:24 pm 
Offline

Joined: Fri Nov 24, 2023 6:55 pm
Posts: 1
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

Quote:
[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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[INFO]: VarName: "OsIndicationsSupported\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
[DEBUG]: UEFI Fn() VarName: [42, 6F, 6F, 74, 4F, 70, 74, 69, 6F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, 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"


Has anyone else encountered this yet or are all of my machines bugged out? Just need to verify im not crazy

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 :D


Attachments:
File comment: Actual code for review. EFI->RuntimeServices->GetNextVariableName
EFI.txt [16.05 KiB]
Downloaded 20 times
Top
 Profile  
 
 Post subject: Re: UEFI GetNextVariableName returns bad string
PostPosted: Tue Feb 13, 2024 12:28 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
The buffer size is measured in bytes, not characters.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group