I'm using the SSDeep fuzzy.dll
to perform fuzzy hashing on a large number of files.
If I run the hashes sequentially, it all works fine. If I try to use multiple threads, it falls over (The app terminates with no exception information and nothing in the logs)
I'm assuming that the DLL is not thread-safe and one thread is attempting to read another's memory or something similar.
What I'd like to do is allow each thread to have its own "copy" of the dll. Note that this isn't an instance as such - It's all static/shared - I simply want to emulate what would happen if 2 processes which referenced the dll were run at the same time - they'd have their own memory space, etc...
Is this possible without actually spawning multiple processes?
<DllImport("C:\SSDeep\Fuzzy.dll",
EntryPoint:="fuzzy_hash_filename",
CallingConvention:=CallingConvention.Cdecl)>
Private Shared Function fuzzy_hash_filename(
<InAttribute(),
MarshalAsAttribute(UnmanagedType.LPStr)>
ByVal Filename As String,
ByVal Result As StringBuilder) As Integer
End Function
Public Shared Function FuzzyHash(Filename As String) As String
Dim Ret As New StringBuilder
Ret.Capacity = NativeConstants.FUZZY_MAX_RESULT
Dim Success = fuzzy_hash_filename(Filename, Ret)
If Success <> 0 Then
Throw New Exception("SSDeep fuzzy hashing failed")
End If
Return Ret.ToString
End Function