Gaining access to named blobs (blob_api.h)

This API is defined in the header file sysroot-*-kos/include/coresrv/blob/blob_api.h from the KasperskyOS SDK.

The API is designed to gain access to named blobs (Binary Large Objects). You can gain access to the following blobs:

Information about API functions is provided in the table below.

Getting the handle of a blob

To get the handle of a blob based on the name of this blob, call the KnBlobGet() function.

The BLOB handle can be transferred to another process via IPC.

The handle of the blob containing the ROMFS image is used not only by the blob_api.h API functions but is also used as input data for the KosRomFsMountByHandle() function from the romfs.h API.

Mapping a blob to a virtual memory region

To reserve a virtual memory region and map the BLOB to it, call the KnBlobMap() function.

The same blob can be mapped simultaneously to multiple virtual memory regions in one or more processes.

To free a virtual memory region that was reserved by calling the KnBlobMap() function, you must close the handle of this region.

Getting the size of a blob

To get the size of a blob, call the KnBlobGetSize() function. The size of a blob is also passed through the size output parameter of the KnBlobGet() function.

Deleting a blob

To initiate the deletion of a blob, call the KnBlobRemove() function. The blob will be deleted only after all of the following conditions are fulfilled:

  1. Each virtual memory region to which the blob is mapped is freed in all processes that mapped it.

    When using the romfs.h API, you should keep in mind that when a ROMFS image is mounted, a call of the KosRomFsMount() or KosRomFsMountByHandle() function will reserve the virtual memory region and map a blob to it. When you unmount a ROMFS image, a call of the KosRomFsUnmount() or KosRomFsUnmountAll() function frees the virtual memory region to which the blob is mapped.

  2. Each BLOB handle in all processes that own these handles is closed or revoked.

    When using the romfs.h API, you should keep in mind that the KosRomFsMount() function closes the blob handle while the KosRomFsMountByHandle() function does not close it. Therefore, after calling the KosRomFsMountByHandle() function, you must manually close the handle.

Blob deletion may be prohibited by the KasperskyOS kernel. In this case, the KnBlobRemove() function returns rcInvalidOperation.

Information about API functions

Blob_api.h functions

Function

Information about the function

KnBlobGet()

Purpose

Gets the handle of a blob based on the name of this blob.

Parameters

  • [in] name – pointer to the BLOB name.
  • [out] rid – pointer to the blob handle.
  • [out, optional] size – pointer to the size of the blob in bytes, or RTL_NULL if the blob size is not required.

Returned values

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

KnBlobRemove()

Purpose

Initiates deletion of a blob.

Parameters

  • [in] name – pointer to the BLOB name.

Returned values

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

KnBlobMap()

Purpose

Reserves a virtual memory region and maps the BLOB to it.

Parameters

  • [in] rid – blob handle.
  • [in] prot – flags defining the access rights to the BLOB. The flags are defined in the header file sysroot-*-kos/include/vmm/flags.h from the KasperskyOS SDK.
  • [in, optional] attr – flags that specify the parameters of the virtual memory region, or 0 if these parameters are not required. The flags are defined in the header file sysroot-*-kos/include/vmm/flags.h from the KasperskyOS SDK.
  • [out] addr – pointer to the base address of the virtual memory region.
  • [out] handle – pointer to the handle of the virtual memory region.

Returned values

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

Additional information

In the prot parameter, you can specify the following combinations of flags:

  • VMM_FLAG_READ – read access.
  • VMM_FLAG_READ | VMM_FLAG_WRITE – read-and-write access.

In the attr parameter, you can specify the following flags:

  • VMM_FLAG_CACHE_DISABLE – disable caching.

KnBlobGetSize()

Purpose

Gets the size of the BLOB.

Parameters

  • [in] handle – blob handle.
  • [out] size – pointer to the BLOB size (in bytes).

Returned values

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

Page top