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

Function StrHexToUint64S

MdePkg/Library/BaseLib/SafeString.c:1007–1084  ·  view source on GitHub ↗

Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64. This function outputs a value of type UINT64 by interpreting the contents of the Unicode string specified by String as a hexadecimal number. The format of the input Unicode string String is: [spaces][zeros][x][hexadecimal digits]. The valid hexadecimal digit character is in the r

Source from the content-addressed store, hash-verified

1005
1006**/
1007RETURN_STATUS
1008EFIAPI
1009StrHexToUint64S (
1010 IN CONST CHAR16 *String,
1011 OUT CHAR16 **EndPointer, OPTIONAL
1012 OUT UINT64 *Data
1013 )
1014{
1015 ASSERT (((UINTN) String & BIT0) == 0);
1016
1017 //
1018 // 1. Neither String nor Data shall be a null pointer.
1019 //
1020 SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER);
1021 SAFE_STRING_CONSTRAINT_CHECK ((Data != NULL), RETURN_INVALID_PARAMETER);
1022
1023 //
1024 // 2. The length of String shall not be greater than RSIZE_MAX.
1025 //
1026// if (RSIZE_MAX != 0) {
1027// SAFE_STRING_CONSTRAINT_CHECK ((StrnLenS (String, RSIZE_MAX + 1) <= RSIZE_MAX), RETURN_INVALID_PARAMETER);
1028// }
1029
1030 if (EndPointer != NULL) {
1031 *EndPointer = (CHAR16 *) String;
1032 }
1033
1034 //
1035 // Ignore the pad spaces (space or tab)
1036 //
1037 while ((*String == L' ') || (*String == L'\t')) {
1038 String++;
1039 }
1040
1041 //
1042 // Ignore leading Zeros after the spaces
1043 //
1044 while (*String == L'0') {
1045 String++;
1046 }
1047
1048 if (CharToUpper (*String) == L'X') {
1049 if (*(String - 1) != L'0') {
1050 *Data = 0;
1051 return RETURN_SUCCESS;
1052 }
1053 //
1054 // Skip the 'X'
1055 //
1056 String++;
1057 }
1058
1059 *Data = 0;
1060
1061 while (InternalIsHexaDecimalDigitCharacter (*String)) {
1062 //
1063 // If the number represented by String overflows according to the range
1064 // defined by UINT64, then MAX_UINT64 is stored in *Data and

Callers 2

StrHexToUint64Function · 0.70
ParseParameterDataFunction · 0.50

Calls 4

CharToUpperFunction · 0.85
LShiftU64Function · 0.85
InternalHexCharToUintnFunction · 0.70

Tested by

no test coverage detected