Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call" after successful C# callback from the C++ code
    primarykey
    data
    text
    <p>I'm making a C# application which is using GameSpy C code (the GP part). The C code is calling a callback (which is C# code) succesfully, but I get this error <code>Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call</code> right after the callback is done. I've made a DLL out of C code, like this:</p> <pre><code> // GPCallback ///////////// __declspec(dllexport) typedef void (* GPCallback)( GPConnection * connection, void * arg, void * param ); // gpConnect //////////// __declspec(dllexport) GPResult gpConnect ( GPConnection * connection, const gsi_char nick[GP_NICK_LEN], const gsi_char email[GP_EMAIL_LEN], const gsi_char password[GP_PASSWORD_LEN], GPEnum firewall, GPEnum blocking, GPCallback callback, void * param ); </code></pre> <p>C# is calling it like this:</p> <pre><code> unsafe public delegate void GPCallback( GPConnection * connection, //GPConnectResponseArg arg, IntPtr arg, IntPtr param ); [DllImport("saketestd.dll")] unsafe static extern GPResult gpConnect( GPConnection * connection, gsi_char nick, gsi_char email, gsi_char password, GPEnum firewall, GPEnum blocking, GPCallback callback, IntPtr param ); unsafe public bool gpConnectE() { bool ret = false; try { GPResult res; debug.AddLine(this.getMethodName() + ": " + "connection before connect: " + connection.ToString("x")); fixed (int* pconn = &connection) { res = gpConnect( pconn, this.NICK, this.EMAIL, this.PASSWORD, GPEnum.GP_NO_FIREWALL, GPEnum.GP_BLOCKING, new GPCallback(this.ConnectResponse), IntPtr.Zero ); } debug.AddLine(this.getMethodName() + ": " + "connection after connect: " + connection.ToString("x")); if (res != GPResult.GP_NO_ERROR) { debug.AddLine(this.getMethodName() + ": " + "failed: " + res); } else { debug.AddLine(this.getMethodName() + ": " + "OK"); ret = true; } } catch (Exception ex) { debug.Text += ex.ToString(); } return ret; } unsafe public void ConnectResponse( GPConnection * connection, //GPConnectResponseArg arg, IntPtr argPtr, IntPtr param ) { debug.AddLine(this.getMethodName() + " called with connection: " + (*connection).ToString("x")); GPConnectResponseArg arg; arg = (GPConnectResponseArg)Marshal.PtrToStructure(argPtr, typeof(GPConnectResponseArg)); if (arg.result == GPResult.GP_NO_ERROR) { debug.AddLine(this.getMethodName() + ": Connected to GP"); this.profileid = arg.profile; } else { debug.AddLine(this.getMethodName() + ": failed"); debug.AddLine(this.getMethodName() + ": result: " + arg.result); debug.AddLine(this.getMethodName() + ": profile: " + arg.profile); debug.AddLine(this.getMethodName() + ": uniquenick: " + arg.uniquenick); } } </code></pre> <p>I believe that I need to clear the stack in my callback or change the calling convention in the DLL (is that possible?). Any other ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload