Newer
Older
AMI-Aptio-BIOS-Reversed / MdePkg / Library / UefiBootServicesTableLib / UefiConfigManager / UefiConfigManager.md
@Ajax Dong Ajax Dong 2 days ago 9 KB Restructure the repo

UefiConfigManager

Function Table

Address Name Description
StrLen
AsciiStrLen
StrnLenS
AsciiStrnLenS
UnicodeVSPrint
UnicodeSPrint
SPrint
GetHiiDatabase
DebugAssert
DebugLog
GetDebugLevel
FreePool
ReadUnaligned16
ReadUnaligned64
ConfigNodeFree
HexParse4
JsonObjectAdd
GetHiiPackageListSize
RegisterVarStoreNodeMapping
RegisterVarStoreNode
CompareVarStoreGuid
CleanupVarStore
ProcessIfrOpcode
ParseIfrGuidOp
ParseIfrOpcodes
ProcessVarStore
InitSetupStoreList
FindVarStoreProtocol
WriteBackSetupStore
InitAttributesNode
UefiConfigManagerEntry
ModuleEntryPoint
Direct memset call (compiler intrinsic or inline assembly)
Copy aligned 8-byte chunks from end
Copy remainder bytes
No overlap: copy forward, 8 bytes at a time
Use qmemcpy for aligned chunks
Copy remaining bytes
toupper }
Assertion checks on buffer, format, sizes
Output literal character
Handle format specifier
skip '%'
Check for flags (only '-' is minimally supported)
Width if (FormatChar == L'') {
Precision if (*FormatChar == L'.') {
Length modifiers
Conversion specifier
Convert to decimal
Output digits
Lookup status string or output hex code
GUID printing - simplified representation
Calls UnicodeVSPrint with BufferSize/2 (CHAR16 half)
Check if we're at TPL level that allows protocol lookup
Locate the HII Database protocol (GUID at unk_6C00)
Actually the debug protocol GUID
Call the debug protocol's assertion handler (at offset +8)
Check if this error level is enabled
Call the protocol's debug print function at offset +0
Read CMOS
Read physical memory at 0xFDAF0490
EFI_D_ERROR only
EFI_D_ERROR ** EFI_D_INIT**
The caller expects the variable to be set even if NULL
Call SetMem to zero it
If this is not a reference (flag 0x100 not set), free children
If flag 0x200 not set, free StringValue
Check for "null"
Check for "false"
Check for "true"
Quoted string
Number (negative sign or digit)
Array if (*Input == '[') {
Object if (*Input == '{') {
indicates integer initially
Handle negative sign
Check for leading zero (octal/hex prefix ignored per JSON spec, but parsed anyway)
Parse integer part
Parse fractional part
float EndPtr++;
Parse exponent
toupper check 'e' or 'E'
Store parsed values in the node
Store the type flags (int vs float) in the pad field
Calculate the length of the string (after escape processing)
Count actual characters (escape sequences count as 1)
Allocate buffer for the decoded string
Handle escape sequences
Unicode escape \uXXXX
Handle surrogate pairs
High surrogate, expect \uXXXX low surrogate
Store the decoded string in the node
Return pointer after closing quote
Skip whitespace
Empty array
Parse first element
Parse remaining elements
Parse next element
Empty object
Parse first member
Parse key string
Move string value to name, mark as key
The original decompiled code swaps Name and StringValue pointers
Parse value
Parse remaining members
Parse key
Continue searching
Free any existing key name on the value
Set the key name
Link into parent's child list
Find the last sibling
First attempt with 512-byte buffer
Free and retry with correct size
First call: get required buffer size
Allocate and re-export
Export with full buffer
Convert bytes to UINT16 units
Returns buffer pointer as status
Append to linked list
Skip leading spaces
Shift the string left
Trim trailing spaces
Return NULL if all spaces were stripped
Gets count
Append at end of linked list at gIfrNvStoreMapHandle + 26
EFI_IFR_VARSTORE VarId = OpcodeData[9]; // VarStoreId
Actual variable name follows
Size VarGuid = OpcodeData + 11; // GUID
EFI_IFR_VARSTORE_NAME_VALUE VarId = OpcodeData[1]; // VarStoreId
EFI_IFR_VARSTORE_EFI VarStoreName = (CHAR8 *)(OpcodeData + 2);
Find or create the varstore mapping in the linked list
Check for matching config section name
Read variable from RuntimeServices
In the original: RuntimeServices->GetVariable(varName, &guid, &attribs, &size, buffer)
Then check for section name matching "Setup" etc.
Allocate and store the variable data
Copy data into entry
Store the config name reference
Entry + 17 stores the config name pointer for the section
Log if debug enabled
Register the mapping
GUIDed opcode processing
processes the variable ID and data, registers mappings
IFR opcode length at offset +2
Process based on opcode type
EFI_IFR_FORM case 0x02: // EFI_IFR_SUBTITLE
EFI_IFR_TEXT case 0x05: // EFI_IFR_ONE_OF
EFI_IFR_CHECKBOX case 0x07: // EFI_IFR_NUMERIC
EFI_IFR_STRING case 0x09: // EFI_IFR_PASSWORD
EFI_IFR_ORDERED_LIST // Questions with varstore - parse variable info
Walk the linked list tracking varstore IDs
EFI_IFR_VARSTORE case 0x25: // EFI_IFR_VARSTORE_NAME_VALUE
EFI_IFR_VARSTORE_EFI ProcessIfrOpcode(ConfigAddr, (UINT16 *)Current, IfrEnd, DummyParam);
EFI_IFR_GUID ParseIfrGuidOp(ConfigAddr, (UINT16 *)Current, DummyParam);
EFI_IFR_DUP case 0x2D: // EFI_IFR_DEFAULTSTORE
Query package list size
Allocate buffer
Export the package list
Parse IFR opcodes from the package list
Skip package list header
Total package list length
0xDF = end marker
IFR package type 2
Process any pending varstore mapping items from the queue
Dequeue and process
Get list of HII handles (RegisteredHandles)
Allocate temporary array for varstore entries (each 53 bytes)
Using raw 8-byte pointer arithmetic as in original
Initialize varstore array
Process each handle
Continue on error
Write back phase
Optimized byte comparison that tries 8-byte aligned reads
Handle misalignment
Compare aligned 8-byte chunks
Get all handles supporting the form map protocol
Call GetData(Handle, 0x19, 0, ConfigData, ConfigSize, ...)
Retry phase: try ResetData
Walk handles again, call ResetData
Restore to fixed TPL
Find the actual variable store protocol
Read variable data
Call ReadFunction
Cleanup BootServices->FreePool(*ConfigData);
Restore TPL again
Entry is valid
Enable system access variable
Format variable name
Write the variable
GUID at offset +25
Attributes at offset +49
DataSize at offset +41
Data at offset +9
Mark as written
Delete the backup variable
Trigger system reset via I/O port 0xCF9
System reset
Locate HII Database Protocol
Locate HII String Protocol
Get number of HII handles
Allocate handle buffer
Initialize setup store list
Write back and cleanup
Create root "BIOS Setup Information Store" node
Object type
Create "Modified" timestamp string
Get current date/time from RuntimeServices
Format timestamp
Store as ASCII via AsciiToUnicode/UnicodeToAscii
Create Attributes node
Initialize protocols and varstore
Configuration is built; clean up
Initialize HOB list
Call the actual entry point

Generated by HR650X BIOS Decompilation Project