Solid File System

Virtual file system enigne that can be embedded into your software.

OnHashValidate event/delegate/callback


Pascal    Plain C    C++ (DLL/Lib)    C++ (VCL)    C++ (.NET)    C#    VB.NET    Java 

SolFSStorage     See also    


This event is fired when custom encryption is used and hash needs to be validated.


    TSolFSValidateHashEvent = procedure( Sender : TObject; Buffer : Pointer; Count : LongWord; HashBuffer : Pointer; var Valid : boolean; var Result : LongInt) of object;

[Plain C]
    typedef Error (__stdcall *SolFSValidateHashFunc)( LongWord UserData, void* Buffer, unsigned long Count, void* HashBuffer, bool* Valid);

[C++ (DLL/Lib)]
    typedef Error (__stdcall *SolFSValidateHashFunc)( LongWord UserData, void* Buffer, unsigned long Count, void* HashBuffer, bool* Valid);

[C++ (VCL)]
    typedef void (__closure *TSolFSValidateHashEvent)( System::TObject* Sender, void* Buffer, unsigned long Count, void* HashBuffer, bool* Valid, Error & Result);

[C++ (.NET)]
    public __delegate void SolFSValidateHashEvent( SolFSStorage* Sender, unsigned char Buffer __gc[], unsigned long Count, unsigned char HashBuffer __gc[], Boolean __gc & Valid, Int32 __gc &Result);

    public void SolFSValidateHashEvent( SolFS.SolFSStorage Sender, uchar[] Buffer, ulong Count, uchar[] HashBuffer, ref bool Valid, ref int Result);

    Sub SolFSValidateHashEvent( ByVal Sender As SolFS.SolFSStorage, ByVal Buffer As Byte(), ByVal Count As UInt32, ByVal HashBuffer As Byte(), ByRef Valid As Boolean, ByRef Result As Int32)

    boolean ISolFSHashEvents.onHashValidate( byte[] Buffer, byte[] HashBuffer )


  • Sender - reference to the class that called the delegate/event handler.
  • Buffer - a reference to the buffer whose hash must be calculated.
  • Count - the number of bytes in the buffer to be hashed
  • HashBuffer - a reference to the buffer where the existing hash is placed. Buffer size is always 32 bytes.
  • Valid - set this parameter to True if the hash in HashBuffer corresponds to the hash of data passed in Buffer. Set to False if the hash is not valid.
  • Result - out parameter (return value for DLL) where the application places the result of the operation. If you are working with file system, Win32 error code is a good candidate for placing to Result parameter. Otherwise you can use any other error codes, just be sure that 0 means success.
    [Java]See Description for details about error reporting in Java.

  • [Plain C] UserData - application-defined parameter which is specified when creating the storage and passed back to callback function.

[Java]  Return values

True if the hash matches the data and False otherwise.


The event is fired when hash of some data must be verified. You must calculate the hash of the Buffer and compare the result with the existing hash passed in HashBuffer. You can use hash algorithms that produce 32 bytes or less as the result.

The callback/event handler must be set before the storage is opened.

You need to implement ISolFSHashEvents interface in your code and pass the object, that implements the events, to one of SolFSStorage constructors that accept storageEvents parameter.

ERROR REPORTING: In Java you can't return more than one parameter, so the natural way is to throw an exception. You can throw any exception, and this exception will be passed back to the code, which called one of SolFS functions. So if you use callback mechanism and throw exception from within event handlers, be sure to wrap each call to SolFS methods with try/catch.

See also

Information about callbacks (Operating System edition only)     OnHashCalculate    

Back to top