alexbakker / SharpTox

Wrapper library for Tox core, av and dns functions
MIT License
76 stars 27 forks source link

ToxEncryptionFunctions.PassKeyDecrypt crashes, try to use ToxEncryptionFunctions.PassDecrypt instead #17

Open alexbakker opened 8 years ago

alexbakker commented 8 years ago

@dmex:

(Offtopic: I also had some issues opening encrypted profiles created by qtox with the ToxEncryptionFunctions.PassKeyDecrypt function. SharpTox will need to use ToxEncryptionFunctions.PassDecrypt to open them successfully)

alexbakker commented 8 years ago

@dmex

6a55876ff9786c30ef4dd17de9e4cd22f6fc1300

I added an overload that uses PassEncrypt and PassDecrypt but that gives me an AccessViolationException as well. Which kind of makes sense because tox_pass_encrypt uses tox_pass_key_encrypt internally. I really don't know what causes the access violation itself though.

alexbakker commented 8 years ago

It works fine on linux, btw. Which makes this even stranger.

dmex commented 8 years ago

I don't get any access violations (on Windows) using either function (I was trying to say SharpTox needs to fallback to PassDecrypt when PassKeyDecrypt fails so that you can successfully open profiles created by 3rd party apps such as qtox - At least that's what I had to add before SharpTox was able to open qtox profiles).

All access violation exceptions are caused by a region of memory being null? You might need to change the ref signatures to IntPtr and use Marshal.AllocHGlobal - and even do the same with individual fields of the structure.

If you're on Windows... include libtox pdbs in the Debug folder and disable the 'Just my code' debug option and also the other option to enable mixed mode debugging... you will see the exact line of code in libtox and what it was trying to access (you can also step into the code directly from the C# code if its included as a separate project in the solution).