Read Function

Description

Retrieves content from a memory file in a Sentinel protection key.

Syntax

hasp_status_t HASP_CALLCONV hasp_read( 
                       hasp_handle_t handle,
                       hasp_fileid_t fileid,
                       hasp_size_t   offset,
                       hasp_size_t   length,
                       void *        buffer
                       )

Parameters

handle

Handle for the session

fileid

Identifier for the file that is to be read. Possible values are:

>For default read-only memory: HASP_FILEID_RO

>For default read/write memory: HASP_FILEID_RW

>For a dynamic memory file (read-only, read/write, or read/write-once): The ID that was assigned to the file when the file was created. The ID is a value from 1 through 65471.

NOTE   Dynamic memory files are only supported by Sentinel HL (Driverless configuration) keys (excluding HL Basic and HL Pro keys).

offset

Byte offset of a segment in the file

length

Length of the segment (in bytes) to be read from the file

buffer

Pointer to the retrieved data

Return Values

HASP_STATUS_OK

HASP_INV_HND

HASP_INV_FILEID

HASP_SCHAN_ERR

HASP_MEM_RANGE

HASP_DEVICE_ERR

HASP_BROKEN_SESSION

HASP_LOCAL_COMM_ERR

HASP_REMOTE_COMM_ERR

Usage Notes

Use the GetSize function to determine the size of the file that you want to read.

NOTE   To defeat a protection key emulator attempting to bypass software protection, you can check periodically that the protection key is available and that a session for the key exists. This should not be done using GetSessionInfo (this function does not detect a remote broken session). Instead, use one of the following functions: Encrypt, Decrypt, Read, Write. These functions will return HASP_BROKEN_SESSION if a session for the protection key does not exist.

Related Topics

GetSize Function

Write Function