I think I have basically understood how to write c# delegates for callbacks, but this one is confusing me. The c++ definition is as follows:
typedef int (__s
[UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] unsafe delegate int CallbackDelegate (int lCode, int lParamSize, IntPtr pParam);
If .NET assumes cdecl instead of stdcall, your stack will most assuredly be hosed.