HaspFile.Write Method

Namespace: Aladdin.Hasp

Description

Writes to the memory of a Sentinel protection key.

Syntax

HaspStatus Write ( Boolean value )

Parameters

value

Boolean object to be written

Return Values

A HaspStatus status code.

Usage Notes

Use the HaspFile constructor to specify the file to write.

To start the write operation from an offset other than zero, set the property HaspFile.FilePos before you call the Write method.

When this method is called, a write cycle is performed for the Sentinel protection key. Sentinel HL keys are certified to withstand a specific number of write cycles. For information on the number of write cycles for which Sentinel HL keys are certified, see the Sentinel HL Data Sheet.

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 method does not detect a remote broken session). Instead, use one of the following methods: Encrypt, Decrypt, Read, Write. These methods will return HASP_BROKEN_SESSION if a session for the protection key does not exist.

High-Availability Memory Write Restriction

In high-availability configurations, write operations to protection key memory using hasp_write() are actively blocked by the Sentinel Licensing API.

When an application attempts to write data to any dynamic memory segment of a high-availability protection key, the API rejects the request and returns status code 121 (HASP_HA_WRITE_NOT_ALLOWED).

NOTE   Pre-populated Read/Write and Write-Once memory files can still be created and deployed in high-availability products using Sentinel EMS. Applications can read this memory data without restriction using hasp_read(). For memory access boundaries and licensing rules, see the Sentinel LDK Software Protection and Licensing Guide (for Sentinel EMS or Sentinel LDK-EMS).

Overloaded Methods

The following overloaded methods are provided. They differ from the method above only in the arguments that they accept.

HaspStatus Write ( Byte   value )

HaspStatus Write ( Char   value )

HaspStatus Write ( Double value )

HaspStatus Write ( Int16  value )

HaspStatus Write ( Int32  value )

HaspStatus Write ( Int64  value )

HaspStatus Write ( Single value )

HaspStatus Write ( String value )

HaspStatus Write ( UInt16 value )

HaspStatus Write ( UInt32 value )

HaspStatus Write ( UInt64 value )

The following additional overloaded method is provided:

public HaspStatus Write(Byte[] buffer,
                        Int32  index,
                        Int32  count)
Parameter Description

buffer

Byte array that contains the data to be written.

index

Index in the byte array from which data is retrieved for writing. Do not confuse the index with the offset in the file from where the write operation starts.

count

Size of the data to be written in the file.

Related Topics

GetSize Method

Read Method