Can complite error? (program C#)

01/02/2012 15:06 Arvydas000#1
Maybe can help me complite this error?.I click F5 and i cannot connect to my server. Drop this error [Only registered and activated users can see links. Click Here To Register...]
01/02/2012 15:47 Lateralus#2
Change the calling convention of the imported function to cdecl (I think the blowfish library is C or C++, right?). I learned this a while back when I was having the same problem after upgrading to .NET 4.0; it turns out that .NET 3.5 disables PInvoke debugging messages. Basically the parameters of that function are getting ordered incorrectly when they get passed to the native function... which means that the stack will get used up and throw an exception eventually, causing your server to crash.
01/02/2012 16:12 Kiyono#3
I don't understand the theory behind the problem like Lateralus but I do know the solution to it.
Search
Code:
public class Blowfish : IDisposable
And replace the DllImports with these:
Code:
[DllImport("libeay32.dll", CallingConvention = CallingConvention.Cdecl)]
        public extern static void CAST_set_key(IntPtr _key, int len, byte[] data);

        [DllImport("libeay32.dll", CallingConvention = CallingConvention.Cdecl)]
        public extern static void BF_ecb_encrypt(byte[] in_, byte[] out_, IntPtr schedule, int enc);

        [DllImport("libeay32.dll", CallingConvention = CallingConvention.Cdecl)]
        public extern static void BF_cbc_encrypt(byte[] in_, byte[] out_, int length, IntPtr schedule, byte[] ivec, int enc);

        [DllImport("libeay32.dll", CallingConvention = CallingConvention.Cdecl)]
        public extern static void CAST_cfb64_encrypt(byte[] in_, byte[] out_, int length, IntPtr schedule, byte[] ivec, ref int num, int enc);

        [DllImport("libeay32.dll", CallingConvention = CallingConvention.Cdecl)]
        public extern static void BF_ofb64_encrypt(byte[] in_, byte[] out_, int length, IntPtr schedule, byte[] ivec, out int num);
01/02/2012 19:12 Mr_PoP#4
the calling convention in native code, you can specify a calling convention __cdecl, __stdcall etc, it's basically the way arguments are passed to a function when it's called on x86, it determines how args are pushed/popped onto stack and return value stored in eax etc, the difference between __cdecl and __stdcall is whether the caller or callee cleans up the stack .

so basicly you want to say :-

Code:
[DllImport("libeay32.dll" , CallingConvention = CallingConvention.Cdecl)]
01/02/2012 20:11 Lateralus#5
Already got there first guys. ;D
01/02/2012 23:42 Mr_PoP#6
Quote:
Originally Posted by Lateralus View Post
Already got there first guys. ;D
yeah ;P , we just gave him the actual code :D
01/03/2012 00:08 Korvacs#7
I released the fix for this in the pserver guide section somewhere, search please =x
01/03/2012 09:05 Arvydas000#8
Thx all for help ;)