Library functions buggy? [solved]
Posted: Mon Mar 03, 2008 8:58 am
Hi,
I have a linux .so library available that surely works in my linux system. I use the following code examples with the latest PureBasic V4.10 for Linux:
The first example works. The second example fails with an invalid memory access at the marked position. But much more weird: Looking at the debug output, the second example switches the results of Message and Hash! In the windows version this example works fine (simply replaced libcryptosysapi.so with diCryptoSys.dll)!
Is it my misstake or is there a bug in such essential function?
Kukulkan
I have a linux .so library available that surely works in my linux system. I use the following code examples with the latest PureBasic V4.10 for Linux:
Code: Select all
; #########################################
; Example 1: This works fine (in the first moment)
; #########################################
#CryptLibrary = 0
If OpenLibrary(#CryptLibrary, "libcryptosysapi.so")
; ok
strMessage.s = "Testmessage"
strDigest.s = Space(64)
Ret.l = CallFunction(#CryptLibrary, "SHA2_StringHexHash", @strDigest.s, @strMessage.s)
Debug "Message: " + strMessage.s
Debug "Hash : " + strDigest.s
CloseLibrary(#CryptLibrary)
EndIf
; #########################################
; Example 2: invalid memory access on marked position
; #########################################
; Sub-Procedure
Procedure.s CalcHash(strToHash.s)
strDigest.s = Space(64)
Ret.l = CallFunction(#CryptLibrary, "SHA2_StringHexHash", @strDigest.s, @strToHash.s)
Debug "Message: " + strToHash.s
Debug "Hash : " + strDigest.s
ProcedureReturn strDigest.s ; <<<< INVALID MEMORY ACCESS
EndProcedure
; Main Program
If OpenLibrary(#CryptLibrary, "libcryptosysapi.so")
; ok
Hash.s = CalcHash("Testmessage")
CloseLibrary(#CryptLibrary)
EndIfIs it my misstake or is there a bug in such essential function?
Kukulkan