title: Marshalling OpenSsl SSL_ctrl function to C#
body: <p>I have a problem with marshalling SSL_ctrl func from OpenSsl 1.0.2 beta.</p>
  
  <p>This func is </p>
  
  <pre><code>long  SSL_ctrl(SSL *ctx, int cmd, long larg, void *parg);
  </code></pre>
  
  <p>I'm trying to marshal it as</p>
  
  <pre><code>[DllImport(SSLDLLNAME, CallingConvention = CallingConvention.Cdecl)]
  public static extern long SSL_ctrl(IntPtr /* SSL* */ ssl,
                                 int cmd,
                                 long larg,
                                 IntPtr parg);
  </code></pre>
  
  <p><em>I've enabled native code debugging in my Visual Studio.</em></p>
  
  <p>The problem is the <strong>last argument</strong>.</p>
  
  <p>I've tried to call that func with different pointers (non zero) but result is always same: 
  native code accepts parg, but parg is equal to <code>0x0</code>.</p>
  
  <p>I've tried to pass strings (got pointer by calling <code>Marshal.StringToHGlobalAnsi(serverName)),</code>
  tried to pass some generated non-zero pointer, but the result is always same. parg is 0x0 in the native code.</p>
  
  <p>Could you please help me with that issue?</p>