Converting UUID and GUID presentation formats (uuid.h, guid.h, uuid_common.h)

APIs are defined in the following header files from the KasperskyOS SDK:

The uuid.h and guid.h APIs let you convert the presentation format for UUIDs (for details about UUID, see RFC 4122) and GUIDs (Microsoft implementation of UUID), respectively. A UUID and GUID may be presented as a byte array, a formatted string (example: 2638179e-9732-4247-aa42-bd86ecc7bde0), or a structure. The functions of the uuid.h and guid.h APIs perform the conversion between these formats. Both the UUID and GUID are a 16-byte ID consisting of five segments. The difference between a UUID and GUID is that the contents of all segments of a UUID reside in memory in big-endian, while the contents of the first three segments of a GUID reside in memory in little-endian and only the contents of the last two segments reside in memory in big-endian.

The uuid_common.h API contains additional macros and a function. This function lets you verify that a formatted string containing UUID or GUID data is correct, and macros can be applied when performing formatted output of a UUID or GUID using functions of the printf family.

Information about API functions and macros is provided in the tables below.

uuid.h functions

Function

Information about the function

UuidStructToRaw()

Purpose

Copies UUID data from a structure to a byte array.

Parameters

  • [in] uuid – pointer to the structure containing UUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] uuidRaw – ID of the byte array containing UUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

UuidRawToStruct()

Purpose

Copies UUID data from a byte array to a structure.

Parameters

  • [in] uuidRaw – ID of the byte array containing UUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] uuid – pointer to the structure containing UUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

UuidStringToRaw()

Purpose

Copies UUID data from a formatted string to a byte array.

Parameters

  • [in] uuidStr – pointer to the formatted string containing UUID data.
  • [out] uuidRaw – ID of the byte array containing UUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

If the formatted string containing UUID data is incorrect (has an inappropriate size, incorrect hyphen placement or invalid symbols), the function returns rcInvalidArgument.

UuidRawToString()

Purpose

Copies UUID data from a byte array to a formatted string.

Parameters

  • [in] uuidRaw – ID of the byte array containing UUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] uuidStr – pointer to the formatted string containing UUID data. The string size (in bytes) including the terminating zero matches the value of the UUID_STR_SIZE constant defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

UuidStringToStruct()

Purpose

Copies UUID data from a formatted string to a structure.

Parameters

  • [in] uuidStr – pointer to the formatted string containing UUID data.
  • [out] uuid – pointer to the structure containing UUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

If the formatted string containing UUID data is incorrect (has an inappropriate size, incorrect hyphen placement or invalid symbols), the function returns rcInvalidArgument.

UuidStructToString()

Purpose

Copies UUID data from a structure to a formatted string.

Parameters

  • [in] uuid – pointer to the structure containing UUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] uuidStr – pointer to the formatted string containing UUID data. The string size (in bytes) including the terminating zero matches the value of the UUID_STR_SIZE constant defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

guid.h functions

Function

Information about the function

GuidStructToRaw()

Purpose

Copies GUID data from a structure to a byte array.

Parameters

  • [in] guid – pointer to the structure containing GUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] guidRaw – ID of the byte array containing GUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

GuidRawToStruct()

Purpose

Copies GUID data from a byte array to a structure.

Parameters

  • [in] guidRaw – ID of the byte array containing GUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] guid – pointer to the structure containing GUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

GuidStringToRaw()

Purpose

Copies GUID data from a formatted string to a byte array.

Parameters

  • [in] guidStr – pointer to the formatted string containing GUID data.
  • [out] guidRaw – ID of the byte array containing GUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

If the formatted string containing GUID data is incorrect (has an inappropriate size, incorrect hyphen placement or invalid symbols), the function returns rcInvalidArgument.

GuidRawToString()

Purpose

Copies GUID data from a byte array to a formatted string.

Parameters

  • [in] guidRaw – ID of the byte array containing GUID data. The parameter type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] guidStr – pointer to the formatted string containing GUID data. The string size (in bytes) including the terminating zero matches the value of the UUID_STR_SIZE constant defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

GuidStringToStruct()

Purpose

Copies GUID data from a formatted string to a structure.

Parameters

  • [in] guidStr – pointer to the formatted string containing GUID data.
  • [out] guid – pointer to the structure containing GUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

If the formatted string containing GUID data is incorrect (has an inappropriate size, incorrect hyphen placement or invalid symbols), the function returns rcInvalidArgument.

GuidStructToString()

Purpose

Copies GUID data from a structure to a formatted string.

Parameters

  • [in] guid – pointer to the structure containing GUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.
  • [out] guidStr – pointer to the formatted string containing GUID data. The string size (in bytes) including the terminating zero matches the value of the UUID_STR_SIZE constant defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Returned values

N/A

uuid_common.h functions and macros

Function/macro

Information about the function/macro

UUID_PRINT_FMT

Purpose

Expands into a formatting string for a function of the printf family when performing formatted output of UUID or GUID.

Parameters

N/A

Macro values

Formatting string for a function of the printf family.

UUID_PRINT_PARAMS()

Purpose

Expands into a sequence of printf family function parameters that match the formatting string resulting from expanding the UUID_PRINT_FMT macro when performing formatted output of a UUID or GUID.

Parameters

  • [in] uuid – pointer to the structure containing UUID or GUID data. The structure type is defined in the header file sysroot-*-kos/include/kos/uuid_common.h from the KasperskyOS SDK.

Macro values

Sequence of printf family function parameters that match the formatting string resulting from expanding the UUID_PRINT_FMT macro.

UuidValidateString()

Purpose

Checks whether a formatted string containing UUID or GUID data is correct (has an appropriate size, correct hyphen placement, and valid symbols).

Parameters

  • [in] uuidStr – pointer to the formatted string containing UUID or GUID data.

Returned values

If the verification is successful, the function returns rcOk, otherwise it returns rcInvalidArgument.

Page top