MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / AsciiStrToGuid

Function AsciiStrToGuid

MdePkg/Library/BaseLib/SafeString.c:3483–3557  ·  view source on GitHub ↗

Convert a Null-terminated ASCII GUID string to a value of type EFI_GUID. This function outputs a GUID value by interpreting the contents of the ASCII string specified by String. The format of the input ASCII string String consists of 36 characters, as follows: aabbccdd-eeff-gghh-iijj-kkllmmnnoopp The pairs aa - pp are two characters in the range [0-9], [a-f]

Source from the content-addressed store, hash-verified

3481
3482**/
3483RETURN_STATUS
3484EFIAPI
3485AsciiStrToGuid (
3486 IN CONST CHAR8 *String,
3487 OUT GUID *Guid
3488 )
3489{
3490 RETURN_STATUS Status;
3491 GUID LocalGuid;
3492
3493 //
3494 // None of String or Guid shall be a null pointer.
3495 //
3496 SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER);
3497 SAFE_STRING_CONSTRAINT_CHECK ((Guid != NULL), RETURN_INVALID_PARAMETER);
3498
3499 //
3500 // Get aabbccdd in big-endian.
3501 //
3502 Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data1), (UINT8 *) &LocalGuid.Data1, sizeof (LocalGuid.Data1));
3503 if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data1)] != '-') {
3504 return RETURN_UNSUPPORTED;
3505 }
3506 //
3507 // Convert big-endian to little-endian.
3508 //
3509 LocalGuid.Data1 = SwapBytes32 (LocalGuid.Data1);
3510 String += 2 * sizeof (LocalGuid.Data1) + 1;
3511
3512 //
3513 // Get eeff in big-endian.
3514 //
3515 Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data2), (UINT8 *) &LocalGuid.Data2, sizeof (LocalGuid.Data2));
3516 if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data2)] != '-') {
3517 return RETURN_UNSUPPORTED;
3518 }
3519 //
3520 // Convert big-endian to little-endian.
3521 //
3522 LocalGuid.Data2 = SwapBytes16 (LocalGuid.Data2);
3523 String += 2 * sizeof (LocalGuid.Data2) + 1;
3524
3525 //
3526 // Get gghh in big-endian.
3527 //
3528 Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data3), (UINT8 *) &LocalGuid.Data3, sizeof (LocalGuid.Data3));
3529 if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data3)] != '-') {
3530 return RETURN_UNSUPPORTED;
3531 }
3532 //
3533 // Convert big-endian to little-endian.
3534 //
3535 LocalGuid.Data3 = SwapBytes16 (LocalGuid.Data3);
3536 String += 2 * sizeof (LocalGuid.Data3) + 1;
3537
3538 //
3539 // Get iijj.
3540 //

Callers

nothing calls this directly

Calls 4

AsciiStrHexToBytesFunction · 0.85
CopyGuidFunction · 0.85
SwapBytes32Function · 0.70
SwapBytes16Function · 0.70

Tested by

no test coverage detected