Implement GetKernelParameterValue to parse and extract boot option values
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 1h0m42s
Builds / ExectOS (amd64, release) (push) Successful in 1h0m40s
Builds / ExectOS (i686, release) (push) Successful in 1h0m32s
Builds / ExectOS (i686, debug) (push) Successful in 1h0m34s

This commit is contained in:
2026-04-13 19:18:04 +02:00
parent cec5e8b16b
commit d37f2e3827
2 changed files with 75 additions and 0 deletions

View File

@@ -25,6 +25,9 @@ namespace KE
STATIC XTAPI SYSTEM_FIRMWARE_TYPE GetFirmwareType(VOID);
STATIC XTAPI XTSTATUS GetKernelParameter(IN PCWSTR ParameterName,
OUT PCWSTR *Parameter);
STATIC XTAPI XTSTATUS GetKernelParameterValue(IN PCWSTR ParameterName,
OUT PWSTR ValueBuffer,
IN SIZE_T BufferSize);
STATIC XTAPI PLIST_ENTRY GetMemoryDescriptors(VOID);
STATIC XTAPI PLIST_ENTRY GetSystemResources(VOID);
STATIC XTAPI VOID InitializeInitializationBlock(IN PKERNEL_INITIALIZATION_BLOCK Block);

View File

@@ -104,6 +104,78 @@ KE::BootInformation::GetKernelParameter(IN PCWSTR ParameterName,
return STATUS_NOT_FOUND;
}
/**
* Retrieves the value of a specified kernel parameter and copies it into a buffer.
*
* @param ParameterName
* Supplies a pointer to a null-terminated wide string specifying the name of the parameter to search for.
*
* @param ValueBuffer
* Supplies a pointer to a variable that receives the null-terminated value of the matching parameter.
*
* @param BufferSize
* Supplies the size of the value buffer, in wide characters.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTAPI
XTSTATUS
KE::BootInformation::GetKernelParameterValue(IN PCWSTR ParameterName,
OUT PWSTR ValueBuffer,
IN SIZE_T BufferSize)
{
PCWSTR Match;
SIZE_T NameLength, Index;
XTSTATUS Status;
/* Validate input parameters */
if(!ParameterName || !ValueBuffer || BufferSize == 0)
{
/* Invalid input parameters, return error */
return STATUS_INVALID_PARAMETER;
}
/* Initialize the output buffer to an empty string */
ValueBuffer[0] = L'\0';
/* Find the parameter in the list using the base function */
Status = GetKernelParameter(ParameterName, &Match);
if(Status != STATUS_SUCCESS)
{
/* Parameter not found, return error */
return Status;
}
/* Move pointer past the parameter name */
NameLength = RTL::WideString::WideStringLength(ParameterName, 0);
Match += NameLength;
/* If the parameter has a value (indicated by '='), copy it */
if(*Match == L'=')
{
/* Skip the assignment operator */
Match++;
/* Copy the value to the caller's buffer until a space or end of string is reached */
Index = 0;
while(*Match != L'\0' && *Match != L' ' && Index < (BufferSize - 1))
{
/* Copy the character */
ValueBuffer[Index] = *Match;
Index++;
Match++;
}
/* Null-terminate the isolated value string */
ValueBuffer[Index] = L'\0';
}
/* Value successfully retrieved (or parameter exists without value) */
return STATUS_SUCCESS;
}
/**
* Retrieves a pointer to the list of memory descriptors.
*